第 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:
commit
98be8331bc
71 files changed
+7919
No files matched your search
Generated
+144
@@ -0,0 +1,144 @@
|
||||
namespace LED显示屏
|
||||
{
|
||||
partial class Form1
|
||||
{
|
||||
/// <summary>
|
||||
/// 必需的设计器变量。
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// 清理所有正在使用的资源。
|
||||
/// </summary>
|
||||
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows 窗体设计器生成的代码
|
||||
|
||||
/// <summary>
|
||||
/// 设计器支持所需的方法 - 不要
|
||||
/// 使用代码编辑器修改此方法的内容。
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.led = new WinFormsDeviceControlLibrary.LED();
|
||||
this.groupBox1 = new System.Windows.Forms.GroupBox();
|
||||
this.com_Port = new System.Windows.Forms.ComboBox();
|
||||
this.btn_Send = new System.Windows.Forms.Button();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.txt_SendText = new System.Windows.Forms.TextBox();
|
||||
this.btn_Open = new System.Windows.Forms.Button();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.groupBox1.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// led
|
||||
//
|
||||
this.led.Location = new System.Drawing.Point(12, 12);
|
||||
this.led.Name = "led";
|
||||
this.led.Size = new System.Drawing.Size(750, 121);
|
||||
this.led.TabIndex = 0;
|
||||
//
|
||||
// groupBox1
|
||||
//
|
||||
this.groupBox1.Controls.Add(this.com_Port);
|
||||
this.groupBox1.Controls.Add(this.btn_Send);
|
||||
this.groupBox1.Controls.Add(this.label2);
|
||||
this.groupBox1.Controls.Add(this.txt_SendText);
|
||||
this.groupBox1.Controls.Add(this.btn_Open);
|
||||
this.groupBox1.Controls.Add(this.label1);
|
||||
this.groupBox1.Location = new System.Drawing.Point(347, 154);
|
||||
this.groupBox1.Name = "groupBox1";
|
||||
this.groupBox1.Size = new System.Drawing.Size(415, 142);
|
||||
this.groupBox1.TabIndex = 1;
|
||||
this.groupBox1.TabStop = false;
|
||||
this.groupBox1.Text = "LED控制";
|
||||
//
|
||||
// com_Port
|
||||
//
|
||||
this.com_Port.FormattingEnabled = true;
|
||||
this.com_Port.Location = new System.Drawing.Point(101, 24);
|
||||
this.com_Port.Name = "com_Port";
|
||||
this.com_Port.Size = new System.Drawing.Size(173, 20);
|
||||
this.com_Port.TabIndex = 6;
|
||||
this.com_Port.Click += new System.EventHandler(this.com_Port_Click);
|
||||
//
|
||||
// btn_Send
|
||||
//
|
||||
this.btn_Send.Location = new System.Drawing.Point(301, 91);
|
||||
this.btn_Send.Name = "btn_Send";
|
||||
this.btn_Send.Size = new System.Drawing.Size(75, 23);
|
||||
this.btn_Send.TabIndex = 5;
|
||||
this.btn_Send.Text = "推 送";
|
||||
this.btn_Send.UseVisualStyleBackColor = true;
|
||||
this.btn_Send.Click += new System.EventHandler(this.btn_Send_Click);
|
||||
//
|
||||
// label2
|
||||
//
|
||||
this.label2.AutoSize = true;
|
||||
this.label2.Location = new System.Drawing.Point(16, 67);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(71, 12);
|
||||
this.label2.TabIndex = 4;
|
||||
this.label2.Text = "推送LED信息";
|
||||
//
|
||||
// txt_SendText
|
||||
//
|
||||
this.txt_SendText.Location = new System.Drawing.Point(101, 64);
|
||||
this.txt_SendText.Name = "txt_SendText";
|
||||
this.txt_SendText.Size = new System.Drawing.Size(286, 21);
|
||||
this.txt_SendText.TabIndex = 3;
|
||||
//
|
||||
// btn_Open
|
||||
//
|
||||
this.btn_Open.Location = new System.Drawing.Point(301, 20);
|
||||
this.btn_Open.Name = "btn_Open";
|
||||
this.btn_Open.Size = new System.Drawing.Size(86, 23);
|
||||
this.btn_Open.TabIndex = 2;
|
||||
this.btn_Open.Text = "打 开";
|
||||
this.btn_Open.UseVisualStyleBackColor = true;
|
||||
this.btn_Open.Click += new System.EventHandler(this.btn_Open_Click);
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(16, 23);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(71, 12);
|
||||
this.label1.TabIndex = 0;
|
||||
this.label1.Text = "串 口";
|
||||
//
|
||||
// Form1
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(774, 308);
|
||||
this.Controls.Add(this.groupBox1);
|
||||
this.Controls.Add(this.led);
|
||||
this.Name = "Form1";
|
||||
this.Text = "LED显示屏";
|
||||
this.groupBox1.ResumeLayout(false);
|
||||
this.groupBox1.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private WinFormsDeviceControlLibrary.LED led;
|
||||
private System.Windows.Forms.GroupBox groupBox1;
|
||||
private System.Windows.Forms.Button btn_Send;
|
||||
private System.Windows.Forms.Label label2;
|
||||
private System.Windows.Forms.TextBox txt_SendText;
|
||||
private System.Windows.Forms.Button btn_Open;
|
||||
private System.Windows.Forms.Label label1;
|
||||
private System.Windows.Forms.ComboBox com_Port;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
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;//调用外部设备控制资源类所在的命名空间
|
||||
using WinFormsDeviceControlLibrary;//引用外部窗体类所在的命名空间
|
||||
|
||||
namespace LED显示屏
|
||||
{
|
||||
public partial class Form1 : Form
|
||||
{
|
||||
public Form1()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void btn_Open_Click(object sender, EventArgs e)
|
||||
{
|
||||
//在com_Port下拉列表中选中的项,作为当前串口
|
||||
DeviceCtrlHelper.ledHelper.OpenLedCom(com_Port.Text);
|
||||
}
|
||||
|
||||
private void btn_Send_Click(object sender, EventArgs e)
|
||||
{
|
||||
// 读txt_SendText控件的内容,保存在字符串变量res中
|
||||
string res = DeviceCtrlHelper.ledHelper.SendLedString(txt_SendText.Text);
|
||||
//判断字符串res是否为空
|
||||
if (res.IndexOf("Error") >= 0)
|
||||
{
|
||||
MessageBox.Show(res); //出错提示
|
||||
}
|
||||
else
|
||||
{
|
||||
led.setLedText(res);//发送
|
||||
}
|
||||
}
|
||||
|
||||
private void com_Port_Click(object sender, EventArgs e)
|
||||
{
|
||||
//清空列表
|
||||
com_Port.Items.Clear();
|
||||
//加载所有可用的串口号到列表中
|
||||
foreach (string item in SerialPort.GetPortNames())
|
||||
{
|
||||
com_Port.Items.Add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace LED显示屏
|
||||
{
|
||||
static class Program
|
||||
{
|
||||
/// <summary>
|
||||
/// 应用程序的主入口点。
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
Application.Run(new Form1());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"title": "项目2 任务1 LED显示屏的使用",
|
||||
"source": "教材书 p23–27,按书上代码整理(控件名以书上代码为准)"
|
||||
}
|
||||
Reference in new issue
Block a user