|
@@ -201,14 +201,26 @@ namespace Monitor
|
|
|
Int32.Parse(Monitor.plcDatablockConfig[0]), Int32.Parse(Monitor.plcDatablockConfig[1]), Int32.Parse(Monitor.plcDatablockConfig[2]),
|
|
|
Monitor.plcTerminalCount, Monitor.plcParkingSpaceCount);
|
|
|
}
|
|
|
+ //启动心跳进程
|
|
|
+ Thread heartbeatThread = new Thread(()=> {
|
|
|
+ while (!Monitor.isClosing)
|
|
|
+ {
|
|
|
+ if (Monitor.PLC != null && Monitor.PLC.isConnected)
|
|
|
+ {
|
|
|
+ Random rnd = new Random();
|
|
|
+ MainBlockStru mbs = new MainBlockStru();
|
|
|
+ mbs.centralHearbeat = (short)rnd.Next(100, 999);
|
|
|
+ mbs.licenseReceived = (short)-1;
|
|
|
+ mbs.bookParkCmd = (short)-1;
|
|
|
+ mbs.bookFetchCmd = (short)-1;
|
|
|
+ Monitor.PLC.WriteToPLC(mbs, PLCDataType.central);
|
|
|
+ }
|
|
|
+ Thread.Sleep(500);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ heartbeatThread.Start();
|
|
|
if (Monitor.PLC.isConnected)
|
|
|
{
|
|
|
- Random rnd = new Random();
|
|
|
- //启动心跳进程
|
|
|
- System.Windows.Forms.Timer heartbeatTimer = new System.Windows.Forms.Timer();
|
|
|
- heartbeatTimer.Interval = 500;
|
|
|
- heartbeatTimer.Tick += new EventHandler(CentralHeartbeat);
|
|
|
- heartbeatTimer.Start();
|
|
|
return true;
|
|
|
}
|
|
|
else { Monitor.PLC.PLCConnect(); }
|
|
@@ -216,25 +228,6 @@ namespace Monitor
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- private void CentralHeartbeat(object sender, EventArgs e)
|
|
|
- {
|
|
|
- Random rnd = new Random();
|
|
|
- if (Monitor.PLC.isConnected)
|
|
|
- {
|
|
|
- MainBlockStru mbs = new MainBlockStru();
|
|
|
- List<object> list = Monitor.PLC.ReadFromPLC(PLCDataType.central, 0);
|
|
|
- if (list!=null && list.Count != 0)
|
|
|
- {
|
|
|
- mbs = (MainBlockStru)list[0];
|
|
|
- mbs.centralHearbeat = (short)rnd.Next(100, 999);
|
|
|
- mbs.licenseReceived = (short)-1;
|
|
|
- mbs.bookParkCmd = (short)-1;
|
|
|
- mbs.bookFetchCmd = (short)-1;
|
|
|
- Monitor.PLC.WriteToPLC(mbs, PLCDataType.central);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
/// <summary>
|
|
|
/// 初始化更新广告
|
|
|
/// </summary>
|