添加去重逻辑
This commit is contained in:
commit
e457b0ab21
2 files changed
+217
-101
No files matched your search
@@ -427,7 +427,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
|
||||
_responseEvent.Reset();
|
||||
serialPortClients.Send(command); // 发送指令
|
||||
// 等待500毫秒或直到收到响应
|
||||
_responseEvent.Wait(TimeSpan.FromMilliseconds(1000));
|
||||
_responseEvent.Wait(TimeSpan.FromMilliseconds(500));
|
||||
// 重置事件状态
|
||||
_responseEvent.Set();
|
||||
//清楚了解状态
|
||||
|
||||
+216
-100
@@ -264,7 +264,9 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
||||
stringQueueSerial_1.Enqueue(new QueueSerial
|
||||
{
|
||||
ID = index,
|
||||
DAT = "SC811" + Selet_Machines(Machines, "SYSKEY", "ID='" + index + "'") + dataTable.Rows[0].ToJsonString()
|
||||
DAT = "SC811[" +
|
||||
Selet_Machines(Machines, "Station", "ID='" + index + "'") + "]" +
|
||||
dataTable.Rows[0].ToJsonString()
|
||||
});
|
||||
}
|
||||
else if (Selet_Machines(Machines, "Serial", "Name='" + WorkOrderdata_m + "'").ToString() == "PORT2")
|
||||
@@ -272,7 +274,9 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
||||
stringQueueSerial_2.Enqueue(new QueueSerial
|
||||
{
|
||||
ID = index,
|
||||
DAT = "SC811" + Selet_Machines(Machines, "SYSKEY", "ID='" + index + "'") + dataTable.Rows[0].ToJsonString()
|
||||
DAT = "SC811[" +
|
||||
Selet_Machines(Machines, "Station", "ID='" + index + "'") + "]" +
|
||||
dataTable.Rows[0].ToJsonString()
|
||||
});
|
||||
}
|
||||
else if (Selet_Machines(Machines, "Serial", "Name='" + WorkOrderdata_m + "'").ToString() == "PORT3")
|
||||
@@ -280,7 +284,9 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
||||
stringQueueSerial_3.Enqueue(new QueueSerial
|
||||
{
|
||||
ID = index,
|
||||
DAT = "SC811" + Selet_Machines(Machines, "SYSKEY", "ID='" + index + "'") + dataTable.Rows[0].ToJsonString()
|
||||
DAT = "SC811[" +
|
||||
Selet_Machines(Machines, "Station", "ID='" + index + "'") + "]" +
|
||||
dataTable.Rows[0].ToJsonString()
|
||||
});
|
||||
}
|
||||
else if (Selet_Machines(Machines, "Serial", "Name='" + WorkOrderdata_m + "'").ToString() == "PORT4")
|
||||
@@ -288,7 +294,9 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
||||
stringQueueSerial_4.Enqueue(new QueueSerial
|
||||
{
|
||||
ID = index,
|
||||
DAT = "SC811" + Selet_Machines(Machines, "SYSKEY", "ID='" + index + "'") + dataTable.Rows[0].ToJsonString()
|
||||
DAT = "SC811[" +
|
||||
Selet_Machines(Machines, "Station", "ID='" + index + "'") + "]" +
|
||||
dataTable.Rows[0].ToJsonString()
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -349,7 +357,9 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
||||
stringQueueSerial_1.Enqueue(new QueueSerial
|
||||
{
|
||||
ID = index,
|
||||
DAT = "SC810" + Selet_Machines(Machines, "SYSKEY", "ID='" + index + "'") + DataTableToDictionary(dataTable).ToJsonString()
|
||||
DAT = "SC810[" +
|
||||
Selet_Machines(Machines, "Station", "ID='" + index + "'") + "]" +
|
||||
DataTableToDictionary(dataTable).ToJsonString()
|
||||
});
|
||||
}
|
||||
else if (Selet_Machines(Machines, "Serial", "Name='" + WorkOrderdata_m + "'").ToString() == "PORT2")
|
||||
@@ -357,7 +367,9 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
||||
stringQueueSerial_2.Enqueue(new QueueSerial
|
||||
{
|
||||
ID = index,
|
||||
DAT = "SC810" + Selet_Machines(Machines, "SYSKEY", "ID='" + index + "'") + DataTableToDictionary(dataTable).ToJsonString()
|
||||
DAT = "SC810[" +
|
||||
Selet_Machines(Machines, "Station", "ID='" + index + "'") + "]" +
|
||||
DataTableToDictionary(dataTable).ToJsonString()
|
||||
});
|
||||
}
|
||||
else if (Selet_Machines(Machines, "Serial", "Name='" + WorkOrderdata_m + "'").ToString() == "PORT3")
|
||||
@@ -365,7 +377,9 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
||||
stringQueueSerial_3.Enqueue(new QueueSerial
|
||||
{
|
||||
ID = index,
|
||||
DAT = "SC810" + Selet_Machines(Machines, "SYSKEY", "ID='" + index + "'") + DataTableToDictionary(dataTable).ToJsonString()
|
||||
DAT = "SC810[" +
|
||||
Selet_Machines(Machines, "Station", "ID='" + index + "'") + "]" +
|
||||
DataTableToDictionary(dataTable).ToJsonString()
|
||||
});
|
||||
}
|
||||
else if (Selet_Machines(Machines, "Serial", "Name='" + WorkOrderdata_m + "'").ToString() == "PORT4")
|
||||
@@ -373,7 +387,9 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
||||
stringQueueSerial_4.Enqueue(new QueueSerial
|
||||
{
|
||||
ID = index,
|
||||
DAT = "SC810" + Selet_Machines(Machines, "SYSKEY", "ID='" + index + "'") + DataTableToDictionary(dataTable).ToJsonString()
|
||||
DAT = "SC810[" +
|
||||
Selet_Machines(Machines, "Station", "ID='" + index + "'") + "]" +
|
||||
DataTableToDictionary(dataTable).ToJsonString()
|
||||
});
|
||||
}
|
||||
|
||||
@@ -428,7 +444,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
||||
{
|
||||
ID = index,
|
||||
DAT = "SC812[" +
|
||||
Selet_Machines(Machines, "Station", "ID='" + k + "'") + "]" +
|
||||
Selet_Machines(Machines, "Station", "ID='" + index + "'") + "]" +
|
||||
DataTableToDictionary(WorkOrder_set).ToJsonString()
|
||||
});
|
||||
}
|
||||
@@ -438,7 +454,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
||||
{
|
||||
ID = index,
|
||||
DAT = "SC812[" +
|
||||
Selet_Machines(Machines, "Station", "ID='" + k + "'") + "]" +
|
||||
Selet_Machines(Machines, "Station", "ID='" + index + "'") + "]" +
|
||||
DataTableToDictionary(WorkOrder_set).ToJsonString()
|
||||
});
|
||||
}
|
||||
@@ -448,7 +464,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
||||
{
|
||||
ID = index,
|
||||
DAT = "SC812[" +
|
||||
Selet_Machines(Machines, "Station", "ID='" + k + "'") + "]" +
|
||||
Selet_Machines(Machines, "Station", "ID='" + index + "'") + "]" +
|
||||
DataTableToDictionary(WorkOrder_set).ToJsonString()
|
||||
});
|
||||
}
|
||||
@@ -458,7 +474,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
||||
{
|
||||
ID = index,
|
||||
DAT = "SC812[" +
|
||||
Selet_Machines(Machines, "Station", "ID='" + k + "'") + "]" +
|
||||
Selet_Machines(Machines, "Station", "ID='" + index + "'") + "]" +
|
||||
DataTableToDictionary(WorkOrder_set).ToJsonString()
|
||||
});
|
||||
}
|
||||
@@ -535,16 +551,11 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
||||
}
|
||||
else
|
||||
{//串口发送
|
||||
if (MachinesRow["State"].ToString() == "802")
|
||||
string mac_s = MachinesRow["State"].ToString();
|
||||
if (mac_s == "802")
|
||||
{
|
||||
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"]);//发送锁定状态
|
||||
if (mode)
|
||||
{
|
||||
@@ -552,80 +563,222 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
||||
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_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")
|
||||
{
|
||||
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 = Convert.ToInt16(MachinesRow["ID"]),
|
||||
DAT = "SC829[" + MachinesRow["Station"] + "]" + dat_829.ToJsonString()
|
||||
ID = id,
|
||||
DAT = dat
|
||||
});
|
||||
}
|
||||
}
|
||||
else if (MachinesRow["Serial"].ToString() == "PORT2")
|
||||
{
|
||||
stringQueueSerial_2.Enqueue(new QueueSerial
|
||||
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)
|
||||
{
|
||||
ID = Convert.ToInt16(MachinesRow["ID"]),
|
||||
DAT = "SC830[" + MachinesRow["Station"] + "]"
|
||||
});
|
||||
|
||||
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()
|
||||
ID = id,
|
||||
DAT = dat
|
||||
});
|
||||
}
|
||||
}
|
||||
else if (MachinesRow["Serial"].ToString() == "PORT3")
|
||||
{
|
||||
stringQueueSerial_3.Enqueue(new QueueSerial
|
||||
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)
|
||||
{
|
||||
ID = Convert.ToInt16(MachinesRow["ID"]),
|
||||
DAT = "SC830[" + MachinesRow["Station"] + "]"
|
||||
});
|
||||
|
||||
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()
|
||||
ID = id,
|
||||
DAT = dat
|
||||
});
|
||||
}
|
||||
}
|
||||
else if (MachinesRow["Serial"].ToString() == "PORT4")
|
||||
{
|
||||
stringQueueSerial_4.Enqueue(new QueueSerial
|
||||
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)
|
||||
{
|
||||
ID = Convert.ToInt16(MachinesRow["ID"]),
|
||||
DAT = "SC830[" + MachinesRow["Station"] + "]"
|
||||
});
|
||||
|
||||
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()
|
||||
ID = id,
|
||||
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
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int m_run = Convert.ToInt16(MachinesRow["WORK_RUN"]);
|
||||
if (m_run == 0)
|
||||
{
|
||||
@@ -644,43 +797,6 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
||||
{
|
||||
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"] + "]"
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user