Commit 9512dcc5 authored by 潘栩锋's avatar 潘栩锋 🚴

修改 断开连接后,3min内可以重新自动扫描

parent 35f80508
...@@ -7,6 +7,8 @@ using System.ComponentModel; ...@@ -7,6 +7,8 @@ using System.ComponentModel;
using FlyADBase; using FlyADBase;
using FLY.Thick.Base.Common; using FLY.Thick.Base.Common;
using FLY.Thick.Base.IService; using FLY.Thick.Base.IService;
using System.Diagnostics;
namespace FLY.Thick.Base.Server namespace FLY.Thick.Base.Server
{ {
public abstract class GM_Base : IGageMode, INotifyErrorArisen public abstract class GM_Base : IGageMode, INotifyErrorArisen
...@@ -241,7 +243,9 @@ namespace FLY.Thick.Base.Server ...@@ -241,7 +243,9 @@ namespace FLY.Thick.Base.Server
{ {
GM_AutoScan mGMAutoScan; GM_AutoScan mGMAutoScan;
DynArea mDynArea; DynArea mDynArea;
DateTime dt_lastscan = DateTime.MinValue; Stopwatch stopwatch = new Stopwatch();
bool isReadyToAutoScan = false;
public GM_Disconnected(FlyAD7 flyad) public GM_Disconnected(FlyAD7 flyad)
: base(flyad) : base(flyad)
{ {
...@@ -257,34 +261,50 @@ namespace FLY.Thick.Base.Server ...@@ -257,34 +261,50 @@ namespace FLY.Thick.Base.Server
void mDynArea_PropertyChanged(object sender, PropertyChangedEventArgs e) void mDynArea_PropertyChanged(object sender, PropertyChangedEventArgs e)
{ {
if (e.PropertyName == "FLYADIsConnect") if (e.PropertyName == nameof(mDynArea.FLYADIsConnect))
{ {
if (!mDynArea.FLYADIsConnect) if (!mDynArea.FLYADIsConnect)
{ {
//AD卡已经断开 //AD卡已经断开
//如果刚才在扫描,在1分钟内,AD卡连接后,重新执行扫描动作
if (mDynArea.ControllerState == CTRL_STATE.SCAN) if (mDynArea.ControllerState == CTRL_STATE.SCAN ||
mDynArea.ControllerState == CTRL_STATE.AUTOSCAN)
{ {
dt_lastscan = DateTime.Now; //之前在扫描中
isReadyToAutoScan = true;
stopwatch.Restart();
}
else {
isReadyToAutoScan = false;
stopwatch.Stop();
} }
Start(); Start();
} }
else else
{ {
if (IsRunning) //AD盒已经重新连接上
if (IsRunning)//还在 CTRL_STATE.DISCONNECTED
{ {
if ((DateTime.Now - dt_lastscan) < TimeSpan.FromMinutes(1))//1min 内重新扫描 if (isReadyToAutoScan)
{ {
//断开连接,到现在重新连上,只过了30秒,重新执行扫描 //需要自动扫描
mGMAutoScan.Start(5); if (stopwatch.Elapsed > TimeSpan.FromMinutes(3))
{
isReadyToAutoScan = false;
stopwatch.Stop();
//断开连接,到现在重新连上,只过了3min,重新执行扫描
mGMAutoScan.Start(5);
}
else
{
Stop();
}
} }
else else
{ {
Stop(); Stop();
} }
} }
dt_lastscan = DateTime.MinValue;
} }
} }
} }
...@@ -296,30 +316,17 @@ namespace FLY.Thick.Base.Server ...@@ -296,30 +316,17 @@ namespace FLY.Thick.Base.Server
public override void Stop() public override void Stop()
{ {
IsRunning = false; IsRunning = false;
isReadyToAutoScan = false;
stopwatch.Stop();
} }
} }
public class GM_AutoScan : GM_Base public class GM_AutoScan : GM_Base
{ {
public int Delay public int Delay { get; set; }
{
get; public int Counter { get; set; } = 5;
set;
}
private int counter=5;
public int Counter
{
get { return counter;
}
set {
if (counter != value)
{
counter = value;
NotifyPropertyChanged("Counter");
}
}
}
Action ReScan; Action ReScan;
DateTime dtLast = DateTime.MinValue; DateTime dtLast = DateTime.MinValue;
public GM_AutoScan(FlyAD7 flyad) public GM_AutoScan(FlyAD7 flyad)
...@@ -395,7 +402,7 @@ namespace FLY.Thick.Base.Server ...@@ -395,7 +402,7 @@ namespace FLY.Thick.Base.Server
void GM_Pause_PropertyChanged(object sender, PropertyChangedEventArgs e) void GM_Pause_PropertyChanged(object sender, PropertyChangedEventArgs e)
{ {
if (e.PropertyName == "Enable") if (e.PropertyName == nameof(Enable))
{ {
if (Enable) if (Enable)
{ {
...@@ -442,7 +449,7 @@ namespace FLY.Thick.Base.Server ...@@ -442,7 +449,7 @@ namespace FLY.Thick.Base.Server
} }
void mDynArea_PropertyChanged(object sender, PropertyChangedEventArgs e) void mDynArea_PropertyChanged(object sender, PropertyChangedEventArgs e)
{ {
if (e.PropertyName == "DataValid") if (e.PropertyName == nameof(mDynArea.DataValid))
{ {
if(Enable) if(Enable)
update_datavalid(); update_datavalid();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment