Compare commits
32
Commits
e020333b82
..
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
eb2828aab0 | ||
|
|
33b970eff9 | ||
|
|
5caf92be59 | ||
|
|
437b8957ce | ||
|
|
a68fb9ae01 | ||
|
|
68b98ac7e4 | ||
|
|
2329ac9abc | ||
|
|
b062420be1 | ||
|
|
a248c41163 | ||
|
|
2b676adbba | ||
|
|
00a5cd3ec7 | ||
|
|
abfcf6e36a | ||
|
|
1df7212414 | ||
|
|
751a2b092f | ||
|
|
8a5e0ecfd9 | ||
|
|
ebcd5b7182 | ||
|
|
7f905617fa | ||
|
|
54d8cc7266 | ||
|
|
33e83fa5d6 | ||
|
|
927c38853d | ||
|
|
552d45485d | ||
|
|
17a5d6b718 | ||
|
|
34d3e6c292 | ||
|
|
5b60ea4765 | ||
|
|
b2817d1b01 | ||
|
|
7403914ba5 | ||
|
|
878d49c4a0 | ||
|
|
e457b0ab21 | ||
|
|
b0ce5bc8f9 | ||
|
|
d3375fd6ac | ||
|
|
7671f0ef08 | ||
|
|
25e6ae1563 |
No files matched your search
Binary file not shown.
Binary file not shown.
@@ -135,6 +135,7 @@
|
|||||||
<Compile Include="UserClass\CSV.cs" />
|
<Compile Include="UserClass\CSV.cs" />
|
||||||
<Compile Include="UserClass\DataGridHelper.cs" />
|
<Compile Include="UserClass\DataGridHelper.cs" />
|
||||||
<Compile Include="UserClass\DataTableForToObservableCollection.cs" />
|
<Compile Include="UserClass\DataTableForToObservableCollection.cs" />
|
||||||
|
<Compile Include="UserClass\DataTableManager .cs" />
|
||||||
<Compile Include="UserClass\get_local_ip_address.cs" />
|
<Compile Include="UserClass\get_local_ip_address.cs" />
|
||||||
<Compile Include="UserClass\HardwareSN.cs" />
|
<Compile Include="UserClass\HardwareSN.cs" />
|
||||||
<Compile Include="UserClass\IniFile.cs" />
|
<Compile Include="UserClass\IniFile.cs" />
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Security.Cryptography;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
@@ -59,6 +60,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
|
|||||||
portclient.Closed = (client, e) => { return EasyTask.CompletedTask; };//从端口断开连接,当连接不成功时不会触发。
|
portclient.Closed = (client, e) => { return EasyTask.CompletedTask; };//从端口断开连接,当连接不成功时不会触发。
|
||||||
portclient.Received = (client, e) =>
|
portclient.Received = (client, e) =>
|
||||||
{
|
{
|
||||||
|
//接受重置事件状态
|
||||||
_responseEvent.Set();
|
_responseEvent.Set();
|
||||||
string[] sArray = Regex.Split(e.ByteBlock.Span.ToString(Encoding.UTF8),
|
string[] sArray = Regex.Split(e.ByteBlock.Span.ToString(Encoding.UTF8),
|
||||||
@"\n", RegexOptions.IgnoreCase);
|
@"\n", RegexOptions.IgnoreCase);
|
||||||
@@ -67,23 +69,25 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
|
|||||||
{
|
{
|
||||||
if (sArray[i].Length > 5)
|
if (sArray[i].Length > 5)
|
||||||
{
|
{
|
||||||
return EasyTask.CompletedTask; ;
|
|
||||||
string SYSAPI = sArray[i].Substring(0, 5);
|
string SYSAPI = sArray[i].Substring(0, 5);
|
||||||
string Station = ClipBetween(sArray[i], '[', ']');
|
string Station = ClipBetween(sArray[i], '[', ']');
|
||||||
string DAT = sArray[i].Substring(sArray[i].IndexOf("]") + 1);
|
string DAT = sArray[i].Substring(sArray[i].IndexOf("]") + 1);
|
||||||
|
|
||||||
if (SYSAPI == "SC800")
|
if (SYSAPI == "SC800")
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Dictionary<string, object> _new = new Dictionary<string, object>();//缓存函数
|
Dictionary<string, object> _new = new Dictionary<string, object>();//缓存函数
|
||||||
_new = JsonConvert.DeserializeObject<Dictionary<string, object>>(DAT);//反序列化
|
_new = JsonConvert.DeserializeObject<Dictionary<string, object>>(DAT);//反序列化
|
||||||
DataRow drEmployee = MainWindowViewModel.Machines.Select("Station='" +
|
lock (MainWindowViewModel.Machines.Rows.SyncRoot)
|
||||||
Station + "' AND Serial = 'PORT1'").First();
|
{
|
||||||
|
DataRow drEmployee = MainWindowViewModel.Machines.Select("Station='" + Station + "' AND Serial = 'PORT1'").First();
|
||||||
drEmployee.BeginEdit();
|
drEmployee.BeginEdit();
|
||||||
drEmployee["State"] = "802";
|
drEmployee["State"] = "802";
|
||||||
drEmployee.EndEdit();
|
drEmployee.EndEdit();
|
||||||
drEmployee.AcceptChanges();
|
drEmployee.AcceptChanges();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
LogGing.ERRDATA(ex); MainWindowViewModel.ERR_c++;
|
LogGing.ERRDATA(ex); MainWindowViewModel.ERR_c++;
|
||||||
@@ -93,32 +97,50 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
DAT = DAT.Substring(DAT.IndexOf("]") + 1);
|
||||||
|
Dictionary<string, object> _dat;
|
||||||
|
_dat = SerializeConvert.JsonDeserializeFromString<Dictionary<string, object>>(DAT);
|
||||||
MainWindowViewModel.SQLiteHelpers.Update("WorkOrder", new Dictionary<string, object> { { "State", 111 } },
|
MainWindowViewModel.SQLiteHelpers.Update("WorkOrder", new Dictionary<string, object> { { "State", 111 } },
|
||||||
"WorkOrder ='" + DAT + "'", null);
|
"WorkOrder ='" + _dat.GetValue("Work") + "' AND ReDye ='" + _dat.GetValue("ReDye") + "'", null);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
LogGing.LogGingDATA("[ERR='" + ex + "']=Exception"); MainWindowViewModel.ERR_c++;
|
LogGing.LogGingDATA("[ERR='" + ex + "']=Exception"); MainWindowViewModel.ERR_c++;
|
||||||
}
|
}
|
||||||
}
|
}//回复的工单记录状态后就位111
|
||||||
else if (SYSAPI == "SC811")
|
else if (SYSAPI == "SC811")
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
{
|
||||||
|
DAT = DAT.Substring(DAT.IndexOf("]") + 1);
|
||||||
|
Dictionary<string, object> _dat;
|
||||||
|
_dat = SerializeConvert.JsonDeserializeFromString<Dictionary<string, object>>(DAT);
|
||||||
|
MainWindowViewModel.SQLiteHelpers.Update("WorkorderSteps", new Dictionary<string, object> { { "Mode", 1 } },
|
||||||
|
"WorkOrder ='" + _dat.GetValue("Work") + "' AND ReDye ='" + _dat.GetValue("ReDye") + "' AND Step ='" +
|
||||||
|
_dat.GetValue("Step") + "'", null);
|
||||||
|
|
||||||
|
int x = MainWindowViewModel.SQLiteHelpers.ExecuteDataSet("select * from WorkorderSteps where WorkOrder='" +
|
||||||
|
_dat.GetValue("Work") + "' AND ReDye ='" + _dat.GetValue("ReDye") + "' AND Mode <> '1'", null).Tables[0].Rows.Count;
|
||||||
|
if (x == 0)
|
||||||
{
|
{
|
||||||
MainWindowViewModel.SQLiteHelpers.Update("WorkOrder", new Dictionary<string, object> { { "State", 113 } },
|
MainWindowViewModel.SQLiteHelpers.Update("WorkOrder", new Dictionary<string, object> { { "State", 113 } },
|
||||||
"WorkOrder ='" + DAT + "'", null);
|
"WorkOrder ='" + _dat.GetValue("Work") + "' AND ReDye ='" + _dat.GetValue("ReDye") + "'", null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex) { LogGing.LogGingDATA("[ERR='" + ex + "']=Exception"); MainWindowViewModel.ERR_c++; }
|
catch (Exception ex) { LogGing.LogGingDATA("[ERR='" + ex + "']=Exception"); MainWindowViewModel.ERR_c++; }
|
||||||
}
|
}//回复的工单明细状态后就位113
|
||||||
else if (SYSAPI == "SC812")
|
else if (SYSAPI == "SC812")
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
DAT = DAT.Substring(DAT.IndexOf("]") + 1);
|
||||||
|
Dictionary<string, object> _dat;
|
||||||
|
_dat = SerializeConvert.JsonDeserializeFromString<Dictionary<string, object>>(DAT);
|
||||||
MainWindowViewModel.SQLiteHelpers.Update("WorkOrder", new Dictionary<string, object> { { "State", 101 } },
|
MainWindowViewModel.SQLiteHelpers.Update("WorkOrder", new Dictionary<string, object> { { "State", 101 } },
|
||||||
"WorkOrder ='" + DAT + "'", null);
|
"WorkOrder ='" + _dat.GetValue("Work") + "' AND ReDye ='" + _dat.GetValue("ReDye") + "'", null);
|
||||||
}
|
}
|
||||||
catch (Exception ex) { LogGing.LogGingDATA("[ERR='" + ex + "']=Exception"); MainWindowViewModel.ERR_c++; }
|
catch (Exception ex) { LogGing.LogGingDATA("[ERR='" + ex + "']=Exception"); MainWindowViewModel.ERR_c++; }
|
||||||
}
|
}//回复的工单设置状态后就位101
|
||||||
else if (SYSAPI == "SC827")
|
else if (SYSAPI == "SC827")
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -132,33 +154,37 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
|
|||||||
{
|
{
|
||||||
Dictionary<string, object> _new = new Dictionary<string, object>();//缓存函数
|
Dictionary<string, object> _new = new Dictionary<string, object>();//缓存函数
|
||||||
_new = JsonConvert.DeserializeObject<Dictionary<string, object>>(DAT);//反序列化
|
_new = JsonConvert.DeserializeObject<Dictionary<string, object>>(DAT);//反序列化
|
||||||
DataRow drEmployee = MainWindowViewModel.Machines.Select("Station='" +
|
string mac;
|
||||||
Station + "' AND Serial = 'PORT1'").First();
|
lock (MainWindowViewModel.Machines.Rows.SyncRoot)
|
||||||
|
{
|
||||||
|
DataRow drEmployee = MainWindowViewModel.Machines.Select("Station='" + Station + "' AND Serial = 'PORT1'").First();
|
||||||
|
mac = drEmployee["Name"].ToString();
|
||||||
drEmployee.BeginEdit();
|
drEmployee.BeginEdit();
|
||||||
drEmployee["ERR"] = _new.GetValue("ERR");
|
drEmployee["ERR"] = _new.GetValue("ERR");
|
||||||
drEmployee["LOCK"] = _new.GetValue("LOCK");
|
drEmployee["LOCK"] = _new.GetValue("LOCK");
|
||||||
drEmployee["Message"] = _new.GetValue("Status");
|
drEmployee["Message"] = _new.GetValue("Status");
|
||||||
drEmployee["WorkOrder"] = _new.GetValue("WorkNumder");
|
drEmployee["WorkOrder"] = _new.GetValue("Work");
|
||||||
drEmployee["Temperature"] = _new.GetValue("MTT");
|
drEmployee["Temperature"] = _new.GetValue("MTT");
|
||||||
drEmployee["WaterLevel"] = _new.GetValue("MTL");
|
drEmployee["WaterLevel"] = _new.GetValue("MTL");
|
||||||
drEmployee["Process"] = _new.GetValue("Process");
|
drEmployee["Process"] = _new.GetValue("Process");
|
||||||
drEmployee["Step"] = _new.GetValue("Step");
|
drEmployee["Step"] = _new.GetValue("Step");
|
||||||
drEmployee["UserButton"] = _new.GetValue("UserButton");
|
drEmployee["UserButton"] = _new.GetValue("UserB");
|
||||||
if (_new.GetValue("UserInfoStart").ToString() != "900")
|
if (_new.GetValue("InfoS").ToString() != "900")
|
||||||
{ drEmployee["UserInfoStart"] = _new.GetValue("UserInfoStart"); }
|
{ drEmployee["UserInfoStart"] = _new.GetValue("InfoS"); }
|
||||||
drEmployee["UserInfo"] = _new.GetValue("UserInfo");
|
drEmployee["UserInfo"] = _new.GetValue("Info");
|
||||||
drEmployee["WORK_RUN"] = _new.GetValue("WORK_RUN");
|
drEmployee["WORK_RUN"] = _new.GetValue("RUN");
|
||||||
drEmployee["RUN_STEPID"] = _new.GetValue("RUN_STEPID");
|
drEmployee["RUN_STEPID"] = _new.GetValue("STEPID");
|
||||||
drEmployee["CALL"] = _new.GetValue("CALL");
|
drEmployee["CALL"] = _new.GetValue("CALL");
|
||||||
drEmployee.EndEdit();
|
drEmployee.EndEdit();
|
||||||
drEmployee.AcceptChanges();
|
drEmployee.AcceptChanges();
|
||||||
|
}
|
||||||
|
|
||||||
if (_new.GetValue("Status").ToString() != "----------")
|
if (_new.GetValue("Status").ToString() != "----------")
|
||||||
{
|
{
|
||||||
Dictionary<string, object> Chart_new = new Dictionary<string, object>();//缓存函数
|
Dictionary<string, object> Chart_new = new Dictionary<string, object>();//缓存函数
|
||||||
Chart_new.Add("WorkOrder", _new.GetValue("WorkNumder"));
|
Chart_new.Add("WorkOrder", _new.GetValue("Work"));
|
||||||
Chart_new.Add("Machine", _new.GetValue("Machine"));
|
//Chart_new.Add("Machine", mac);
|
||||||
Chart_new.Add("Time", _new.GetValue("Time"));
|
//Chart_new.Add("Time", _new.GetValue("Time"));
|
||||||
Chart_new.Add("MST", _new.GetValue("MST"));
|
Chart_new.Add("MST", _new.GetValue("MST"));
|
||||||
Chart_new.Add("MTT", _new.GetValue("MTT"));
|
Chart_new.Add("MTT", _new.GetValue("MTT"));
|
||||||
Chart_new.Add("MTL", _new.GetValue("MTL"));
|
Chart_new.Add("MTL", _new.GetValue("MTL"));
|
||||||
@@ -174,7 +200,10 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
|
|||||||
MainWindowViewModel.SQLiteChartAdress.InsertData("Chart", Chart_new);// 执行插入
|
MainWindowViewModel.SQLiteChartAdress.InsertData("Chart", Chart_new);// 执行插入
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex) { LogGing.LogGingDATA("[ERR='" + ex + "']=Exception"); MainWindowViewModel.ERR_c++; }
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
LogGing.LogGingDATA("[ERR='" + ex + "']=Exception"); MainWindowViewModel.ERR_c++;
|
||||||
|
}
|
||||||
}//当前信息
|
}//当前信息
|
||||||
else if (SYSAPI == "SC831")
|
else if (SYSAPI == "SC831")
|
||||||
{
|
{
|
||||||
@@ -378,8 +407,6 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
|
|||||||
string[] sArray = Regex.Split(e.ByteBlock.Span.ToString(Encoding.UTF8),
|
string[] sArray = Regex.Split(e.ByteBlock.Span.ToString(Encoding.UTF8),
|
||||||
@"\n", RegexOptions.IgnoreCase);
|
@"\n", RegexOptions.IgnoreCase);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return EasyTask.CompletedTask; ;
|
return EasyTask.CompletedTask; ;
|
||||||
};
|
};
|
||||||
await portclient.SetupAsync(new TouchSocketConfig()
|
await portclient.SetupAsync(new TouchSocketConfig()
|
||||||
@@ -391,7 +418,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
|
|||||||
PortName = com,//COM
|
PortName = com,//COM
|
||||||
StopBits = System.IO.Ports.StopBits.One,//停止位
|
StopBits = System.IO.Ports.StopBits.One,//停止位
|
||||||
})
|
})
|
||||||
.SetSerialDataHandlingAdapter(() => new PeriodPackageAdapter() { CacheTimeout = TimeSpan.FromMilliseconds(100) })
|
.SetSerialDataHandlingAdapter(() => new PeriodPackageAdapter() { CacheTimeout = TimeSpan.FromMilliseconds(500) })
|
||||||
.ConfigurePlugins(a =>
|
.ConfigurePlugins(a =>
|
||||||
{
|
{
|
||||||
//a.Add<MyPlugin>();
|
//a.Add<MyPlugin>();
|
||||||
@@ -419,10 +446,36 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
|
|||||||
var t = CRCcheck16.ToCRC16(command);
|
var t = CRCcheck16.ToCRC16(command);
|
||||||
_responseEvent.Reset();
|
_responseEvent.Reset();
|
||||||
serialPortClients.Send(command); // 发送指令
|
serialPortClients.Send(command); // 发送指令
|
||||||
|
|
||||||
// 等待500毫秒或直到收到响应
|
// 等待500毫秒或直到收到响应
|
||||||
_responseEvent.Wait(TimeSpan.FromMilliseconds(1000));
|
if (!_responseEvent.Wait(TimeSpan.FromMilliseconds(1000)))
|
||||||
// 重置事件状态
|
{
|
||||||
_responseEvent.Set();
|
_responseEvent.Set();
|
||||||
|
//清楚了解状态
|
||||||
|
string Station = ClipBetween(command, '[', ']');
|
||||||
|
lock (MainWindowViewModel.Machines.Rows.SyncRoot)
|
||||||
|
{
|
||||||
|
DataRow drEmployee = MainWindowViewModel.Machines.Select("Station='" +
|
||||||
|
Station + "' AND Serial = 'PORT1'").First();
|
||||||
|
if (drEmployee.Field<int>("State") != 800)
|
||||||
|
{
|
||||||
|
drEmployee.BeginEdit();
|
||||||
|
drEmployee["State"] = "800";
|
||||||
|
drEmployee["WorkOrder"] = "------";
|
||||||
|
drEmployee["Dyelot"] = "";
|
||||||
|
drEmployee["Temperature"] = 0.0;
|
||||||
|
drEmployee["WaterLevel"] = 0.0;
|
||||||
|
drEmployee["Process"] = "";
|
||||||
|
drEmployee["Step"] = "";
|
||||||
|
drEmployee["Message"] = "";
|
||||||
|
drEmployee["SYSKEY"] = "";
|
||||||
|
drEmployee["WORK_RUN"] = "-1";
|
||||||
|
drEmployee["ERR"] = false;
|
||||||
|
drEmployee.EndEdit();
|
||||||
|
drEmployee.AcceptChanges();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception) { }
|
catch (Exception) { }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,13 +48,15 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
|
|||||||
tcpClient.Connected = (client, e) =>
|
tcpClient.Connected = (client, e) =>
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
{
|
||||||
|
lock (MainWindowViewModel.Machines.Rows.SyncRoot)
|
||||||
{
|
{
|
||||||
DataRow drEmployee = MainWindowViewModel.Machines.Select("IP='" + client.IP + "'").First();
|
DataRow drEmployee = MainWindowViewModel.Machines.Select("IP='" + client.IP + "'").First();
|
||||||
drEmployee.BeginEdit();
|
drEmployee.BeginEdit();
|
||||||
drEmployee["State"] = "801";
|
drEmployee["State"] = "801";
|
||||||
drEmployee.EndEdit();
|
drEmployee.EndEdit();
|
||||||
drEmployee.AcceptChanges();
|
drEmployee.AcceptChanges();
|
||||||
|
}
|
||||||
LogGing.LogGingDATA("[IP='" + client.IP + "' AND port='" + client.Port + "']=Link_OK");
|
LogGing.LogGingDATA("[IP='" + client.IP + "' AND port='" + client.Port + "']=Link_OK");
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@@ -67,6 +69,8 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
|
|||||||
tcpClient.Closing = (client, e) =>
|
tcpClient.Closing = (client, e) =>
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
{
|
||||||
|
lock (MainWindowViewModel.Machines.Rows.SyncRoot)
|
||||||
{
|
{
|
||||||
DataRow drEmployee = MainWindowViewModel.Machines.Select("IP='" + client.IP + "'").First();
|
DataRow drEmployee = MainWindowViewModel.Machines.Select("IP='" + client.IP + "'").First();
|
||||||
drEmployee.BeginEdit();
|
drEmployee.BeginEdit();
|
||||||
@@ -74,7 +78,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
|
|||||||
drEmployee["WorkOrder"] = "------";
|
drEmployee["WorkOrder"] = "------";
|
||||||
drEmployee["Dyelot"] = "";
|
drEmployee["Dyelot"] = "";
|
||||||
drEmployee["Temperature"] = 0.0;
|
drEmployee["Temperature"] = 0.0;
|
||||||
drEmployee["WaterLevel"] = "----";
|
drEmployee["WaterLevel"] = 0.0;
|
||||||
drEmployee["Process"] = "";
|
drEmployee["Process"] = "";
|
||||||
drEmployee["Step"] = "";
|
drEmployee["Step"] = "";
|
||||||
drEmployee["Message"] = "";
|
drEmployee["Message"] = "";
|
||||||
@@ -83,6 +87,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
|
|||||||
drEmployee["ERR"] = false;
|
drEmployee["ERR"] = false;
|
||||||
drEmployee.EndEdit();
|
drEmployee.EndEdit();
|
||||||
drEmployee.AcceptChanges();
|
drEmployee.AcceptChanges();
|
||||||
|
}
|
||||||
LogGing.LogGingDATA("[IP='" + client.IP + "' AND port='" + client.Port + "']=Link_STOP");
|
LogGing.LogGingDATA("[IP='" + client.IP + "' AND port='" + client.Port + "']=Link_STOP");
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@@ -94,6 +99,8 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
|
|||||||
tcpClient.Closed = (client, e) =>
|
tcpClient.Closed = (client, e) =>
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
{
|
||||||
|
lock (MainWindowViewModel.Machines.Rows.SyncRoot)
|
||||||
{
|
{
|
||||||
DataRow drEmployee = MainWindowViewModel.Machines.Select("IP='" + client.IP + "'").First();
|
DataRow drEmployee = MainWindowViewModel.Machines.Select("IP='" + client.IP + "'").First();
|
||||||
drEmployee.BeginEdit();
|
drEmployee.BeginEdit();
|
||||||
@@ -101,7 +108,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
|
|||||||
drEmployee["WorkOrder"] = "------";
|
drEmployee["WorkOrder"] = "------";
|
||||||
drEmployee["Dyelot"] = "";
|
drEmployee["Dyelot"] = "";
|
||||||
drEmployee["Temperature"] = 0.0;
|
drEmployee["Temperature"] = 0.0;
|
||||||
drEmployee["WaterLevel"] = "----";
|
drEmployee["WaterLevel"] = 0.0;
|
||||||
drEmployee["Process"] = "";
|
drEmployee["Process"] = "";
|
||||||
drEmployee["Step"] = "";
|
drEmployee["Step"] = "";
|
||||||
drEmployee["Message"] = "";
|
drEmployee["Message"] = "";
|
||||||
@@ -110,6 +117,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
|
|||||||
drEmployee["ERR"] = false;
|
drEmployee["ERR"] = false;
|
||||||
drEmployee.EndEdit();
|
drEmployee.EndEdit();
|
||||||
drEmployee.AcceptChanges();
|
drEmployee.AcceptChanges();
|
||||||
|
}
|
||||||
LogGing.LogGingDATA("[IP='" + client.IP + "' AND port='" + client.Port + "']=Link_INTERRUPT");
|
LogGing.LogGingDATA("[IP='" + client.IP + "' AND port='" + client.Port + "']=Link_INTERRUPT");
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@@ -130,6 +138,8 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
|
|||||||
DAT = DAT.Substring(DAT.IndexOf("]") + 1);
|
DAT = DAT.Substring(DAT.IndexOf("]") + 1);
|
||||||
Dictionary<string, object> Chart_new = new Dictionary<string, object>();//缓存函数
|
Dictionary<string, object> Chart_new = new Dictionary<string, object>();//缓存函数
|
||||||
Chart_new = JsonConvert.DeserializeObject<Dictionary<string, object>>(DAT);//反序列化
|
Chart_new = JsonConvert.DeserializeObject<Dictionary<string, object>>(DAT);//反序列化
|
||||||
|
lock (MainWindowViewModel.Machines.Rows.SyncRoot)
|
||||||
|
{
|
||||||
DataRow drEmployee = MainWindowViewModel.Machines.Select("IP='" + client.IP + "'").First();
|
DataRow drEmployee = MainWindowViewModel.Machines.Select("IP='" + client.IP + "'").First();
|
||||||
drEmployee.BeginEdit();
|
drEmployee.BeginEdit();
|
||||||
drEmployee["SYSKEY"] = Chart_new.GetValue("SYSKEY").ToString();
|
drEmployee["SYSKEY"] = Chart_new.GetValue("SYSKEY").ToString();
|
||||||
@@ -139,6 +149,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
|
|||||||
drEmployee.EndEdit();
|
drEmployee.EndEdit();
|
||||||
drEmployee.AcceptChanges();
|
drEmployee.AcceptChanges();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
LogGing.ERRDATA(ex); MainWindowViewModel.ERR_c++;
|
LogGing.ERRDATA(ex); MainWindowViewModel.ERR_c++;
|
||||||
@@ -149,8 +160,13 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
DAT = DAT.Substring(DAT.IndexOf("]") + 1);
|
DAT = DAT.Substring(DAT.IndexOf("]") + 1);
|
||||||
|
|
||||||
MainWindowViewModel.SQLiteHelpers.Update("WorkOrder", new Dictionary<string, object> { { "State", 111 } },
|
MainWindowViewModel.SQLiteHelpers.Update("WorkOrder", new Dictionary<string, object> { { "State", 111 } },
|
||||||
"WorkOrder ='" + DAT + "'", null);
|
"WorkOrder ='" + DAT + "'", null);
|
||||||
|
// Dictionary<string, object> _dat;
|
||||||
|
// _dat = SerializeConvert.JsonDeserializeFromString<Dictionary<string, object>>(DAT);
|
||||||
|
// MainWindowViewModel.SQLiteHelpers.Update("WorkOrder", new Dictionary<string, object> { { "State", 111 } },
|
||||||
|
// "WorkOrder ='" + _dat.GetValue("WorkOrder") + "' AND ReDye ='" + _dat.GetValue("ReDye") + "'", null);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@@ -162,8 +178,13 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
DAT = DAT.Substring(DAT.IndexOf("]") + 1);
|
DAT = DAT.Substring(DAT.IndexOf("]") + 1);
|
||||||
MainWindowViewModel.SQLiteHelpers.Update("WorkOrder", new Dictionary<string, object> { { "State", 113 } },
|
|
||||||
|
MainWindowViewModel.SQLiteHelpers.Update("WorkOrder", new Dictionary<string, object> { { "State", 111 } },
|
||||||
"WorkOrder ='" + DAT + "'", null);
|
"WorkOrder ='" + DAT + "'", null);
|
||||||
|
// Dictionary<string, object> _dat;
|
||||||
|
// _dat = SerializeConvert.JsonDeserializeFromString<Dictionary<string, object>>(DAT);
|
||||||
|
// MainWindowViewModel.SQLiteHelpers.Update("WorkOrder", new Dictionary<string, object> { { "State", 113 } },
|
||||||
|
// "WorkOrder ='" + _dat.GetValue("WorkOrder") + "' AND ReDye ='"+ _dat.GetValue("ReDye") + "'", null);
|
||||||
}
|
}
|
||||||
catch (Exception ex) { LogGing.LogGingDATA("[ERR='" + ex + "']=Exception"); MainWindowViewModel.ERR_c++; }
|
catch (Exception ex) { LogGing.LogGingDATA("[ERR='" + ex + "']=Exception"); MainWindowViewModel.ERR_c++; }
|
||||||
}
|
}
|
||||||
@@ -212,6 +233,8 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
|
|||||||
DataTable dataTable = JsonConvert.DeserializeObject<DataTable>(DAT);//反序列化
|
DataTable dataTable = JsonConvert.DeserializeObject<DataTable>(DAT);//反序列化
|
||||||
|
|
||||||
foreach (DataRow sourceRow in dataTable.Rows)
|
foreach (DataRow sourceRow in dataTable.Rows)
|
||||||
|
{
|
||||||
|
lock (MainWindowViewModel.Dyelot_CALL.Rows.SyncRoot)
|
||||||
{
|
{
|
||||||
// 创建新行(基于目标表结构)
|
// 创建新行(基于目标表结构)
|
||||||
DataRow newRow = MainWindowViewModel.Dyelot_CALL.NewRow();
|
DataRow newRow = MainWindowViewModel.Dyelot_CALL.NewRow();
|
||||||
@@ -247,6 +270,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
catch (Exception ex) { LogGing.LogGingDATA("[ERR='" + ex + "']=Exception"); MainWindowViewModel.ERR_c++; }
|
catch (Exception ex) { LogGing.LogGingDATA("[ERR='" + ex + "']=Exception"); MainWindowViewModel.ERR_c++; }
|
||||||
}//获取呼叫领料单
|
}//获取呼叫领料单
|
||||||
else if (SYSAPI == "SC830")
|
else if (SYSAPI == "SC830")
|
||||||
@@ -256,7 +280,12 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
|
|||||||
DAT = DAT.Substring(DAT.IndexOf("]") + 1);
|
DAT = DAT.Substring(DAT.IndexOf("]") + 1);
|
||||||
Dictionary<string, object> _new = new Dictionary<string, object>();//缓存函数
|
Dictionary<string, object> _new = new Dictionary<string, object>();//缓存函数
|
||||||
_new = JsonConvert.DeserializeObject<Dictionary<string, object>>(DAT);//反序列化
|
_new = JsonConvert.DeserializeObject<Dictionary<string, object>>(DAT);//反序列化
|
||||||
|
string mac;
|
||||||
|
// 首先确保 DataTable 使用线程安全的访问方式
|
||||||
|
lock (MainWindowViewModel.Machines.Rows.SyncRoot)
|
||||||
|
{
|
||||||
DataRow drEmployee = MainWindowViewModel.Machines.Select("IP='" + client.IP + "'").First();
|
DataRow drEmployee = MainWindowViewModel.Machines.Select("IP='" + client.IP + "'").First();
|
||||||
|
mac = drEmployee["Name"].ToString();
|
||||||
drEmployee.BeginEdit();
|
drEmployee.BeginEdit();
|
||||||
drEmployee["ERR"] = _new.GetValue("ERR");
|
drEmployee["ERR"] = _new.GetValue("ERR");
|
||||||
drEmployee["LOCK"] = _new.GetValue("LOCK");
|
drEmployee["LOCK"] = _new.GetValue("LOCK");
|
||||||
@@ -275,12 +304,12 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
|
|||||||
drEmployee["CALL"] = _new.GetValue("CALL");
|
drEmployee["CALL"] = _new.GetValue("CALL");
|
||||||
drEmployee.EndEdit();
|
drEmployee.EndEdit();
|
||||||
drEmployee.AcceptChanges();
|
drEmployee.AcceptChanges();
|
||||||
|
}
|
||||||
if (_new.GetValue("Status").ToString() != "----------")
|
if (_new.GetValue("Status").ToString() != "----------")
|
||||||
{
|
{
|
||||||
Dictionary<string, object> Chart_new = new Dictionary<string, object>();//缓存函数
|
Dictionary<string, object> Chart_new = new Dictionary<string, object>();//缓存函数
|
||||||
Chart_new.Add("WorkOrder", _new.GetValue("WorkNumder"));
|
Chart_new.Add("WorkOrder", _new.GetValue("WorkNumder"));
|
||||||
Chart_new.Add("Machine", drEmployee["Name"]);
|
Chart_new.Add("Machine", mac);
|
||||||
Chart_new.Add("Time", DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"));
|
Chart_new.Add("Time", DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"));
|
||||||
Chart_new.Add("MST", _new.GetValue("MST"));
|
Chart_new.Add("MST", _new.GetValue("MST"));
|
||||||
Chart_new.Add("MTT", _new.GetValue("MTT"));
|
Chart_new.Add("MTT", _new.GetValue("MTT"));
|
||||||
@@ -308,7 +337,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
|
|||||||
MainWindowViewModel.dt_TP = JsonConvert.DeserializeObject<DataTable>(DAT);//反序列化
|
MainWindowViewModel.dt_TP = JsonConvert.DeserializeObject<DataTable>(DAT);//反序列化
|
||||||
}
|
}
|
||||||
catch (Exception ex) { LogGing.LogGingDATA("[ERR='" + ex + "']=Exception"); MainWindowViewModel.ERR_c++; }
|
catch (Exception ex) { LogGing.LogGingDATA("[ERR='" + ex + "']=Exception"); MainWindowViewModel.ERR_c++; }
|
||||||
}
|
}//步骤信息
|
||||||
else if (SYSAPI == "SC832")
|
else if (SYSAPI == "SC832")
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -380,7 +409,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
|
|||||||
MachinesView.LOG_dataTable = JsonConvert.DeserializeObject<DataTable>(DAT);//反序列化
|
MachinesView.LOG_dataTable = JsonConvert.DeserializeObject<DataTable>(DAT);//反序列化
|
||||||
}
|
}
|
||||||
catch (Exception ex) { LogGing.LogGingDATA("[ERR='" + ex + "']=Exception"); MainWindowViewModel.ERR_c++; }
|
catch (Exception ex) { LogGing.LogGingDATA("[ERR='" + ex + "']=Exception"); MainWindowViewModel.ERR_c++; }
|
||||||
}
|
}//信息
|
||||||
else if (SYSAPI == "SC910")
|
else if (SYSAPI == "SC910")
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|||||||
@@ -0,0 +1,360 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Data;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SunlightCentralizedControlManagement_SCCM_.UserClass
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 线程安全的 DataTable 管理器
|
||||||
|
/// 提供对 DataTable 的安全并发访问
|
||||||
|
/// </summary>
|
||||||
|
public class DataTableManager : IDisposable
|
||||||
|
{
|
||||||
|
private DataTable _dataTable;
|
||||||
|
private readonly ReaderWriterLockSlim _lock = new ReaderWriterLockSlim();
|
||||||
|
private bool _disposed = false;
|
||||||
|
|
||||||
|
#region 构造函数
|
||||||
|
public DataTableManager()
|
||||||
|
{
|
||||||
|
_dataTable = new DataTable();
|
||||||
|
}
|
||||||
|
|
||||||
|
public DataTableManager(DataTable dataTable)
|
||||||
|
{
|
||||||
|
_dataTable = dataTable ?? throw new ArgumentNullException(nameof(dataTable));
|
||||||
|
}
|
||||||
|
|
||||||
|
public DataTableManager(string tableName)
|
||||||
|
{
|
||||||
|
_dataTable = new DataTable(tableName);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 基本操作
|
||||||
|
/// <summary>
|
||||||
|
/// 安全地添加列
|
||||||
|
/// </summary>
|
||||||
|
public void AddColumn(string columnName, Type dataType)
|
||||||
|
{
|
||||||
|
ExecuteWriteOperation(table =>
|
||||||
|
{
|
||||||
|
table.Columns.Add(columnName, dataType);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 安全地添加行
|
||||||
|
/// </summary>
|
||||||
|
public void AddRow(params object[] values)
|
||||||
|
{
|
||||||
|
ExecuteWriteOperation(table =>
|
||||||
|
{
|
||||||
|
DataRow newRow = table.NewRow();
|
||||||
|
for (int i = 0; i < Math.Min(values.Length, table.Columns.Count); i++)
|
||||||
|
{
|
||||||
|
newRow[i] = values[i] ?? DBNull.Value;
|
||||||
|
}
|
||||||
|
table.Rows.Add(newRow);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 安全地更新单元格值
|
||||||
|
/// </summary>
|
||||||
|
public bool UpdateCell(int rowIndex, string columnName, object value)
|
||||||
|
{
|
||||||
|
return ExecuteWriteOperation(table =>
|
||||||
|
{
|
||||||
|
if (IsValidRowIndex(table, rowIndex) && table.Columns.Contains(columnName))
|
||||||
|
{
|
||||||
|
table.Rows[rowIndex][columnName] = value ?? DBNull.Value;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 安全地删除行
|
||||||
|
/// </summary>
|
||||||
|
public bool DeleteRow(int rowIndex)
|
||||||
|
{
|
||||||
|
return ExecuteWriteOperation(table =>
|
||||||
|
{
|
||||||
|
if (IsValidRowIndex(table, rowIndex))
|
||||||
|
{
|
||||||
|
table.Rows[rowIndex].Delete();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 查询操作
|
||||||
|
/// <summary>
|
||||||
|
/// 安全地获取行
|
||||||
|
/// </summary>
|
||||||
|
public DataRow GetRow(int rowIndex)
|
||||||
|
{
|
||||||
|
return ExecuteReadOperation(table =>
|
||||||
|
{
|
||||||
|
return IsValidRowIndex(table, rowIndex) ? table.Rows[rowIndex] : null;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 安全地查找行(使用筛选条件)
|
||||||
|
/// </summary>
|
||||||
|
public DataRow[] FindRows(string filterExpression)
|
||||||
|
{
|
||||||
|
return ExecuteReadOperation(table =>
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return string.IsNullOrEmpty(filterExpression)
|
||||||
|
? table.Select()
|
||||||
|
: table.Select(filterExpression);
|
||||||
|
}
|
||||||
|
catch (EvaluateException)
|
||||||
|
{
|
||||||
|
return new DataRow[0];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 安全地获取行数
|
||||||
|
/// </summary>
|
||||||
|
public int GetRowCount()
|
||||||
|
{
|
||||||
|
return ExecuteReadOperation(table => table.Rows.Count);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 安全地检查行是否存在
|
||||||
|
/// </summary>
|
||||||
|
public bool RowExists(int rowIndex)
|
||||||
|
{
|
||||||
|
return ExecuteReadOperation(table => IsValidRowIndex(table, rowIndex));
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 批量操作
|
||||||
|
/// <summary>
|
||||||
|
/// 安全地批量添加行
|
||||||
|
/// </summary>
|
||||||
|
public void BulkAddRows(IEnumerable<object[]> rowsData)
|
||||||
|
{
|
||||||
|
ExecuteWriteOperation(table =>
|
||||||
|
{
|
||||||
|
foreach (var rowData in rowsData)
|
||||||
|
{
|
||||||
|
DataRow newRow = table.NewRow();
|
||||||
|
for (int i = 0; i < Math.Min(rowData.Length, table.Columns.Count); i++)
|
||||||
|
{
|
||||||
|
newRow[i] = rowData[i] ?? DBNull.Value;
|
||||||
|
}
|
||||||
|
table.Rows.Add(newRow);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 安全地清空所有数据
|
||||||
|
/// </summary>
|
||||||
|
public void Clear()
|
||||||
|
{
|
||||||
|
ExecuteWriteOperation(table =>
|
||||||
|
{
|
||||||
|
table.Clear();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 数据导出
|
||||||
|
/// <summary>
|
||||||
|
/// 获取数据快照(线程安全的副本)
|
||||||
|
/// </summary>
|
||||||
|
public DataTable GetSnapshot()
|
||||||
|
{
|
||||||
|
return ExecuteReadOperation(table =>
|
||||||
|
{
|
||||||
|
return table.Copy(); // 创建数据的独立副本
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取只读视图
|
||||||
|
/// </summary>
|
||||||
|
public DataView GetReadOnlyView()
|
||||||
|
{
|
||||||
|
return ExecuteReadOperation(table =>
|
||||||
|
{
|
||||||
|
return new DataView(table) { AllowEdit = false };
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 导出到新 DataTable(包含结构)
|
||||||
|
/// </summary>
|
||||||
|
public DataTable ExportToDataTable()
|
||||||
|
{
|
||||||
|
return ExecuteReadOperation(table =>
|
||||||
|
{
|
||||||
|
DataTable exported = table.Clone();
|
||||||
|
exported.Merge(table, false, MissingSchemaAction.Add);
|
||||||
|
return exported;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 锁操作核心
|
||||||
|
/// <summary>
|
||||||
|
/// 执行读取操作(共享锁)
|
||||||
|
/// </summary>
|
||||||
|
private T ExecuteReadOperation<T>(Func<DataTable, T> operation)
|
||||||
|
{
|
||||||
|
_lock.EnterReadLock();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return operation(_dataTable);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
_lock.ExitReadLock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 执行写入操作(独占锁)
|
||||||
|
/// </summary>
|
||||||
|
private void ExecuteWriteOperation(Action<DataTable> operation)
|
||||||
|
{
|
||||||
|
_lock.EnterWriteLock();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
operation(_dataTable);
|
||||||
|
_dataTable.AcceptChanges();
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
_lock.ExitWriteLock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private T ExecuteWriteOperation<T>(Func<DataTable, T> operation)
|
||||||
|
{
|
||||||
|
_lock.EnterWriteLock();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var result = operation(_dataTable);
|
||||||
|
_dataTable.AcceptChanges();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
_lock.ExitWriteLock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool IsValidRowIndex(DataTable table, int rowIndex)
|
||||||
|
{
|
||||||
|
return rowIndex >= 0 && rowIndex < table.Rows.Count;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 高级功能
|
||||||
|
/// <summary>
|
||||||
|
/// 带超时的安全操作
|
||||||
|
/// </summary>
|
||||||
|
public bool TryUpdateCell(int rowIndex, string columnName, object value, int timeoutMs = 5000)
|
||||||
|
{
|
||||||
|
if (_lock.TryEnterWriteLock(timeoutMs))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (IsValidRowIndex(_dataTable, rowIndex) && _dataTable.Columns.Contains(columnName))
|
||||||
|
{
|
||||||
|
_dataTable.Rows[rowIndex][columnName] = value ?? DBNull.Value;
|
||||||
|
_dataTable.AcceptChanges();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
_lock.ExitWriteLock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 执行事务性操作
|
||||||
|
/// </summary>
|
||||||
|
public void ExecuteTransaction(Action<DataTable> transaction)
|
||||||
|
{
|
||||||
|
_lock.EnterWriteLock();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// 开始事务
|
||||||
|
_dataTable.BeginLoadData();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
transaction(_dataTable);
|
||||||
|
_dataTable.AcceptChanges();
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
_dataTable.RejectChanges();
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
_dataTable.EndLoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
_lock.ExitWriteLock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 属性和清理
|
||||||
|
public string TableName
|
||||||
|
{
|
||||||
|
get => ExecuteReadOperation(table => table.TableName);
|
||||||
|
set => ExecuteWriteOperation(table => table.TableName = value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public DataColumnCollection Columns
|
||||||
|
{
|
||||||
|
get => ExecuteReadOperation(table => table.Columns);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
if (!_disposed)
|
||||||
|
{
|
||||||
|
_lock?.Dispose();
|
||||||
|
_dataTable?.Dispose();
|
||||||
|
_disposed = true;
|
||||||
|
}
|
||||||
|
GC.SuppressFinalize(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
~DataTableManager()
|
||||||
|
{
|
||||||
|
Dispose();
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -76,6 +76,8 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
|||||||
{
|
{
|
||||||
Dictionary<string, object> Machines_DAT = new Dictionary<string, object>();//缓存函数
|
Dictionary<string, object> Machines_DAT = new Dictionary<string, object>();//缓存函数
|
||||||
if (MainWindowViewModel.SQLiteHelpers.ExecuteDataSet("select * from Machines where name ='" + comboBoxMachine.Text + "'", null).Tables[0].Rows.Count == 0)
|
if (MainWindowViewModel.SQLiteHelpers.ExecuteDataSet("select * from Machines where name ='" + comboBoxMachine.Text + "'", null).Tables[0].Rows.Count == 0)
|
||||||
|
{
|
||||||
|
lock (MainWindowViewModel.Machines.Rows.SyncRoot)
|
||||||
{
|
{
|
||||||
DataRow dat_ = MainWindowViewModel.Machines.NewRow();
|
DataRow dat_ = MainWindowViewModel.Machines.NewRow();
|
||||||
dat_.BeginEdit();
|
dat_.BeginEdit();
|
||||||
@@ -127,7 +129,10 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
|||||||
Machines_DAT.Clear();
|
Machines_DAT.Clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
lock (MainWindowViewModel.Machines.Rows.SyncRoot)
|
||||||
{
|
{
|
||||||
DataRow dr = MainWindowViewModel.Machines.Rows[ID_];
|
DataRow dr = MainWindowViewModel.Machines.Rows[ID_];
|
||||||
dr.BeginEdit();
|
dr.BeginEdit();
|
||||||
@@ -139,8 +144,10 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
|||||||
dr["Model"] = comboBoxtype.Text;
|
dr["Model"] = comboBoxtype.Text;
|
||||||
dr["Station"] = Station.Text;
|
dr["Station"] = Station.Text;
|
||||||
if (comboBoxtype.Text.Contains(link_model))
|
if (comboBoxtype.Text.Contains(link_model))
|
||||||
{ dr["Desktop"] = true;
|
{
|
||||||
dr["Type"] = true; }
|
dr["Desktop"] = true;
|
||||||
|
dr["Type"] = true;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dr["Desktop"] = false;
|
dr["Desktop"] = false;
|
||||||
@@ -166,6 +173,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
|||||||
Machines_DAT.Clear();
|
Machines_DAT.Clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
Griddata.ItemsSource = MainWindowViewModel.Machines.DefaultView;
|
Griddata.ItemsSource = MainWindowViewModel.Machines.DefaultView;
|
||||||
comboBoxMachine.Text = null;
|
comboBoxMachine.Text = null;
|
||||||
TextMachineGroup.Text = null;
|
TextMachineGroup.Text = null;
|
||||||
@@ -186,10 +194,12 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
|||||||
{
|
{
|
||||||
MessageBoxResult vr = System.Windows.MessageBox.Show(Properties.Resources.Delete + comboBoxMachine.Text, "SCCM", MessageBoxButton.OKCancel, MessageBoxImage.Question);
|
MessageBoxResult vr = System.Windows.MessageBox.Show(Properties.Resources.Delete + comboBoxMachine.Text, "SCCM", MessageBoxButton.OKCancel, MessageBoxImage.Question);
|
||||||
if (vr == MessageBoxResult.OK) // 如果是确定,就执行下面代码
|
if (vr == MessageBoxResult.OK) // 如果是确定,就执行下面代码
|
||||||
|
{
|
||||||
|
lock (MainWindowViewModel.Machines.Rows.SyncRoot)
|
||||||
{
|
{
|
||||||
MainWindowViewModel.Machines.Rows.RemoveAt(ID_ - 1);
|
MainWindowViewModel.Machines.Rows.RemoveAt(ID_ - 1);
|
||||||
DatSteps(MainWindowViewModel.Machines);
|
DatSteps(MainWindowViewModel.Machines);
|
||||||
|
}
|
||||||
Dictionary<string, object> Machines_DAT = new Dictionary<string, object>();//缓存函数
|
Dictionary<string, object> Machines_DAT = new Dictionary<string, object>();//缓存函数
|
||||||
|
|
||||||
MainWindowViewModel.SQLiteHelpers.Delete("Machines", null, null);//
|
MainWindowViewModel.SQLiteHelpers.Delete("Machines", null, null);//
|
||||||
|
|||||||
+452
-26
@@ -145,6 +145,8 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
|||||||
private void MenuItem_LOCK_XML(object sender, RoutedEventArgs e)
|
private void MenuItem_LOCK_XML(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrEmpty(machine))
|
if (!string.IsNullOrEmpty(machine))
|
||||||
|
{
|
||||||
|
lock (MainWindowViewModel.Machines.Rows.SyncRoot)
|
||||||
{
|
{
|
||||||
bool mode = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First().Field<bool>("LOCK");
|
bool mode = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First().Field<bool>("LOCK");
|
||||||
|
|
||||||
@@ -167,12 +169,12 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
|||||||
DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First();
|
DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First();
|
||||||
int index = Convert.ToInt16(drEmployee.Field<object>("ID"));
|
int index = Convert.ToInt16(drEmployee.Field<object>("ID"));
|
||||||
|
|
||||||
if (MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First().Field<bool>("Type"))
|
if (drEmployee.Field<bool>("Type"))
|
||||||
{//网络
|
{//网络
|
||||||
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
|
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
|
||||||
{
|
{
|
||||||
ID = index,
|
ID = index,
|
||||||
DAT = "SC829" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, "SYSKEY", "ID='" + index + "'") + dat_.ToJsonString()
|
DAT = "SC829" + drEmployee.Field<string>("SYSKEY") + dat_.ToJsonString()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -190,7 +192,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
|||||||
stringQueueSerial_2.Enqueue(new QueueSerial
|
stringQueueSerial_2.Enqueue(new QueueSerial
|
||||||
{
|
{
|
||||||
ID = index,
|
ID = index,
|
||||||
DAT = "SC829" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, "SYSKEY", "ID='" + index + "'") + dat_.ToJsonString()
|
DAT = "SC829" + drEmployee.Field<string>("Station") + dat_.ToJsonString()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else if (drEmployee.Field<string>("Serial") == "PORT3")
|
else if (drEmployee.Field<string>("Serial") == "PORT3")
|
||||||
@@ -198,7 +200,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
|||||||
stringQueueSerial_3.Enqueue(new QueueSerial
|
stringQueueSerial_3.Enqueue(new QueueSerial
|
||||||
{
|
{
|
||||||
ID = index,
|
ID = index,
|
||||||
DAT = "SC829" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, "SYSKEY", "ID='" + index + "'") + dat_.ToJsonString()
|
DAT = "SC829" + drEmployee.Field<string>("Station") + dat_.ToJsonString()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else if (drEmployee.Field<string>("Serial") == "PORT4")
|
else if (drEmployee.Field<string>("Serial") == "PORT4")
|
||||||
@@ -206,7 +208,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
|||||||
stringQueueSerial_4.Enqueue(new QueueSerial
|
stringQueueSerial_4.Enqueue(new QueueSerial
|
||||||
{
|
{
|
||||||
ID = index,
|
ID = index,
|
||||||
DAT = "SC829" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, "SYSKEY", "ID='" + index + "'") + dat_.ToJsonString()
|
DAT = "SC829" + drEmployee.Field<string>("Station") + dat_.ToJsonString()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -219,10 +221,13 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
|||||||
MessageBox.Show(machine + Properties.Resources.user_unlock, "800", MessageBoxButton.OK, MessageBoxImage.Information);
|
MessageBox.Show(machine + Properties.Resources.user_unlock, "800", MessageBoxButton.OK, MessageBoxImage.Information);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}//锁定
|
}//锁定
|
||||||
private void MenuItem_AUTO_XML(object sender, RoutedEventArgs e)
|
private void MenuItem_AUTO_XML(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrEmpty(machine))
|
if (!string.IsNullOrEmpty(machine))
|
||||||
|
{
|
||||||
|
lock (MainWindowViewModel.Machines.Rows.SyncRoot)
|
||||||
{
|
{
|
||||||
bool mode = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First().Field<bool>("AUTO");
|
bool mode = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First().Field<bool>("AUTO");
|
||||||
|
|
||||||
@@ -244,12 +249,12 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
|||||||
|
|
||||||
DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First();
|
DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First();
|
||||||
int index = Convert.ToInt16(drEmployee.Field<object>("ID"));
|
int index = Convert.ToInt16(drEmployee.Field<object>("ID"));
|
||||||
if (MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First().Field<bool>("Type"))
|
if (drEmployee.Field<bool>("Type"))
|
||||||
{//网络
|
{//网络
|
||||||
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
|
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
|
||||||
{
|
{
|
||||||
ID = index,
|
ID = index,
|
||||||
DAT = "SC829" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, "SYSKEY", "ID='" + index + "'") + dat_.ToJsonString()
|
DAT = "SC829" + drEmployee.Field<string>("SYSKEY") + dat_.ToJsonString()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -259,7 +264,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
|||||||
stringQueueSerial_1.Enqueue(new QueueSerial
|
stringQueueSerial_1.Enqueue(new QueueSerial
|
||||||
{
|
{
|
||||||
ID = index,
|
ID = index,
|
||||||
DAT = "SC829" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, "SYSKEY", "ID='" + index + "'") + dat_.ToJsonString()
|
DAT = "SC829" + drEmployee.Field<string>("Station") + dat_.ToJsonString()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else if (drEmployee.Field<string>("Serial") == "PORT2")
|
else if (drEmployee.Field<string>("Serial") == "PORT2")
|
||||||
@@ -267,7 +272,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
|||||||
stringQueueSerial_2.Enqueue(new QueueSerial
|
stringQueueSerial_2.Enqueue(new QueueSerial
|
||||||
{
|
{
|
||||||
ID = index,
|
ID = index,
|
||||||
DAT = "SC829" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, "SYSKEY", "ID='" + index + "'") + dat_.ToJsonString()
|
DAT = "SC829" + drEmployee.Field<string>("Station") + dat_.ToJsonString()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else if (drEmployee.Field<string>("Serial") == "PORT3")
|
else if (drEmployee.Field<string>("Serial") == "PORT3")
|
||||||
@@ -275,7 +280,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
|||||||
stringQueueSerial_3.Enqueue(new QueueSerial
|
stringQueueSerial_3.Enqueue(new QueueSerial
|
||||||
{
|
{
|
||||||
ID = index,
|
ID = index,
|
||||||
DAT = "SC829" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, "SYSKEY", "ID='" + index + "'") + dat_.ToJsonString()
|
DAT = "SC829" + drEmployee.Field<string>("Station") + dat_.ToJsonString()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else if (drEmployee.Field<string>("Serial") == "PORT4")
|
else if (drEmployee.Field<string>("Serial") == "PORT4")
|
||||||
@@ -283,12 +288,12 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
|||||||
stringQueueSerial_4.Enqueue(new QueueSerial
|
stringQueueSerial_4.Enqueue(new QueueSerial
|
||||||
{
|
{
|
||||||
ID = index,
|
ID = index,
|
||||||
DAT = "SC829" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, "SYSKEY", "ID='" + index + "'") + dat_.ToJsonString()
|
DAT = "SC829" + drEmployee.Field<string>("Station") + dat_.ToJsonString()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}//手自动
|
}//手自动
|
||||||
private void MenuItem_Stop_XML(object sender, RoutedEventArgs e)
|
private void MenuItem_Stop_XML(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
@@ -297,14 +302,55 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
|||||||
Dictionary<string, object> dat_821 = new Dictionary<string, object>();
|
Dictionary<string, object> dat_821 = new Dictionary<string, object>();
|
||||||
dat_821.Clear();
|
dat_821.Clear();
|
||||||
dat_821.Add("INSTRUCTION", "STOP");
|
dat_821.Add("INSTRUCTION", "STOP");
|
||||||
|
lock (MainWindowViewModel.Machines.Rows.SyncRoot)
|
||||||
|
{
|
||||||
DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First();
|
DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First();
|
||||||
int index = Convert.ToInt16(drEmployee.Field<object>("ID"));
|
int index = Convert.ToInt16(drEmployee.Field<object>("ID"));
|
||||||
|
if (drEmployee.Field<bool>("Type"))
|
||||||
|
{//网络
|
||||||
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
|
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
|
||||||
{
|
{
|
||||||
ID = index,
|
ID = index,
|
||||||
DAT = "SC821" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, "SYSKEY", "ID='" + index + "'") + dat_821.ToJsonString()
|
DAT = "SC821" + drEmployee.Field<string>("SYSKEY") + dat_821.ToJsonString()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{//串口
|
||||||
|
if (drEmployee.Field<string>("Serial") == "PORT1")
|
||||||
|
{
|
||||||
|
stringQueueSerial_1.Enqueue(new QueueSerial
|
||||||
|
{
|
||||||
|
ID = index,
|
||||||
|
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else if (drEmployee.Field<string>("Serial") == "PORT2")
|
||||||
|
{
|
||||||
|
stringQueueSerial_2.Enqueue(new QueueSerial
|
||||||
|
{
|
||||||
|
ID = index,
|
||||||
|
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else if (drEmployee.Field<string>("Serial") == "PORT3")
|
||||||
|
{
|
||||||
|
stringQueueSerial_3.Enqueue(new QueueSerial
|
||||||
|
{
|
||||||
|
ID = index,
|
||||||
|
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else if (drEmployee.Field<string>("Serial") == "PORT4")
|
||||||
|
{
|
||||||
|
stringQueueSerial_4.Enqueue(new QueueSerial
|
||||||
|
{
|
||||||
|
ID = index,
|
||||||
|
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}//停止
|
}//停止
|
||||||
private void MenuItem_Start_XML(object sender, RoutedEventArgs e)
|
private void MenuItem_Start_XML(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
@@ -312,12 +358,50 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
|||||||
{
|
{
|
||||||
DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First();
|
DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First();
|
||||||
int index = Convert.ToInt16(drEmployee.Field<object>("ID"));
|
int index = Convert.ToInt16(drEmployee.Field<object>("ID"));
|
||||||
|
if (drEmployee.Field<bool>("Type"))
|
||||||
|
{//网络
|
||||||
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
|
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
|
||||||
{
|
{
|
||||||
ID = index,
|
ID = index,
|
||||||
DAT = "SC822" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, "SYSKEY", "ID='" + index + "'")
|
DAT = "SC822" + drEmployee.Field<string>("SYSKEY")
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{//串口
|
||||||
|
if (drEmployee.Field<string>("Serial") == "PORT1")
|
||||||
|
{
|
||||||
|
stringQueueSerial_1.Enqueue(new QueueSerial
|
||||||
|
{
|
||||||
|
ID = index,
|
||||||
|
DAT = "SC822" + drEmployee.Field<string>("Station")
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else if (drEmployee.Field<string>("Serial") == "PORT2")
|
||||||
|
{
|
||||||
|
stringQueueSerial_2.Enqueue(new QueueSerial
|
||||||
|
{
|
||||||
|
ID = index,
|
||||||
|
DAT = "SC822" + drEmployee.Field<string>("Station")
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else if (drEmployee.Field<string>("Serial") == "PORT3")
|
||||||
|
{
|
||||||
|
stringQueueSerial_3.Enqueue(new QueueSerial
|
||||||
|
{
|
||||||
|
ID = index,
|
||||||
|
DAT = "SC822" + drEmployee.Field<string>("Station")
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else if (drEmployee.Field<string>("Serial") == "PORT4")
|
||||||
|
{
|
||||||
|
stringQueueSerial_4.Enqueue(new QueueSerial
|
||||||
|
{
|
||||||
|
ID = index,
|
||||||
|
DAT = "SC822" + drEmployee.Field<string>("Station")
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}//开始
|
}//开始
|
||||||
private void ListViewItem_DyeingMachine(object sender, MouseButtonEventArgs e)
|
private void ListViewItem_DyeingMachine(object sender, MouseButtonEventArgs e)
|
||||||
{
|
{
|
||||||
@@ -390,12 +474,49 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
|||||||
}
|
}
|
||||||
|
|
||||||
int index = Convert.ToInt16(drEmployee.Field<object>("ID"));
|
int index = Convert.ToInt16(drEmployee.Field<object>("ID"));
|
||||||
|
if (drEmployee.Field<bool>("Type"))
|
||||||
|
{//网络
|
||||||
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
|
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
|
||||||
{
|
{
|
||||||
ID = index,
|
ID = index,
|
||||||
DAT = "SC833" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, "SYSKEY", "ID='" + index + "'")
|
DAT = "SC833" + drEmployee.Field<string>("SYSKEY")
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{//串口
|
||||||
|
if (drEmployee.Field<string>("Serial") == "PORT1")
|
||||||
|
{
|
||||||
|
stringQueueSerial_1.Enqueue(new QueueSerial
|
||||||
|
{
|
||||||
|
ID = index,
|
||||||
|
DAT = "SC833" + drEmployee.Field<string>("Station")
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else if (drEmployee.Field<string>("Serial") == "PORT2")
|
||||||
|
{
|
||||||
|
stringQueueSerial_2.Enqueue(new QueueSerial
|
||||||
|
{
|
||||||
|
ID = index,
|
||||||
|
DAT = "SC833" + drEmployee.Field<string>("Station")
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else if (drEmployee.Field<string>("Serial") == "PORT3")
|
||||||
|
{
|
||||||
|
stringQueueSerial_3.Enqueue(new QueueSerial
|
||||||
|
{
|
||||||
|
ID = index,
|
||||||
|
DAT = "SC833" + drEmployee.Field<string>("Station")
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else if (drEmployee.Field<string>("Serial") == "PORT4")
|
||||||
|
{
|
||||||
|
stringQueueSerial_4.Enqueue(new QueueSerial
|
||||||
|
{
|
||||||
|
ID = index,
|
||||||
|
DAT = "SC833" + drEmployee.Field<string>("Station")
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
machines_info = 2;
|
machines_info = 2;
|
||||||
log.Visibility = Visibility.Collapsed;
|
log.Visibility = Visibility.Collapsed;
|
||||||
rdp.Visibility = Visibility.Collapsed;
|
rdp.Visibility = Visibility.Collapsed;
|
||||||
@@ -423,12 +544,50 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
|||||||
dat_821.Add("INSTRUCTION", "CONTINUE");
|
dat_821.Add("INSTRUCTION", "CONTINUE");
|
||||||
DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First();
|
DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First();
|
||||||
int index = Convert.ToInt16(drEmployee.Field<object>("ID"));
|
int index = Convert.ToInt16(drEmployee.Field<object>("ID"));
|
||||||
|
if (drEmployee.Field<bool>("Type"))
|
||||||
|
{//网络
|
||||||
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
|
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
|
||||||
{
|
{
|
||||||
ID = index,
|
ID = index,
|
||||||
DAT = "SC821" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, "SYSKEY", "ID='" + index + "'") + dat_821.ToJsonString()
|
DAT = "SC821" + drEmployee.Field<string>("SYSKEY") + dat_821.ToJsonString()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{//串口
|
||||||
|
if (drEmployee.Field<string>("Serial") == "PORT1")
|
||||||
|
{
|
||||||
|
stringQueueSerial_1.Enqueue(new QueueSerial
|
||||||
|
{
|
||||||
|
ID = index,
|
||||||
|
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else if (drEmployee.Field<string>("Serial") == "PORT2")
|
||||||
|
{
|
||||||
|
stringQueueSerial_2.Enqueue(new QueueSerial
|
||||||
|
{
|
||||||
|
ID = index,
|
||||||
|
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else if (drEmployee.Field<string>("Serial") == "PORT3")
|
||||||
|
{
|
||||||
|
stringQueueSerial_3.Enqueue(new QueueSerial
|
||||||
|
{
|
||||||
|
ID = index,
|
||||||
|
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else if (drEmployee.Field<string>("Serial") == "PORT4")
|
||||||
|
{
|
||||||
|
stringQueueSerial_4.Enqueue(new QueueSerial
|
||||||
|
{
|
||||||
|
ID = index,
|
||||||
|
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Insert.IsHitTestVisible = false;
|
Insert.IsHitTestVisible = false;
|
||||||
edit.IsHitTestVisible = false;
|
edit.IsHitTestVisible = false;
|
||||||
Resume.IsHitTestVisible = false;
|
Resume.IsHitTestVisible = false;
|
||||||
@@ -446,12 +605,50 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
|||||||
dat_821.Add("INSTRUCTION", "PAUSE");
|
dat_821.Add("INSTRUCTION", "PAUSE");
|
||||||
DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First();
|
DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First();
|
||||||
int index = Convert.ToInt16(drEmployee.Field<object>("ID"));
|
int index = Convert.ToInt16(drEmployee.Field<object>("ID"));
|
||||||
|
if (drEmployee.Field<bool>("Type"))
|
||||||
|
{//网络
|
||||||
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
|
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
|
||||||
{
|
{
|
||||||
ID = index,
|
ID = index,
|
||||||
DAT = "SC821" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, "SYSKEY", "ID='" + index + "'") + dat_821.ToJsonString()
|
DAT = "SC821" + drEmployee.Field<string>("SYSKEY") + dat_821.ToJsonString()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{//串口
|
||||||
|
if (drEmployee.Field<string>("Serial") == "PORT1")
|
||||||
|
{
|
||||||
|
stringQueueSerial_1.Enqueue(new QueueSerial
|
||||||
|
{
|
||||||
|
ID = index,
|
||||||
|
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else if (drEmployee.Field<string>("Serial") == "PORT2")
|
||||||
|
{
|
||||||
|
stringQueueSerial_2.Enqueue(new QueueSerial
|
||||||
|
{
|
||||||
|
ID = index,
|
||||||
|
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else if (drEmployee.Field<string>("Serial") == "PORT3")
|
||||||
|
{
|
||||||
|
stringQueueSerial_3.Enqueue(new QueueSerial
|
||||||
|
{
|
||||||
|
ID = index,
|
||||||
|
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else if (drEmployee.Field<string>("Serial") == "PORT4")
|
||||||
|
{
|
||||||
|
stringQueueSerial_4.Enqueue(new QueueSerial
|
||||||
|
{
|
||||||
|
ID = index,
|
||||||
|
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Insert.IsHitTestVisible = true;
|
Insert.IsHitTestVisible = true;
|
||||||
edit.IsHitTestVisible = true;
|
edit.IsHitTestVisible = true;
|
||||||
Paused.IsHitTestVisible = true;
|
Paused.IsHitTestVisible = true;
|
||||||
@@ -470,12 +667,50 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
|||||||
dat_821.Add("INSTRUCTION", "STOP");
|
dat_821.Add("INSTRUCTION", "STOP");
|
||||||
DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First();
|
DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First();
|
||||||
int index = Convert.ToInt16(drEmployee.Field<object>("ID"));
|
int index = Convert.ToInt16(drEmployee.Field<object>("ID"));
|
||||||
|
if (drEmployee.Field<bool>("Type"))
|
||||||
|
{//网络
|
||||||
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
|
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
|
||||||
{
|
{
|
||||||
ID = index,
|
ID = index,
|
||||||
DAT = "SC821" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, "SYSKEY", "ID='" + index + "'") + dat_821.ToJsonString()
|
DAT = "SC821" + drEmployee.Field<string>("SYSKEY") + dat_821.ToJsonString()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{//串口
|
||||||
|
if (drEmployee.Field<string>("Serial") == "PORT1")
|
||||||
|
{
|
||||||
|
stringQueueSerial_1.Enqueue(new QueueSerial
|
||||||
|
{
|
||||||
|
ID = index,
|
||||||
|
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else if (drEmployee.Field<string>("Serial") == "PORT2")
|
||||||
|
{
|
||||||
|
stringQueueSerial_2.Enqueue(new QueueSerial
|
||||||
|
{
|
||||||
|
ID = index,
|
||||||
|
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else if (drEmployee.Field<string>("Serial") == "PORT3")
|
||||||
|
{
|
||||||
|
stringQueueSerial_3.Enqueue(new QueueSerial
|
||||||
|
{
|
||||||
|
ID = index,
|
||||||
|
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else if (drEmployee.Field<string>("Serial") == "PORT4")
|
||||||
|
{
|
||||||
|
stringQueueSerial_4.Enqueue(new QueueSerial
|
||||||
|
{
|
||||||
|
ID = index,
|
||||||
|
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}//停止
|
}//停止
|
||||||
private void ListViewItem_edit(object sender, MouseButtonEventArgs e)
|
private void ListViewItem_edit(object sender, MouseButtonEventArgs e)
|
||||||
{
|
{
|
||||||
@@ -532,11 +767,49 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
|||||||
|
|
||||||
DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First();
|
DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First();
|
||||||
int index = Convert.ToInt16(drEmployee.Field<object>("ID"));
|
int index = Convert.ToInt16(drEmployee.Field<object>("ID"));
|
||||||
|
if (drEmployee.Field<bool>("Type"))
|
||||||
|
{//网络
|
||||||
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
|
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
|
||||||
{
|
{
|
||||||
ID = index,
|
ID = index,
|
||||||
DAT = "SC821" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, "SYSKEY", "ID='" + index + "'") + dat_821.ToJsonString()
|
DAT = "SC821" + drEmployee.Field<string>("SYSKEY") + dat_821.ToJsonString()
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{//串口
|
||||||
|
if (drEmployee.Field<string>("Serial") == "PORT1")
|
||||||
|
{
|
||||||
|
stringQueueSerial_1.Enqueue(new QueueSerial
|
||||||
|
{
|
||||||
|
ID = index,
|
||||||
|
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else if (drEmployee.Field<string>("Serial") == "PORT2")
|
||||||
|
{
|
||||||
|
stringQueueSerial_2.Enqueue(new QueueSerial
|
||||||
|
{
|
||||||
|
ID = index,
|
||||||
|
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else if (drEmployee.Field<string>("Serial") == "PORT3")
|
||||||
|
{
|
||||||
|
stringQueueSerial_3.Enqueue(new QueueSerial
|
||||||
|
{
|
||||||
|
ID = index,
|
||||||
|
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else if (drEmployee.Field<string>("Serial") == "PORT4")
|
||||||
|
{
|
||||||
|
stringQueueSerial_4.Enqueue(new QueueSerial
|
||||||
|
{
|
||||||
|
ID = index,
|
||||||
|
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
TechnologicalProcess_bool = true;
|
TechnologicalProcess_bool = true;
|
||||||
}
|
}
|
||||||
private void ListViewItem_Jump(object sender, MouseButtonEventArgs e)
|
private void ListViewItem_Jump(object sender, MouseButtonEventArgs e)
|
||||||
@@ -560,11 +833,49 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
|||||||
|
|
||||||
DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First();
|
DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First();
|
||||||
int index = Convert.ToInt16(drEmployee.Field<object>("ID"));
|
int index = Convert.ToInt16(drEmployee.Field<object>("ID"));
|
||||||
|
if (drEmployee.Field<bool>("Type"))
|
||||||
|
{//网络
|
||||||
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
|
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
|
||||||
{
|
{
|
||||||
ID = index,
|
ID = index,
|
||||||
DAT = "SC821" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, "SYSKEY", "ID='" + index + "'") + dat_821.ToJsonString()
|
DAT = "SC821" + drEmployee.Field<string>("SYSKEY") + dat_821.ToJsonString()
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{//串口
|
||||||
|
if (drEmployee.Field<string>("Serial") == "PORT1")
|
||||||
|
{
|
||||||
|
stringQueueSerial_1.Enqueue(new QueueSerial
|
||||||
|
{
|
||||||
|
ID = index,
|
||||||
|
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else if (drEmployee.Field<string>("Serial") == "PORT2")
|
||||||
|
{
|
||||||
|
stringQueueSerial_2.Enqueue(new QueueSerial
|
||||||
|
{
|
||||||
|
ID = index,
|
||||||
|
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else if (drEmployee.Field<string>("Serial") == "PORT3")
|
||||||
|
{
|
||||||
|
stringQueueSerial_3.Enqueue(new QueueSerial
|
||||||
|
{
|
||||||
|
ID = index,
|
||||||
|
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else if (drEmployee.Field<string>("Serial") == "PORT4")
|
||||||
|
{
|
||||||
|
stringQueueSerial_4.Enqueue(new QueueSerial
|
||||||
|
{
|
||||||
|
ID = index,
|
||||||
|
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
TechnologicalProcess_bool = true;
|
TechnologicalProcess_bool = true;
|
||||||
}//跳步
|
}//跳步
|
||||||
@@ -623,11 +934,49 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
|||||||
|
|
||||||
DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First();
|
DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First();
|
||||||
int index = Convert.ToInt16(drEmployee.Field<object>("ID"));
|
int index = Convert.ToInt16(drEmployee.Field<object>("ID"));
|
||||||
|
if (drEmployee.Field<bool>("Type"))
|
||||||
|
{//网络
|
||||||
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
|
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
|
||||||
{
|
{
|
||||||
ID = index,
|
ID = index,
|
||||||
DAT = "SC821" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, "SYSKEY", "ID='" + index + "'") + dat_821.ToJsonString()
|
DAT = "SC821" + drEmployee.Field<string>("SYSKEY") + dat_821.ToJsonString()
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{//串口
|
||||||
|
if (drEmployee.Field<string>("Serial") == "PORT1")
|
||||||
|
{
|
||||||
|
stringQueueSerial_1.Enqueue(new QueueSerial
|
||||||
|
{
|
||||||
|
ID = index,
|
||||||
|
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else if (drEmployee.Field<string>("Serial") == "PORT2")
|
||||||
|
{
|
||||||
|
stringQueueSerial_2.Enqueue(new QueueSerial
|
||||||
|
{
|
||||||
|
ID = index,
|
||||||
|
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else if (drEmployee.Field<string>("Serial") == "PORT3")
|
||||||
|
{
|
||||||
|
stringQueueSerial_3.Enqueue(new QueueSerial
|
||||||
|
{
|
||||||
|
ID = index,
|
||||||
|
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else if (drEmployee.Field<string>("Serial") == "PORT4")
|
||||||
|
{
|
||||||
|
stringQueueSerial_4.Enqueue(new QueueSerial
|
||||||
|
{
|
||||||
|
ID = index,
|
||||||
|
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
private void ListViewItem_Delete(object sender, MouseButtonEventArgs e)
|
private void ListViewItem_Delete(object sender, MouseButtonEventArgs e)
|
||||||
@@ -640,11 +989,49 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
|||||||
dat_821.Add("ID", ID);
|
dat_821.Add("ID", ID);
|
||||||
DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First();
|
DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First();
|
||||||
int index = Convert.ToInt16(drEmployee.Field<object>("ID"));
|
int index = Convert.ToInt16(drEmployee.Field<object>("ID"));
|
||||||
|
if (drEmployee.Field<bool>("Type"))
|
||||||
|
{//网络
|
||||||
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
|
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
|
||||||
{
|
{
|
||||||
ID = index,
|
ID = index,
|
||||||
DAT = "SC821" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, "SYSKEY", "ID='" + index + "'") + dat_821.ToJsonString()
|
DAT = "SC821" + drEmployee.Field<string>("SYSKEY") + dat_821.ToJsonString()
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{//串口
|
||||||
|
if (drEmployee.Field<string>("Serial") == "PORT1")
|
||||||
|
{
|
||||||
|
stringQueueSerial_1.Enqueue(new QueueSerial
|
||||||
|
{
|
||||||
|
ID = index,
|
||||||
|
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else if (drEmployee.Field<string>("Serial") == "PORT2")
|
||||||
|
{
|
||||||
|
stringQueueSerial_2.Enqueue(new QueueSerial
|
||||||
|
{
|
||||||
|
ID = index,
|
||||||
|
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else if (drEmployee.Field<string>("Serial") == "PORT3")
|
||||||
|
{
|
||||||
|
stringQueueSerial_3.Enqueue(new QueueSerial
|
||||||
|
{
|
||||||
|
ID = index,
|
||||||
|
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else if (drEmployee.Field<string>("Serial") == "PORT4")
|
||||||
|
{
|
||||||
|
stringQueueSerial_4.Enqueue(new QueueSerial
|
||||||
|
{
|
||||||
|
ID = index,
|
||||||
|
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
MainWindowViewModel.dt_TP.Select("Step="+ID).First().Delete();
|
MainWindowViewModel.dt_TP.Select("Step="+ID).First().Delete();
|
||||||
MainWindowViewModel.dt_TP.AcceptChanges();
|
MainWindowViewModel.dt_TP.AcceptChanges();
|
||||||
@@ -687,6 +1074,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void MenuItem_Delete(object sender, RoutedEventArgs e)//右键删除
|
private void MenuItem_Delete(object sender, RoutedEventArgs e)//右键删除
|
||||||
|
|
||||||
{
|
{
|
||||||
int rownum = Gridstep.SelectedIndex;//获取鼠标选中行并定义变量
|
int rownum = Gridstep.SelectedIndex;//获取鼠标选中行并定义变量
|
||||||
if (rownum != -1)//判断鼠标定位是否有效
|
if (rownum != -1)//判断鼠标定位是否有效
|
||||||
@@ -700,11 +1088,49 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
|||||||
dat_821.Add("ID", ID);
|
dat_821.Add("ID", ID);
|
||||||
DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First();
|
DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First();
|
||||||
int index = Convert.ToInt16(drEmployee.Field<object>("ID"));
|
int index = Convert.ToInt16(drEmployee.Field<object>("ID"));
|
||||||
|
if (drEmployee.Field<bool>("Type"))
|
||||||
|
{//网络
|
||||||
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
|
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
|
||||||
{
|
{
|
||||||
ID = index,
|
ID = index,
|
||||||
DAT = "SC821" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, "SYSKEY", "ID='" + index + "'") + dat_821.ToJsonString()
|
DAT = "SC821" + drEmployee.Field<string>("SYSKEY") + dat_821.ToJsonString()
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{//串口
|
||||||
|
if (drEmployee.Field<string>("Serial") == "PORT1")
|
||||||
|
{
|
||||||
|
stringQueueSerial_1.Enqueue(new QueueSerial
|
||||||
|
{
|
||||||
|
ID = index,
|
||||||
|
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else if (drEmployee.Field<string>("Serial") == "PORT2")
|
||||||
|
{
|
||||||
|
stringQueueSerial_2.Enqueue(new QueueSerial
|
||||||
|
{
|
||||||
|
ID = index,
|
||||||
|
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else if (drEmployee.Field<string>("Serial") == "PORT3")
|
||||||
|
{
|
||||||
|
stringQueueSerial_3.Enqueue(new QueueSerial
|
||||||
|
{
|
||||||
|
ID = index,
|
||||||
|
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else if (drEmployee.Field<string>("Serial") == "PORT4")
|
||||||
|
{
|
||||||
|
stringQueueSerial_4.Enqueue(new QueueSerial
|
||||||
|
{
|
||||||
|
ID = index,
|
||||||
|
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
MainWindowViewModel.dt_TP.Select("Step=" + ID).First().Delete();
|
MainWindowViewModel.dt_TP.Select("Step=" + ID).First().Delete();
|
||||||
MainWindowViewModel.dt_TP.AcceptChanges();
|
MainWindowViewModel.dt_TP.AcceptChanges();
|
||||||
@@ -757,7 +1183,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
|||||||
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
|
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
|
||||||
{
|
{
|
||||||
ID = index,
|
ID = index,
|
||||||
DAT = "SC832" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, "SYSKEY", "ID='" + index + "'")
|
DAT = "SC832" + drEmployee.Field<string>("SYSKEY")
|
||||||
});
|
});
|
||||||
}//信息
|
}//信息
|
||||||
else if (machines_info == 1)
|
else if (machines_info == 1)
|
||||||
@@ -775,7 +1201,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
|||||||
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
|
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
|
||||||
{
|
{
|
||||||
ID = index,
|
ID = index,
|
||||||
DAT = "SC831" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, "SYSKEY", "ID='" + index + "'")
|
DAT = "SC831" + drEmployee.Field<string>("SYSKEY")
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
using SunlightCentralizedControlManagement_SCCM_.UserClass;
|
|
||||||
|
|
||||||
|
using SunlightCentralizedControlManagement_SCCM_.UserClass;
|
||||||
using SunlightCentralizedControlManagement_SCCM_.ViewModel;
|
using SunlightCentralizedControlManagement_SCCM_.ViewModel;
|
||||||
using SunlightCentralizedControlManagement_SCCM_.WindowsView;
|
using SunlightCentralizedControlManagement_SCCM_.WindowsView;
|
||||||
using System;
|
using System;
|
||||||
|
|||||||
+443
-216
@@ -86,6 +86,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
|||||||
public static SQLiteHelper SQLiteChartAdress = null; //定义数据库
|
public static SQLiteHelper SQLiteChartAdress = null; //定义数据库
|
||||||
private static readonly string ChartAdress = Environment.CurrentDirectory + "\\DataBase\\Chart.db"; //数据库路径
|
private static readonly string ChartAdress = Environment.CurrentDirectory + "\\DataBase\\Chart.db"; //数据库路径
|
||||||
public static DataTable Machines = new DataTable(); //设备表缓存
|
public static DataTable Machines = new DataTable(); //设备表缓存
|
||||||
|
//public static DataTableManager Machines = new DataTableManager("MachinesTa");
|
||||||
// public static DataRow MachinesROW;
|
// public static DataRow MachinesROW;
|
||||||
public static DataTable USER_data = new DataTable();
|
public static DataTable USER_data = new DataTable();
|
||||||
public static DataTable Dyelot_CALL = new DataTable();
|
public static DataTable Dyelot_CALL = new DataTable();
|
||||||
@@ -229,74 +230,134 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
|||||||
void Tick_Main_1S(object sender, EventArgs e)//Tick_Event周期执行事件1S
|
void Tick_Main_1S(object sender, EventArgs e)//Tick_Event周期执行事件1S
|
||||||
{
|
{
|
||||||
/*下传工单信息*/
|
/*下传工单信息*/
|
||||||
DataTable WorkOrderstepdata = SQLiteHelpers.ExecuteDataSet("select * from WorkOrder where (State='111' or State='112') AND EndTime >'" +
|
DataTable WorkOrderstepdata = SQLiteHelpers.ExecuteDataSet("select * from WorkOrder where (State='111' OR State='112') AND StartTime >'" +
|
||||||
DateTime.Now.AddHours(-8).ToString("yyyy/MM/dd HH:mm:ss") + "'", null).Tables[0]; //读取表写入缓存
|
DateTime.Now.AddHours(-8).ToString("yyyy/MM/dd HH:mm:ss") + "'", null).Tables[0]; //读取表写入缓存
|
||||||
for (int k = 0; k < WorkOrderstepdata.Rows.Count; k++)
|
for (int k = 0; k < WorkOrderstepdata.Rows.Count; k++)
|
||||||
{
|
{
|
||||||
string WorkOrderdata_m = WorkOrderstepdata.Select()[k].Field<object>("Machines").ToString();
|
string WorkOrderdata_m = WorkOrderstepdata.Select()[k].Field<object>("Machines").ToString();
|
||||||
//string m= WorkOrderstepdata.Rows[k].Field<string>("Machines");
|
|
||||||
if (Convert.ToBoolean(Selet_Machines(Machines, "Type", "Name='" + WorkOrderdata_m + "'")))
|
|
||||||
{//网络
|
|
||||||
//string WorkOrderdata_m = WorkOrderstepdata.Select()[k].Field<object>("Machines").ToString();
|
|
||||||
DataTable dataTable = SQLiteHelpers.ExecuteDataSet("select * from WorkorderSteps where WorkOrder='" +
|
DataTable dataTable = SQLiteHelpers.ExecuteDataSet("select * from WorkorderSteps where WorkOrder='" +
|
||||||
WorkOrderstepdata.Select()[k].Field<object>("WorkOrder").ToString() + "'", null).Tables[0];
|
WorkOrderstepdata.Select()[k].Field<object>("WorkOrder").ToString() + "'", null).Tables[0];
|
||||||
int index = Convert.ToInt16(Selet_Machines(Machines, "ID", "Name='" + WorkOrderdata_m + "'").ToString());
|
int index = Convert.ToInt16(Selet_Machines(Machines, "ID", "Name='" + WorkOrderdata_m + "'").ToString());
|
||||||
|
|
||||||
|
lock (MainWindowViewModel.Machines.Rows.SyncRoot)
|
||||||
|
{
|
||||||
|
if (Convert.ToBoolean(Selet_Machines(Machines, "Type", "Name='" + WorkOrderdata_m + "'")))
|
||||||
|
{//网络
|
||||||
stringQueue.Enqueue(new QueueString
|
stringQueue.Enqueue(new QueueString
|
||||||
{
|
{
|
||||||
ID = index,
|
ID = index,
|
||||||
DAT = "SC811" + Selet_Machines(Machines, "SYSKEY", "ID='" + index + "'") + dataTable.ToJsonString()
|
DAT = "SC811" + Selet_Machines(Machines, "SYSKEY", "ID='" + index + "'") + dataTable.ToJsonString()
|
||||||
});
|
});
|
||||||
SQLiteHelpers.Update("WorkOrder", new Dictionary<string, object> { { "State", 112 } },
|
|
||||||
"WorkOrder ='" + WorkOrderstepdata.Select()[k].Field<object>("WorkOrder").ToString() + "'", null);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{//串口
|
{//串口
|
||||||
DataTable dataTable = SQLiteHelpers.ExecuteDataSet("select * from WorkorderSteps where WorkOrder='" +
|
foreach (DataRow dataRow in dataTable.Select("Mode<>'1'"))
|
||||||
WorkOrderstepdata.Select()[k].Field<object>("WorkOrder").ToString() + "' AND ReDye ='"+
|
{
|
||||||
WorkOrderstepdata.Select()[k].Field<object>("ReDye").ToString() + "' AND Mode<> '201'", null).Tables[0];
|
Dictionary<string, object> dat_ = new Dictionary<string, object>();
|
||||||
|
dat_.Add("Work", dataRow["WorkOrder"].ToString());
|
||||||
|
dat_.Add("Dye", dataRow["DYELOT"].ToString());
|
||||||
|
dat_.Add("Time", dataRow["StepTime"].ToString());
|
||||||
|
dat_.Add("ReDye", dataRow["ReDye"].ToString());
|
||||||
|
dat_.Add("Program", dataRow["Program"].ToString());
|
||||||
|
dat_.Add("Step", dataRow["Step"].ToString());
|
||||||
|
dat_.Add("StepID", dataRow["StepID"].ToString());
|
||||||
|
dat_.Add("P1", dataRow["Parameter1"].ToString());
|
||||||
|
dat_.Add("P2", dataRow["Parameter2"].ToString());
|
||||||
|
dat_.Add("P3", dataRow["Parameter3"].ToString());
|
||||||
|
dat_.Add("P4", dataRow["Parameter4"].ToString());
|
||||||
|
dat_.Add("P5", dataRow["Parameter5"].ToString());
|
||||||
|
dat_.Add("P6", dataRow["Parameter6"].ToString());
|
||||||
|
dat_.Add("P7", dataRow["Parameter7"].ToString());
|
||||||
|
dat_.Add("P8", dataRow["Parameter8"].ToString());
|
||||||
|
dat_.Add("P9", dataRow["Parameter9"].ToString());
|
||||||
|
dat_.Add("P10", dataRow["Parameter10"].ToString());
|
||||||
|
dat_.Add("SIDS1", dataRow["StepID_S1"].ToString());
|
||||||
|
dat_.Add("SIDS2", dataRow["StepID_S2"].ToString());
|
||||||
|
dat_.Add("SIDS3", dataRow["StepID_S3"].ToString());
|
||||||
|
dat_.Add("P1S1", dataRow["Parameter1_S1"].ToString());
|
||||||
|
dat_.Add("P2S1", dataRow["Parameter2_S1"].ToString());
|
||||||
|
dat_.Add("P3S1", dataRow["Parameter3_S1"].ToString());
|
||||||
|
dat_.Add("P4S1", dataRow["Parameter4_S1"].ToString());
|
||||||
|
dat_.Add("P5S1", dataRow["Parameter5_S1"].ToString());
|
||||||
|
dat_.Add("P1S2", dataRow["Parameter1_S2"].ToString());
|
||||||
|
dat_.Add("P2S2", dataRow["Parameter2_S2"].ToString());
|
||||||
|
dat_.Add("P3S2", dataRow["Parameter3_S2"].ToString());
|
||||||
|
dat_.Add("P4S2", dataRow["Parameter4_S2"].ToString());
|
||||||
|
dat_.Add("P5S2", dataRow["Parameter5_S2"].ToString());
|
||||||
|
dat_.Add("P1S3", dataRow["Parameter1_S3"].ToString());
|
||||||
|
dat_.Add("P2S3", dataRow["Parameter2_S3"].ToString());
|
||||||
|
dat_.Add("P3S3", dataRow["Parameter3_S3"].ToString());
|
||||||
|
dat_.Add("P4S3", dataRow["Parameter4_S3"].ToString());
|
||||||
|
dat_.Add("P5S3", dataRow["Parameter5_S3"].ToString());
|
||||||
|
|
||||||
|
string dat = "SC811[" + Selet_Machines(Machines, "Station", "ID='" + index + "'") + "]" + dat_.ToJsonString();
|
||||||
|
|
||||||
int index = Convert.ToInt16(Selet_Machines(Machines, "ID", "Name='" + WorkOrderdata_m + "'").ToString());
|
|
||||||
if (Selet_Machines(Machines, "Serial", "Name='" + WorkOrderdata_m + "'").ToString() == "PORT1")
|
if (Selet_Machines(Machines, "Serial", "Name='" + WorkOrderdata_m + "'").ToString() == "PORT1")
|
||||||
|
{ // 检查队列中是否已存在相同项
|
||||||
|
bool exists = stringQueueSerial_1.Any(item => item.ID == index && item.DAT == dat);
|
||||||
|
if (!exists)
|
||||||
{
|
{
|
||||||
stringQueueSerial_1.Enqueue(new QueueSerial
|
stringQueueSerial_1.Enqueue(new QueueSerial
|
||||||
{
|
{
|
||||||
ID = index,
|
ID = index,
|
||||||
DAT = "SC811" + Selet_Machines(Machines, "SYSKEY", "ID='" + index + "'") + dataTable.Rows[0].ToJsonString()
|
DAT = dat
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else if (Selet_Machines(Machines, "Serial", "Name='" + WorkOrderdata_m + "'").ToString() == "PORT2")
|
else if (Selet_Machines(Machines, "Serial", "Name='" + WorkOrderdata_m + "'").ToString() == "PORT2")
|
||||||
|
{ // 检查队列中是否已存在相同项
|
||||||
|
bool exists = stringQueueSerial_2.Any(item => item.ID == index && item.DAT == dat);
|
||||||
|
if (!exists)
|
||||||
{
|
{
|
||||||
stringQueueSerial_2.Enqueue(new QueueSerial
|
stringQueueSerial_2.Enqueue(new QueueSerial
|
||||||
{
|
{
|
||||||
ID = index,
|
ID = index,
|
||||||
DAT = "SC811" + Selet_Machines(Machines, "SYSKEY", "ID='" + index + "'") + dataTable.Rows[0].ToJsonString()
|
DAT = "SC811[" + Selet_Machines(Machines, "Station", "ID='" + index + "'") + "]" + dat_.ToJsonString()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else if (Selet_Machines(Machines, "Serial", "Name='" + WorkOrderdata_m + "'").ToString() == "PORT3")
|
else if (Selet_Machines(Machines, "Serial", "Name='" + WorkOrderdata_m + "'").ToString() == "PORT3")
|
||||||
|
{ // 检查队列中是否已存在相同项
|
||||||
|
bool exists = stringQueueSerial_3.Any(item => item.ID == index && item.DAT == dat);
|
||||||
|
if (!exists)
|
||||||
{
|
{
|
||||||
stringQueueSerial_3.Enqueue(new QueueSerial
|
stringQueueSerial_3.Enqueue(new QueueSerial
|
||||||
{
|
{
|
||||||
ID = index,
|
ID = index,
|
||||||
DAT = "SC811" + Selet_Machines(Machines, "SYSKEY", "ID='" + index + "'") + dataTable.Rows[0].ToJsonString()
|
DAT = "SC811[" + Selet_Machines(Machines, "Station", "ID='" + index + "'") + "]" + dat_.ToJsonString()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else if (Selet_Machines(Machines, "Serial", "Name='" + WorkOrderdata_m + "'").ToString() == "PORT4")
|
else if (Selet_Machines(Machines, "Serial", "Name='" + WorkOrderdata_m + "'").ToString() == "PORT4")
|
||||||
|
{ // 检查队列中是否已存在相同项
|
||||||
|
bool exists = stringQueueSerial_4.Any(item => item.ID == index && item.DAT == dat);
|
||||||
|
if (!exists)
|
||||||
{
|
{
|
||||||
stringQueueSerial_4.Enqueue(new QueueSerial
|
stringQueueSerial_4.Enqueue(new QueueSerial
|
||||||
{
|
{
|
||||||
ID = index,
|
ID = index,
|
||||||
DAT = "SC811" + Selet_Machines(Machines, "SYSKEY", "ID='" + index + "'") + dataTable.Rows[0].ToJsonString()
|
DAT = "SC811[" + Selet_Machines(Machines, "Station", "ID='" + index + "'") + "]" + dat_.ToJsonString()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if (WorkOrderstepdata.Select()[k].Field<object>("State").ToString() == "111")
|
||||||
|
{
|
||||||
|
SQLiteHelpers.Update("WorkOrder", new Dictionary<string, object> { { "State", 112 } },
|
||||||
|
"WorkOrder ='" + WorkOrderstepdata.Select()[k].Field<object>("WorkOrder").ToString() + "'", null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
/*下传工单总览*/
|
/*下传工单总览*/
|
||||||
DataTable WorkOrderdata = SQLiteHelpers.ExecuteDataSet("select * from WorkOrder where (State='100' or State='110') AND EndTime >'" +
|
DataTable WorkOrderdata = SQLiteHelpers.ExecuteDataSet("select * from WorkOrder where (State='100' OR State='110') AND StartTime >'" +
|
||||||
DateTime.Now.AddHours(-8).ToString("yyyy/MM/dd HH:mm:ss") + "'", null).Tables[0]; //读取表写入缓存
|
DateTime.Now.AddHours(-8).ToString("yyyy/MM/dd HH:mm:ss") + "'", null).Tables[0]; //读取表写入缓存
|
||||||
for (int k = 0; k < WorkOrderdata.Rows.Count; k++)
|
for (int k = 0; k < WorkOrderdata.Rows.Count; k++)
|
||||||
{
|
{
|
||||||
string WorkOrderdata_m = WorkOrderdata.Select()[k].Field<object>("Machines").ToString();
|
string WorkOrderdata_m = WorkOrderdata.Select()[k].Field<object>("Machines").ToString();
|
||||||
//string m = WorkOrderdata.Rows[k].Field<string>("Machines");
|
//string m = WorkOrderdata.Rows[k].Field<string>("Machines");
|
||||||
|
lock (MainWindowViewModel.Machines.Rows.SyncRoot)
|
||||||
|
{
|
||||||
if (Convert.ToBoolean(Selet_Machines(Machines, "Type", "Name='" + WorkOrderdata_m + "'")))
|
if (Convert.ToBoolean(Selet_Machines(Machines, "Type", "Name='" + WorkOrderdata_m + "'")))
|
||||||
{//网络
|
{//网络
|
||||||
//string WorkOrderdata_m = WorkOrderdata.Select()[k].Field<object>("Machines").ToString();
|
//string WorkOrderdata_m = WorkOrderdata.Select()[k].Field<object>("Machines").ToString();
|
||||||
@@ -318,8 +379,6 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
|||||||
ID = index,
|
ID = index,
|
||||||
DAT = "SC810" + Selet_Machines(Machines, "SYSKEY", "ID='" + index + "'") + DataTableToDictionary(dataTable).ToJsonString()
|
DAT = "SC810" + Selet_Machines(Machines, "SYSKEY", "ID='" + index + "'") + DataTableToDictionary(dataTable).ToJsonString()
|
||||||
});
|
});
|
||||||
SQLiteHelpers.Update("WorkOrder", new Dictionary<string, object> { { "State", 110 } },
|
|
||||||
"WorkOrder ='" + WorkOrderdata.Select()[k].Field<object>("WorkOrder").ToString() + "'", null);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -327,7 +386,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
|||||||
//string WorkOrderdata_m = WorkOrderdata.Select()[k].Field<object>("Machines").ToString();
|
//string WorkOrderdata_m = WorkOrderdata.Select()[k].Field<object>("Machines").ToString();
|
||||||
string State = Selet_Machines(Machines, "State", "Name='" + WorkOrderdata_m + "'").ToString();
|
string State = Selet_Machines(Machines, "State", "Name='" + WorkOrderdata_m + "'").ToString();
|
||||||
|
|
||||||
if ((State == "101") || (State == "201") || (State == "202") || (State == "309"))
|
if ((State == "101") || (State == "201") || (State == "202") || (State == "309") || (State == "802"))
|
||||||
{
|
{
|
||||||
DataTable dataTable = WorkOrderdata.Clone();
|
DataTable dataTable = WorkOrderdata.Clone();
|
||||||
// WorkOrderdata.Columns.Remove("Machines");
|
// WorkOrderdata.Columns.Remove("Machines");
|
||||||
@@ -337,52 +396,81 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
|||||||
dt_temp.EndEdit();
|
dt_temp.EndEdit();
|
||||||
dataTable.Rows.Add(dt_temp.ItemArray);
|
dataTable.Rows.Add(dt_temp.ItemArray);
|
||||||
|
|
||||||
|
Dictionary<string, object> dat_ = new Dictionary<string, object>();
|
||||||
|
dat_.Add("Work", dt_temp["WorkOrder"].ToString());
|
||||||
|
dat_.Add("Dye", dt_temp["DYELOT"].ToString());
|
||||||
|
dat_.Add("STime", dt_temp["StartTime"].ToString());
|
||||||
|
dat_.Add("Time", dt_temp["Time"].ToString());
|
||||||
|
dat_.Add("ReDye", 0);
|
||||||
|
|
||||||
int index = Convert.ToInt16(Selet_Machines(Machines, "ID", "Name='" + WorkOrderdata_m + "'").ToString());
|
int index = Convert.ToInt16(Selet_Machines(Machines, "ID", "Name='" + WorkOrderdata_m + "'").ToString());
|
||||||
|
string dat = "SC810[" + Selet_Machines(Machines, "Station", "ID='" + index + "'") + "]" + dat_.ToJsonString();
|
||||||
if (Selet_Machines(Machines, "Serial", "Name='" + WorkOrderdata_m + "'").ToString() == "PORT1")
|
if (Selet_Machines(Machines, "Serial", "Name='" + WorkOrderdata_m + "'").ToString() == "PORT1")
|
||||||
|
{ // 检查队列中是否已存在相同项
|
||||||
|
bool exists = stringQueueSerial_1.Any(item => item.ID == index && item.DAT == dat);
|
||||||
|
if (!exists)
|
||||||
{
|
{
|
||||||
stringQueueSerial_1.Enqueue(new QueueSerial
|
stringQueueSerial_1.Enqueue(new QueueSerial
|
||||||
{
|
{
|
||||||
ID = index,
|
ID = index,
|
||||||
DAT = "SC810" + Selet_Machines(Machines, "SYSKEY", "ID='" + index + "'") + DataTableToDictionary(dataTable).ToJsonString()
|
DAT = dat
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else if (Selet_Machines(Machines, "Serial", "Name='" + WorkOrderdata_m + "'").ToString() == "PORT2")
|
else if (Selet_Machines(Machines, "Serial", "Name='" + WorkOrderdata_m + "'").ToString() == "PORT2")
|
||||||
|
{ // 检查队列中是否已存在相同项
|
||||||
|
bool exists = stringQueueSerial_2.Any(item => item.ID == index && item.DAT == dat);
|
||||||
|
if (!exists)
|
||||||
{
|
{
|
||||||
stringQueueSerial_2.Enqueue(new QueueSerial
|
stringQueueSerial_2.Enqueue(new QueueSerial
|
||||||
{
|
{
|
||||||
ID = index,
|
ID = index,
|
||||||
DAT = "SC810" + Selet_Machines(Machines, "SYSKEY", "ID='" + index + "'") + DataTableToDictionary(dataTable).ToJsonString()
|
DAT = dat
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else if (Selet_Machines(Machines, "Serial", "Name='" + WorkOrderdata_m + "'").ToString() == "PORT3")
|
else if (Selet_Machines(Machines, "Serial", "Name='" + WorkOrderdata_m + "'").ToString() == "PORT3")
|
||||||
|
{ // 检查队列中是否已存在相同项
|
||||||
|
bool exists = stringQueueSerial_3.Any(item => item.ID == index && item.DAT == dat);
|
||||||
|
if (!exists)
|
||||||
{
|
{
|
||||||
stringQueueSerial_3.Enqueue(new QueueSerial
|
stringQueueSerial_3.Enqueue(new QueueSerial
|
||||||
{
|
{
|
||||||
ID = index,
|
ID = index,
|
||||||
DAT = "SC810" + Selet_Machines(Machines, "SYSKEY", "ID='" + index + "'") + DataTableToDictionary(dataTable).ToJsonString()
|
DAT = dat
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else if (Selet_Machines(Machines, "Serial", "Name='" + WorkOrderdata_m + "'").ToString() == "PORT4")
|
else if (Selet_Machines(Machines, "Serial", "Name='" + WorkOrderdata_m + "'").ToString() == "PORT4")
|
||||||
|
{ // 检查队列中是否已存在相同项
|
||||||
|
bool exists = stringQueueSerial_4.Any(item => item.ID == index && item.DAT == dat);
|
||||||
|
if (!exists)
|
||||||
{
|
{
|
||||||
stringQueueSerial_4.Enqueue(new QueueSerial
|
stringQueueSerial_4.Enqueue(new QueueSerial
|
||||||
{
|
{
|
||||||
ID = index,
|
ID = index,
|
||||||
DAT = "SC810" + Selet_Machines(Machines, "SYSKEY", "ID='" + index + "'") + DataTableToDictionary(dataTable).ToJsonString()
|
DAT = dat
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (WorkOrderdata.Select()[k].Field<object>("State").ToString() == "110")
|
||||||
|
{
|
||||||
SQLiteHelpers.Update("WorkOrder", new Dictionary<string, object> { { "State", 110 } },
|
SQLiteHelpers.Update("WorkOrder", new Dictionary<string, object> { { "State", 110 } },
|
||||||
"WorkOrder ='" + WorkOrderdata.Select()[k].Field<object>("WorkOrder").ToString() + "'", null);
|
"WorkOrder ='" + WorkOrderdata.Select()[k].Field<object>("WorkOrder").ToString() + "'", null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*下传工单设置*/
|
/*下传工单设置*/
|
||||||
DataTable WorkOrderset_ = SQLiteHelpers.ExecuteDataSet("select * from WorkOrder where (State='113'or State='114') AND EndTime >'" +
|
DataTable WorkOrderset_ = SQLiteHelpers.ExecuteDataSet("select * from WorkOrder where (State='113' OR State='114') AND StartTime >'" +
|
||||||
DateTime.Now.AddHours(-8).ToString("yyyy/MM/dd HH:mm:ss") + "'", null).Tables[0]; //读取表写入缓存
|
DateTime.Now.AddHours(-8).ToString("yyyy/MM/dd HH:mm:ss") + "'", null).Tables[0]; //读取表写入缓存
|
||||||
for (int k = 0; k < WorkOrderset_.Rows.Count; k++)
|
for (int k = 0; k < WorkOrderset_.Rows.Count; k++)
|
||||||
{
|
{
|
||||||
string WorkOrderset_m = WorkOrderset_.Select()[k].Field<object>("Machines").ToString();
|
string WorkOrderset_m = WorkOrderset_.Select()[k].Field<object>("Machines").ToString();
|
||||||
//string m = WorkOrderset_.Rows[k].Field<string>("Machines");
|
//string m = WorkOrderset_.Rows[k].Field<string>("Machines");
|
||||||
|
lock (MainWindowViewModel.Machines.Rows.SyncRoot)
|
||||||
|
{
|
||||||
if (Convert.ToBoolean(Selet_Machines(Machines, "Type", "Name='" + WorkOrderset_m + "'")))
|
if (Convert.ToBoolean(Selet_Machines(Machines, "Type", "Name='" + WorkOrderset_m + "'")))
|
||||||
{//网络
|
{//网络
|
||||||
//string WorkOrderset_m = WorkOrderset_.Select()[k].Field<object>("Machines").ToString();
|
//string WorkOrderset_m = WorkOrderset_.Select()[k].Field<object>("Machines").ToString();
|
||||||
@@ -399,9 +487,6 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
|||||||
DAT = "SC812" + Selet_Machines(Machines, "SYSKEY", "ID='" + index + "'") + DataTableToDictionary(WorkOrder_set).ToJsonString()
|
DAT = "SC812" + Selet_Machines(Machines, "SYSKEY", "ID='" + index + "'") + DataTableToDictionary(WorkOrder_set).ToJsonString()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
SQLiteHelpers.Update("WorkOrder", new Dictionary<string, object> { { "State", 114 } },
|
|
||||||
"WorkOrder ='" + WorkOrderset_.Select()[k].Field<object>("WorkOrder").ToString() + "'", null);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{//串口
|
{//串口
|
||||||
@@ -413,56 +498,71 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
|||||||
if (WorkOrder_set.Rows.Count > 0)
|
if (WorkOrder_set.Rows.Count > 0)
|
||||||
{
|
{
|
||||||
int index = Convert.ToInt16(Selet_Machines(Machines, "ID", "Name='" + WorkOrderset_m + "'").ToString());
|
int index = Convert.ToInt16(Selet_Machines(Machines, "ID", "Name='" + WorkOrderset_m + "'").ToString());
|
||||||
|
string dat = "SC812[" + Selet_Machines(Machines, "Station", "ID='" + index + "'") + "]" +
|
||||||
|
DataTableToDictionary(WorkOrder_set).ToJsonString();
|
||||||
if (Selet_Machines(Machines, "Serial", "Name='" + WorkOrderset_m + "'").ToString() == "PORT1")
|
if (Selet_Machines(Machines, "Serial", "Name='" + WorkOrderset_m + "'").ToString() == "PORT1")
|
||||||
|
{
|
||||||
|
bool exists = stringQueueSerial_1.Any(item => item.ID == index && item.DAT == dat);
|
||||||
|
if (!exists)
|
||||||
{
|
{
|
||||||
stringQueueSerial_1.Enqueue(new QueueSerial
|
stringQueueSerial_1.Enqueue(new QueueSerial
|
||||||
{
|
{
|
||||||
ID = index,
|
ID = index,
|
||||||
DAT = "SC812[" +
|
DAT = dat
|
||||||
Selet_Machines(Machines, "Station", "ID='" + k + "'") + "]" +
|
|
||||||
DataTableToDictionary(WorkOrder_set).ToJsonString()
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else if (Selet_Machines(Machines, "Serial", "Name='" + WorkOrderset_m + "'").ToString() == "PORT2")
|
else if (Selet_Machines(Machines, "Serial", "Name='" + WorkOrderset_m + "'").ToString() == "PORT2")
|
||||||
|
{
|
||||||
|
bool exists = stringQueueSerial_2.Any(item => item.ID == index && item.DAT == dat);
|
||||||
|
if (!exists)
|
||||||
{
|
{
|
||||||
stringQueueSerial_2.Enqueue(new QueueSerial
|
stringQueueSerial_2.Enqueue(new QueueSerial
|
||||||
{
|
{
|
||||||
ID = index,
|
ID = index,
|
||||||
DAT = "SC812[" +
|
DAT = dat
|
||||||
Selet_Machines(Machines, "Station", "ID='" + k + "'") + "]" +
|
|
||||||
DataTableToDictionary(WorkOrder_set).ToJsonString()
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else if (Selet_Machines(Machines, "Serial", "Name='" + WorkOrderset_m + "'").ToString() == "PORT3")
|
else if (Selet_Machines(Machines, "Serial", "Name='" + WorkOrderset_m + "'").ToString() == "PORT3")
|
||||||
|
{
|
||||||
|
bool exists = stringQueueSerial_3.Any(item => item.ID == index && item.DAT == dat);
|
||||||
|
if (!exists)
|
||||||
{
|
{
|
||||||
stringQueueSerial_3.Enqueue(new QueueSerial
|
stringQueueSerial_3.Enqueue(new QueueSerial
|
||||||
{
|
{
|
||||||
ID = index,
|
ID = index,
|
||||||
DAT = "SC812[" +
|
DAT = dat
|
||||||
Selet_Machines(Machines, "Station", "ID='" + k + "'") + "]" +
|
|
||||||
DataTableToDictionary(WorkOrder_set).ToJsonString()
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else if (Selet_Machines(Machines, "Serial", "Name='" + WorkOrderset_m + "'").ToString() == "PORT4")
|
else if (Selet_Machines(Machines, "Serial", "Name='" + WorkOrderset_m + "'").ToString() == "PORT4")
|
||||||
|
{
|
||||||
|
bool exists = stringQueueSerial_4.Any(item => item.ID == index && item.DAT == dat);
|
||||||
|
if (!exists)
|
||||||
{
|
{
|
||||||
stringQueueSerial_4.Enqueue(new QueueSerial
|
stringQueueSerial_4.Enqueue(new QueueSerial
|
||||||
{
|
{
|
||||||
ID = index,
|
ID = index,
|
||||||
DAT = "SC812[" +
|
DAT = dat
|
||||||
Selet_Machines(Machines, "Station", "ID='" + k + "'") + "]" +
|
|
||||||
DataTableToDictionary(WorkOrder_set).ToJsonString()
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SQLiteHelpers.Update("WorkOrder", new Dictionary<string, object> { { "State", 110 } },
|
}
|
||||||
"WorkOrder ='" + WorkOrderdata.Select()[k].Field<object>("WorkOrder").ToString() + "'", null);
|
}
|
||||||
|
if (WorkOrderset_.Select()[k].Field<object>("State").ToString() == "113")
|
||||||
|
{
|
||||||
|
SQLiteHelpers.Update("WorkOrder", new Dictionary<string, object> { { "State", 114 } },
|
||||||
|
"WorkOrder ='" + WorkOrderset_.Select()[k].Field<object>("WorkOrder").ToString() + "'", null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//系统时间
|
//系统时间
|
||||||
Sys_Time = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
|
Sys_Time = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
|
||||||
//更新机台状态与发送指令
|
//更新机台状态与发送指令
|
||||||
|
lock (MainWindowViewModel.Machines.Rows.SyncRoot)
|
||||||
|
{
|
||||||
foreach (DataRow MachinesRow in Machines.Rows)
|
foreach (DataRow MachinesRow in Machines.Rows)
|
||||||
{
|
{
|
||||||
if (Convert.ToBoolean(MachinesRow["Type"]))
|
if (Convert.ToBoolean(MachinesRow["Type"]))
|
||||||
@@ -524,16 +624,11 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{//串口发送
|
{//串口发送
|
||||||
if (MachinesRow["State"].ToString() == "802")
|
string mac_s = MachinesRow["State"].ToString();
|
||||||
|
if (mac_s == "802")
|
||||||
{
|
{
|
||||||
if (MachinesRow["Serial"].ToString() == "PORT1")
|
if (MachinesRow["Serial"].ToString() == "PORT1")
|
||||||
{
|
{
|
||||||
stringQueueSerial_1.Enqueue(new QueueSerial
|
|
||||||
{
|
|
||||||
ID = Convert.ToInt16(MachinesRow["ID"]),
|
|
||||||
DAT = "SC830[" + MachinesRow["Station"] + "]"
|
|
||||||
});
|
|
||||||
|
|
||||||
bool mode = Convert.ToBoolean(MachinesRow["LOCK"]);//发送锁定状态
|
bool mode = Convert.ToBoolean(MachinesRow["LOCK"]);//发送锁定状态
|
||||||
if (mode)
|
if (mode)
|
||||||
{
|
{
|
||||||
@@ -541,80 +636,223 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
|||||||
dat_829.Clear();
|
dat_829.Clear();
|
||||||
dat_829.Add("NAME", "LOCK");
|
dat_829.Add("NAME", "LOCK");
|
||||||
dat_829.Add("VALUE", "True");
|
dat_829.Add("VALUE", "True");
|
||||||
|
|
||||||
|
int id = Convert.ToInt16(MachinesRow["ID"]);
|
||||||
|
string dat = "SC829[" + MachinesRow["Station"] + "]" + dat_829.ToJsonString();
|
||||||
|
// 检查队列中是否已存在相同项
|
||||||
|
bool exists = stringQueueSerial_1.Any(item => item.ID == id && item.DAT == dat);
|
||||||
|
if (!exists)
|
||||||
|
{
|
||||||
stringQueueSerial_1.Enqueue(new QueueSerial
|
stringQueueSerial_1.Enqueue(new QueueSerial
|
||||||
{
|
{
|
||||||
ID = Convert.ToInt16(MachinesRow["ID"]),
|
ID = id,
|
||||||
DAT = "SC829[" + MachinesRow["Station"] + "]" + dat_829.ToJsonString()
|
DAT = dat
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Updata_Machines(Machines, "State", "ID='" + MachinesRow["ID"] + "'", "101");
|
||||||
|
}
|
||||||
|
else if (MachinesRow["Serial"].ToString() == "PORT2")
|
||||||
|
{
|
||||||
|
bool mode = Convert.ToBoolean(MachinesRow["LOCK"]);//发送锁定状态
|
||||||
|
if (mode)
|
||||||
|
{
|
||||||
|
Dictionary<string, object> dat_829 = new Dictionary<string, object>();
|
||||||
|
dat_829.Clear();
|
||||||
|
dat_829.Add("NAME", "LOCK");
|
||||||
|
dat_829.Add("VALUE", "True");
|
||||||
|
|
||||||
|
int id = Convert.ToInt16(MachinesRow["ID"]);
|
||||||
|
string dat = "SC829[" + MachinesRow["Station"] + "]" + dat_829.ToJsonString();
|
||||||
|
// 检查队列中是否已存在相同项
|
||||||
|
bool exists = stringQueueSerial_2.Any(item => item.ID == id && item.DAT == dat);
|
||||||
|
if (!exists)
|
||||||
|
{
|
||||||
|
stringQueueSerial_2.Enqueue(new QueueSerial
|
||||||
|
{
|
||||||
|
ID = id,
|
||||||
|
DAT = dat
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (MachinesRow["Serial"].ToString() == "PORT3")
|
||||||
|
{
|
||||||
|
bool mode = Convert.ToBoolean(MachinesRow["LOCK"]);//发送锁定状态
|
||||||
|
if (mode)
|
||||||
|
{
|
||||||
|
Dictionary<string, object> dat_829 = new Dictionary<string, object>();
|
||||||
|
dat_829.Clear();
|
||||||
|
dat_829.Add("NAME", "LOCK");
|
||||||
|
dat_829.Add("VALUE", "True");
|
||||||
|
|
||||||
|
int id = Convert.ToInt16(MachinesRow["ID"]);
|
||||||
|
string dat = "SC829[" + MachinesRow["Station"] + "]" + dat_829.ToJsonString();
|
||||||
|
// 检查队列中是否已存在相同项
|
||||||
|
bool exists = stringQueueSerial_3.Any(item => item.ID == id && item.DAT == dat);
|
||||||
|
if (!exists)
|
||||||
|
{
|
||||||
|
stringQueueSerial_3.Enqueue(new QueueSerial
|
||||||
|
{
|
||||||
|
ID = id,
|
||||||
|
DAT = dat
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (MachinesRow["Serial"].ToString() == "PORT4")
|
||||||
|
{
|
||||||
|
bool mode = Convert.ToBoolean(MachinesRow["LOCK"]);//发送锁定状态
|
||||||
|
if (mode)
|
||||||
|
{
|
||||||
|
Dictionary<string, object> dat_829 = new Dictionary<string, object>();
|
||||||
|
dat_829.Clear();
|
||||||
|
dat_829.Add("NAME", "LOCK");
|
||||||
|
dat_829.Add("VALUE", "True");
|
||||||
|
|
||||||
|
int id = Convert.ToInt16(MachinesRow["ID"]);
|
||||||
|
string dat = "SC829[" + MachinesRow["Station"] + "]" + dat_829.ToJsonString();
|
||||||
|
// 检查队列中是否已存在相同项
|
||||||
|
bool exists = stringQueueSerial_4.Any(item => item.ID == id && item.DAT == dat);
|
||||||
|
if (!exists)
|
||||||
|
{
|
||||||
|
stringQueueSerial_4.Enqueue(new QueueSerial
|
||||||
|
{
|
||||||
|
ID = id,
|
||||||
|
DAT = dat
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (mac_s == "800")
|
||||||
|
{
|
||||||
|
if (MachinesRow["Serial"].ToString() == "PORT1")
|
||||||
|
{
|
||||||
|
int id = Convert.ToInt16(MachinesRow["ID"]);
|
||||||
|
string dat = "SC800[" + MachinesRow["Station"] + "]";
|
||||||
|
// 检查队列中是否已存在相同项
|
||||||
|
bool exists = stringQueueSerial_1.Any(item => item.ID == id && item.DAT == dat);
|
||||||
|
if (!exists)
|
||||||
|
{
|
||||||
|
stringQueueSerial_1.Enqueue(new QueueSerial
|
||||||
|
{
|
||||||
|
ID = id,
|
||||||
|
DAT = dat
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (MachinesRow["Serial"].ToString() == "PORT2")
|
else if (MachinesRow["Serial"].ToString() == "PORT2")
|
||||||
|
{
|
||||||
|
int id = Convert.ToInt16(MachinesRow["ID"]);
|
||||||
|
string dat = "SC800[" + MachinesRow["Station"] + "]";
|
||||||
|
// 检查队列中是否已存在相同项
|
||||||
|
bool exists = stringQueueSerial_2.Any(item => item.ID == id && item.DAT == dat);
|
||||||
|
if (!exists)
|
||||||
{
|
{
|
||||||
stringQueueSerial_2.Enqueue(new QueueSerial
|
stringQueueSerial_2.Enqueue(new QueueSerial
|
||||||
{
|
{
|
||||||
ID = Convert.ToInt16(MachinesRow["ID"]),
|
ID = id,
|
||||||
DAT = "SC830[" + MachinesRow["Station"] + "]"
|
DAT = dat
|
||||||
});
|
|
||||||
|
|
||||||
bool mode = Convert.ToBoolean(MachinesRow["LOCK"]);//发送锁定状态
|
|
||||||
if (mode)
|
|
||||||
{
|
|
||||||
Dictionary<string, object> dat_829 = new Dictionary<string, object>();
|
|
||||||
dat_829.Clear();
|
|
||||||
dat_829.Add("NAME", "LOCK");
|
|
||||||
dat_829.Add("VALUE", "True");
|
|
||||||
stringQueueSerial_2.Enqueue(new QueueSerial
|
|
||||||
{
|
|
||||||
ID = Convert.ToInt16(MachinesRow["ID"]),
|
|
||||||
DAT = "SC829[" + MachinesRow["Station"] + "]" + dat_829.ToJsonString()
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (MachinesRow["Serial"].ToString() == "PORT3")
|
else if (MachinesRow["Serial"].ToString() == "PORT3")
|
||||||
|
{
|
||||||
|
int id = Convert.ToInt16(MachinesRow["ID"]);
|
||||||
|
string dat = "SC800[" + MachinesRow["Station"] + "]";
|
||||||
|
// 检查队列中是否已存在相同项
|
||||||
|
bool exists = stringQueueSerial_3.Any(item => item.ID == id && item.DAT == dat);
|
||||||
|
if (!exists)
|
||||||
{
|
{
|
||||||
stringQueueSerial_3.Enqueue(new QueueSerial
|
stringQueueSerial_3.Enqueue(new QueueSerial
|
||||||
{
|
{
|
||||||
ID = Convert.ToInt16(MachinesRow["ID"]),
|
ID = id,
|
||||||
DAT = "SC830[" + MachinesRow["Station"] + "]"
|
DAT = dat
|
||||||
});
|
|
||||||
|
|
||||||
bool mode = Convert.ToBoolean(MachinesRow["LOCK"]);//发送锁定状态
|
|
||||||
if (mode)
|
|
||||||
{
|
|
||||||
Dictionary<string, object> dat_829 = new Dictionary<string, object>();
|
|
||||||
dat_829.Clear();
|
|
||||||
dat_829.Add("NAME", "LOCK");
|
|
||||||
dat_829.Add("VALUE", "True");
|
|
||||||
stringQueueSerial_3.Enqueue(new QueueSerial
|
|
||||||
{
|
|
||||||
ID = Convert.ToInt16(MachinesRow["ID"]),
|
|
||||||
DAT = "SC829[" + MachinesRow["Station"] + "]" + dat_829.ToJsonString()
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (MachinesRow["Serial"].ToString() == "PORT4")
|
else if (MachinesRow["Serial"].ToString() == "PORT4")
|
||||||
|
{
|
||||||
|
int id = Convert.ToInt16(MachinesRow["ID"]);
|
||||||
|
string dat = "SC800[" + MachinesRow["Station"] + "]";
|
||||||
|
// 检查队列中是否已存在相同项
|
||||||
|
bool exists = stringQueueSerial_4.Any(item => item.ID == id && item.DAT == dat);
|
||||||
|
if (!exists)
|
||||||
{
|
{
|
||||||
stringQueueSerial_4.Enqueue(new QueueSerial
|
stringQueueSerial_4.Enqueue(new QueueSerial
|
||||||
{
|
{
|
||||||
ID = Convert.ToInt16(MachinesRow["ID"]),
|
ID = id,
|
||||||
DAT = "SC830[" + MachinesRow["Station"] + "]"
|
DAT = dat
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ((mac_s == "101") || (mac_s == "201") || (mac_s == "202") || (mac_s == "301") || (mac_s == "309"))//获取信息
|
||||||
|
{
|
||||||
|
if (MachinesRow["Serial"].ToString() == "PORT1")
|
||||||
|
{
|
||||||
|
int id = Convert.ToInt16(MachinesRow["ID"]);
|
||||||
|
string dat = "SC830[" + MachinesRow["Station"] + "]";
|
||||||
|
// 检查队列中是否已存在相同项
|
||||||
|
bool exists = stringQueueSerial_1.Any(item => item.ID == id && item.DAT == dat);
|
||||||
|
if (!exists)
|
||||||
|
{
|
||||||
|
stringQueueSerial_1.Enqueue(new QueueSerial
|
||||||
|
{
|
||||||
|
ID = id,
|
||||||
|
DAT = dat
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (MachinesRow["Serial"].ToString() == "PORT2")
|
||||||
|
{
|
||||||
|
int id = Convert.ToInt16(MachinesRow["ID"]);
|
||||||
|
string dat = "SC830[" + MachinesRow["Station"] + "]";
|
||||||
|
// 检查队列中是否已存在相同项
|
||||||
|
bool exists = stringQueueSerial_2.Any(item => item.ID == id && item.DAT == dat);
|
||||||
|
if (!exists)
|
||||||
|
{
|
||||||
|
stringQueueSerial_2.Enqueue(new QueueSerial
|
||||||
|
{
|
||||||
|
ID = id,
|
||||||
|
DAT = dat
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (MachinesRow["Serial"].ToString() == "PORT3")
|
||||||
|
{
|
||||||
|
int id = Convert.ToInt16(MachinesRow["ID"]);
|
||||||
|
string dat = "SC830[" + MachinesRow["Station"] + "]";
|
||||||
|
// 检查队列中是否已存在相同项
|
||||||
|
bool exists = stringQueueSerial_3.Any(item => item.ID == id && item.DAT == dat);
|
||||||
|
if (!exists)
|
||||||
|
{
|
||||||
|
stringQueueSerial_3.Enqueue(new QueueSerial
|
||||||
|
{
|
||||||
|
ID = id,
|
||||||
|
DAT = dat
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (MachinesRow["Serial"].ToString() == "PORT4")
|
||||||
|
{
|
||||||
|
int id = Convert.ToInt16(MachinesRow["ID"]);
|
||||||
|
string dat = "SC830[" + MachinesRow["Station"] + "]";
|
||||||
|
// 检查队列中是否已存在相同项
|
||||||
|
bool exists = stringQueueSerial_4.Any(item => item.ID == id && item.DAT == dat);
|
||||||
|
if (!exists)
|
||||||
|
{
|
||||||
|
stringQueueSerial_4.Enqueue(new QueueSerial
|
||||||
|
{
|
||||||
|
ID = id,
|
||||||
|
DAT = dat
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool mode = Convert.ToBoolean(MachinesRow["LOCK"]);//发送锁定状态
|
|
||||||
if (mode)
|
|
||||||
{
|
|
||||||
Dictionary<string, object> dat_829 = new Dictionary<string, object>();
|
|
||||||
dat_829.Clear();
|
|
||||||
dat_829.Add("NAME", "LOCK");
|
|
||||||
dat_829.Add("VALUE", "True");
|
|
||||||
stringQueueSerial_4.Enqueue(new QueueSerial
|
|
||||||
{
|
|
||||||
ID = Convert.ToInt16(MachinesRow["ID"]),
|
|
||||||
DAT = "SC829[" + MachinesRow["Station"] + "]" + dat_829.ToJsonString()
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
int m_run = Convert.ToInt16(MachinesRow["WORK_RUN"]);
|
int m_run = Convert.ToInt16(MachinesRow["WORK_RUN"]);
|
||||||
if (m_run == 0)
|
if (m_run == 0)
|
||||||
{
|
{
|
||||||
@@ -633,46 +871,9 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
|||||||
{
|
{
|
||||||
Updata_Machines(Machines, "State", "ID='" + MachinesRow["ID"] + "'", "309");//错误
|
Updata_Machines(Machines, "State", "ID='" + MachinesRow["ID"] + "'", "309");//错误
|
||||||
}
|
}
|
||||||
|
|
||||||
string mac_s = MachinesRow["State"].ToString();
|
|
||||||
if ((mac_s == "101") || (mac_s == "201") || (mac_s == "202") || (mac_s == "301") || (mac_s == "309"))//获取信息
|
|
||||||
{
|
|
||||||
if (MachinesRow["Serial"].ToString() == "PORT1")
|
|
||||||
{
|
|
||||||
stringQueueSerial_1.Enqueue(new QueueSerial
|
|
||||||
{
|
|
||||||
ID = Convert.ToInt16(MachinesRow["ID"]),
|
|
||||||
DAT = "SC830[" + MachinesRow["Station"] + "]"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else if (MachinesRow["Serial"].ToString() == "PORT2")
|
|
||||||
{
|
|
||||||
stringQueueSerial_2.Enqueue(new QueueSerial
|
|
||||||
{
|
|
||||||
ID = Convert.ToInt16(MachinesRow["ID"]),
|
|
||||||
DAT = "SC830[" + MachinesRow["Station"] + "]"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else if (MachinesRow["Serial"].ToString() == "PORT3")
|
|
||||||
{
|
|
||||||
stringQueueSerial_3.Enqueue(new QueueSerial
|
|
||||||
{
|
|
||||||
ID = Convert.ToInt16(MachinesRow["ID"]),
|
|
||||||
DAT = "SC830[" + MachinesRow["Station"] + "]"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else if (MachinesRow["Serial"].ToString() == "PORT4")
|
|
||||||
{
|
|
||||||
stringQueueSerial_4.Enqueue(new QueueSerial
|
|
||||||
{
|
|
||||||
ID = Convert.ToInt16(MachinesRow["ID"]),
|
|
||||||
DAT = "SC830[" + MachinesRow["Station"] + "]"
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (Time5 > 5)
|
if (Time5 > 5)
|
||||||
{
|
{
|
||||||
Tick_Event_5S();
|
Tick_Event_5S();
|
||||||
@@ -688,86 +889,6 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
|||||||
}
|
}
|
||||||
async void Tick_Event_5S()//Tick_Event周期执行事件5S
|
async void Tick_Event_5S()//Tick_Event周期执行事件5S
|
||||||
{
|
{
|
||||||
foreach (DataRow MachinesRow in Machines.Rows)
|
|
||||||
{
|
|
||||||
/**发送800指令**/
|
|
||||||
if (MachinesRow["State"].ToString() == "801")
|
|
||||||
{
|
|
||||||
stringQueue.Enqueue(new QueueString
|
|
||||||
{
|
|
||||||
ID = Convert.ToInt16(MachinesRow["ID"]),
|
|
||||||
DAT = "SC800:SCCM[" + MachinesRow["IP"] + ";" + MachinesRow["PORT"] + "]"
|
|
||||||
});//信息插入队列
|
|
||||||
}
|
|
||||||
|
|
||||||
/**染机用户信息**/
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (MachinesRow["UserInfoStart"].ToString() == "901")//打开用户提示信息
|
|
||||||
{
|
|
||||||
MainWindow.InfData.Rows.Add(new object[] {
|
|
||||||
MachinesRow["Name"],Properties.Resources.Pequest + MachinesRow["UserInfo"],
|
|
||||||
MachinesRow["SYSKEY"],MachinesRow["ID"]});
|
|
||||||
|
|
||||||
Updata_Machines(Machines, "UserInfoStart", "ID='" + MachinesRow["ID"] + "'", "900");
|
|
||||||
}
|
|
||||||
if (MachinesRow["UserInfoStart"].ToString() == "902")//删除用户提示信息
|
|
||||||
{
|
|
||||||
MainWindow.InfData.Select("ID='" + MachinesRow["ID"] + "'").First().Delete();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception EX) { LogGing.ERRDATA(EX); }
|
|
||||||
/**染机呼叫状态**/
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (Convert.ToBoolean(MachinesRow["CALL"]))
|
|
||||||
{
|
|
||||||
if (Convert.ToBoolean(MachinesRow["Type"]))
|
|
||||||
{//网络
|
|
||||||
stringQueue.Enqueue(new QueueString
|
|
||||||
{
|
|
||||||
ID = Convert.ToInt16(MachinesRow["ID"]),
|
|
||||||
DAT = "SC827" + MachinesRow["SYSKEY"]
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{//串口
|
|
||||||
if (MachinesRow["Serial"].ToString() == "PORT1")
|
|
||||||
{
|
|
||||||
stringQueueSerial_1.Enqueue(new QueueSerial
|
|
||||||
{
|
|
||||||
ID = Convert.ToInt16(MachinesRow["ID"]),
|
|
||||||
DAT = "SC827[" + MachinesRow["Station"] + "]"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else if (MachinesRow["Serial"].ToString() == "PORT2")
|
|
||||||
{
|
|
||||||
stringQueueSerial_2.Enqueue(new QueueSerial
|
|
||||||
{
|
|
||||||
ID = Convert.ToInt16(MachinesRow["ID"]),
|
|
||||||
DAT = "SC827[" + MachinesRow["Station"] + "]"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else if (MachinesRow["Serial"].ToString() == "PORT3")
|
|
||||||
{
|
|
||||||
stringQueueSerial_3.Enqueue(new QueueSerial
|
|
||||||
{
|
|
||||||
ID = Convert.ToInt16(MachinesRow["ID"]),
|
|
||||||
DAT = "SC827[" + MachinesRow["Station"] + "]"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else if (MachinesRow["Serial"].ToString() == "PORT4")
|
|
||||||
{
|
|
||||||
stringQueueSerial_4.Enqueue(new QueueSerial
|
|
||||||
{
|
|
||||||
ID = Convert.ToInt16(MachinesRow["ID"]),
|
|
||||||
DAT = "SC827[" + MachinesRow["Station"] + "]"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception EX) { LogGing.ERRDATA(EX); }
|
|
||||||
try
|
try
|
||||||
{//处理呼叫请求列表完成发送后(202》203)
|
{//处理呼叫请求列表完成发送后(202》203)
|
||||||
if (Dyelot_CALL.Select("State='202'").Count() > 0)
|
if (Dyelot_CALL.Select("State='202'").Count() > 0)
|
||||||
@@ -964,6 +1085,90 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception EX) { LogGing.ERRDATA(EX); }
|
catch (Exception EX) { LogGing.ERRDATA(EX); }
|
||||||
|
|
||||||
|
lock (MainWindowViewModel.Machines.Rows.SyncRoot)
|
||||||
|
{
|
||||||
|
foreach (DataRow MachinesRow in Machines.Rows)
|
||||||
|
{
|
||||||
|
/**发送800指令**/
|
||||||
|
if (MachinesRow["State"].ToString() == "801")
|
||||||
|
{
|
||||||
|
stringQueue.Enqueue(new QueueString
|
||||||
|
{
|
||||||
|
ID = Convert.ToInt16(MachinesRow["ID"]),
|
||||||
|
DAT = "SC800:SCCM[" + MachinesRow["IP"] + ";" + MachinesRow["PORT"] + "]"
|
||||||
|
});//信息插入队列
|
||||||
|
}
|
||||||
|
|
||||||
|
/**染机用户信息**/
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (MachinesRow["UserInfoStart"].ToString() == "901")//打开用户提示信息
|
||||||
|
{
|
||||||
|
MainWindow.InfData.Rows.Add(new object[] {
|
||||||
|
MachinesRow["Name"],Properties.Resources.Pequest + MachinesRow["UserInfo"],
|
||||||
|
MachinesRow["SYSKEY"],MachinesRow["ID"]});
|
||||||
|
|
||||||
|
Updata_Machines(Machines, "UserInfoStart", "ID='" + MachinesRow["ID"] + "'", "900");
|
||||||
|
}
|
||||||
|
if (MachinesRow["UserInfoStart"].ToString() == "902")//删除用户提示信息
|
||||||
|
{
|
||||||
|
MainWindow.InfData.Select("ID='" + MachinesRow["ID"] + "'").First().Delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception EX) { LogGing.ERRDATA(EX); }
|
||||||
|
/**染机呼叫状态**/
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (Convert.ToBoolean(MachinesRow["CALL"]))
|
||||||
|
{
|
||||||
|
if (Convert.ToBoolean(MachinesRow["Type"]))
|
||||||
|
{//网络
|
||||||
|
stringQueue.Enqueue(new QueueString
|
||||||
|
{
|
||||||
|
ID = Convert.ToInt16(MachinesRow["ID"]),
|
||||||
|
DAT = "SC827" + MachinesRow["SYSKEY"]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{//串口
|
||||||
|
if (MachinesRow["Serial"].ToString() == "PORT1")
|
||||||
|
{
|
||||||
|
stringQueueSerial_1.Enqueue(new QueueSerial
|
||||||
|
{
|
||||||
|
ID = Convert.ToInt16(MachinesRow["ID"]),
|
||||||
|
DAT = "SC827[" + MachinesRow["Station"] + "]"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else if (MachinesRow["Serial"].ToString() == "PORT2")
|
||||||
|
{
|
||||||
|
stringQueueSerial_2.Enqueue(new QueueSerial
|
||||||
|
{
|
||||||
|
ID = Convert.ToInt16(MachinesRow["ID"]),
|
||||||
|
DAT = "SC827[" + MachinesRow["Station"] + "]"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else if (MachinesRow["Serial"].ToString() == "PORT3")
|
||||||
|
{
|
||||||
|
stringQueueSerial_3.Enqueue(new QueueSerial
|
||||||
|
{
|
||||||
|
ID = Convert.ToInt16(MachinesRow["ID"]),
|
||||||
|
DAT = "SC827[" + MachinesRow["Station"] + "]"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else if (MachinesRow["Serial"].ToString() == "PORT4")
|
||||||
|
{
|
||||||
|
stringQueueSerial_4.Enqueue(new QueueSerial
|
||||||
|
{
|
||||||
|
ID = Convert.ToInt16(MachinesRow["ID"]),
|
||||||
|
DAT = "SC827[" + MachinesRow["Station"] + "]"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception EX) { LogGing.ERRDATA(EX); }
|
||||||
|
/**染机呼叫完成**/
|
||||||
try
|
try
|
||||||
{//301列表发送完成至染机(203=>301)
|
{//301列表发送完成至染机(203=>301)
|
||||||
foreach (DataRow row in Dyelot_CALL.Select("State='301' OR State='309'"))
|
foreach (DataRow row in Dyelot_CALL.Select("State='301' OR State='309'"))
|
||||||
@@ -1035,9 +1240,12 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
|||||||
catch (Exception EX) { LogGing.ERRDATA(EX); }
|
catch (Exception EX) { LogGing.ERRDATA(EX); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
void Tick_Event_30S()
|
void Tick_Event_30S()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
{
|
||||||
|
lock (MainWindowViewModel.Machines.Rows.SyncRoot)
|
||||||
{
|
{
|
||||||
/*曲线图*/
|
/*曲线图*/
|
||||||
for (int i = 0; i < Machines.Rows.Count; i++)//曲线图
|
for (int i = 0; i < Machines.Rows.Count; i++)//曲线图
|
||||||
@@ -1053,6 +1261,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
catch (Exception EX) { LogGing.ERRDATA(EX); }
|
catch (Exception EX) { LogGing.ERRDATA(EX); }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1060,6 +1269,8 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
|||||||
public static SerialPortClient[] MachiensPortClient = new SerialPortClient[4];
|
public static SerialPortClient[] MachiensPortClient = new SerialPortClient[4];
|
||||||
//public static DataRow[] machinesdata = new DataRow[999];
|
//public static DataRow[] machinesdata = new DataRow[999];
|
||||||
public void ClientNEW()
|
public void ClientNEW()
|
||||||
|
{
|
||||||
|
lock (MainWindowViewModel.Machines.Rows.SyncRoot)
|
||||||
{
|
{
|
||||||
foreach (DataRow dataRow in Machines.Rows)
|
foreach (DataRow dataRow in Machines.Rows)
|
||||||
{
|
{
|
||||||
@@ -1077,7 +1288,10 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
|||||||
dataRow.AcceptChanges();
|
dataRow.AcceptChanges();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
public void TcpClientNEW()
|
public void TcpClientNEW()
|
||||||
|
{
|
||||||
|
lock (MainWindowViewModel.Machines.Rows.SyncRoot)
|
||||||
{
|
{
|
||||||
foreach (DataRow dataRow in Machines.Rows)
|
foreach (DataRow dataRow in Machines.Rows)
|
||||||
{
|
{
|
||||||
@@ -1089,6 +1303,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
public async void PortClientNEW()
|
public async void PortClientNEW()
|
||||||
{
|
{
|
||||||
if (Machines.Select("Type='false' AND Serial='PORT1'").Length > 0)
|
if (Machines.Select("Type='false' AND Serial='PORT1'").Length > 0)
|
||||||
@@ -1162,6 +1377,8 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
lock (MainWindowViewModel.Machines.Rows.SyncRoot)
|
||||||
{
|
{
|
||||||
foreach (DataRow MachinesRow in Machines.Select("Type='false' AND Serial='PORT1'"))
|
foreach (DataRow MachinesRow in Machines.Select("Type='false' AND Serial='PORT1'"))
|
||||||
{
|
{
|
||||||
@@ -1180,6 +1397,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -1211,6 +1429,8 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
lock (MainWindowViewModel.Machines.Rows.SyncRoot)
|
||||||
{
|
{
|
||||||
foreach (DataRow MachinesRow in Machines.Select("Type='false' AND Serial='PORT2'"))
|
foreach (DataRow MachinesRow in Machines.Select("Type='false' AND Serial='PORT2'"))
|
||||||
{
|
{
|
||||||
@@ -1229,6 +1449,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -1260,6 +1481,8 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
lock (MainWindowViewModel.Machines.Rows.SyncRoot)
|
||||||
{
|
{
|
||||||
foreach (DataRow MachinesRow in Machines.Select("Type='false' AND Serial='PORT3'"))
|
foreach (DataRow MachinesRow in Machines.Select("Type='false' AND Serial='PORT3'"))
|
||||||
{
|
{
|
||||||
@@ -1278,6 +1501,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -1309,6 +1533,8 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
lock (MainWindowViewModel.Machines.Rows.SyncRoot)
|
||||||
{
|
{
|
||||||
foreach (DataRow MachinesRow in Machines.Select("Type='false' AND Serial='PORT4'"))
|
foreach (DataRow MachinesRow in Machines.Select("Type='false' AND Serial='PORT4'"))
|
||||||
{
|
{
|
||||||
@@ -1327,6 +1553,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using SunlightCentralizedControlManagement_SCCM_.ViewModel;
|
using ScottPlot.TickGenerators.TimeUnits;
|
||||||
|
using SunlightCentralizedControlManagement_SCCM_.ViewModel;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
@@ -22,6 +23,7 @@ using System.Windows.Threading;
|
|||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
using TouchSocket.Core;
|
using TouchSocket.Core;
|
||||||
using static SunlightCentralizedControlManagement_SCCM_.UserClass.SqliteHelper;
|
using static SunlightCentralizedControlManagement_SCCM_.UserClass.SqliteHelper;
|
||||||
|
using static SunlightCentralizedControlManagement_SCCM_.ViewModel.MainWindowViewModel;
|
||||||
|
|
||||||
namespace SunlightCentralizedControlManagement_SCCM_.WindowsView
|
namespace SunlightCentralizedControlManagement_SCCM_.WindowsView
|
||||||
{
|
{
|
||||||
@@ -51,11 +53,70 @@ namespace SunlightCentralizedControlManagement_SCCM_.WindowsView
|
|||||||
dat_821.Add("WorkOrder", WorkOrder_);
|
dat_821.Add("WorkOrder", WorkOrder_);
|
||||||
DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine_ + "'").First();
|
DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine_ + "'").First();
|
||||||
int index = Convert.ToInt16(drEmployee.Field<object>("ID"));
|
int index = Convert.ToInt16(drEmployee.Field<object>("ID"));
|
||||||
|
string dat = "SC821" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, "SYSKEY", "ID='" + index + "'") + dat_821.ToJsonString();
|
||||||
|
|
||||||
|
lock (MainWindowViewModel.Machines.Rows.SyncRoot)
|
||||||
|
{
|
||||||
|
if (drEmployee.Field<bool>("Type"))
|
||||||
|
{//网络
|
||||||
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
|
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
|
||||||
{
|
{
|
||||||
ID = index,
|
ID = index,
|
||||||
DAT = "SC821" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, "SYSKEY", "ID='" + index + "'") + dat_821.ToJsonString()
|
DAT = dat
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{//串口
|
||||||
|
if (drEmployee.Field<string>("Serial") == "PORT1")
|
||||||
|
{
|
||||||
|
bool exists = stringQueueSerial_1.Any(item => item.ID == index && item.DAT == dat);
|
||||||
|
if (!exists)
|
||||||
|
{
|
||||||
|
stringQueueSerial_1.Enqueue(new QueueSerial
|
||||||
|
{
|
||||||
|
ID = index,
|
||||||
|
DAT = dat
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (drEmployee.Field<string>("Serial") == "PORT2")
|
||||||
|
{
|
||||||
|
bool exists = stringQueueSerial_2.Any(item => item.ID == index && item.DAT == dat);
|
||||||
|
if (!exists)
|
||||||
|
{
|
||||||
|
stringQueueSerial_2.Enqueue(new QueueSerial
|
||||||
|
{
|
||||||
|
ID = index,
|
||||||
|
DAT = dat
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (drEmployee.Field<string>("Serial") == "PORT3")
|
||||||
|
{
|
||||||
|
bool exists = stringQueueSerial_3.Any(item => item.ID == index && item.DAT == dat);
|
||||||
|
if (!exists)
|
||||||
|
{
|
||||||
|
stringQueueSerial_3.Enqueue(new QueueSerial
|
||||||
|
{
|
||||||
|
ID = index,
|
||||||
|
DAT = dat
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (drEmployee.Field<string>("Serial") == "PORT4")
|
||||||
|
{
|
||||||
|
bool exists = stringQueueSerial_4.Any(item => item.ID == index && item.DAT == dat);
|
||||||
|
if (!exists)
|
||||||
|
{
|
||||||
|
stringQueueSerial_4.Enqueue(new QueueSerial
|
||||||
|
{
|
||||||
|
ID = index,
|
||||||
|
DAT = dat
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this.Close();
|
this.Close();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user