|
|
@ -76,22 +76,42 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel |
|
|
|
{ |
|
|
|
Sys_Time = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"); |
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < Machinesdata_Count; i++) |
|
|
|
{ |
|
|
|
if (Selet_Machines(Machines, "State", i).ToString() == "802") |
|
|
|
{ |
|
|
|
MachiensTcpClient[i].SendAsync("SC830"+ Selet_Machines(Machines, "SYSKEY", i).ToString()); |
|
|
|
Updata_Machines(Machines, "State", i, "101"); |
|
|
|
// DataRow dt = machinesdata[i];
|
|
|
|
//Updata_Machines(Machines, Convert.ToInt16(dt["ID"]), "State", "800");
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
void Tick_Event_5S(object sender, EventArgs e)//Tick_Event周期执行事件5S
|
|
|
|
{ |
|
|
|
for (int i = 0; i < Machinesdata_Count; i++) |
|
|
|
{ |
|
|
|
if ( Selet_Machines(Machines,"State", i).ToString() =="801") |
|
|
|
MachiensTcpClient[i].SendAsync("SC800:SCCM["+ MachiensTcpClient[i].IP+";"+ MachiensTcpClient[i].Port+"]"); |
|
|
|
|
|
|
|
if (Selet_Machines(Machines, "State", i).ToString() == "801") |
|
|
|
{ |
|
|
|
MachiensTcpClient[i].SendAsync("SC800:SCCM[" + MachiensTcpClient[i].IP + ";" + MachiensTcpClient[i].Port + "]"); |
|
|
|
} |
|
|
|
// MachiensTcpClient[1].SendAsync("SC851BED2E58B6EBB4BD4");
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
void DisTimer_500MS(object sender, EventArgs e)//Tick_Event周期执行事件500MS
|
|
|
|
{ |
|
|
|
for (int i = 0; i < Machinesdata_Count; i++) |
|
|
|
{ |
|
|
|
if (Selet_Machines(Machines, "State", i).ToString() == "101") |
|
|
|
{ |
|
|
|
MachiensTcpClient[i].SendAsync("SC830" + Selet_Machines(Machines, "SYSKEY", i).ToString()); |
|
|
|
|
|
|
|
// DataRow dt = machinesdata[i];
|
|
|
|
//Updata_Machines(Machines, Convert.ToInt16(dt["ID"]), "State", "800");
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private SQLiteHelper SQLiteHelpers = null; //定义数据库
|
|
|
@ -121,7 +141,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel |
|
|
|
{ |
|
|
|
MachiensTcpClient[i] = new TcpClient(); |
|
|
|
DataRow dt = machinesdata[i]; |
|
|
|
Updata_Machines(Machines, Convert.ToInt16(dt["ID"]), "State", "800"); |
|
|
|
Updata_Machines(Machines, "State", Convert.ToInt16(dt["ID"]), "800"); |
|
|
|
_ = AsyncTcpClient.TcpClient(MachiensTcpClient[i] //建立tcp连接
|
|
|
|
, Selet_Machines(Machines, "IP", Convert.ToInt16(dt["ID"])).ToString() |
|
|
|
, Selet_Machines(Machines, "PORT", Convert.ToInt16(dt["ID"])).ToString()); |
|
|
@ -155,7 +175,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public static void Updata_Machines(DataTable DB, int key, string name, string Value)//更新数据
|
|
|
|
public static void Updata_Machines(DataTable DB, string name, int key, string Value)//更新数据
|
|
|
|
{ |
|
|
|
try |
|
|
|
{ |
|
|
|