Browse Source

修改实时曲线缓存逻辑

master
sc 2 months ago
parent
commit
6e690b78b7
  1. 10
      View/Whole.xaml.cs
  2. 30
      ViewModel/MainWindowViewModel.cs

10
View/Whole.xaml.cs

@ -128,11 +128,11 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
t30S = 0; t30S = 0;
inf[i].DataAdd(dateTime,(double)Selet_Machines(MainWindowViewModel.Machines, "Temperature", i)); inf[i].DataAdd(dateTime,(double)Selet_Machines(MainWindowViewModel.Machines, "Temperature", i));
DataRow whole_Dat = MainWindowViewModel.Whole_dat.NewRow(); // DataRow whole_Dat = MainWindowViewModel.Whole_dat.NewRow();
whole_Dat["Machine"] = Selet_Machines(MainWindowViewModel.Machines, "NAME", i).ToString(); // whole_Dat["Machine"] = Selet_Machines(MainWindowViewModel.Machines, "NAME", i).ToString();
whole_Dat["DateTime"] = dateTime; // whole_Dat["DateTime"] = dateTime;
whole_Dat["DAT"] = (double)Selet_Machines(MainWindowViewModel.Machines, "Temperature", i); // whole_Dat["DAT"] = (double)Selet_Machines(MainWindowViewModel.Machines, "Temperature", i);
MainWindowViewModel.Whole_dat.Rows.Add(whole_Dat); // MainWindowViewModel.Whole_dat.Rows.Add(whole_Dat);
} }
} }

30
ViewModel/MainWindowViewModel.cs

@ -190,7 +190,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
dis50ms.Tick += new EventHandler(DisTimer_50MS);//每执行的方法 dis50ms.Tick += new EventHandler(DisTimer_50MS);//每执行的方法
dis50ms.Start();//计时开始 dis50ms.Start();//计时开始
}//时间周期初始化 }//时间周期初始化
int Time5 = 0, Time60 = 0; int Time5 = 0, Time30 = 0;
void DisTimer_50MS(object sender, EventArgs e)//Tick_Event周期执行事件50MS void DisTimer_50MS(object sender, EventArgs e)//Tick_Event周期执行事件50MS
{ {
if (stringQueue.Count > 0) //信息发送队列 if (stringQueue.Count > 0) //信息发送队列
@ -319,12 +319,12 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
Time5 = 0; Time5 = 0;
} }
else { Time5++; } else { Time5++; }
if (Time60 > 60) if (Time30 > 30)
{ {
// Tick_Event_60S(); Tick_Event_30S();
Time60 = 0; Time30 = 0;
} }
else { Time60++; } else { Time30++; }
} }
async void Tick_Event_5S()//Tick_Event周期执行事件5S async void Tick_Event_5S()//Tick_Event周期执行事件5S
{ {
@ -613,20 +613,20 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
} }
} }
async void Tick_Event_60S() void Tick_Event_30S()
{ {
for (int i = 0; i < Machinesdata_Count; i++) for (int i = 0; i < Machines.Rows.Count; i++)
{ {
if (Selet_Machines(Machines, "State", "ID='" + i + "'").ToString() == "800") if (Selet_Machines(Machines, "State", "ID='" + i + "'").ToString() !="800")
{ {
MachiensTcpClient[i] = new TcpClient(); DataRow whole_Dat = Whole_dat.NewRow();
DataRow dt = machinesdata[i]; whole_Dat["Machine"] = Selet_Machines(Machines, "NAME", "ID='" + i + "'").ToString();
await AsyncTcpClient.TcpClient(MachiensTcpClient[i] //建立tcp连接 whole_Dat["DateTime"] = DateTime.Now;
, Selet_Machines(Machines, "IP", "ID='" + Convert.ToInt16(dt["ID"]) + "'" ).ToString() whole_Dat["DAT"] = (double)Selet_Machines(Machines, "Temperature", "ID='" + i + "'");
, Selet_Machines(Machines, "PORT", "ID='" + Convert.ToInt16(dt["ID"]) + "'").ToString()); Whole_dat.Rows.Add(whole_Dat);
} }
}//重连 }
} }
public static TcpClient[] MachiensTcpClient = new TcpClient[999]; public static TcpClient[] MachiensTcpClient = new TcpClient[999];
public static DataRow[] machinesdata = new DataRow[999]; public static DataRow[] machinesdata = new DataRow[999];

Loading…
Cancel
Save