diff --git a/DM_Weight/App.config b/DM_Weight/App.config
index 480ac08..cbce923 100644
--- a/DM_Weight/App.config
+++ b/DM_Weight/App.config
@@ -37,7 +37,7 @@
-
+
@@ -117,8 +117,8 @@
-
-
+
+
diff --git a/DM_Weight/Finger/FingerprintUtil.cs b/DM_Weight/Finger/FingerprintUtil.cs
index 502a6c1..5d957ce 100644
--- a/DM_Weight/Finger/FingerprintUtil.cs
+++ b/DM_Weight/Finger/FingerprintUtil.cs
@@ -19,15 +19,15 @@ namespace DM_Weight.Finger
public class FingerprintUtil
{
- private static ILog logger = LogManager.GetLogger(typeof(FingerprintUtil));
- public static zkemkeeper.CZKEMClass axCZKEM1= new zkemkeeper.CZKEMClass();
- public static bool bIsConnected = false;
+ private ILog logger = LogManager.GetLogger(typeof(FingerprintUtil));
+ public zkemkeeper.CZKEMClass axCZKEM1= new zkemkeeper.CZKEMClass();
+ public bool bIsConnected = false;
- private static string fingerIp = ConfigurationManager.AppSettings["fingerIp"].ToString();
- private static int fingerPort = 4370;
- private static int machineNumber = Convert.ToInt32(ConfigurationManager.AppSettings["machineNumber"].ToString());
- private static int machineType = Convert.ToInt32(ConfigurationManager.AppSettings["machineType"].ToString());
- private static IEventAggregator _eventAggregator;
+ private string fingerIp = ConfigurationManager.AppSettings["fingerIp"].ToString();
+ private int fingerPort = 4370;
+ private int machineNumber = Convert.ToInt32(ConfigurationManager.AppSettings["machineNumber"].ToString());
+ private int machineType = Convert.ToInt32(ConfigurationManager.AppSettings["machineType"].ToString());
+ private IEventAggregator _eventAggregator;
public FingerprintUtil(IEventAggregator eventAggregator)
{
_eventAggregator = eventAggregator;
@@ -38,7 +38,7 @@ namespace DM_Weight.Finger
//});
}
- public static void ConnectionMain()
+ public void ConnectionMain()
{
try
{
@@ -55,9 +55,6 @@ namespace DM_Weight.Finger
}
}
-
- logger.Info($"连接指纹机2");
-
_eventAggregator.GetEvent().Publish(new FingerprintMsg()
{
Message = "CONNECT",
@@ -72,10 +69,11 @@ namespace DM_Weight.Finger
///
/// 用于退出登录重连指纹机
///
- public static void FingerDisconnect()
+ public void FingerDisconnect()
{
try
{
+ logger.Info("重连指纹机");
axCZKEM1.Disconnect();
axCZKEM1.OnAttTransactionEx -= new zkemkeeper._IZKEMEvents_OnAttTransactionExEventHandler(axCZKEM1_OnAttTransactionEx);
axCZKEM1.OnEnrollFingerEx -= new zkemkeeper._IZKEMEvents_OnEnrollFingerExEventHandler(axCZKEM1_OnEnrollFingerEx);
@@ -89,7 +87,7 @@ namespace DM_Weight.Finger
}
//If your fingerprint(or your card) passes the verification,this event will be triggered
- private static void axCZKEM1_OnAttTransactionEx(string sEnrollNumber, int iIsInValid, int iAttState, int iVerifyMethod, int iYear, int iMonth, int iDay, int iHour, int iMinute, int iSecond, int iWorkCode)
+ private void axCZKEM1_OnAttTransactionEx(string sEnrollNumber, int iIsInValid, int iAttState, int iVerifyMethod, int iYear, int iMonth, int iDay, int iHour, int iMinute, int iSecond, int iWorkCode)
{
FingerprintMsg message = new FingerprintMsg()
{
@@ -102,7 +100,7 @@ namespace DM_Weight.Finger
}
//When you are enrolling your finger,this event will be triggered.
- private static void axCZKEM1_OnEnrollFinger(int iEnrollNumber, int iFingerIndex, int iActionResult, int iTemplateLength)
+ private void axCZKEM1_OnEnrollFinger(int iEnrollNumber, int iFingerIndex, int iActionResult, int iTemplateLength)
{
FingerprintMsg message = new FingerprintMsg()
{
@@ -119,7 +117,7 @@ namespace DM_Weight.Finger
_eventAggregator.GetEvent().Publish(message);
}
- private static void axCZKEM1_OnEnrollFingerEx(string iEnrollNumber, int iFingerIndex, int iActionResult, int iTemplateLength)
+ private void axCZKEM1_OnEnrollFingerEx(string iEnrollNumber, int iFingerIndex, int iActionResult, int iTemplateLength)
{
FingerprintMsg message = new FingerprintMsg()
{
diff --git a/DM_Weight/Port/FingerHelper.cs b/DM_Weight/Port/FingerHelper.cs
index c4f3a46..8a52416 100644
--- a/DM_Weight/Port/FingerHelper.cs
+++ b/DM_Weight/Port/FingerHelper.cs
@@ -1,4 +1,5 @@
using Common.Logging;
+using DM_Weight.Finger;
using Mina.Core.Future;
using Mina.Filter.Codec;
using Mina.Transport.Socket;
@@ -18,8 +19,10 @@ namespace DM_Weight.Port
AsyncSocketConnector acceptor = new AsyncSocketConnector();
IConnectFuture iConnectFuture;
string ip = ConfigurationManager.AppSettings["fingerIp"].ToString();
- public FingerHelper()
+ FingerprintUtil _fingerprintUtil;
+ public FingerHelper(FingerprintUtil fingerprintUtil)
{
+ _fingerprintUtil = fingerprintUtil;
acceptor.ExceptionCaught += (o, e) => logger.Error(e.Exception);
//acceptor.FilterChain.AddLast("logger", new LoggingFilter());
@@ -38,6 +41,7 @@ namespace DM_Weight.Port
logger.Info("SessionClosed");
Task.Delay(50).Wait();
SocketConnect();
+ _fingerprintUtil.FingerDisconnect();
};
this.SocketConnect();
}
@@ -45,7 +49,7 @@ namespace DM_Weight.Port
{
iConnectFuture = acceptor.Connect(new IPEndPoint(IPAddress.Parse(ip), 4370)).Await();
- Console.WriteLine(iConnectFuture.Connected.ToString());
+ logger.Info($"再次连接结果:{iConnectFuture.Connected.ToString()}");
}
public void SendMessage(MyBaseMessage baseMessage)
diff --git a/DM_Weight/Port/ModbusHelper.cs b/DM_Weight/Port/ModbusHelper.cs
index e669eb2..3b197a9 100644
--- a/DM_Weight/Port/ModbusHelper.cs
+++ b/DM_Weight/Port/ModbusHelper.cs
@@ -81,10 +81,10 @@ namespace DM_Weight.Port
BoxOperate = false;
this.SetModusIpMaster();
// return TimeSpan.FromSeconds (1);
- Task.Factory.StartNew(() =>
- {
- FingerprintUtil.FingerDisconnect();
- });
+ //Task.Factory.StartNew(() =>
+ //{
+ // FingerprintUtil.FingerDisconnect();
+ //});
}).Execute(() =>
{
bool[] flags = new bool[18];
@@ -120,10 +120,10 @@ namespace DM_Weight.Port
logger.Info($"打开箱子出错,第{retryCount}次重试,异常信息{exception}");
Thread.Sleep(50);
this.SetModusIpMaster();
- Task.Factory.StartNew(() =>
- {
- FingerprintUtil.FingerDisconnect();
- });
+ //Task.Factory.StartNew(() =>
+ //{
+ // FingerprintUtil.FingerDisconnect();
+ //});
//return TimeSpan.FromSeconds (1);
})).Execute(() =>
{
@@ -173,6 +173,7 @@ namespace DM_Weight.Port
private static SpeechSynthesizer speechSynthesizer = new SpeechSynthesizer();
public static void SpeakAsync(string textinfo)
{
+ speechSynthesizer.Rate = 2;
speechSynthesizer.SpeakAsync(textinfo);
}
}
diff --git a/DM_Weight/Port/SocketHelper.cs b/DM_Weight/Port/SocketHelper.cs
index 27727d5..42eb96a 100644
--- a/DM_Weight/Port/SocketHelper.cs
+++ b/DM_Weight/Port/SocketHelper.cs
@@ -1,4 +1,5 @@
-using DM_Weight.Models;
+using DM_Weight.Finger;
+using DM_Weight.Models;
using DM_Weight.msg;
using DM_Weight.util;
using DM_Weight.ViewModels;
@@ -31,9 +32,11 @@ namespace DM_Weight.Port
string ip = ConfigurationManager.AppSettings["modbusIp"].ToString();
int port =Convert.ToInt32(ConfigurationManager.AppSettings["modbusPort"]);
IEventAggregator _eventAggregator;
- public SocketHelper(IEventAggregator eventAggregator)
+ public DateTime dateTime { get; set; } = DateTime.Now;
+ FingerprintUtil _fingerprintUtil;
+ public SocketHelper(IEventAggregator eventAggregator, FingerprintUtil fingerprintUtil)
{
- _eventAggregator=eventAggregator;
+ _eventAggregator = eventAggregator;
acceptor.ExceptionCaught += (o, e) =>
{
logger.Error($"网口通信超时:{e.Exception}");
@@ -54,17 +57,16 @@ namespace DM_Weight.Port
{
OpenStatus = (bool)e.Message;
logger.Info("MessageReceived>>>>>>>>>>>>>>>>" + OpenStatus);
- if(OpenStatus)
- {
- HomeWindow.idleTimer.Stop();
- }
- else
- {
- HomeWindow.idleTimer.AutoReset = true;
- HomeWindow.idleTimer.Interval = Convert.ToInt32(ConfigurationManager.AppSettings["autoExit"] ?? "0") * 1000;
- HomeWindow.idleTimer.Start();
+ //if(OpenStatus)
+ //{
+ // HomeWindow.idleTimer.Stop();
+ //}
+ //else
+ //{
+ // HomeWindow.idleTimer.Interval = Convert.ToInt32(ConfigurationManager.AppSettings["autoExit"] ?? "0") * 1000;
+ // HomeWindow.idleTimer.Start();
- }
+ //}
};
@@ -73,15 +75,44 @@ namespace DM_Weight.Port
logger.Info("SessionClosed");
//Task.Delay(50).Wait();
SocketConnect();
+ Task.Factory.StartNew(() =>
+ {
+ _fingerprintUtil.FingerDisconnect();
+ });
};
this.SocketConnect();
+ _fingerprintUtil = fingerprintUtil;
}
+ int i = 0;
public void SocketConnect()
{
-
+ Thread.Sleep(50);
+ i++;
iConnectFuture = acceptor.Connect(new IPEndPoint(IPAddress.Parse(ip), port)).Await();
+ logger.Info($"第{i}次连接结果:{iConnectFuture.Connected.ToString()}");
+ if (!iConnectFuture.Connected)
+ {
+ if (i <= 3)
+ {
+ //没连上会再连两次
+ SocketConnect();
+ }
+ else
+ {
+ logger.Error($"尝试{i}次连接后均连接不上");
+ AlertMsg alertMsg = new AlertMsg
+ {
+ Message = $"网口连接断开!",
+ Type = MsgType.ERROR
+ };
+ _eventAggregator.GetEvent().Publish(alertMsg);
+ }
+ }
+ else
+ {
+ i = 0;
+ }
- logger.Info(iConnectFuture.Connected.ToString());
}
public void SendMessage(MyBaseMessage baseMessage)
diff --git a/DM_Weight/ViewModels/CheckOrderNewWindowViewModel.cs b/DM_Weight/ViewModels/CheckOrderNewWindowViewModel.cs
index 9c00981..6c8e8ca 100644
--- a/DM_Weight/ViewModels/CheckOrderNewWindowViewModel.cs
+++ b/DM_Weight/ViewModels/CheckOrderNewWindowViewModel.cs
@@ -862,6 +862,7 @@ namespace DM_Weight.ViewModels
try
{
_socketHelper.SendMessage(new MyBaseMessage() { lockNo = (short)(DrawerNo) });
+ _socketHelper.dateTime = DateTime.Now;
}
catch (Exception ex)
{
@@ -871,12 +872,14 @@ namespace DM_Weight.ViewModels
Type = MsgType.ERROR,
};
_eventAggregator.GetEvent().Publish(alertMsg);
+ logger.Info($"网口连接异常,正在重试{ex.Message}");
return;
}
_socketHelper.OpenStatus = true;
Thread.Sleep(200);
- int i = 10;
- new PromiseUtil().taskAsyncLoop(500, 0, async (options, next, stop) =>
+ int i = 40;
+ int iException = 0;
+ new PromiseUtil().taskAsyncLoop(200, 0, async (options, next, stop) =>
{
_socketHelper.IsMultiThread = true;
@@ -896,30 +899,43 @@ namespace DM_Weight.ViewModels
if (i == 0)
{
ModbusHelper.SpeakAsync("请及时关闭药箱");
- i = 10;
+ i = 40;
}
next();
}
else
{
+ _socketHelper.OpenStatus = false;
+ _socketHelper.IsMultiThread = false;
+ _socketHelper.dateTime = DateTime.Now;
stop();
}
}
else
{
+ _socketHelper.OpenStatus = false;
_socketHelper.IsMultiThread = false;
+ _socketHelper.dateTime = DateTime.Now;
stop();
}
+ iException = 0;
}
catch (Exception ex)
{
- _socketHelper.OpenStatus = false;
+ iException++;
+ if (iException >= 3)
+ {
+ _socketHelper.OpenStatus = false;
+ }
+ // _socketHelper.OpenStatus = false;
AlertMsg alertMsg = new AlertMsg
{
Message = $"网口连接异常,正在重试{ex.Message}",
Type = MsgType.ERROR,
};
_eventAggregator.GetEvent().Publish(alertMsg);
+ logger.Info($"网口连接异常,正在重试{ex.Message}");
+ next();
}
});
diff --git a/DM_Weight/ViewModels/HomeWindowViewModel.cs b/DM_Weight/ViewModels/HomeWindowViewModel.cs
index 1453e1b..b5c444f 100644
--- a/DM_Weight/ViewModels/HomeWindowViewModel.cs
+++ b/DM_Weight/ViewModels/HomeWindowViewModel.cs
@@ -570,48 +570,31 @@ namespace DM_Weight.ViewModels
FindDrawerCount();
int autoExit = Convert.ToInt32(ConfigurationManager.AppSettings["autoExit"] ?? "0");
- //int stopRecord = Convert.ToInt32(ConfigurationManager.AppSettings["stopRecord"] ?? "0");
- //if (autoExit > 0)
- //{
- // System.Timers.Timer timer = new System.Timers.Timer();
- // timer.Interval = 100;
- // timer.Elapsed += (sender, e) =>
- // {
- // // 串口无人操作
- // bool[] boolArrs = ModbusHelper.GetInstance().GetAllBoxState();
- // bool allTrue = Array.TrueForAll(boolArrs, b => b==false);
- // logger.Info($"进入自动退出定时方法{allTrue}");
- // //false是关着,true是开着
- // if (allTrue)
- // {
- // //PerformanceCounter pc = new PerformanceCounter("System", "% Idle Time", true);
- // //float systemIdleTime = pc.NextValue();
- // //Console.WriteLine($"systemIdleTime:{systemIdleTime}");
-
- // //// 获取系统空闲时间
- // //TimeSpan idleTime = SystemInformation.IdleTime;
- // //// 打印空闲时间
- // //Console.WriteLine("系统空闲时间: " + idleTime.ToString());
- // long lTime = CheckComputerFreeState.GetLastInputTime();
- // logger.Info($"自动退出时间{lTime}");
- // // 30秒内无人操作鼠标键盘
- // //if ((DateTime.Now - _portUtil.dateTime).TotalSeconds > autoExit && CheckComputerFreeState.GetLastInputTime() > autoExit)
- // if (lTime > autoExit)
- // {
- // logger.Info($"设备{autoExit}秒内无人操作,用户【{Operator?.Nickname}】自动退出登录");
- // _chkFunction.HIKStopDVRRecord();
- // Operator = null;
- // Reviewer = null;
- // Application.Current.Dispatcher.Invoke(() =>
- // {
- // _regionManager.RequestNavigate("MainRegion", "LoginWindow");
- // timer.Stop();
- // });
- // }
- // }
- // };
- // timer.Start();
- //}
+ if (autoExit > 0)
+ {
+ System.Timers.Timer timer = new System.Timers.Timer();
+ timer.Interval = autoExit* 1000;
+ timer.Elapsed += (sender, e) =>
+ {
+ // 串口无人操作
+ if (!_socketHelper.OpenStatus)
+ {
+ // 无人操作鼠标键盘
+ if ((DateTime.Now - _socketHelper.dateTime).TotalSeconds > autoExit && CheckComputerFreeState.GetLastInputTime() > autoExit)
+ {
+ logger.Info($"设备内无人操作,用户【{Operator?.Nickname}】自动退出登录");
+ Operator = null;
+ Reviewer = null;
+ Application.Current.Dispatcher.Invoke(() =>
+ {
+ _regionManager.RequestNavigate("MainRegion", "LoginWindow");
+ timer.Stop();
+ });
+ }
+ }
+ };
+ timer.Start();
+ }
#region 温度查询定时
//int interval = Convert.ToInt32(ConfigurationManager.AppSettings["Interval"]);
//if (interval > 0)
@@ -624,7 +607,7 @@ namespace DM_Weight.ViewModels
// //WDTimer.AutoReset = true;
// //WDTimer.Enabled = true;
//}
- Task.Factory.StartNew(async () =>
+ Task.Factory.StartNew(() =>
{
while (true)
{
@@ -639,7 +622,7 @@ namespace DM_Weight.ViewModels
AddTime = DateTime.Now
}).ExecuteCommand();
logger.Info($"保存温湿度信息:{temp.Temp},{temp.Humi}");
- await Task.Delay(1200000);//20分钟查一次
+ Task.Delay(1200000);//20分钟查一次
}
else
{
@@ -688,14 +671,14 @@ namespace DM_Weight.ViewModels
Reviewer = null;
try
{
- if (_socketHelper.IsMultiThread)
- {
- Application.Current.Dispatcher.BeginInvoke(() =>
- {
- _regionManager.RequestNavigate("MainRegion", "LoginWindow");
- });
- }
- else
+ //if (_socketHelper.IsMultiThread)
+ //{
+ // Application.Current.Dispatcher.BeginInvoke(() =>
+ // {
+ // _regionManager.RequestNavigate("MainRegion", "LoginWindow");
+ // });
+ //}
+ //else
{
diff --git a/DM_Weight/ViewModels/LoginWindowViewModel.cs b/DM_Weight/ViewModels/LoginWindowViewModel.cs
index 9893856..f21b754 100644
--- a/DM_Weight/ViewModels/LoginWindowViewModel.cs
+++ b/DM_Weight/ViewModels/LoginWindowViewModel.cs
@@ -62,7 +62,7 @@ namespace DM_Weight.ViewModels
}
private HkcChangeShifts listHkcChangeShifts=new HkcChangeShifts();
- //private FingerprintUtil _fingerprintUtil;
+ private FingerprintUtil _fingerprintUtil;
private PortUtil _portUtil;
@@ -114,17 +114,17 @@ namespace DM_Weight.ViewModels
// _regionManager = regionManager;
// _eventAggregator = eventAggregator;
//}
- public LoginWindowViewModel(IRegionManager regionManager, IEventAggregator eventAggregator, PortUtil portUtil)
+ public LoginWindowViewModel(IRegionManager regionManager, IEventAggregator eventAggregator, PortUtil portUtil,FingerprintUtil fingerprintUtil)
{
- //_fingerprintUtil = fingerprintUtil;
+ _fingerprintUtil = fingerprintUtil;
_portUtil = portUtil;
_regionManager = regionManager;
_eventAggregator = eventAggregator;
- //FingerMsg = !_fingerprintUtil.bIsConnected;
- FingerMsg = !FingerprintUtil.bIsConnected;
+ FingerMsg = !_fingerprintUtil.bIsConnected;
+ //FingerMsg = !FingerprintUtil.bIsConnected;
_eventAggregator.GetEvent().Subscribe(LoginEvent);
- logger.Info($"LoginWindowViewModel;FingerMsg:{FingerprintUtil.bIsConnected}");
- //_fingerprintUtil.FingerDisconnect();
+ logger.Info($"LoginWindowViewModel;FingerMsg:{_fingerprintUtil.bIsConnected}");
+ _fingerprintUtil.FingerDisconnect();
}
private DelegateCommand? _loginCommand;
diff --git a/DM_Weight/ViewModels/MainWindowViewModel.cs b/DM_Weight/ViewModels/MainWindowViewModel.cs
index 460b9a6..a21acc9 100644
--- a/DM_Weight/ViewModels/MainWindowViewModel.cs
+++ b/DM_Weight/ViewModels/MainWindowViewModel.cs
@@ -106,7 +106,7 @@ namespace DM_Weight.ViewModels
}
if (_socketHelper.IsMultiThread)
{
- Application.Current.Dispatcher.Invoke(new Action(() => {
+ Application.Current.Dispatcher.BeginInvoke(new Action(() => {
this.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c"));
SnackbarMessageQueue.Enqueue(msg.Message);
}));
diff --git a/DM_Weight/ViewModels/OpenBoxNewWindowViewModel.cs b/DM_Weight/ViewModels/OpenBoxNewWindowViewModel.cs
index 5804416..0b6565d 100644
--- a/DM_Weight/ViewModels/OpenBoxNewWindowViewModel.cs
+++ b/DM_Weight/ViewModels/OpenBoxNewWindowViewModel.cs
@@ -662,6 +662,7 @@ namespace DM_Weight.ViewModels
try
{
_socketHelper.SendMessage(new MyBaseMessage() { lockNo = (short)(DrawerNo - 1) });
+ _socketHelper.dateTime = DateTime.Now;
}
catch (Exception ex)
{
@@ -709,8 +710,9 @@ namespace DM_Weight.ViewModels
// }
//});
Thread.Sleep(200);
- int i = 10;
- new PromiseUtil().taskAsyncLoop(500, 0, async (options, next, stop) =>
+ int i = 40;
+ int iException = 0;
+ new PromiseUtil().taskAsyncLoop(200, 0, async (options, next, stop) =>
{
_socketHelper.IsMultiThread = true;
try
@@ -730,30 +732,41 @@ namespace DM_Weight.ViewModels
if (i == 0)
{
ModbusHelper.SpeakAsync("请及时关闭药箱");
- i = 10;
+ i = 40;
}
next();
}
else
{
+ _socketHelper.IsMultiThread = false;
+ _socketHelper.OpenStatus = false;
+ _socketHelper.dateTime=DateTime.Now;
stop();
}
}
else
{
_socketHelper.IsMultiThread = false;
+ _socketHelper.OpenStatus = false;
+ _socketHelper.dateTime = DateTime.Now;
stop();
}
+ iException = 0;
}
catch (Exception ex)
{
- _socketHelper.OpenStatus = false;
+ iException++;
+ if (iException >= 3)
+ {
+ _socketHelper.OpenStatus = false;
+ }
AlertMsg alertMsg = new AlertMsg
{
Message = $"网口连接异常,正在重试{ex.Message}",
Type = MsgType.ERROR,
};
_eventAggregator.GetEvent().Publish(alertMsg);
+ next();
}
});
//StateTimer.Start();
diff --git a/DM_Weight/Views/HomeWindow.xaml.cs b/DM_Weight/Views/HomeWindow.xaml.cs
index 2344e42..1f2f420 100644
--- a/DM_Weight/Views/HomeWindow.xaml.cs
+++ b/DM_Weight/Views/HomeWindow.xaml.cs
@@ -32,54 +32,56 @@ namespace DM_Weight.Views
{
private readonly ILog logger = LogManager.GetLogger(typeof(HomeWindow));
int autoExit = Convert.ToInt32(ConfigurationManager.AppSettings["autoExit"] ?? "0");
- public static System.Timers.Timer idleTimer;//= new System.Timers.Timer(60000);
+ //public static System.Timers.Timer idleTimer;//= new System.Timers.Timer(60000);
IEventAggregator _eventAggregator;
SocketHelper _socketHelper;
public HomeWindow(IEventAggregator eventAggregator, SocketHelper socketHelper)
{
InitializeComponent();
- if (autoExit > 0)
- {
- idleTimer = new System.Timers.Timer(autoExit * 1000);
- idleTimer.Elapsed += OnTimerElapsed;
- this.MouseDown += OnUserActivity;
- this.MouseMove += OnUserActivity;
- this.KeyDown += OnUserActivity;
- idleTimer.Start();
- _eventAggregator = eventAggregator;
- }
+ //if (autoExit > 0)
+ //{
+ // idleTimer = new System.Timers.Timer(autoExit * 1000);
+ // idleTimer.Elapsed += OnTimerElapsed;
+ // idleTimer.AutoReset = true;
+ // idleTimer.Enabled= true;
+ // this.MouseDown += OnUserActivity;
+ // this.MouseMove += OnUserActivity;
+ // this.KeyDown += OnUserActivity;
+ // idleTimer.Start();
+ // _eventAggregator = eventAggregator;
+ //}
_socketHelper = socketHelper;
}
- private void OnUserActivity(object sender, EventArgs e)
- {
- idleTimer.Stop();
-
- idleTimer.AutoReset = true;
- idleTimer.Interval =autoExit * 1000;
- idleTimer.Start();
- }
- private void OnTimerElapsed(object sender, ElapsedEventArgs e)
- {
- // 串口无人操作
- //bool[] boolArrs = ModbusHelper.GetInstance().GetAllBoxState();
- //bool allTrue = Array.TrueForAll(boolArrs, b => b == false);
- logger.Info($"进入自动退出定时方法{ModbusHelper.BoxOperate}");
- //if (ModbusHelper.BoxOperate)
- if (!_socketHelper.OpenStatus)
- {
- if (idleTimer.Enabled)
- {
- idleTimer.Stop();
- //无人操作,自动退出
- _eventAggregator.GetEvent().Publish();
- }
- }
- //else
- //{
- // idleTimer.Interval = autoExit * 1000;
- // idleTimer.AutoReset = true;
- //}
- }
+ //private void OnUserActivity(object sender, EventArgs e)
+ //{
+ // idleTimer.Stop();
+ // idleTimer.Interval =autoExit * 1000;
+ // idleTimer.Start();
+ //}
+ //private void OnTimerElapsed(object sender, ElapsedEventArgs e)
+ //{
+ // idleTimer.Stop();
+ // // 串口无人操作
+ // //bool[] boolArrs = ModbusHelper.GetInstance().GetAllBoxState();
+ // //bool allTrue = Array.TrueForAll(boolArrs, b => b == false);
+ // logger.Info($"进入自动退出定时方法{ModbusHelper.BoxOperate}");
+ // //if (ModbusHelper.BoxOperate)
+ // if (!_socketHelper.OpenStatus)
+ // {
+ // if (idleTimer.Enabled)
+ // {
+ // idleTimer.Stop();
+ // //无人操作,自动退出
+ // _eventAggregator.GetEvent().Publish();
+ // }
+ // }
+ // idleTimer.Start();
+ // //else
+ // //{
+ // // idleTimer.Interval = autoExit * 1000;
+ // // idleTimer.AutoReset = true;
+ // //}
+ //}
}
}