This commit is contained in:
sc committed 2024-12-07 00:05:46 +08:00
commit b15d8a1eab
4 files changed
+67 -14

No files matched your search

+35 -6
View File
@@ -101,6 +101,13 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
};
disTimer.Tick += new EventHandler(DisTimer_500MS);//每一秒执行的方法
disTimer.Start();//计时开始
DispatcherTimer dis50ms = new DispatcherTimer
{
Interval = TimeSpan.FromMilliseconds(50) //毫秒
};
dis50ms.Tick += new EventHandler(DisTimer_50MS);//每一秒执行的方法
dis50ms.Start();//计时开始
}//时间周期初始化
void Tick_Event_1S(object sender, EventArgs e)//Tick_Event周期执行事件1S
{
@@ -116,13 +123,14 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
//Updata_Machines(Machines, Convert.ToInt16(dt["ID"]), "State", "800");
}
}
for (int i = 0; i < Machinesdata_Count; i++)
for (int i = 0; i < Machinesdata_Count; i++)
{
string mac_s = Selet_Machines(Machines, "State", i).ToString();
if ((mac_s == "101") || (mac_s == "201") || (mac_s == "202") || (mac_s == "309"))//获取信息
{
MachiensTcpClient[i].SendAsync("SC830" + Selet_Machines(Machines, "SYSKEY", i).ToString());
stringQueue.Enqueue(new QueueString { ID = i, DAT = "SC830" + Selet_Machines(Machines, "SYSKEY", i).ToString() });//信息插入队列
// MachiensTcpClient[i].SendAsync("SC830" + Selet_Machines(Machines, "SYSKEY", i).ToString());
}
}
}
@@ -134,15 +142,22 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
if (Selet_Machines(Machines, "State", i).ToString() == "801")
{
MachiensTcpClient[i].SendAsync("SC800:SCCM[" + MachiensTcpClient[i].IP + ";" + MachiensTcpClient[i].Port + "]");
}
}
}
}
void DisTimer_500MS(object sender, EventArgs e)//Tick_Event周期执行事件500MS
{
DATA_view();
}
void DisTimer_50MS(object sender, EventArgs e)//Tick_Event周期执行事件50MS
{
if (stringQueue.Count > 0) //信息发送队列
{
QueueString t= stringQueue.Dequeue();
MachiensTcpClient[t.ID].SendAsync(t.DAT);
}
}
private SQLiteHelper SQLiteHelpers = null; //定义数据库
@@ -369,7 +384,8 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
public string Process { get; set; }
public string Step { get; set; }
public string Message { get; set; }
public string State { get; set; }
}
public ObservableCollection<T> ToObservableCollection<T>(DataTable dt) where T : class, new()
{
@@ -418,5 +434,18 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
}
return lst;
}
//通讯队列
public class QueueString
{
public int ID { get; set; }
public string DAT { get; set; }
}
public static class Queue
{
public static int ID { get; set; }
public static string DAT { get; set; }
}
// 创建一个字符串类型的队列
public static Queue<QueueString> stringQueue = new Queue<QueueString>();
}
}