|
|
@ -16,8 +16,10 @@ using System.Data; |
|
|
|
using System.Data.Entity.Core.Common.CommandTrees.ExpressionBuilder; |
|
|
|
using System.Data.SqlClient; |
|
|
|
using System.Diagnostics.Eventing.Reader; |
|
|
|
using System.IO.Ports; |
|
|
|
using System.Linq; |
|
|
|
using System.Reflection; |
|
|
|
using System.Security.Cryptography; |
|
|
|
using System.Speech.Synthesis; |
|
|
|
using System.Text; |
|
|
|
using System.Threading; |
|
|
@ -84,6 +86,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel |
|
|
|
public static DataTable Whole_dat = new DataTable(); |
|
|
|
public static UserControls.info[] inf = new UserControls.info[999]; //定义总览信息卡
|
|
|
|
public static int ERR_c = 0;//错误计数器
|
|
|
|
public bool UPort1, UPort2, UPort3; |
|
|
|
public static bool[] USER_Capacity { set; get; } = new bool[99]; |
|
|
|
|
|
|
|
public MainWindowViewModel() |
|
|
@ -113,6 +116,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel |
|
|
|
Whole_dat.Columns.Add("DAT", Type.GetType("System.Double")); |
|
|
|
|
|
|
|
USERCapacity(App.USER_Purview);//App.USER_Purview);
|
|
|
|
UPort();//启动串口
|
|
|
|
CountDown(); |
|
|
|
TcpClientNEW(); |
|
|
|
SQL_LINK(); |
|
|
@ -142,7 +146,114 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static SerialPort port1 = new SerialPort();//创建串口
|
|
|
|
public static SerialPort port2 = new SerialPort();//创建串口
|
|
|
|
public static SerialPort port3 = new SerialPort();//创建串口
|
|
|
|
void UPort() |
|
|
|
{ |
|
|
|
try |
|
|
|
{ |
|
|
|
int Ba = 9600; |
|
|
|
try { Ba = Convert.ToInt32(Configini.IniReadvalue("SYS", "BAUD1")); } |
|
|
|
catch (Exception) { Ba = 9600; } |
|
|
|
port1.PortName = Configini.IniReadvalue("SYS", "COMP1"); |
|
|
|
port1.BaudRate = Ba;//配置
|
|
|
|
port1.DataBits = 8; |
|
|
|
port1.Parity = Parity.Even; |
|
|
|
port1.StopBits = StopBits.One; |
|
|
|
port1.ReadTimeout = 500; |
|
|
|
port1.WriteTimeout = 500; |
|
|
|
port1.Open();//打开串口
|
|
|
|
UPort1 = true; |
|
|
|
} |
|
|
|
catch (Exception e) |
|
|
|
{ |
|
|
|
UPort1 = false; |
|
|
|
LogGing.LogGingDATA(e.Message); |
|
|
|
} |
|
|
|
try |
|
|
|
{ |
|
|
|
int Ba2 = 9600; |
|
|
|
try { Ba2 = Convert.ToInt32(Configini.IniReadvalue("SYS", "BAUD1")); } |
|
|
|
catch (Exception) { Ba2 = 9600; } |
|
|
|
port2.PortName = Configini.IniReadvalue("SYS", "COMP2"); |
|
|
|
port2.BaudRate = Ba2;//配置
|
|
|
|
port2.DataBits = 8; |
|
|
|
port2.Parity = Parity.Even; |
|
|
|
port2.StopBits = StopBits.One; |
|
|
|
port2.ReadTimeout = 500; |
|
|
|
port2.WriteTimeout = 500; |
|
|
|
port2.Open();//打开串口
|
|
|
|
UPort2 = true; |
|
|
|
} |
|
|
|
catch (Exception e) |
|
|
|
{ |
|
|
|
UPort2 = false; |
|
|
|
LogGing.LogGingDATA(e.Message); |
|
|
|
} |
|
|
|
try |
|
|
|
{ |
|
|
|
int Ba3 = 9600; |
|
|
|
try { Ba3 = Convert.ToInt32(Configini.IniReadvalue("SYS", "BAUD1")); } |
|
|
|
catch (Exception) { Ba3 = 9600; } |
|
|
|
port3.PortName = Configini.IniReadvalue("SYS", "COMP3"); |
|
|
|
port3.BaudRate = Ba3;//配置
|
|
|
|
port3.DataBits = 8; |
|
|
|
port3.Parity = Parity.Even; |
|
|
|
port3.StopBits = StopBits.One; |
|
|
|
port3.ReadTimeout = 500; |
|
|
|
port3.WriteTimeout = 500; |
|
|
|
port3.Open();//打开串口
|
|
|
|
UPort3 = true; |
|
|
|
} |
|
|
|
catch (Exception e) |
|
|
|
{ |
|
|
|
UPort3 = false; |
|
|
|
LogGing.LogGingDATA(e.Message); |
|
|
|
} |
|
|
|
}//ck
|
|
|
|
private async void Port_link() |
|
|
|
{ |
|
|
|
await Task.Run(() => |
|
|
|
{ |
|
|
|
try |
|
|
|
{ |
|
|
|
if (stringQueueSerial.Count > 0) //信息发送队列
|
|
|
|
{ |
|
|
|
QueueSerial t = stringQueueSerial.Dequeue(); |
|
|
|
if (t.ID == "PORT1") |
|
|
|
{ |
|
|
|
if (UPort1) |
|
|
|
{ |
|
|
|
port1.Write(t.DAT); |
|
|
|
} |
|
|
|
} |
|
|
|
else if (t.ID == "PORT2") |
|
|
|
{ |
|
|
|
if (UPort2) |
|
|
|
{ |
|
|
|
port2.Write(t.DAT); |
|
|
|
} |
|
|
|
} |
|
|
|
else if (t.ID == "PORT3") |
|
|
|
{ |
|
|
|
if (UPort3) |
|
|
|
{ |
|
|
|
port3.Write(t.DAT); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
catch (Exception ex) |
|
|
|
{ |
|
|
|
} |
|
|
|
finally |
|
|
|
{ |
|
|
|
Port_link(); |
|
|
|
} |
|
|
|
}); |
|
|
|
}//发送
|
|
|
|
public async void SQL_LINK()//连接dbc数据库
|
|
|
|
{ |
|
|
|
if (conn_SC.State == ConnectionState.Open) conn_SC.Close(); |
|
|
@ -215,54 +326,80 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel |
|
|
|
"AND EndTime >'" + DateTime.Now.AddHours(-8).ToString("yyyy/MM/dd HH:mm:ss") + "'", null).Tables[0]; //读取表写入缓存
|
|
|
|
for (int k = 0; k < WorkOrderstepdata.Rows.Count; k++) |
|
|
|
{ |
|
|
|
string WorkOrderdata_m = WorkOrderstepdata.Select()[k].Field<object>("Machines").ToString(); |
|
|
|
DataTable dataTable = WorkOrderSQL.ExecuteDataSet("select * from WorkorderSteps where WorkOrder='" + |
|
|
|
WorkOrderstepdata.Select()[k].Field<object>("WorkOrder").ToString() + "'", null).Tables[0]; |
|
|
|
int index = Convert.ToInt16(Selet_Machines(Machines, "ID", "Name='" + WorkOrderdata_m + "'").ToString()); |
|
|
|
stringQueue.Enqueue(new QueueString |
|
|
|
if (Selet_Machines(Machines, "Type", "ID='" + k + "'").ToString() == "838") |
|
|
|
{ |
|
|
|
ID = index, |
|
|
|
DAT = "SC811" + Selet_Machines(Machines, "SYSKEY", "ID='" + index + "'") + dataTable.ToJsonString() |
|
|
|
}); |
|
|
|
WorkOrderSQL.Update("WorkOrder", new Dictionary<string, object> { { "State", 112 } }, |
|
|
|
"WorkOrder ='" + WorkOrderstepdata.Select()[k].Field<object>("WorkOrder").ToString() + "'", null); |
|
|
|
string WorkOrderdata_m = WorkOrderstepdata.Select()[k].Field<object>("Machines").ToString(); |
|
|
|
DataTable dataTable = WorkOrderSQL.ExecuteDataSet("select * from WorkorderSteps where WorkOrder='" + |
|
|
|
WorkOrderstepdata.Select()[k].Field<object>("WorkOrder").ToString() + "'", null).Tables[0]; |
|
|
|
int index = Convert.ToInt16(Selet_Machines(Machines, "ID", "Name='" + WorkOrderdata_m + "'").ToString()); |
|
|
|
stringQueue.Enqueue(new QueueString |
|
|
|
{ |
|
|
|
ID = index, |
|
|
|
DAT = "SC811" + Selet_Machines(Machines, "SYSKEY", "ID='" + index + "'") + dataTable.ToJsonString() |
|
|
|
}); |
|
|
|
WorkOrderSQL.Update("WorkOrder", new Dictionary<string, object> { { "State", 112 } }, |
|
|
|
"WorkOrder ='" + WorkOrderstepdata.Select()[k].Field<object>("WorkOrder").ToString() + "'", null); |
|
|
|
} |
|
|
|
else if (Selet_Machines(Machines, "Type", "ID='" + k + "'").ToString() == "828") |
|
|
|
{ |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
/*下传工单总览*/ |
|
|
|
DataTable WorkOrderdata = WorkOrderSQL.ExecuteDataSet("select * from WorkOrder where State='100' or State='110'" + |
|
|
|
"AND EndTime >'" + DateTime.Now.AddHours(-8).ToString("yyyy/MM/dd HH:mm:ss") + "'", null).Tables[0]; //读取表写入缓存
|
|
|
|
for (int k = 0; k < WorkOrderdata.Rows.Count; k++) |
|
|
|
{ |
|
|
|
string WorkOrderdata_m = WorkOrderdata.Select()[k].Field<object>("Machines").ToString(); |
|
|
|
string State = Selet_Machines(Machines, "State", "Name='" + WorkOrderdata_m + "'").ToString(); |
|
|
|
|
|
|
|
if ((State == "101") || (State == "201") || (State == "202") || (State == "309")) |
|
|
|
if (Selet_Machines(Machines, "Type", "ID='" + k + "'").ToString() == "838") |
|
|
|
{ |
|
|
|
DataTable dataTable = WorkOrderdata.Clone(); |
|
|
|
// WorkOrderdata.Columns.Remove("Machines");
|
|
|
|
DataRow dt_temp = WorkOrderdata.Select()[k]; |
|
|
|
dt_temp.BeginEdit(); |
|
|
|
dt_temp["State"] = "101"; |
|
|
|
dt_temp.EndEdit(); |
|
|
|
dataTable.Rows.Add(dt_temp.ItemArray); |
|
|
|
string WorkOrderdata_m = WorkOrderdata.Select()[k].Field<object>("Machines").ToString(); |
|
|
|
string State = Selet_Machines(Machines, "State", "Name='" + WorkOrderdata_m + "'").ToString(); |
|
|
|
|
|
|
|
int index = Convert.ToInt16(Selet_Machines(Machines, "ID", "Name='" + WorkOrderdata_m + "'").ToString()); |
|
|
|
stringQueue.Enqueue(new QueueString |
|
|
|
if ((State == "101") || (State == "201") || (State == "202") || (State == "309")) |
|
|
|
{ |
|
|
|
ID = index, |
|
|
|
DAT = "SC810" + Selet_Machines(Machines, "SYSKEY", "ID='" + index + "'") + DataTableToDictionary(dataTable).ToJsonString() |
|
|
|
}); |
|
|
|
DataTable WorkOrderset = WorkOrderSQL.ExecuteDataSet("select * from WorkOrderSet where WorkOrder='" + |
|
|
|
dt_temp["WorkOrder"] + "'", null).Tables[0]; //读取表写入缓存
|
|
|
|
if (WorkOrderset.Rows.Count > 0) { |
|
|
|
DataTable dataTable = WorkOrderdata.Clone(); |
|
|
|
// WorkOrderdata.Columns.Remove("Machines");
|
|
|
|
DataRow dt_temp = WorkOrderdata.Select()[k]; |
|
|
|
dt_temp.BeginEdit(); |
|
|
|
dt_temp["State"] = "101"; |
|
|
|
dt_temp.EndEdit(); |
|
|
|
dataTable.Rows.Add(dt_temp.ItemArray); |
|
|
|
|
|
|
|
int index = Convert.ToInt16(Selet_Machines(Machines, "ID", "Name='" + WorkOrderdata_m + "'").ToString()); |
|
|
|
stringQueue.Enqueue(new QueueString |
|
|
|
{ |
|
|
|
ID = index, |
|
|
|
DAT = "SC812" + Selet_Machines(Machines, "SYSKEY", "ID='" + index + "'") + DataTableToDictionary(WorkOrderset).ToJsonString() |
|
|
|
}); |
|
|
|
} |
|
|
|
DAT = "SC810" + Selet_Machines(Machines, "SYSKEY", "ID='" + index + "'") + DataTableToDictionary(dataTable).ToJsonString() |
|
|
|
}); |
|
|
|
WorkOrderSQL.Update("WorkOrder", new Dictionary<string, object> { { "State", 110 } }, |
|
|
|
"WorkOrder ='" + WorkOrderdata.Select()[k].Field<object>("WorkOrder").ToString() + "'", null); |
|
|
|
} |
|
|
|
} |
|
|
|
else if (Selet_Machines(Machines, "Type", "ID='" + k + "'").ToString() == "828") |
|
|
|
{ |
|
|
|
string WorkOrderdata_m = WorkOrderdata.Select()[k].Field<object>("Machines").ToString(); |
|
|
|
string State = Selet_Machines(Machines, "State", "Name='" + WorkOrderdata_m + "'").ToString(); |
|
|
|
string POR = Selet_Machines(Machines, "Serial", "ID='" + k + "'").ToString(); |
|
|
|
|
|
|
|
WorkOrderSQL.Update("WorkOrder", new Dictionary<string, object> { { "State", 110 } }, |
|
|
|
"WorkOrder ='" + WorkOrderdata.Select()[k].Field<object>("WorkOrder").ToString() + "'", null); |
|
|
|
if ((State == "101") || (State == "201") || (State == "202") || (State == "309")) |
|
|
|
{ |
|
|
|
DataTable dataTable = WorkOrderdata.Clone(); |
|
|
|
// WorkOrderdata.Columns.Remove("Machines");
|
|
|
|
DataRow dt_temp = WorkOrderdata.Select()[k]; |
|
|
|
dt_temp.BeginEdit(); |
|
|
|
dt_temp["State"] = "101"; |
|
|
|
dt_temp.EndEdit(); |
|
|
|
dataTable.Rows.Add(dt_temp.ItemArray); |
|
|
|
|
|
|
|
int index = Convert.ToInt16(Selet_Machines(Machines, "ID", "Name='" + WorkOrderdata_m + "'").ToString()); |
|
|
|
stringQueueSerial.Enqueue(new QueueSerial |
|
|
|
{ |
|
|
|
ID = POR, |
|
|
|
DAT = "SC810" + Selet_Machines(Machines, "SYSKEY", "ID='" + index + "'") + DataTableToDictionary(dataTable).ToJsonString() |
|
|
|
}); |
|
|
|
WorkOrderSQL.Update("WorkOrder", new Dictionary<string, object> { { "State", 110 } }, |
|
|
|
"WorkOrder ='" + WorkOrderdata.Select()[k].Field<object>("WorkOrder").ToString() + "'", null); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
/*下传工单设置*/ |
|
|
@ -270,23 +407,48 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel |
|
|
|
"AND EndTime >'" + DateTime.Now.AddHours(-8).ToString("yyyy/MM/dd HH:mm:ss") + "'", null).Tables[0]; //读取表写入缓存
|
|
|
|
for (int k = 0; k < WorkOrderset_.Rows.Count; k++) |
|
|
|
{ |
|
|
|
string WorkOrderset_m = WorkOrderset_.Select()[k].Field<object>("Machines").ToString(); |
|
|
|
string WorkOrderset_w = WorkOrderset_.Select()[k].Field<object>("WorkOrder").ToString(); |
|
|
|
int index = Convert.ToInt16(Selet_Machines(Machines, "ID", "Name='" + WorkOrderset_m + "'").ToString()); |
|
|
|
|
|
|
|
DataTable WorkOrder_set = WorkOrderSQL.ExecuteDataSet("select * from WorkOrderSet where WorkOrder='" + |
|
|
|
WorkOrderset_w + "'", null).Tables[0]; //读取表写入缓存
|
|
|
|
if (WorkOrder_set.Rows.Count > 0) |
|
|
|
if (Selet_Machines(Machines, "Type", "ID='" + k + "'").ToString() == "838") |
|
|
|
{ |
|
|
|
stringQueue.Enqueue(new QueueString |
|
|
|
string WorkOrderset_m = WorkOrderset_.Select()[k].Field<object>("Machines").ToString(); |
|
|
|
string WorkOrderset_w = WorkOrderset_.Select()[k].Field<object>("WorkOrder").ToString(); |
|
|
|
int index = Convert.ToInt16(Selet_Machines(Machines, "ID", "Name='" + WorkOrderset_m + "'").ToString()); |
|
|
|
|
|
|
|
DataTable WorkOrder_set = WorkOrderSQL.ExecuteDataSet("select * from WorkOrderSet where WorkOrder='" + |
|
|
|
WorkOrderset_w + "'", null).Tables[0]; //读取表写入缓存
|
|
|
|
if (WorkOrder_set.Rows.Count > 0) |
|
|
|
{ |
|
|
|
ID = index, |
|
|
|
DAT = "SC812" + Selet_Machines(Machines, "SYSKEY", "ID='" + index + "'") + DataTableToDictionary(WorkOrder_set).ToJsonString() |
|
|
|
}); |
|
|
|
stringQueue.Enqueue(new QueueString |
|
|
|
{ |
|
|
|
ID = index, |
|
|
|
DAT = "SC812" + Selet_Machines(Machines, "SYSKEY", "ID='" + index + "'") + DataTableToDictionary(WorkOrder_set).ToJsonString() |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
WorkOrderSQL.Update("WorkOrder", new Dictionary<string, object> { { "State", 110 } }, |
|
|
|
"WorkOrder ='" + WorkOrderdata.Select()[k].Field<object>("WorkOrder").ToString() + "'", null); |
|
|
|
} |
|
|
|
else if (Selet_Machines(Machines, "Type", "ID='" + k + "'").ToString() == "828") |
|
|
|
{ |
|
|
|
string WorkOrderset_m = WorkOrderset_.Select()[k].Field<object>("Machines").ToString(); |
|
|
|
string WorkOrderset_w = WorkOrderset_.Select()[k].Field<object>("WorkOrder").ToString(); |
|
|
|
string POR = Selet_Machines(Machines, "Serial", "ID='" + k + "'").ToString(); |
|
|
|
|
|
|
|
WorkOrderSQL.Update("WorkOrder", new Dictionary<string, object> { { "State", 110 } }, |
|
|
|
"WorkOrder ='" + WorkOrderdata.Select()[k].Field<object>("WorkOrder").ToString() + "'", null); |
|
|
|
DataTable WorkOrder_set = WorkOrderSQL.ExecuteDataSet("select * from WorkOrderSet where WorkOrder='" + |
|
|
|
WorkOrderset_w + "'", null).Tables[0]; //读取表写入缓存
|
|
|
|
if (WorkOrder_set.Rows.Count > 0) |
|
|
|
{ |
|
|
|
stringQueueSerial.Enqueue(new QueueSerial |
|
|
|
{ |
|
|
|
ID = POR, |
|
|
|
DAT = "SC812[" + |
|
|
|
Selet_Machines(Machines, "Station", "ID='" + k + "'") + "]" + |
|
|
|
DataTableToDictionary(WorkOrder_set).ToJsonString() |
|
|
|
}); |
|
|
|
} |
|
|
|
WorkOrderSQL.Update("WorkOrder", new Dictionary<string, object> { { "State", 110 } }, |
|
|
|
"WorkOrder ='" + WorkOrderdata.Select()[k].Field<object>("WorkOrder").ToString() + "'", null); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
WorkOrderSQL.Close(); |
|
|
|
|
|
|
@ -295,61 +457,129 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel |
|
|
|
//更新机台状态与发送指令
|
|
|
|
for (int i = 0; i < Machinesdata_Count; i++) |
|
|
|
{ |
|
|
|
if (Selet_Machines(Machines, "State", "ID='" + i + "'").ToString() == "802") |
|
|
|
if (Selet_Machines(Machines, "Type", "ID='" + i + "'").ToString() == "838") |
|
|
|
{ |
|
|
|
stringQueue.Enqueue(new QueueString |
|
|
|
{ |
|
|
|
ID = i, |
|
|
|
DAT = "SC830" + Selet_Machines(Machines, "SYSKEY", "ID='" + i + "'").ToString() |
|
|
|
});//信息插入队列
|
|
|
|
|
|
|
|
bool mode = Machines.Select("ID='" + i + "'").First().Field<bool>("LOCK");//发送锁定状态
|
|
|
|
if (mode) |
|
|
|
if (Selet_Machines(Machines, "State", "ID='" + i + "'").ToString() == "802") |
|
|
|
{ |
|
|
|
Dictionary<string, object> dat_829 = new Dictionary<string, object>(); |
|
|
|
dat_829.Clear(); |
|
|
|
dat_829.Add("NAME", "LOCK"); |
|
|
|
dat_829.Add("VALUE", "True"); |
|
|
|
DataRow drEmployee = Machines.Select("ID='" + i + "'").First(); |
|
|
|
int index = Convert.ToInt16(drEmployee.Field<object>("ID")); |
|
|
|
stringQueue.Enqueue(new QueueString |
|
|
|
{ |
|
|
|
ID = index, |
|
|
|
DAT = "SC829" + Selet_Machines(Machines, "SYSKEY", "ID='" + index + "'") + dat_829.ToJsonString() |
|
|
|
}); |
|
|
|
ID = i, |
|
|
|
DAT = "SC830" + Selet_Machines(Machines, "SYSKEY", "ID='" + i + "'").ToString() |
|
|
|
});//信息插入队列
|
|
|
|
|
|
|
|
bool mode = Machines.Select("ID='" + i + "'").First().Field<bool>("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"); |
|
|
|
DataRow drEmployee = Machines.Select("ID='" + i + "'").First(); |
|
|
|
int index = Convert.ToInt16(drEmployee.Field<object>("ID")); |
|
|
|
stringQueue.Enqueue(new QueueString |
|
|
|
{ |
|
|
|
ID = index, |
|
|
|
DAT = "SC829" + Selet_Machines(Machines, "SYSKEY", "ID='" + index + "'") + dat_829.ToJsonString() |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
Updata_Machines(Machines, "State", "ID='" + i + "'", "101"); |
|
|
|
} |
|
|
|
int m_run = (int)Selet_Machines(Machines, "WORK_RUN", "ID='" + i + "'"); |
|
|
|
if (m_run == 0) |
|
|
|
{ |
|
|
|
Updata_Machines(Machines, "State", "ID='" + i + "'", "101");//停止状态
|
|
|
|
} |
|
|
|
else if (m_run == 1) |
|
|
|
{ |
|
|
|
Updata_Machines(Machines, "State", "ID='" + i + "'", "101");//暂停状态
|
|
|
|
} |
|
|
|
else if (m_run == 2) |
|
|
|
{ |
|
|
|
Updata_Machines(Machines, "State", "ID='" + i + "'", "202");//运行
|
|
|
|
} |
|
|
|
|
|
|
|
Updata_Machines(Machines, "State", "ID='" + i + "'", "101"); |
|
|
|
} |
|
|
|
int m_run = (int)Selet_Machines(Machines, "WORK_RUN", "ID='" + i + "'"); |
|
|
|
if (m_run==0) |
|
|
|
{ |
|
|
|
Updata_Machines(Machines, "State", "ID='" + i + "'", "101");//停止状态
|
|
|
|
if ((bool)Selet_Machines(Machines, "ERR", "ID='" + i + "'")) |
|
|
|
{ |
|
|
|
Updata_Machines(Machines, "State", "ID='" + i + "'", "309");//错误
|
|
|
|
} |
|
|
|
|
|
|
|
string mac_s = Selet_Machines(Machines, "State", "ID='" + i + "'").ToString(); |
|
|
|
if ((mac_s == "101") || (mac_s == "201") || (mac_s == "202") || (mac_s == "301") || (mac_s == "309"))//获取信息
|
|
|
|
{ |
|
|
|
stringQueueinf.Enqueue(new QueueString |
|
|
|
{ |
|
|
|
ID = i, |
|
|
|
DAT = "SC830" + Selet_Machines(Machines, "SYSKEY", "ID='" + i + "'").ToString() |
|
|
|
});//信息插入队列
|
|
|
|
} |
|
|
|
} |
|
|
|
else if (m_run==1) |
|
|
|
{ |
|
|
|
Updata_Machines(Machines, "State", "ID='" + i + "'", "101");//暂停状态
|
|
|
|
} |
|
|
|
else if (m_run==2) |
|
|
|
else if (Selet_Machines(Machines, "Type", "ID='" + i + "'").ToString() == "828") |
|
|
|
{ |
|
|
|
Updata_Machines(Machines, "State", "ID='" + i + "'", "202");//运行
|
|
|
|
} |
|
|
|
if (Selet_Machines(Machines, "State", "ID='" + i + "'").ToString() == "800") |
|
|
|
{//串口发送
|
|
|
|
string POR = Selet_Machines(Machines, "Serial", "ID='" + i + "'").ToString(); |
|
|
|
|
|
|
|
if ((bool)Selet_Machines(Machines, "ERR", "ID='" + i + "'")) |
|
|
|
{ |
|
|
|
Updata_Machines(Machines, "State", "ID='" + i + "'", "309");//错误
|
|
|
|
} |
|
|
|
stringQueueSerial.Enqueue(new QueueSerial |
|
|
|
{ |
|
|
|
ID = POR, |
|
|
|
DAT = "SC830[" + |
|
|
|
Selet_Machines(Machines, "Station", "ID='" + i + "'") + "]" |
|
|
|
}); |
|
|
|
|
|
|
|
string mac_s = Selet_Machines(Machines, "State", "ID='" + i + "'").ToString(); |
|
|
|
if ((mac_s == "101") || (mac_s == "201") || (mac_s == "202") || (mac_s == "301") || (mac_s == "309"))//获取信息
|
|
|
|
{ |
|
|
|
stringQueueinf.Enqueue(new QueueString |
|
|
|
bool mode = Machines.Select("ID='" + i + "'").First().Field<bool>("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"); |
|
|
|
DataRow drEmployee = Machines.Select("ID='" + i + "'").First(); |
|
|
|
stringQueueSerial.Enqueue(new QueueSerial |
|
|
|
{ |
|
|
|
ID = POR, |
|
|
|
DAT = "SC829[" + |
|
|
|
Selet_Machines(Machines, "Station", "ID='" + i + "'") + "]" + |
|
|
|
dat_829.ToJsonString() |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
Updata_Machines(Machines, "State", "ID='" + i + "'", "101"); |
|
|
|
} |
|
|
|
|
|
|
|
int m_run = (int)Selet_Machines(Machines, "WORK_RUN", "ID='" + i + "'"); |
|
|
|
if (m_run == 0) |
|
|
|
{ |
|
|
|
ID = i, |
|
|
|
DAT = "SC830" + Selet_Machines(Machines, "SYSKEY", "ID='" + i + "'").ToString() |
|
|
|
});//信息插入队列
|
|
|
|
Updata_Machines(Machines, "State", "ID='" + i + "'", "101");//停止状态
|
|
|
|
} |
|
|
|
else if (m_run == 1) |
|
|
|
{ |
|
|
|
Updata_Machines(Machines, "State", "ID='" + i + "'", "101");//暂停状态
|
|
|
|
} |
|
|
|
else if (m_run == 2) |
|
|
|
{ |
|
|
|
Updata_Machines(Machines, "State", "ID='" + i + "'", "202");//运行
|
|
|
|
} |
|
|
|
|
|
|
|
if ((bool)Selet_Machines(Machines, "ERR", "ID='" + i + "'")) |
|
|
|
{ |
|
|
|
Updata_Machines(Machines, "State", "ID='" + i + "'", "309");//错误
|
|
|
|
} |
|
|
|
|
|
|
|
string mac_s = Selet_Machines(Machines, "State", "ID='" + i + "'").ToString(); |
|
|
|
if ((mac_s == "101") || (mac_s == "201") || (mac_s == "202") || (mac_s == "301") || (mac_s == "309"))//获取信息
|
|
|
|
{ |
|
|
|
string POR = Selet_Machines(Machines, "Serial", "ID='" + i + "'").ToString(); |
|
|
|
stringQueueSerial.Enqueue(new QueueSerial |
|
|
|
{ |
|
|
|
ID = POR, |
|
|
|
DAT = "SC830[" + |
|
|
|
Selet_Machines(Machines, "Station", "ID='" + i + "'") + "]" |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (Time5 > 5) |
|
|
|
{ |
|
|
|
Tick_Event_5S(); |
|
|
@ -400,11 +630,25 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel |
|
|
|
{ |
|
|
|
if ((bool)Selet_Machines(Machines, "CALL", "ID='" + i + "'")) |
|
|
|
{ |
|
|
|
stringQueue.Enqueue(new QueueString |
|
|
|
if (Selet_Machines(Machines, "Type", "ID='" + i + "'").ToString() == "828") |
|
|
|
{ |
|
|
|
ID = i, |
|
|
|
DAT = "SC827" + Selet_Machines(Machines, "SYSKEY", "ID='" + i + "'") |
|
|
|
}); |
|
|
|
string POR = Selet_Machines(Machines, "Serial", "ID='" + i + "'").ToString(); |
|
|
|
|
|
|
|
stringQueueSerial.Enqueue(new QueueSerial |
|
|
|
{ |
|
|
|
ID = POR, |
|
|
|
DAT = "SC827[" + |
|
|
|
Selet_Machines(Machines, "Station", "ID='" + i + "'") + "]" |
|
|
|
}); |
|
|
|
} |
|
|
|
else if (Selet_Machines(Machines, "Type", "ID='" + i + "'").ToString() == "838") |
|
|
|
{ |
|
|
|
stringQueue.Enqueue(new QueueString |
|
|
|
{ |
|
|
|
ID = i, |
|
|
|
DAT = "SC827" + Selet_Machines(Machines, "SYSKEY", "ID='" + i + "'") |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
catch (Exception EX) { LogGing.ERRDATA(EX); } |
|
|
@ -628,11 +872,11 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel |
|
|
|
Product_.Add("Amount", row.Field<object>("Amount")); |
|
|
|
Product_.Add("DispenseEndTime", row.Field<object>("DispenseEndTime")); |
|
|
|
|
|
|
|
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString |
|
|
|
stringQueue.Enqueue(new QueueString |
|
|
|
{ |
|
|
|
ID = Convert.ToInt16(MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, |
|
|
|
ID = Convert.ToInt16(Selet_Machines(Machines, |
|
|
|
"ID", "Name='" + row.Field<string>("Machine") + "'")), |
|
|
|
DAT = "SC828" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, |
|
|
|
DAT = "SC828" + Selet_Machines(Machines, |
|
|
|
"SYSKEY", "Name='" + row.Field<string>("Machine") + "'") + Product_.ToJsonString() |
|
|
|
}); |
|
|
|
if (row["State"].ToString() == "309") |
|
|
@ -772,6 +1016,11 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel |
|
|
|
//通讯队列
|
|
|
|
public static UInt32 RX=0; |
|
|
|
public static UInt32 TX=0; |
|
|
|
public class QueueSerial |
|
|
|
{ |
|
|
|
public string ID { get; set; } |
|
|
|
public string DAT { get; set; } |
|
|
|
} |
|
|
|
public class QueueString |
|
|
|
{ |
|
|
|
public int ID { get; set; } |
|
|
@ -785,6 +1034,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel |
|
|
|
// 创建一个字符串类型的队列
|
|
|
|
public static Queue<QueueString> stringQueue = new Queue<QueueString>(); |
|
|
|
public static Queue<QueueString> stringQueueinf = new Queue<QueueString>(); |
|
|
|
public static Queue<QueueSerial> stringQueueSerial = new Queue<QueueSerial>(); |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 将 DataTable 转换为 Dictionary 类型数据
|
|
|
|