change - 更改数据库结构 准备重构

master
SoulStar 3 months ago
parent 4bf8ca37cf
commit 95d9dc3c61

@ -50,6 +50,7 @@
<Reference Include="System.Data.SQLite">
<HintPath>..\Dll\System.Data.SQLite.dll</HintPath>
</Reference>
<Reference Include="System.Drawing" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
@ -58,11 +59,15 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Entity\LightsEntity.cs" />
<Compile Include="Entity\MonitorEntity.cs" />
<Compile Include="Entity\RFIDConfigEntity.cs" />
<Compile Include="Entity\RFIDLogsEntity.cs" />
<Compile Include="Entity\RFIDStatesEntity.cs" />
<Compile Include="Mapper\Maps.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SQLiteContext.cs" />
<Compile Include="SqlLiteTool.cs" />
<Compile Include="Entitys.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />

@ -4,7 +4,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace NDSD_Screwdriver.Entity
namespace DNSD_DB.Entity
{
public class LightsEntity
{

@ -5,7 +5,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace NDSD_Screwdriver.Entity
namespace DNSD_DB.Entity
{
public class MonitorEntity
{

@ -1,11 +1,14 @@
using System;
using Chloe.Annotations;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using Chloe.Annotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DNSD_DB
namespace DNSD_DB.Entity
{
public class RfidSetting
public class RFIDConfigEntity
{
[Column(IsPrimaryKey = true)]
[AutoIncrement]
@ -14,7 +17,6 @@ namespace DNSD_DB
public string RfidNo { get; set; }
public string Green { get; set; }
public string Yellow { get; set; }
@ -26,17 +28,4 @@ namespace DNSD_DB
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; }
}
}

@ -0,0 +1,22 @@
using Chloe.Annotations;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DNSD_DB.Entity
{
public class RFIDLogsEntity
{
[Column(IsPrimaryKey = true)]
[AutoIncrement]
public int ID { get; set; }
public DateTime CreateTime { get; set; }
public string LogText { get; set; }
public string RFIDId { get; set; } = string.Empty;
}
}

@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DNSD_DB.Entity
{
public class RFIDStatesEntity
{
/// <summary>
/// RFID值
/// </summary>
public string RFIDValue { get; set; }
/// <summary>
/// 状态指示 0未操作 1正在操作 2准备操作 3已完成 4超时报警
/// </summary>
public int RFIDState { get; set; } = 0;
}
}

@ -1,24 +1,25 @@
using Chloe.Entity;
using DNSD_DB.Entity;
namespace DNSD_DB.Mapper
{
public class RfidSettingMap : EntityTypeBuilder<RfidSetting>
public class RFIDConfigEntityMap : EntityTypeBuilder<RFIDConfigEntity>
{
public RfidSettingMap()
public RFIDConfigEntityMap()
{
this.MapTo("RfidSetting");
this.MapTo("RFIDConfigEntity");
this.Property(a => a.ID).IsAutoIncrement().IsPrimaryKey();
}
}
public class RFIDLogMap : EntityTypeBuilder<RFIDLog>
public class RFIDLogsEntityMap : EntityTypeBuilder<RFIDLogsEntity>
{
public RFIDLogMap()
public RFIDLogsEntityMap()
{
this.MapTo("RFIDLog");
this.MapTo("RFIDLogsEntity");
this.Property(a => a.ID).IsAutoIncrement().IsPrimaryKey();
}
}

@ -13,8 +13,8 @@ namespace DNSD_DB
public static void CreateTable(string db)
{
DbConfiguration.UseTypeBuilders(typeof(RfidSettingMap));
DbConfiguration.UseTypeBuilders(typeof(RFIDLogMap));
DbConfiguration.UseTypeBuilders(typeof(RFIDConfigEntityMap));
DbConfiguration.UseTypeBuilders(typeof(RFIDLogsEntityMap));

@ -1,4 +1,7 @@
using System;
using Chloe;
using DNSD_DB;
using DNSD_DB.Entity;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
@ -51,6 +54,41 @@ namespace NDSD_Screwdriver
default: return Brushes.Transparent;
}
}
/// <summary>
/// 插入无RFID编号日志
/// </summary>
/// <param name="dbContext"></param>
/// <param name="text"></param>
public static void LogInsert(IDbContext dbContext, string text)
{
dbContext.Insert(new RFIDLogsEntity()
{
CreateTime = DateTime.Now,
LogText = text,
});
}
/// <summary>
/// 插入有RFID编号日志
/// </summary>
/// <param name="dbContext"></param>
/// <param name="text"></param>
public static void LogInsert(IDbContext dbContext, string text, string rfid)
{
dbContext.Insert(new RFIDLogsEntity()
{
CreateTime = DateTime.Now,
LogText = text,
RFIDId = rfid
});
}
public static void SignAnalysis(IDbContext dbContext)
{
}
}
public enum LightState

@ -42,9 +42,14 @@
this.Yellow = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Red = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.label3 = new System.Windows.Forms.Label();
this.Groupbox3 = new System.Windows.Forms.GroupBox();
this.AlarmTimeValueTextBox = new System.Windows.Forms.TextBox();
this.label4 = new System.Windows.Forms.Label();
this.SetAlarmTimeValueButton = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
this.groupBox1.SuspendLayout();
this.groupBox2.SuspendLayout();
this.Groupbox3.SuspendLayout();
this.SuspendLayout();
//
// dataGridView1
@ -63,6 +68,7 @@
this.dataGridView1.RowTemplate.Height = 30;
this.dataGridView1.Size = new System.Drawing.Size(615, 657);
this.dataGridView1.TabIndex = 0;
this.dataGridView1.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_CellContentClick);
//
// groupBox1
//
@ -194,11 +200,51 @@
this.label3.TabIndex = 4;
this.label3.Text = "配置报警灯时,请按照:绿->黄->红 的顺序从大到小填写DO口";
//
// Groupbox3
//
this.Groupbox3.Controls.Add(this.SetAlarmTimeValueButton);
this.Groupbox3.Controls.Add(this.label4);
this.Groupbox3.Controls.Add(this.AlarmTimeValueTextBox);
this.Groupbox3.Location = new System.Drawing.Point(651, 98);
this.Groupbox3.Name = "Groupbox3";
this.Groupbox3.Size = new System.Drawing.Size(351, 96);
this.Groupbox3.TabIndex = 5;
this.Groupbox3.TabStop = false;
this.Groupbox3.Text = "超时报警时间设置";
//
// AlarmTimeValueTextBox
//
this.AlarmTimeValueTextBox.Location = new System.Drawing.Point(120, 37);
this.AlarmTimeValueTextBox.Name = "AlarmTimeValueTextBox";
this.AlarmTimeValueTextBox.Size = new System.Drawing.Size(100, 25);
this.AlarmTimeValueTextBox.TabIndex = 0;
this.AlarmTimeValueTextBox.Text = "10";
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(15, 42);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(97, 15);
this.label4.TabIndex = 1;
this.label4.Text = "报警时间阈值";
//
// SetAlarmTimeValueButton
//
this.SetAlarmTimeValueButton.Location = new System.Drawing.Point(237, 24);
this.SetAlarmTimeValueButton.Name = "SetAlarmTimeValueButton";
this.SetAlarmTimeValueButton.Size = new System.Drawing.Size(95, 50);
this.SetAlarmTimeValueButton.TabIndex = 2;
this.SetAlarmTimeValueButton.Text = "设置";
this.SetAlarmTimeValueButton.UseVisualStyleBackColor = true;
this.SetAlarmTimeValueButton.Click += new System.EventHandler(this.SetAlarmTimeValueButton_Click);
//
// FrmSetting
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1160, 819);
this.Controls.Add(this.Groupbox3);
this.Controls.Add(this.label3);
this.Controls.Add(this.groupBox2);
this.Controls.Add(this.btnSave);
@ -210,6 +256,8 @@
this.groupBox1.ResumeLayout(false);
this.groupBox2.ResumeLayout(false);
this.groupBox2.PerformLayout();
this.Groupbox3.ResumeLayout(false);
this.Groupbox3.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
@ -231,5 +279,9 @@
private System.Windows.Forms.DataGridViewTextBoxColumn Yellow;
private System.Windows.Forms.DataGridViewTextBoxColumn Red;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.GroupBox Groupbox3;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.TextBox AlarmTimeValueTextBox;
private System.Windows.Forms.Button SetAlarmTimeValueButton;
}
}

@ -1,6 +1,7 @@
using Chloe;
using DNSD_DB;
using DNSD_DB.Entity;
using NewLife.Data;
using NewLife.Reflection;
@ -27,19 +28,17 @@ namespace NDSD_Screwdriver
public FrmSetting()
{
InitializeComponent();
SqlLiteTool.CreateTable(AppTool.GetDb());
Init();
}
public void Init()
{
dataGridView1.AutoGenerateColumns = false;
var ctx = SqlLiteTool.GetDb(AppTool.GetDb());
var list = ctx.Query<RfidSetting>().Where(x => x.IsEnable == true).ToList();
var list = ctx.Query<RFIDConfigEntity>().Where(x => x.IsEnable == true).ToList();
// dataGridView1.DataSource = list;//DataGridView的行可以添加删除只有允许添加行、删除行
dataGridView1.DataSource = new BindingList<RfidSetting>(list);//DataGridView的行可以添加删除只有允许添加行、删除行
dataGridView1.DataSource = new BindingList<RFIDConfigEntity>(list);//DataGridView的行可以添加删除只有允许添加行、删除行
dataGridView1.AllowUserToAddRows = true;
dataGridView1.AllowUserToDeleteRows = true;
@ -83,13 +82,13 @@ namespace NDSD_Screwdriver
private void btnSave_Click(object sender, EventArgs e)
{
List<RfidSetting> list = new List<RfidSetting>();
List<RFIDConfigEntity> list = new List<RFIDConfigEntity>();
foreach (DataGridViewRow row in dataGridView1.Rows)
{
// 检查行的类型,确保不是新行或者标题行
if (!row.IsNewRow && row.Cells[0].Value != null)
{
RfidSetting rfidSetting = new RfidSetting();
RFIDConfigEntity RFIDConfigEntity = new RFIDConfigEntity();
// 获取当前行的值,并添加到列表中
string rfid = row.Cells[0].Value.ToString();
@ -103,9 +102,9 @@ namespace NDSD_Screwdriver
return;
}
rfidSetting.IsEnable = true;
rfidSetting.CreateDateTime = DateTime.Now;
rfidSetting.RfidNo = rfid;
RFIDConfigEntity.IsEnable = true;
RFIDConfigEntity.CreateDateTime = DateTime.Now;
RFIDConfigEntity.RfidNo = rfid;
if (string.IsNullOrEmpty(green))
{
@ -123,7 +122,7 @@ namespace NDSD_Screwdriver
}
}
rfidSetting.Green = green;
RFIDConfigEntity.Green = green;
@ -143,7 +142,7 @@ namespace NDSD_Screwdriver
}
}
rfidSetting.Yellow = yellow;
RFIDConfigEntity.Yellow = yellow;
if (string.IsNullOrEmpty(red))
{
@ -161,8 +160,8 @@ namespace NDSD_Screwdriver
}
}
rfidSetting.Red = red;
list.Add(rfidSetting);
RFIDConfigEntity.Red = red;
list.Add(RFIDConfigEntity);
}
}
@ -170,7 +169,7 @@ namespace NDSD_Screwdriver
if (list.Count > 0)
{
var ctx = SqlLiteTool.GetDb(AppTool.GetDb());
ctx.Update<RfidSetting>(a => a.IsEnable == true, a => new RfidSetting()
ctx.Update<RFIDConfigEntity>(a => a.IsEnable == true, a => new RFIDConfigEntity()
{
IsEnable = false
});
@ -195,6 +194,16 @@ namespace NDSD_Screwdriver
MemorySetting.ServerIP = ServerIPTextbox.Text;
MemorySetting.ServerPort = ServerPortTextbox.Text;
}
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
}
private void SetAlarmTimeValueButton_Click(object sender, EventArgs e)
{
MemorySetting.AlarmTimeValue = Convert.ToInt32(AlarmTimeValueTextBox.Text);
}
}
}

@ -29,7 +29,7 @@
private void InitializeComponent()
{
this.DOTest = new System.Windows.Forms.Button();
this.dataGridView1 = new System.Windows.Forms.DataGridView();
this.LogDataGridView = new System.Windows.Forms.DataGridView();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.ScrewdriverMonitor = new DNSD_Controls.HslTable();
this.TestButton = new System.Windows.Forms.Button();
@ -38,7 +38,9 @@
this.ServerRestartButton = new System.Windows.Forms.Button();
this.StartServerButton = new System.Windows.Forms.Button();
this.ServerStopButton = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
this.logTime = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.LogValue = new System.Windows.Forms.DataGridViewTextBoxColumn();
((System.ComponentModel.ISupportInitialize)(this.LogDataGridView)).BeginInit();
this.groupBox1.SuspendLayout();
this.SuspendLayout();
//
@ -52,20 +54,24 @@
this.DOTest.UseVisualStyleBackColor = true;
this.DOTest.Click += new System.EventHandler(this.DOTest_Click);
//
// dataGridView1
// LogDataGridView
//
this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView1.Dock = System.Windows.Forms.DockStyle.Fill;
this.dataGridView1.Location = new System.Drawing.Point(3, 21);
this.dataGridView1.Name = "dataGridView1";
this.dataGridView1.RowHeadersWidth = 51;
this.dataGridView1.RowTemplate.Height = 27;
this.dataGridView1.Size = new System.Drawing.Size(388, 826);
this.dataGridView1.TabIndex = 1;
this.LogDataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.LogDataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.logTime,
this.LogValue});
this.LogDataGridView.Dock = System.Windows.Forms.DockStyle.Fill;
this.LogDataGridView.Location = new System.Drawing.Point(3, 21);
this.LogDataGridView.Name = "LogDataGridView";
this.LogDataGridView.RowHeadersWidth = 51;
this.LogDataGridView.RowTemplate.Height = 27;
this.LogDataGridView.Size = new System.Drawing.Size(388, 826);
this.LogDataGridView.TabIndex = 1;
//
// groupBox1
//
this.groupBox1.Controls.Add(this.dataGridView1);
this.groupBox1.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.groupBox1.Controls.Add(this.LogDataGridView);
this.groupBox1.Dock = System.Windows.Forms.DockStyle.Right;
this.groupBox1.Location = new System.Drawing.Point(754, 0);
this.groupBox1.Name = "groupBox1";
@ -163,6 +169,19 @@
this.ServerStopButton.UseVisualStyleBackColor = true;
this.ServerStopButton.Click += new System.EventHandler(this.ServerStopButton_Click);
//
// logTime
//
this.logTime.HeaderText = "日志时间";
this.logTime.MinimumWidth = 6;
this.logTime.Name = "logTime";
//
// LogValue
//
this.LogValue.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
this.LogValue.HeaderText = "日志内容";
this.LogValue.MinimumWidth = 6;
this.LogValue.Name = "LogValue";
//
// MainForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F);
@ -180,7 +199,7 @@
this.Name = "MainForm";
this.Text = "MainForm";
this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.MainForm_FormClosed);
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.LogDataGridView)).EndInit();
this.groupBox1.ResumeLayout(false);
this.ResumeLayout(false);
@ -189,7 +208,7 @@
#endregion
private System.Windows.Forms.Button DOTest;
private System.Windows.Forms.DataGridView dataGridView1;
private System.Windows.Forms.DataGridView LogDataGridView;
private System.Windows.Forms.GroupBox groupBox1;
private DNSD_Controls.HslTable ScrewdriverMonitor;
private System.Windows.Forms.Button TestButton;
@ -198,5 +217,7 @@
private System.Windows.Forms.Button ServerRestartButton;
private System.Windows.Forms.Button StartServerButton;
private System.Windows.Forms.Button ServerStopButton;
private System.Windows.Forms.DataGridViewTextBoxColumn logTime;
private System.Windows.Forms.DataGridViewTextBoxColumn LogValue;
}
}

@ -1,7 +1,7 @@
using DNSD_DB;
using NDSD_Screwdriver.Entity;
using Chloe;
using DNSD_DB;
using DNSD_DB.Entity;
using NDSD_Screwdriver.Tool;
using NDSD_TouchSocket;
using System;
using System.Collections.Generic;
@ -35,7 +35,7 @@ namespace NDSD_Screwdriver
/// </summary>
private List<MonitorEntity> monitorEntities;
private List<RfidSetting> rfidSettings;
private List<RFIDConfigEntity> RFIDConfigEntitys;
private Random rand = new Random();
@ -55,29 +55,50 @@ namespace NDSD_Screwdriver
public int ReadyRowIndex = 0;
/// <summary>
/// RFID列表
/// RFID状态列表
/// </summary>
public string[] RFIDs;
public List<RFIDStatesEntity> RFIDStatesEntities;
/// <summary>
/// 报警灯配置实例
/// </summary>
public List<LightsEntity> lightsEntities;
/// <summary>
/// 日志实例
/// </summary>
public List<RFIDLogsEntity> RFIDLogsEntitys;
/// <summary>
/// 日志数据库操作实例
/// </summary>
public IDbContext LogContext;
Thread thread;
bool flag = false;
bool IsFirst = true;
SerialPortFactory serialPort;
private CancellationTokenSource cancellationTokenSource;
private int textindex = 0;
public int textRFID;
public MainForm()
{
SqlLiteTool.CreateTable(AppTool.GetDb());
InitializeComponent();
LogContext = SqlLiteTool.GetDb(AppTool.GetDb());
RFIDLogsEntitys = LogContext.Query<RFIDLogsEntity>().ToList();
DOperate = new DOperate();
if (!server.ServerOpen(MemorySetting.ServerIP, MemorySetting.ServerPort))
{
MessageBox.Show("服务端打开失败!");
FormUtils.LogInsert(LogContext, "服务端打开失败");
}
FlashThread();
serialPort = new SerialPortFactory();
@ -91,10 +112,13 @@ namespace NDSD_Screwdriver
if (!server.ServerStop())
{
MessageBox.Show("服务端关闭失败!");
FormUtils.LogInsert(LogContext, "服务端关闭失败");
}
if (!server.ServerDispose())
{
MessageBox.Show("服务端释放失败!");
FormUtils.LogInsert(LogContext, "服务端释放失败");
}
}
}
@ -122,22 +146,20 @@ namespace NDSD_Screwdriver
/// <param name="e"></param>
private void TestButton1_Click(object sender, EventArgs e)
{
if (RFIDs.Length == 0)
if (RFIDStatesEntities.Count == 0)
{
MessageBox.Show("没有值,请先设置。");
}
SetNowWorkRow(RFIDs[textindex]);
SetNowWorkRow(RFIDStatesEntities[NowRowIndex].RFIDValue);
SetNowRowsLightState(1);
if (flag && thread.ThreadState == ThreadState.Suspended)
{
thread.Resume();
}
RefreshRoll();
if (++textindex >= RFIDs.Length)
if (++NowRowIndex >= RFIDStatesEntities.Count)
{
textindex = 0;
NowRowIndex = 0;
}
}
@ -151,8 +173,16 @@ namespace NDSD_Screwdriver
NowRowIndex = 0;
//读取rfid数据
var ctx = SqlLiteTool.GetDb(AppTool.GetDb());
var list = ctx.Query<RfidSetting>().Where(x => x.IsEnable == true).ToList();
RFIDs = list.Select(x => x.RfidNo).ToArray();
var list = ctx.Query<RFIDConfigEntity>().Where(x => x.IsEnable == true).ToList();
var strs = list.Select(x => x.RfidNo).ToArray();
RFIDStatesEntities = new List<RFIDStatesEntity>();
foreach (var a in strs)
{
RFIDStatesEntities.Add(new RFIDStatesEntity()
{
RFIDValue = a,
});
}
//读取报警灯数据
lightsEntities = new List<LightsEntity>();
for (int i = 0; i < list.Count; i++)
@ -166,7 +196,7 @@ namespace NDSD_Screwdriver
}
//初始化列表框架
monitorEntities = new List<MonitorEntity>();
for (int i = 0; i < RFIDs.Length; i++)
for (int i = 0; i < RFIDStatesEntities.Count; i++)
{
monitorEntities.Add(new MonitorEntity()
{
@ -179,9 +209,9 @@ namespace NDSD_Screwdriver
thread.Suspend();
}
//更新值
for (int i = 0; i < RFIDs.Length; i++)
for (int i = 0; i < RFIDStatesEntities.Count; i++)
{
monitorEntities[i].RowEntitys[1].Value = RFIDs[i];
monitorEntities[i].RowEntitys[1].Value = RFIDStatesEntities[i].RFIDValue;
}
RefreshRoll();
}
@ -279,7 +309,7 @@ namespace NDSD_Screwdriver
/// </summary>
private void RefreshRoll()
{
for (int i = 0; i < RFIDs.Length; i++)
for (int i = 0; i < RFIDStatesEntities.Count; i++)
{
ScrewdriverMonitor.AddRowTop(new string[]{
"",
@ -315,7 +345,7 @@ namespace NDSD_Screwdriver
}
monitorEntities[NowRowIndex].RowEntitys[2].Color = brush;
SetNextRowsFlash();
for (int i = 0; i < RFIDs.Length; i++)
for (int i = 0; i < RFIDStatesEntities.Count; i++)
{
monitorEntities[i].RowEntitys[0].Value = i == NowRowIndex ? "=>" : "";
}
@ -326,8 +356,7 @@ namespace NDSD_Screwdriver
/// </summary>
private void SetNextRowsFlash()
{
ReadyRowIndex = NowRowIndex + 1;
if (ReadyRowIndex >= RFIDs.Length)
if (ReadyRowIndex >= RFIDStatesEntities.Count)
{
ReadyRowIndex = 0;
thread.Suspend();
@ -347,24 +376,46 @@ namespace NDSD_Screwdriver
/// <param name="rfid">读取到的RFID</param>
private void SetNowWorkRow(string rfid)
{
for (int i = 0; i < RFIDs.Length; i++)
{
if (monitorEntities[i].RowEntitys[1].Value == rfid)
ReadyRowIndex = NowRowIndex + 1;
//RFIDStatesEntities[ReadyRowIndex].RFIDState = 2;
//if (IsFirst)
//{
// IsFirst = false;
for (int i = 0; i < RFIDStatesEntities.Count; i++)
{
NowRowIndex = i;
return;
if (monitorEntities[i].RowEntitys[1].Value == rfid)
{
NowRowIndex = i;
return;
}
}
}
//}
//else
//{
// for (int i = 0; i < RFIDStatesEntities.Count; i++)
// {
// if (RFIDStatesEntities[i].RFIDState == 2)
// {
// NowRowIndex = i;
// return;
// }
// }
//}
}
/// <summary>
/// 根据IO口控制灯的开关
/// IO控制
/// </summary>
private void LightControl()
{
}
private void ComDataAnalysis(string str)
{
}
/// <summary>
/// 列表回调函数
/// </summary>
@ -402,8 +453,9 @@ namespace NDSD_Screwdriver
{
while (!cancellationTokenSource.Token.IsCancellationRequested)
{
// 这里是你的长期运行逻辑
Thread.Sleep(1000); // 模拟一些长时间的工作
Thread.Sleep(rand.Next(4, 16) * 1000); // 模拟一些长时间的工作
}
}, cancellationTokenSource.Token);
}

@ -117,4 +117,16 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="logTime.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="LogValue.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="logTime.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="LogValue.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
</root>

@ -8,8 +8,19 @@ namespace NDSD_Screwdriver
{
public static class MemorySetting
{
/// <summary>
/// 服务端IP
/// </summary>
public static string ServerIP { get; set; } = "192.168.0.101";
/// <summary>
/// 服务端端口
/// </summary>
public static string ServerPort { get; set; } = "6001";
/// <summary>
/// 超时报警时间
/// </summary>
public static int AlarmTimeValue { get; set; } = 10;
}
}

@ -102,7 +102,6 @@
</ItemGroup>
<ItemGroup>
<Compile Include="AppTool.cs" />
<Compile Include="Entity\LightsEntity.cs" />
<Compile Include="FrmSetting.cs">
<SubType>Form</SubType>
</Compile>
@ -115,7 +114,6 @@
<Compile Include="MainForm.Designer.cs">
<DependentUpon>MainForm.cs</DependentUpon>
</Compile>
<Compile Include="Entity\MonitorEntity.cs" />
<Compile Include="MemorySetting.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />

Loading…
Cancel
Save