第 1 阶段:虚拟实训台,项目 2、3 的示例跑通
- 实训台状态由服务器统一保存:滑块和开关设定传感器读数,推给学生程序; 学生程序控制的灯、继电器、LED 屏回写到实训台 - 网页按教材实训台布局图绘制实训台,传感器卡片上直接调节环境 - 新控件:CheckBox、RadioButton(事件顺序与 WinForms 一致),Lamp、Alarm - 设备类库:串口未打开时控制无效,与实物一致 - 修正:列表属性序列化时数字被转成字符串 - 示例:项目 2 任务 2–3、项目 3 任务 1–2;网址参数 ?sample= 打开指定示例 - 测试:实训台单元测试,项目 2、3 的端到端测试 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
98be8331bc
commit
26104ae81e
38 files changed
+2346
-77
No files matched your search
@@ -0,0 +1,68 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using System.IO.Ports;
|
||||
using DeviceCtrlLibrary;
|
||||
|
||||
namespace ZigBee路灯
|
||||
{
|
||||
public partial class Form1 : Form
|
||||
{
|
||||
public Form1()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
//控制开关灯
|
||||
private void LampOnOff(int RelayNum, bool IsOpen)
|
||||
{
|
||||
DeviceCtrlHelper.zigBeeHelper.OnOff(RelayNum, IsOpen);
|
||||
lamp1.OnOff(IsOpen);
|
||||
}
|
||||
|
||||
private void Form1_Load(object sender, EventArgs e)
|
||||
{
|
||||
//清空列表
|
||||
com_port.Items.Clear();
|
||||
//加载所有可用的串口号到列表中
|
||||
foreach (string item in SerialPort.GetPortNames())
|
||||
{
|
||||
com_port.Items.Add(item);
|
||||
}
|
||||
}
|
||||
|
||||
private void btn_open_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (btn_open.Text.Equals("打开"))
|
||||
{
|
||||
//打开ZigBee协调器所在的串口
|
||||
DeviceCtrlHelper.zigBeeHelper.Open(com_port.Text);
|
||||
btn_open.Text = "关闭";
|
||||
}
|
||||
else if (btn_open.Text.Equals("关闭"))
|
||||
{
|
||||
//关闭串口
|
||||
DeviceCtrlHelper.zigBeeHelper.Close();
|
||||
btn_open.Text = "打开";
|
||||
}
|
||||
}
|
||||
|
||||
private void rb_Open_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
//开灯
|
||||
LampOnOff(1, true);
|
||||
}
|
||||
|
||||
private void rb_Close_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
//关灯
|
||||
LampOnOff(1, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user