第 0 阶段:教材项目 2 任务 1 在网页中原样运行

- runtime:仿真 WinForms 子集(Form、Button、Label、TextBox、ComboBox、
  GroupBox、Timer、MessageBox、界面线程消息循环、跨线程检查)、
  教材设备类库(DeviceCtrlHelper、LED 控件)、运行器(常驻编译服务 + 运行模式)
- server:Bun + Hono,WebSocket 会话,每次运行一个进程,消息转发
- web:Vue + Naive UI,WinForms 风格窗体渲染、MessageBox、实训台 LED 屏
- 端到端测试与 100 个程序并发的压力测试
- 教材逐任务摘要(docs/教材摘要)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
xuyueandClaude Opus 5.5 committed 2026-10-22 10:15:14 +08:00
commit 98be8331bc
71 files changed
+7919

No files matched your search

+38
View File
@@ -0,0 +1,38 @@
using System.ComponentModel;
namespace System.IO.Ports;
/// <summary>
/// 学生代码只用 SerialPort.GetPortNames() 填下拉框,设备读写都走 DeviceCtrlHelper。
/// 这里返回实训台上的虚拟串口;直接读写串口不在教学范围内,调用时给出提示。
/// </summary>
public class SerialPort : Component
{
/// <summary>COM1 是电脑自带串口,COM2–COM5 对应实训台上的 4017、4150、ZigBee 协调器和 LED 屏</summary>
private static readonly string[] VirtualPorts = { "COM1", "COM2", "COM3", "COM4", "COM5" };
public SerialPort() { }
public SerialPort(string portName) => PortName = portName;
public SerialPort(string portName, int baudRate) : this(portName) => BaudRate = baudRate;
public static string[] GetPortNames() => (string[])VirtualPorts.Clone();
public string PortName { get; set; } = "COM1";
public int BaudRate { get; set; } = 9600;
public int DataBits { get; set; } = 8;
public int ReadTimeout { get; set; } = -1;
public int WriteTimeout { get; set; } = -1;
public bool IsOpen { get; private set; }
public void Open() => throw NotSupported();
public void Close() => IsOpen = false;
public void Write(string text) => throw NotSupported();
public void WriteLine(string text) => throw NotSupported();
public string ReadLine() => throw NotSupported();
public string ReadExisting() => throw NotSupported();
private static NotSupportedException NotSupported() =>
new("仿真平台不支持直接读写串口,请使用 DeviceCtrlHelper 操作实训台设备。");
}