|
@ -643,6 +643,46 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel |
|
|
} |
|
|
} |
|
|
async void Tick_Event_5S()//Tick_Event周期执行事件5S
|
|
|
async void Tick_Event_5S()//Tick_Event周期执行事件5S
|
|
|
{ |
|
|
{ |
|
|
|
|
|
DataTable Workorddr = SQLiteHelpers.ExecuteDataSet("select * from WorkorderSteps ", null).Tables[0]; //读取表写入缓存
|
|
|
|
|
|
int y = Workorddr.Rows.Count; |
|
|
|
|
|
object[] datal = new object[19]; |
|
|
|
|
|
for (int i = 0; i < Workorddr.Rows.Count; i++) |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
/*AsyncSerialPortClient.SendCommandAndWait( |
|
|
|
|
|
MachiensPortClient[2], |
|
|
|
|
|
"SC800[" + MachinesRow["Station"] + "]" + f);*/ |
|
|
|
|
|
if (i >= 20) break; |
|
|
|
|
|
|
|
|
|
|
|
datal[0] = Workorddr.Rows[i]["Step"]; |
|
|
|
|
|
datal[1] = Workorddr.Rows[i]["StepID"]; |
|
|
|
|
|
datal[2] = Workorddr.Rows[i]["Parameter1"] ?? 0; |
|
|
|
|
|
datal[3] = Workorddr.Rows[i]["Parameter2"] ?? 0; |
|
|
|
|
|
datal[4] = Workorddr.Rows[i]["Parameter3"] ?? 0; |
|
|
|
|
|
datal[5] = Workorddr.Rows[i]["Parameter4"] ?? 0; |
|
|
|
|
|
datal[6] = Workorddr.Rows[i]["Parameter5"] ?? 0; |
|
|
|
|
|
datal[7] = Workorddr.Rows[i]["StepID_S1"]; |
|
|
|
|
|
datal[8] = Workorddr.Rows[i]["StepID_S2"]; |
|
|
|
|
|
datal[9] = Workorddr.Rows[i].Field<double?>("Parameter1_S1") ?? 0; |
|
|
|
|
|
datal[10] = Workorddr.Rows[i].Field<double?>("Parameter1_S2") ?? 0; |
|
|
|
|
|
datal[11] = Workorddr.Rows[i].Field<double?>("Parameter2_S1") ?? 0; |
|
|
|
|
|
datal[12] = Workorddr.Rows[i].Field<double?>("Parameter2_S2") ?? 0; |
|
|
|
|
|
datal[13] = Workorddr.Rows[i].Field<double?>("Parameter3_S1") ?? 0; |
|
|
|
|
|
datal[14] = Workorddr.Rows[i].Field<double?>("Parameter3_S2") ?? 0; |
|
|
|
|
|
datal[15] = Workorddr.Rows[i].Field<double?>("Parameter4_S1") ?? 0; |
|
|
|
|
|
datal[16] = Workorddr.Rows[i].Field<double?>("Parameter4_S2") ?? 0; |
|
|
|
|
|
datal[17] = Workorddr.Rows[i].Field<double?>("Parameter5_S1") ?? 0; |
|
|
|
|
|
datal[18] = Workorddr.Rows[i].Field<double?>("Parameter5_S2") ?? 0; |
|
|
|
|
|
|
|
|
|
|
|
stringQueueSerial_3.Enqueue(new QueueSerial |
|
|
|
|
|
{ |
|
|
|
|
|
ID = 45, |
|
|
|
|
|
DAT = "SC810[" + 1 + "]" + datal.ToJsonString() |
|
|
|
|
|
});//信息插入队列
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach (DataRow MachinesRow in Machines.Rows) |
|
|
foreach (DataRow MachinesRow in Machines.Rows) |
|
|
{ |
|
|
{ |
|
|
/**发送800指令**/ |
|
|
/**发送800指令**/ |
|
@ -984,7 +1024,6 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel |
|
|
Selet_Machines(Machines, "SYSKEY", "Name='" + row["Machine"] + "'"), |
|
|
Selet_Machines(Machines, "SYSKEY", "Name='" + row["Machine"] + "'"), |
|
|
Selet_Machines(Machines, "ID", "Name='" + row["Machine"] + "'")}); |
|
|
Selet_Machines(Machines, "ID", "Name='" + row["Machine"] + "'")}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
Dyelot_CALL.Rows.Remove(row); |
|
|
Dyelot_CALL.Rows.Remove(row); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -1044,40 +1083,53 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel |
|
|
{ |
|
|
{ |
|
|
if (Machines.Select("Type='false' AND Serial='PORT1'").Length > 0) |
|
|
if (Machines.Select("Type='false' AND Serial='PORT1'").Length > 0) |
|
|
{ |
|
|
{ |
|
|
|
|
|
AsyncSerialPortClient.PortCOM1 = Configini.IniReadvalue("SYS", "COMP1"); |
|
|
MachiensPortClient[0] = new SerialPortClient(); |
|
|
MachiensPortClient[0] = new SerialPortClient(); |
|
|
|
|
|
|
|
|
await AsyncSerialPortClient.PortClient(MachiensPortClient[0] //建立连接
|
|
|
await AsyncSerialPortClient.PortClient(MachiensPortClient[0] //建立连接
|
|
|
, Configini.IniReadvalue("SYS", "COMP1") |
|
|
, Configini.IniReadvalue("SYS", "COMP1") |
|
|
, Convert.ToInt32(Configini.IniReadvalue("SYS", "BAUD1"))); |
|
|
, Convert.ToInt32(Configini.IniReadvalue("SYS", "BAUD1"))); |
|
|
Port1_link(); |
|
|
Thread myThread1 = new Thread(Port1_link); |
|
|
|
|
|
myThread1.Start(); |
|
|
} |
|
|
} |
|
|
if (Machines.Select("Type='false' AND Serial='PORT2'").Length > 0) |
|
|
if (Machines.Select("Type='false' AND Serial='PORT2'").Length > 0) |
|
|
{ |
|
|
{ |
|
|
|
|
|
AsyncSerialPortClient.PortCOM2 = Configini.IniReadvalue("SYS", "COMP2"); |
|
|
MachiensPortClient[1] = new SerialPortClient(); |
|
|
MachiensPortClient[1] = new SerialPortClient(); |
|
|
await AsyncSerialPortClient.PortClient(MachiensPortClient[1] //建立连接
|
|
|
|
|
|
|
|
|
await AsyncSerialPortClient.PortClient2(MachiensPortClient[1] //建立连接
|
|
|
, Configini.IniReadvalue("SYS", "COMP2") |
|
|
, Configini.IniReadvalue("SYS", "COMP2") |
|
|
, Convert.ToInt32(Configini.IniReadvalue("SYS", "BAUD2"))); |
|
|
, Convert.ToInt32(Configini.IniReadvalue("SYS", "BAUD2"))); |
|
|
Port2_link(); |
|
|
|
|
|
|
|
|
Thread myThread2 = new Thread(Port2_link); |
|
|
|
|
|
myThread2.Start(); |
|
|
} |
|
|
} |
|
|
if (Machines.Select("Type='false' AND Serial='PORT3'").Length > 0) |
|
|
if (Machines.Select("Type='false' AND Serial='PORT3'").Length > 0) |
|
|
{ |
|
|
{ |
|
|
|
|
|
AsyncSerialPortClient.PortCOM3 = Configini.IniReadvalue("SYS", "COMP3"); |
|
|
MachiensPortClient[2] = new SerialPortClient(); |
|
|
MachiensPortClient[2] = new SerialPortClient(); |
|
|
await AsyncSerialPortClient.PortClient(MachiensPortClient[2] //建立连接
|
|
|
|
|
|
|
|
|
await AsyncSerialPortClient.PortClient3(MachiensPortClient[2] //建立连接
|
|
|
, Configini.IniReadvalue("SYS", "COMP3") |
|
|
, Configini.IniReadvalue("SYS", "COMP3") |
|
|
, Convert.ToInt32(Configini.IniReadvalue("SYS", "BAUD3"))); |
|
|
, Convert.ToInt32(Configini.IniReadvalue("SYS", "BAUD3"))); |
|
|
Port3_link(); |
|
|
|
|
|
|
|
|
Thread myThread3 = new Thread(Port3_link); |
|
|
|
|
|
myThread3.Start(); |
|
|
} |
|
|
} |
|
|
if (Machines.Select("Type='false' AND Serial='PORT4'").Length > 0) |
|
|
if (Machines.Select("Type='false' AND Serial='PORT4'").Length > 0) |
|
|
{ |
|
|
{ |
|
|
|
|
|
AsyncSerialPortClient.PortCOM4 = Configini.IniReadvalue("SYS", "COMP4"); |
|
|
MachiensPortClient[3] = new SerialPortClient(); |
|
|
MachiensPortClient[3] = new SerialPortClient(); |
|
|
await AsyncSerialPortClient.PortClient(MachiensPortClient[3] //建立连接
|
|
|
|
|
|
|
|
|
await AsyncSerialPortClient.PortClient4(MachiensPortClient[3] //建立连接
|
|
|
, Configini.IniReadvalue("SYS", "COMP4") |
|
|
, Configini.IniReadvalue("SYS", "COMP4") |
|
|
, Convert.ToInt32(Configini.IniReadvalue("SYS", "BAUD4"))); |
|
|
, Convert.ToInt32(Configini.IniReadvalue("SYS", "BAUD4"))); |
|
|
Port4_link(); |
|
|
|
|
|
|
|
|
Thread myThread4 = new Thread(Port4_link); |
|
|
|
|
|
myThread4.Start(); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
private void Port1_link() |
|
|
private void Port1_link() |
|
|
{ |
|
|
|
|
|
Task.Run(() => |
|
|
|
|
|
{ |
|
|
{ |
|
|
try |
|
|
try |
|
|
{ |
|
|
{ |
|
@ -1087,14 +1139,14 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel |
|
|
{ |
|
|
{ |
|
|
QueueSerial t = stringQueueSerial_1.Dequeue(); |
|
|
QueueSerial t = stringQueueSerial_1.Dequeue(); |
|
|
|
|
|
|
|
|
AsyncSerialPortClient.SendCommandAndWait(MachiensPortClient[0], t.DAT); |
|
|
AsyncSerialPortClient.SendCommandAndWait(MachiensPortClient[0], t.DAT+"\n"); |
|
|
//MachiensPortClient[t.ID].Send(t.DAT);
|
|
|
//MachiensPortClient[t.ID].Send(t.DAT);
|
|
|
} |
|
|
} |
|
|
if (MachinesRow["State"].ToString() == "800") |
|
|
if (MachinesRow["State"].ToString() == "800") |
|
|
{ |
|
|
{ |
|
|
AsyncSerialPortClient.SendCommandAndWait( |
|
|
AsyncSerialPortClient.SendCommandAndWait( |
|
|
MachiensPortClient[0], |
|
|
MachiensPortClient[0], |
|
|
"SC800[" + MachinesRow["Station"] + "]"); |
|
|
"SC800[" + MachinesRow["Station"] + "]\n"); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -1103,14 +1155,10 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel |
|
|
} |
|
|
} |
|
|
finally |
|
|
finally |
|
|
{ |
|
|
{ |
|
|
// if (stringQueueSerial.Count == 0) return;
|
|
|
|
|
|
Port1_link();//回调
|
|
|
Port1_link();//回调
|
|
|
} |
|
|
} |
|
|
}); |
|
|
|
|
|
}//发送
|
|
|
}//发送
|
|
|
private void Port2_link() |
|
|
private void Port2_link() |
|
|
{ |
|
|
|
|
|
Task.Run(() => |
|
|
|
|
|
{ |
|
|
{ |
|
|
try |
|
|
try |
|
|
{ |
|
|
{ |
|
@ -1120,14 +1168,14 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel |
|
|
{ |
|
|
{ |
|
|
QueueSerial t = stringQueueSerial_2.Dequeue(); |
|
|
QueueSerial t = stringQueueSerial_2.Dequeue(); |
|
|
|
|
|
|
|
|
AsyncSerialPortClient.SendCommandAndWait(MachiensPortClient[1], t.DAT); |
|
|
AsyncSerialPortClient.SendCommandAndWait2(MachiensPortClient[1], t.DAT+ "\n"); |
|
|
//MachiensPortClient[t.ID].Send(t.DAT);
|
|
|
//MachiensPortClient[t.ID].Send(t.DAT);
|
|
|
} |
|
|
} |
|
|
if (MachinesRow["State"].ToString() == "800") |
|
|
if (MachinesRow["State"].ToString() == "800") |
|
|
{ |
|
|
{ |
|
|
AsyncSerialPortClient.SendCommandAndWait( |
|
|
AsyncSerialPortClient.SendCommandAndWait2( |
|
|
MachiensPortClient[1], |
|
|
MachiensPortClient[1], |
|
|
"SC800[" + MachinesRow["Station"] + "]"); |
|
|
"SC800[" + MachinesRow["Station"] + "]\n"); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -1136,14 +1184,10 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel |
|
|
} |
|
|
} |
|
|
finally |
|
|
finally |
|
|
{ |
|
|
{ |
|
|
// if (stringQueueSerial.Count == 0) return;
|
|
|
|
|
|
Port2_link();//回调
|
|
|
Port2_link();//回调
|
|
|
} |
|
|
} |
|
|
}); |
|
|
|
|
|
}//发送
|
|
|
}//发送
|
|
|
private void Port3_link() |
|
|
private void Port3_link() |
|
|
{ |
|
|
|
|
|
Task.Run(() => |
|
|
|
|
|
{ |
|
|
{ |
|
|
try |
|
|
try |
|
|
{ |
|
|
{ |
|
@ -1153,16 +1197,14 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel |
|
|
{ |
|
|
{ |
|
|
QueueSerial t = stringQueueSerial_3.Dequeue(); |
|
|
QueueSerial t = stringQueueSerial_3.Dequeue(); |
|
|
|
|
|
|
|
|
AsyncSerialPortClient.SendCommandAndWait(MachiensPortClient[2], t.DAT); |
|
|
AsyncSerialPortClient.SendCommandAndWait3(MachiensPortClient[2],t.DAT+ "\n"); |
|
|
//MachiensPortClient[t.ID].Send(t.DAT);
|
|
|
//MachiensPortClient[t.ID].Send(t.DAT);
|
|
|
} |
|
|
} |
|
|
if (MachinesRow["State"].ToString() == "800") |
|
|
else if (MachinesRow["State"].ToString() == "800") |
|
|
{ |
|
|
{ |
|
|
DataTable Workorddr = SQLiteHelpers.ExecuteDataSet("select * from Dyelot ", null).Tables[0]; //读取表写入缓存
|
|
|
AsyncSerialPortClient.SendCommandAndWait3( |
|
|
|
|
|
|
|
|
AsyncSerialPortClient.SendCommandAndWait( |
|
|
|
|
|
MachiensPortClient[2], |
|
|
MachiensPortClient[2], |
|
|
"SC800[" + MachinesRow["Station"] + "]"+Workorddr.ToJsonString()); |
|
|
"SC800[" + MachinesRow["Station"] + "]\n"); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -1171,14 +1213,10 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel |
|
|
} |
|
|
} |
|
|
finally |
|
|
finally |
|
|
{ |
|
|
{ |
|
|
// if (stringQueueSerial.Count == 0) return;
|
|
|
|
|
|
Port3_link();//回调
|
|
|
Port3_link();//回调
|
|
|
} |
|
|
} |
|
|
}); |
|
|
|
|
|
}//发送
|
|
|
}//发送
|
|
|
private void Port4_link() |
|
|
private void Port4_link() |
|
|
{ |
|
|
|
|
|
Task.Run(() => |
|
|
|
|
|
{ |
|
|
{ |
|
|
try |
|
|
try |
|
|
{ |
|
|
{ |
|
@ -1188,14 +1226,14 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel |
|
|
{ |
|
|
{ |
|
|
QueueSerial t = stringQueueSerial_4.Dequeue(); |
|
|
QueueSerial t = stringQueueSerial_4.Dequeue(); |
|
|
|
|
|
|
|
|
AsyncSerialPortClient.SendCommandAndWait(MachiensPortClient[3], t.DAT); |
|
|
AsyncSerialPortClient.SendCommandAndWait4(MachiensPortClient[3],t.DAT+ "\n"); |
|
|
//MachiensPortClient[t.ID].Send(t.DAT);
|
|
|
//MachiensPortClient[t.ID].Send(t.DAT);
|
|
|
} |
|
|
} |
|
|
if (MachinesRow["State"].ToString() == "800") |
|
|
if (MachinesRow["State"].ToString() == "800") |
|
|
{ |
|
|
{ |
|
|
AsyncSerialPortClient.SendCommandAndWait( |
|
|
AsyncSerialPortClient.SendCommandAndWait4( |
|
|
MachiensPortClient[3], |
|
|
MachiensPortClient[3], |
|
|
"SC800[" + MachinesRow["Station"] + "]"); |
|
|
"SC800[" + MachinesRow["Station"] + "]\n"); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -1204,10 +1242,8 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel |
|
|
} |
|
|
} |
|
|
finally |
|
|
finally |
|
|
{ |
|
|
{ |
|
|
// if (stringQueueSerial.Count == 0) return;
|
|
|
|
|
|
Port4_link();//回调
|
|
|
Port4_link();//回调
|
|
|
} |
|
|
} |
|
|
}); |
|
|
|
|
|
}//发送
|
|
|
}//发送
|
|
|
|
|
|
|
|
|
public static string SYS_WorkNumder; //工单号
|
|
|
public static string SYS_WorkNumder; //工单号
|
|
|