|
@@ -339,35 +339,9 @@ namespace parkMonitor.server
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- //plc掉线则将系统暂停
|
|
|
- EntityForCore.ins.globalStatus = false;
|
|
|
- if (linkCount-- >= 0)
|
|
|
+ if (EntityForCore.ins.globalStatus)
|
|
|
{
|
|
|
- Task.Factory.StartNew(() =>
|
|
|
- {
|
|
|
- MyTimer mt = new MyTimer();
|
|
|
- mt.StartTiming();
|
|
|
- while (!isClosing)
|
|
|
- {
|
|
|
- mt.EndTiming();
|
|
|
- int count;
|
|
|
- if (mt.IsLonger(1, 1, true, out count))
|
|
|
- {
|
|
|
- //断线后只显示一次
|
|
|
- UILogServer.ins.warn("尝试重连PLC");
|
|
|
- Log.WriteLog(LogType.NOT_DATABASE, LogFile.LOG, "PLC重连中,请稍候。。。。。。");
|
|
|
- }
|
|
|
- LinkStart();
|
|
|
- Thread.Sleep(10000);
|
|
|
- if (isConnection)
|
|
|
- {
|
|
|
- EntityForCore.ins.globalStatus = true;
|
|
|
- linkCount = 0;
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
- linkCount = -1;
|
|
|
+ Reconnect();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -377,6 +351,41 @@ namespace parkMonitor.server
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private void Reconnect()
|
|
|
+ {
|
|
|
+ //plc掉线则将系统暂停
|
|
|
+ EntityForCore.ins.globalStatus = false;
|
|
|
+ //if (linkCount-- >= 0)
|
|
|
+ //{
|
|
|
+ linkCount = 10;
|
|
|
+ Task.Factory.StartNew(() =>
|
|
|
+ {
|
|
|
+ MyTimer mt = new MyTimer();
|
|
|
+ mt.StartTiming();
|
|
|
+ while (linkCount-- > 0)
|
|
|
+ {
|
|
|
+ mt.EndTiming();
|
|
|
+ int count;
|
|
|
+ if (mt.IsLonger(1, 1, true, out count))
|
|
|
+ {
|
|
|
+ //断线后只显示一次
|
|
|
+ UILogServer.ins.warn("暂停系统,尝试重连PLC");
|
|
|
+ Log.WriteLog(LogType.NOT_DATABASE, LogFile.LOG, "PLC重连中,请稍候。。。。。。");
|
|
|
+ }
|
|
|
+ LinkStart();
|
|
|
+ Thread.Sleep(10000);
|
|
|
+ if (isConnection)
|
|
|
+ {
|
|
|
+ EntityForCore.ins.globalStatus = true;
|
|
|
+ linkCount = 10;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }).Wait();
|
|
|
+ //linkCount = -1;
|
|
|
+ //}
|
|
|
+ }
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 从PLC读取数据
|
|
|
/// </summary>
|
|
@@ -854,19 +863,19 @@ namespace parkMonitor.server
|
|
|
}
|
|
|
});
|
|
|
|
|
|
- ////模拟plc与激光自动操作
|
|
|
- //Task.Factory.StartNew(() =>
|
|
|
- //{
|
|
|
- // laserAnim();
|
|
|
- //});
|
|
|
- //Task.Factory.StartNew(() =>
|
|
|
- //{
|
|
|
- // wheelbaseAnim();
|
|
|
- //});
|
|
|
- //Task.Factory.StartNew(() =>
|
|
|
- //{
|
|
|
- // autoCycling();
|
|
|
- //});
|
|
|
+ //模拟plc与激光自动操作
|
|
|
+ Task.Factory.StartNew(() =>
|
|
|
+ {
|
|
|
+ laserAnim();
|
|
|
+ });
|
|
|
+ Task.Factory.StartNew(() =>
|
|
|
+ {
|
|
|
+ wheelbaseAnim();
|
|
|
+ });
|
|
|
+ Task.Factory.StartNew(() =>
|
|
|
+ {
|
|
|
+ autoCycling();
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
/// <summary>
|