Browse Source

修改连线逻辑

master
sc 7 months ago
parent
commit
26c41a0c10
  1. 4
      UserClass/AsyncTcpClient.cs
  2. 2
      View/MonitorView.xaml.cs
  3. 15
      ViewModel/MainWindowViewModel.cs

4
UserClass/AsyncTcpClient.cs

@ -90,7 +90,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
{ {
DataRow drEmployee = MainWindowViewModel.Machines.Select("IP='" + client.IP + "'").First(); DataRow drEmployee = MainWindowViewModel.Machines.Select("IP='" + client.IP + "'").First();
drEmployee.BeginEdit(); drEmployee.BeginEdit();
drEmployee["State"] = "899"; drEmployee["State"] = "800";
drEmployee["WorkOrder"] = "------"; drEmployee["WorkOrder"] = "------";
drEmployee["Dyelot"] = ""; drEmployee["Dyelot"] = "";
drEmployee["Temperature"] = "---.-"; drEmployee["Temperature"] = "---.-";
@ -123,7 +123,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
DataRow drEmployee = MainWindowViewModel.Machines.Select("IP='" + client.IP + "'").First(); DataRow drEmployee = MainWindowViewModel.Machines.Select("IP='" + client.IP + "'").First();
drEmployee.BeginEdit(); drEmployee.BeginEdit();
drEmployee["SYSKEY"] = Chart_new.GetValue("SYSKEY").ToString(); drEmployee["SYSKEY"] = Chart_new.GetValue("SYSKEY").ToString();
drEmployee["NAME"] = Chart_new.GetValue("MACHINE").ToString(); // drEmployee["NAME"] = Chart_new.GetValue("MACHINE").ToString();
drEmployee["Groups"] = Chart_new.GetValue("GROUP").ToString(); drEmployee["Groups"] = Chart_new.GetValue("GROUP").ToString();
drEmployee["State"] = "802"; drEmployee["State"] = "802";
drEmployee.EndEdit(); drEmployee.EndEdit();

2
View/MonitorView.xaml.cs

@ -40,7 +40,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
{ {
public MonitorView() public MonitorView()
{ {
DataContext = new MainWindowViewModel(); //DataContext = new MainWindowViewModel();
InitializeComponent(); InitializeComponent();
CountDown(); CountDown();
} }

15
ViewModel/MainWindowViewModel.cs

@ -15,7 +15,9 @@ using System.Data.SqlClient;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using System.Text; using System.Text;
using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Timers;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Forms; using System.Windows.Forms;
using System.Windows.Media; using System.Windows.Media;
@ -150,13 +152,12 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
ERR_c++; ERR_c++;
} }
} }
public void CountDown() public void CountDown()
{ {
DispatcherTimer timer1s = new DispatcherTimer//初始化循环,每1秒调用一次Tick DispatcherTimer timer1s = new DispatcherTimer(DispatcherPriority.Normal);//初始化循环,每1秒调用一次Tick
{ timer1s.Interval = TimeSpan.FromMilliseconds(950);//秒
Interval = TimeSpan.FromSeconds(1)//秒 timer1s.Tick += Tick_Main_1S;
};
timer1s.Tick += Tick_Event_1S;
timer1s.Start(); timer1s.Start();
DispatcherTimer dis50ms = new DispatcherTimer DispatcherTimer dis50ms = new DispatcherTimer
@ -174,7 +175,9 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
MachiensTcpClient[t.ID].SendAsync(t.DAT); MachiensTcpClient[t.ID].SendAsync(t.DAT);
} }
} }
void Tick_Event_1S(object sender, EventArgs e)//Tick_Event周期执行事件1S
void Tick_Main_1S(object sender, EventArgs e)//Tick_Event周期执行事件1S
{ {
DATA_view(); DATA_view();
//下传工单信息 //下传工单信息

Loading…
Cancel
Save