diff --git a/DNSD_DB/DNSD_DB.csproj b/DNSD_DB/DNSD_DB.csproj
index 717ec3b..0ca0a39 100644
--- a/DNSD_DB/DNSD_DB.csproj
+++ b/DNSD_DB/DNSD_DB.csproj
@@ -58,11 +58,11 @@
-
+
-
+
diff --git a/DNSD_DB/Entitys.cs b/DNSD_DB/Entitys.cs
new file mode 100644
index 0000000..85e9b79
--- /dev/null
+++ b/DNSD_DB/Entitys.cs
@@ -0,0 +1,42 @@
+using System;
+using System.ComponentModel;
+using Chloe.Annotations;
+
+namespace DNSD_DB
+{
+
+ public class RfidSetting
+ {
+ [Column(IsPrimaryKey = true)]
+ [AutoIncrement]
+ [DisplayName("自增主键")]
+ public int ID { get; set; }
+
+ public string RfidNo { get; set; }
+
+
+ public string Green { get; set; }
+
+ public string Yellow { get; set; }
+
+ public string Red { get; set; }
+
+ public bool IsEnable { get; set; }
+
+ public DateTime CreateDateTime { get; set; }
+
+ }
+
+ public class RFIDLog
+ {
+ [Column(IsPrimaryKey = true)]
+ [AutoIncrement]
+ public int ID { get; set; }
+
+ public DateTime CreateTime { get; set; }
+
+ public string LogText { get; set; }
+
+ public string RFIDId { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/DNSD_DB/Mapper/StudentMap.cs b/DNSD_DB/Mapper/Maps.cs
similarity index 76%
rename from DNSD_DB/Mapper/StudentMap.cs
rename to DNSD_DB/Mapper/Maps.cs
index 96c30ab..6ce9b73 100644
--- a/DNSD_DB/Mapper/StudentMap.cs
+++ b/DNSD_DB/Mapper/Maps.cs
@@ -2,22 +2,23 @@
namespace DNSD_DB.Mapper
{
- public class StudentMap:EntityTypeBuilder
+
+ public class RfidSettingMap : EntityTypeBuilder
{
- public StudentMap()
+ public RfidSettingMap()
{
- this.MapTo("Student");
+
+ this.MapTo("RfidSetting");
this.Property(a => a.ID).IsAutoIncrement().IsPrimaryKey();
}
}
-
- public class RfidSettingMap : EntityTypeBuilder
+ public class RFIDLogMap : EntityTypeBuilder
{
- public RfidSettingMap()
+ public RFIDLogMap()
{
- this.MapTo("RfidSetting");
+ this.MapTo("RFIDLog");
this.Property(a => a.ID).IsAutoIncrement().IsPrimaryKey();
}
}
diff --git a/DNSD_DB/SqlLiteTool.cs b/DNSD_DB/SqlLiteTool.cs
index 596305a..feac795 100644
--- a/DNSD_DB/SqlLiteTool.cs
+++ b/DNSD_DB/SqlLiteTool.cs
@@ -13,9 +13,11 @@ namespace DNSD_DB
public static void CreateTable(string db)
{
- DbConfiguration.UseTypeBuilders(typeof(StudentMap));
DbConfiguration.UseTypeBuilders(typeof(RfidSettingMap));
-
+ DbConfiguration.UseTypeBuilders(typeof(RFIDLogMap));
+
+
+
IDbContext dbContext = new SQLiteContext(new SQLiteConnectionFactory(db));
new SQLiteTableGenerator(dbContext).CreateTables(TableCreateMode.CreateIfNotExists);
}
diff --git a/DNSD_DB/Student.cs b/DNSD_DB/Student.cs
deleted file mode 100644
index c76e440..0000000
--- a/DNSD_DB/Student.cs
+++ /dev/null
@@ -1,66 +0,0 @@
-using System;
-using System.ComponentModel;
-using Chloe.Annotations;
-
-namespace DNSD_DB
-{
- public class Student
- {
- ///
- /// 学生ID [主键,自动递增]
- ///
- [Column(IsPrimaryKey = true)]
- [AutoIncrement]
- [DisplayName("学生ID")]
- public int ID { get; set; }
-
- ///
- /// 班级ID
- ///
-
- public int ClassID { get; set; }
-
- ///
- /// 学生姓名
- ///
-
- public string Name { get; set; }
-
- ///
- /// 学生年龄
- ///
-
- public int Age { get; set; }
-
- ///
- /// 学生性别
- ///
-
- public string Gender { get; set; }
- }
-
-
-
- public class RfidSetting
- {
- [Column(IsPrimaryKey = true)]
- [AutoIncrement]
- [DisplayName("自增主见")]
- public int ID { get; set; }
-
-
- public string RfidNo { get; set; }
-
-
- public string Green { get; set; }
-
- public string Yellow { get; set; }
-
- public string Red { get; set; }
-
- public bool IsEnable { get; set; }
-
- public DateTime CreateDateTime { get; set; }
-
- }
-}
\ No newline at end of file
diff --git a/NDSD-Screwdriver/Entity/LightsEntity.cs b/NDSD-Screwdriver/Entity/LightsEntity.cs
new file mode 100644
index 0000000..0c967ba
--- /dev/null
+++ b/NDSD-Screwdriver/Entity/LightsEntity.cs
@@ -0,0 +1,17 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace NDSD_Screwdriver.Entity
+{
+ public class LightsEntity
+ {
+ public int Green { get; set; }
+
+ public int Yellow { get; set; }
+
+ public int Red { get; set; }
+ }
+}
diff --git a/NDSD-Screwdriver/FormUtils.cs b/NDSD-Screwdriver/FormUtils.cs
index d699a02..3da38db 100644
--- a/NDSD-Screwdriver/FormUtils.cs
+++ b/NDSD-Screwdriver/FormUtils.cs
@@ -11,6 +11,10 @@ namespace NDSD_Screwdriver
{
public static Random r = new Random();
+ ///
+ /// 随机颜色测试
+ ///
+ ///
public static Brush TestRamColor()
{
int i = r.Next(0, 4);
@@ -22,9 +26,18 @@ namespace NDSD_Screwdriver
{
return Brushes.Yellow;
}
- else return Brushes.Red;
+ else /*if (i == 3)*/
+ {
+ return Brushes.Red;
+ }
+ //else return Brushes.Transparent;
}
-
+
+ ///
+ /// 颜色枚举值转换为颜色
+ ///
+ ///
+ ///
public static Brush EnumColorToBrush(LightState lightState)
{
switch (lightState)
diff --git a/NDSD-Screwdriver/FrmSetting.Designer.cs b/NDSD-Screwdriver/FrmSetting.Designer.cs
index 1ef7167..af3d2b4 100644
--- a/NDSD-Screwdriver/FrmSetting.Designer.cs
+++ b/NDSD-Screwdriver/FrmSetting.Designer.cs
@@ -29,10 +29,6 @@
private void InitializeComponent()
{
this.dataGridView1 = new System.Windows.Forms.DataGridView();
- this.RfidNo = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.Green = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.Yellow = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.Red = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.btnSave = new System.Windows.Forms.Button();
this.groupBox2 = new System.Windows.Forms.GroupBox();
@@ -41,6 +37,11 @@
this.label1 = new System.Windows.Forms.Label();
this.ServerPortTextbox = new System.Windows.Forms.TextBox();
this.ServerIPTextbox = new System.Windows.Forms.TextBox();
+ this.RfidNo = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ this.Green = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ this.Yellow = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ this.Red = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ this.label3 = new System.Windows.Forms.Label();
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
this.groupBox1.SuspendLayout();
this.groupBox2.SuspendLayout();
@@ -63,46 +64,6 @@
this.dataGridView1.Size = new System.Drawing.Size(615, 657);
this.dataGridView1.TabIndex = 0;
//
- // RfidNo
- //
- this.RfidNo.DataPropertyName = "RfidNo";
- this.RfidNo.HeaderText = "Rfid";
- this.RfidNo.MaxInputLength = 10;
- this.RfidNo.MinimumWidth = 8;
- this.RfidNo.Name = "RfidNo";
- this.RfidNo.Resizable = System.Windows.Forms.DataGridViewTriState.False;
- this.RfidNo.Width = 150;
- //
- // Green
- //
- this.Green.DataPropertyName = "Green";
- this.Green.HeaderText = "绿灯";
- this.Green.MaxInputLength = 2;
- this.Green.MinimumWidth = 8;
- this.Green.Name = "Green";
- this.Green.Resizable = System.Windows.Forms.DataGridViewTriState.False;
- this.Green.Width = 80;
- //
- // Yellow
- //
- this.Yellow.DataPropertyName = "Yellow";
- this.Yellow.HeaderText = "黄灯";
- this.Yellow.MaxInputLength = 2;
- this.Yellow.MinimumWidth = 8;
- this.Yellow.Name = "Yellow";
- this.Yellow.Resizable = System.Windows.Forms.DataGridViewTriState.False;
- this.Yellow.Width = 80;
- //
- // Red
- //
- this.Red.DataPropertyName = "Red";
- this.Red.HeaderText = "红灯";
- this.Red.MaxInputLength = 5;
- this.Red.MinimumWidth = 8;
- this.Red.Name = "Red";
- this.Red.Resizable = System.Windows.Forms.DataGridViewTriState.False;
- this.Red.Width = 80;
- //
// groupBox1
//
this.groupBox1.Controls.Add(this.dataGridView1);
@@ -117,7 +78,7 @@
//
// btnSave
//
- this.btnSave.Location = new System.Drawing.Point(27, 753);
+ this.btnSave.Location = new System.Drawing.Point(27, 723);
this.btnSave.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.btnSave.Name = "btnSave";
this.btnSave.Size = new System.Drawing.Size(163, 75);
@@ -184,11 +145,61 @@
this.ServerIPTextbox.TabIndex = 0;
this.ServerIPTextbox.Text = "192.168.0.101";
//
+ // RfidNo
+ //
+ this.RfidNo.DataPropertyName = "RfidNo";
+ this.RfidNo.HeaderText = "Rfid";
+ this.RfidNo.MaxInputLength = 20;
+ this.RfidNo.MinimumWidth = 20;
+ this.RfidNo.Name = "RfidNo";
+ this.RfidNo.Resizable = System.Windows.Forms.DataGridViewTriState.False;
+ this.RfidNo.Width = 150;
+ //
+ // Green
+ //
+ this.Green.DataPropertyName = "Green";
+ this.Green.HeaderText = "绿灯";
+ this.Green.MaxInputLength = 2;
+ this.Green.MinimumWidth = 8;
+ this.Green.Name = "Green";
+ this.Green.Resizable = System.Windows.Forms.DataGridViewTriState.False;
+ this.Green.Width = 80;
+ //
+ // Yellow
+ //
+ this.Yellow.DataPropertyName = "Yellow";
+ this.Yellow.HeaderText = "黄灯";
+ this.Yellow.MaxInputLength = 2;
+ this.Yellow.MinimumWidth = 8;
+ this.Yellow.Name = "Yellow";
+ this.Yellow.Resizable = System.Windows.Forms.DataGridViewTriState.False;
+ this.Yellow.Width = 80;
+ //
+ // Red
+ //
+ this.Red.DataPropertyName = "Red";
+ this.Red.HeaderText = "红灯";
+ this.Red.MaxInputLength = 5;
+ this.Red.MinimumWidth = 8;
+ this.Red.Name = "Red";
+ this.Red.Resizable = System.Windows.Forms.DataGridViewTriState.False;
+ this.Red.Width = 80;
+ //
+ // label3
+ //
+ this.label3.AutoSize = true;
+ this.label3.Location = new System.Drawing.Point(169, 9);
+ this.label3.Name = "label3";
+ this.label3.Size = new System.Drawing.Size(423, 15);
+ this.label3.TabIndex = 4;
+ this.label3.Text = "配置报警灯时,请按照:绿->黄->红 的顺序从大到小填写DO口";
+ //
// FrmSetting
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(1796, 937);
+ this.ClientSize = new System.Drawing.Size(1160, 819);
+ this.Controls.Add(this.label3);
this.Controls.Add(this.groupBox2);
this.Controls.Add(this.btnSave);
this.Controls.Add(this.groupBox1);
@@ -200,6 +211,7 @@
this.groupBox2.ResumeLayout(false);
this.groupBox2.PerformLayout();
this.ResumeLayout(false);
+ this.PerformLayout();
}
@@ -208,15 +220,16 @@
private System.Windows.Forms.DataGridView dataGridView1;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.Button btnSave;
- private System.Windows.Forms.DataGridViewTextBoxColumn RfidNo;
- private System.Windows.Forms.DataGridViewTextBoxColumn Green;
- private System.Windows.Forms.DataGridViewTextBoxColumn Yellow;
- private System.Windows.Forms.DataGridViewTextBoxColumn Red;
private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.TextBox ServerPortTextbox;
private System.Windows.Forms.TextBox ServerIPTextbox;
private System.Windows.Forms.Button SetServerIPButton;
+ private System.Windows.Forms.DataGridViewTextBoxColumn RfidNo;
+ private System.Windows.Forms.DataGridViewTextBoxColumn Green;
+ private System.Windows.Forms.DataGridViewTextBoxColumn Yellow;
+ private System.Windows.Forms.DataGridViewTextBoxColumn Red;
+ private System.Windows.Forms.Label label3;
}
}
\ No newline at end of file
diff --git a/NDSD-Screwdriver/MainForm.cs b/NDSD-Screwdriver/MainForm.cs
index 9d8d31a..1ccbdaf 100644
--- a/NDSD-Screwdriver/MainForm.cs
+++ b/NDSD-Screwdriver/MainForm.cs
@@ -14,6 +14,7 @@ using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
+using System.Xml.Serialization;
namespace NDSD_Screwdriver
{
@@ -34,6 +35,8 @@ namespace NDSD_Screwdriver
///
private List monitorEntities;
+ private List rfidSettings;
+
private Random rand = new Random();
/////
@@ -46,23 +49,28 @@ namespace NDSD_Screwdriver
///
public int NowRowIndex = 0;
+ ///
+ /// 准备工作的行号
+ ///
+ public int ReadyRowIndex = 0;
+
///
/// RFID列表
///
- public string[] RFIDs = new string[]
- {
- "1111222233334444",
- "2222222233334444",
- "3333222233334444",
- "4444222233334444",
- "5555222233334444"
- };
+ public string[] RFIDs;
+
+ public List lightsEntities;
+ Thread thread;
+
+ bool flag = false;
SerialPortFactory serialPort;
-
+
private CancellationTokenSource cancellationTokenSource;
+ private int textindex = 0;
+
public MainForm()
{
InitializeComponent();
@@ -71,25 +79,27 @@ namespace NDSD_Screwdriver
{
MessageBox.Show("服务端打开失败!");
}
-
- serialPort=new SerialPortFactory();
-
+ FlashThread();
+ serialPort = new SerialPortFactory();
StartLongRunningTask();
}
-
- private void StartLongRunningTask()
+
+ private void MainForm_FormClosed(object sender, FormClosedEventArgs e)
{
- cancellationTokenSource = new CancellationTokenSource();
- Task.Run(() =>
+ if (server != null)
{
- while (!cancellationTokenSource.Token.IsCancellationRequested)
+ if (!server.ServerStop())
{
- // 这里是你的长期运行逻辑
- Thread.Sleep(1000); // 模拟一些长时间的工作
+ MessageBox.Show("服务端关闭失败!");
}
- }, cancellationTokenSource.Token);
+ if (!server.ServerDispose())
+ {
+ MessageBox.Show("服务端释放失败!");
+ }
+ }
}
-
+
+ #region 按钮
///
/// 打开DO测试
@@ -99,117 +109,153 @@ namespace NDSD_Screwdriver
private void DOTest_Click(object sender, EventArgs e)
{
- string str= serialPort.Read();
+ //string str = serialPort.Read();
ScrewdriverTest screwdriverTest = new ScrewdriverTest(server, DOperate);
screwdriverTest.Show();
}
- private void MainForm_FormClosed(object sender, FormClosedEventArgs e)
+ ///
+ /// 测试按钮
+ ///
+ ///
+ ///
+ private void TestButton1_Click(object sender, EventArgs e)
{
- if (server != null)
+ if (RFIDs.Length == 0)
{
- if (!server.ServerStop())
- {
- MessageBox.Show("服务端关闭失败!");
- }
- if (!server.ServerDispose())
- {
- MessageBox.Show("服务端释放失败!");
- }
+ MessageBox.Show("没有值,请先设置。");
+ }
+
+
+ SetNowWorkRow(RFIDs[textindex]);
+ SetNowRowsLightState(1);
+ if (flag && thread.ThreadState == ThreadState.Suspended)
+ {
+ thread.Resume();
+ }
+ RefreshRoll();
+ if (++textindex >= RFIDs.Length)
+ {
+ textindex = 0;
}
}
///
- /// 列表回调函数
+ /// 初始化按钮
///
- ///
- ///
- ///
- ///
- ///
- ///
- private void ScrewdriverMonitor_OnDrawCellTextEvent(Graphics g, int rowIndex, int colIndex, RectangleF rectangle, string value, StringFormat sf)
+ ///
+ ///
+ private void InitButton_Click(object sender, EventArgs e)
{
- foreach (MonitorEntity entity in monitorEntities)
+ NowRowIndex = 0;
+ //读取rfid数据
+ var ctx = SqlLiteTool.GetDb(AppTool.GetDb());
+ var list = ctx.Query().Where(x => x.IsEnable == true).ToList();
+ RFIDs = list.Select(x => x.RfidNo).ToArray();
+ //读取报警灯数据
+ lightsEntities = new List();
+ for (int i = 0; i < list.Count; i++)
{
- if (rowIndex == entity.RowIndex)
+ lightsEntities.Add(new LightsEntity()
{
- foreach (RowEntity rowEneiey in entity.RowEntitys)
- {
- if (colIndex == rowEneiey.ColumnIndex)
- {
- g.FillRectangle(rowEneiey.Color, rectangle);
- g.DrawString(rowEneiey.Value, this.ScrewdriverMonitor.Font, Brushes.Black, rectangle, sf);
- }
- }
- }
+ Green = Convert.ToInt32(list[i].Green),
+ Yellow = Convert.ToInt32(list[i].Yellow),
+ Red = Convert.ToInt32(list[i].Red),
+ });
+ }
+ //初始化列表框架
+ monitorEntities = new List();
+ for (int i = 0; i < RFIDs.Length; i++)
+ {
+ monitorEntities.Add(new MonitorEntity()
+ {
+ RowIndex = i,
+ RowEntitys = InitRows(i)
+ });
}
+ if (flag)
+ {
+ thread.Suspend();
+ }
+ //更新值
+ for (int i = 0; i < RFIDs.Length; i++)
+ {
+ monitorEntities[i].RowEntitys[1].Value = RFIDs[i];
+ }
+ RefreshRoll();
}
///
- /// 测试按钮
+ /// 打开设置界面
///
///
///
- private void TestButton1_Click(object sender, EventArgs e)
+ private void SettingButton_Click(object sender, EventArgs e)
{
- if (RFIDs.Length == 0)
+ FrmSetting frmSetting = new FrmSetting();
+ frmSetting.Show();
+ }
+
+ ///
+ /// 服务端重启按钮
+ ///
+ ///
+ ///
+ private void ServerRestartButton_Click(object sender, EventArgs e)
+ {
+ if (server.ServerRestart(MemorySetting.ServerIP, MemorySetting.ServerPort))
{
- MessageBox.Show("没有值,请先设置。");
+ MessageBox.Show("服务器重启成功!");
}
-
- SetNowRowsLightState(FormUtils.TestRamColor());
-
- RefreshRoll();
- if (++NowRowIndex >= RFIDs.Length)
+ else
{
- NowRowIndex = 0;
+ MessageBox.Show("服务器重启失败!请手动启动服务器。");
}
- }
- private void InitButton_Click(object sender, EventArgs e)
- {
- NowRowIndex = 0;
- InitMonitirIntity();
- //var ctx = SqlLiteTool.GetDb(AppTool.GetDb());
- //var list = ctx.Query().Where(x => x.IsEnable == true).ToList();
- //RFIDs = list.Select(x => x.RfidNo).ToArray();
- SetRFIDValue(RFIDs);
}
///
- /// 刷新列表
+ /// 服务端手动启动
///
- private void RefreshRoll()
+ ///
+ ///
+ private void StartServerButton_Click(object sender, EventArgs e)
{
- for (int i = 0; i < RFIDs.Length; i++)
+ if (!server.ServerOpen(MemorySetting.ServerIP, MemorySetting.ServerPort))
{
- ScrewdriverMonitor.AddRowTop(new string[]{
- "",
- "",
- ""
- });
+ MessageBox.Show("服务端打开失败!");
+ }
+ else
+ {
+ MessageBox.Show("服务器启动成功");
}
}
///
- /// 初始化整个列表
+ /// 服务端手动停止
///
- private void InitMonitirIntity()
+ ///
+ ///
+ private void ServerStopButton_Click(object sender, EventArgs e)
{
- monitorEntities = new List();
- for (int i = 0; i < RFIDs.Length; i++)
+ if (server != null)
{
- monitorEntities.Add(new MonitorEntity()
+ if (!server.ServerStop())
{
- RowIndex = i,
- RowEntitys = InitRows(i)
- });
+ MessageBox.Show("服务端关闭失败!");
+ }
+ if (!server.ServerDispose())
+ {
+ MessageBox.Show("服务端释放失败!");
+ }
}
- RefreshRoll();
}
+ #endregion
+
+ #region 功能性方法
+
///
/// 初始化一行
///
@@ -229,84 +275,162 @@ namespace NDSD_Screwdriver
}
///
- /// 初始化RFID数据
+ /// 刷新列表
///
- /// RFID列表
- private void SetRFIDValue(string[] rFIDvalue)
+ private void RefreshRoll()
{
- for (int i = 0; i < rFIDvalue.Length; i++)
+ for (int i = 0; i < RFIDs.Length; i++)
{
- monitorEntities[i].RowEntitys[1].Value = rFIDvalue[i];
+ ScrewdriverMonitor.AddRowTop(new string[]{
+ "",
+ "",
+ ""
+ });
}
}
///
- /// 设置当前行指示灯的状态以及工作的行
+ /// 设置当前行指示灯的状态以及工作的行的标识 输入枚举类
///
///
private void SetNowRowsLightState(LightState lightState)
{
- monitorEntities[NowRowIndex].RowEntitys[2].Color = FormUtils.EnumColorToBrush(lightState);
+ SetNowRowsLightState(FormUtils.EnumColorToBrush(lightState));
+ }
- for (int i = 0; i < RFIDs.Length; i++)
- {
- monitorEntities[NowRowIndex].RowEntitys[0].Value = i == NowRowIndex ? "=>" : "";
- }
+ private void SetNowRowsLightState(int lightState)
+ {
+ SetNowRowsLightState((LightState)lightState);
}
+ ///
+ /// 设置当前行指示灯的状态以及工作的行的标识 输入Brush
+ ///
+ ///
private void SetNowRowsLightState(Brush brush)
{
+ if (monitorEntities.Count == 0)
+ {
+ return;
+ }
monitorEntities[NowRowIndex].RowEntitys[2].Color = brush;
+ SetNextRowsFlash();
for (int i = 0; i < RFIDs.Length; i++)
{
monitorEntities[i].RowEntitys[0].Value = i == NowRowIndex ? "=>" : "";
}
}
- private void SettingButton_Click(object sender, EventArgs e)
- {
- FrmSetting frmSetting = new FrmSetting();
- frmSetting.Show();
- }
-
- private void ServerRestartButton_Click(object sender, EventArgs e)
+ ///
+ /// 设置待工作灯闪烁
+ ///
+ private void SetNextRowsFlash()
{
- if (server.ServerRestart(MemorySetting.ServerIP, MemorySetting.ServerPort))
+ ReadyRowIndex = NowRowIndex + 1;
+ if (ReadyRowIndex >= RFIDs.Length)
{
- MessageBox.Show("服务器重启成功!");
+ ReadyRowIndex = 0;
+ thread.Suspend();
+ return;
}
- else
+ if (!flag)
{
- MessageBox.Show("服务器重启失败!请手动启动服务器。");
+ thread.Start();
+ flag = true;
}
-
}
- private void StartServerButton_Click(object sender, EventArgs e)
+
+ ///
+ /// 根据读取到的RFID条码设置当前工作的行
+ ///
+ /// 读取到的RFID
+ private void SetNowWorkRow(string rfid)
{
- if (!server.ServerOpen(MemorySetting.ServerIP, MemorySetting.ServerPort))
+ for (int i = 0; i < RFIDs.Length; i++)
{
- MessageBox.Show("服务端打开失败!");
+ if (monitorEntities[i].RowEntitys[1].Value == rfid)
+ {
+ NowRowIndex = i;
+ return;
+ }
}
- else
+ }
+
+ ///
+ /// 根据IO口控制灯的开关
+ ///
+ private void LightControl()
+ {
+
+ }
+
+ ///
+ /// 列表回调函数
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ private void ScrewdriverMonitor_OnDrawCellTextEvent(Graphics g, int rowIndex, int colIndex, RectangleF rectangle, string value, StringFormat sf)
+ {
+ foreach (MonitorEntity entity in monitorEntities)
{
- MessageBox.Show("服务器启动成功");
+ if (rowIndex == entity.RowIndex)
+ {
+ foreach (RowEntity rowEneiey in entity.RowEntitys)
+ {
+ if (colIndex == rowEneiey.ColumnIndex)
+ {
+ g.FillRectangle(rowEneiey.Color, rectangle);
+ g.DrawString(rowEneiey.Value, this.ScrewdriverMonitor.Font, Brushes.Black, rectangle, sf);
+ }
+ }
+ }
}
}
- private void ServerStopButton_Click(object sender, EventArgs e)
+ ///
+ /// RFID刷新任务
+ ///
+ private void StartLongRunningTask()
{
- if (server != null)
+ cancellationTokenSource = new CancellationTokenSource();
+ Task.Run(() =>
{
- if (!server.ServerStop())
+ while (!cancellationTokenSource.Token.IsCancellationRequested)
{
- MessageBox.Show("服务端关闭失败!");
+ // 这里是你的长期运行逻辑
+ Thread.Sleep(1000); // 模拟一些长时间的工作
}
- if (!server.ServerDispose())
+ }, cancellationTokenSource.Token);
+ }
+
+ ///
+ /// 等待工作指示灯闪烁进程
+ ///
+ private void FlashThread()
+ {
+ //等待闪烁线程
+ thread = new Thread(() =>
+ {
+ while (true)
{
- MessageBox.Show("服务端释放失败!");
+ DOperate.DTimeOpen(1, 1);
+ monitorEntities[ReadyRowIndex].RowEntitys[2].Color = Brushes.Yellow;
+ RefreshRoll();
+ Thread.Sleep(1000);
+ monitorEntities[ReadyRowIndex].RowEntitys[2].Color = Brushes.Transparent;
+ RefreshRoll();
+ Thread.Sleep(1000);
}
- }
+ });
}
+
+ #endregion
+
+
}
}
diff --git a/NDSD-Screwdriver/NDSD_Screwdriver.csproj b/NDSD-Screwdriver/NDSD_Screwdriver.csproj
index 9954e5d..343bb22 100644
--- a/NDSD-Screwdriver/NDSD_Screwdriver.csproj
+++ b/NDSD-Screwdriver/NDSD_Screwdriver.csproj
@@ -102,6 +102,7 @@
+
Form