修改开药箱、温度查询逻辑
This commit is contained in:
parent
303c6f337d
commit
b1974bd1a5
|
@ -117,8 +117,8 @@
|
|||
<add key="HIKPassword" value="HKC123456"/>
|
||||
|
||||
<!--交接柜网口地址及端口-->
|
||||
<add key="modbusIp" value="10.1.100.13"/>
|
||||
<add key="modbusPort" value="502"/>
|
||||
<add key="modbusIp" value="127.0.0.1"/>
|
||||
<add key="modbusPort" value="4002"/>
|
||||
|
||||
<!--温湿度串口-->
|
||||
<add key="wsdSerialPort" value="COM1"/>
|
||||
|
|
|
@ -113,6 +113,12 @@ namespace DM_Weight.Models
|
|||
{
|
||||
get;set;
|
||||
}
|
||||
//归属用户的用户名
|
||||
[SugarColumn(ColumnName = "commnet")]
|
||||
public string BelongUserName
|
||||
{
|
||||
get;set;
|
||||
}
|
||||
//private int _addQuantity = 0;
|
||||
//[SugarColumn(IsIgnore = true)]
|
||||
//public int AddQuantity
|
||||
|
@ -209,8 +215,8 @@ namespace DM_Weight.Models
|
|||
[SugarColumn(ColumnName = "drug_manu_no")]
|
||||
public string DrugSpec { get=> _drugSpec;set=>SetProperty(ref _drugSpec, value); }
|
||||
|
||||
private string _belongUserName;
|
||||
[SugarColumn(IsIgnore =true)]
|
||||
public string BelongUserName { get => _belongUserName;set=>SetProperty(ref _belongUserName, value); }
|
||||
//private string _belongUserName;
|
||||
//[SugarColumn(IsIgnore =true)]
|
||||
//public string BelongUserName { get => _belongUserName;set=>SetProperty(ref _belongUserName, value); }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,12 +10,12 @@ namespace DM_Weight.Port
|
|||
{
|
||||
public int addr { get; set; } = 1;
|
||||
public short lockNo { get; set; }
|
||||
public short delay { get; set; } = 20;
|
||||
public short delay { get; set; } = 2;
|
||||
public int functionCode { get; set; } = 6;
|
||||
|
||||
|
||||
public MyBaseMessage() { }
|
||||
public MyBaseMessage(short lockNo, int addr = 1, short delay = 20, int functionCode = 6)
|
||||
public MyBaseMessage(short lockNo, int addr = 1, short delay = 2, int functionCode = 6)
|
||||
{
|
||||
this.addr = addr;
|
||||
this.lockNo = lockNo;
|
||||
|
|
|
@ -68,8 +68,6 @@ namespace DM_Weight.Port
|
|||
|
||||
//}
|
||||
};
|
||||
|
||||
|
||||
acceptor.SessionClosed += (o, e) =>
|
||||
{
|
||||
logger.Info("SessionClosed");
|
||||
|
|
|
@ -395,8 +395,9 @@ namespace DM_Weight.ViewModels
|
|||
//}
|
||||
|
||||
//TotalCount = totalCount;
|
||||
PageCount = (int)Math.Ceiling((double)TotalCount / PageSize);
|
||||
if (currentList != null && currentList.EffDate != null && Convert.ToDateTime(currentList.EffDate).ToString("yyyy-MM-dd") == DateTime.Now.ToString("yyyy-MM-dd"))
|
||||
//PageCount = (int)Math.Ceiling((double)TotalCount / PageSize);
|
||||
//if (currentList != null && currentList.EffDate != null && Convert.ToDateTime(currentList.EffDate).ToString("yyyy-MM-dd") == DateTime.Now.ToString("yyyy-MM-dd"))
|
||||
if (currentList != null && currentList.EffDate != null)
|
||||
{
|
||||
switch (DrawerNo)
|
||||
{
|
||||
|
@ -905,17 +906,17 @@ namespace DM_Weight.ViewModels
|
|||
}
|
||||
else
|
||||
{
|
||||
_socketHelper.OpenStatus = false;
|
||||
_socketHelper.IsMultiThread = false;
|
||||
_socketHelper.dateTime = DateTime.Now;
|
||||
//_socketHelper.OpenStatus = false;
|
||||
_socketHelper.IsMultiThread = false;
|
||||
stop();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_socketHelper.OpenStatus = false;
|
||||
_socketHelper.IsMultiThread = false;
|
||||
_socketHelper.dateTime = DateTime.Now;
|
||||
//_socketHelper.OpenStatus = false;
|
||||
_socketHelper.IsMultiThread = false;
|
||||
stop();
|
||||
}
|
||||
iException = 0;
|
||||
|
@ -975,6 +976,7 @@ namespace DM_Weight.ViewModels
|
|||
public void OnNavigatedTo(NavigationContext navigationContext)
|
||||
{
|
||||
RequestData();
|
||||
|
||||
List<ChannelList> listCls = SqlSugarHelper.Db.Queryable<ChannelList>()
|
||||
.LeftJoin<UserList>((cl, ul) => ul.UserBarcode == cl.BelongUser)
|
||||
.Where(cl => cl.MachineId == "DM5")
|
||||
|
|
|
@ -25,6 +25,8 @@ using DM_Weight.msg;
|
|||
using DM_Weight.HIKVISION;
|
||||
using System.Threading;
|
||||
using System.Diagnostics;
|
||||
using MaterialDesignThemes.Wpf;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace DM_Weight.ViewModels
|
||||
{
|
||||
|
@ -148,7 +150,15 @@ namespace DM_Weight.ViewModels
|
|||
// }
|
||||
// }
|
||||
// }
|
||||
SetProperty(ref _selectedChildMenu, value);
|
||||
if (!_socketHelper.OpenStatus)
|
||||
{
|
||||
SetProperty(ref _selectedChildMenu, value);
|
||||
}
|
||||
else
|
||||
{
|
||||
ModbusHelper.SpeakAsync("请先关药箱");
|
||||
return;
|
||||
}
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
@ -216,20 +226,23 @@ namespace DM_Weight.ViewModels
|
|||
_regionManager.RequestNavigate("ContentRegion", "ReturnDrugWindow");
|
||||
}
|
||||
}
|
||||
else if (SelectedChildMenu.PremissionPath.Equals("SettingMainWindow") || SelectedChildMenu.PremissionPath.Equals("SettingWindow"))
|
||||
//else if (SelectedChildMenu.PremissionPath.Equals("SettingMainWindow") || SelectedChildMenu.PremissionPath.Equals("SettingWindow"))
|
||||
//{
|
||||
// if (Convert.ToInt32(ConfigurationManager.AppSettings["hasFridge"]) > 0)
|
||||
// {
|
||||
// _regionManager.RequestNavigate("ContentRegion", "SettingMainWindow");
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// _regionManager.RequestNavigate("ContentRegion", "SettingWindow");
|
||||
// }
|
||||
//}
|
||||
//else
|
||||
{
|
||||
if (Convert.ToInt32(ConfigurationManager.AppSettings["hasFridge"]) > 0)
|
||||
System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() =>
|
||||
{
|
||||
_regionManager.RequestNavigate("ContentRegion", "SettingMainWindow");
|
||||
}
|
||||
else
|
||||
{
|
||||
_regionManager.RequestNavigate("ContentRegion", "SettingWindow");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_regionManager.RequestNavigate("ContentRegion", SelectedChildMenu.PremissionPath);
|
||||
_regionManager.RequestNavigate("ContentRegion", SelectedChildMenu.PremissionPath);
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -255,9 +268,16 @@ namespace DM_Weight.ViewModels
|
|||
// SelectedChildMenu = value.Children[0];
|
||||
// }
|
||||
//}
|
||||
SetProperty(ref _selectedMenu, value);
|
||||
if (!_socketHelper.OpenStatus)
|
||||
SetProperty(ref _selectedMenu, value);
|
||||
else
|
||||
{
|
||||
ModbusHelper.SpeakAsync("请先关药箱");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
//PremissionDm? PreSelectedMenu;
|
||||
|
||||
private DelegateCommand _selectionCommon;
|
||||
public DelegateCommand SelectionCommon
|
||||
|
@ -266,6 +286,17 @@ namespace DM_Weight.ViewModels
|
|||
}
|
||||
private void SelectionMethod()
|
||||
{
|
||||
//if (SelectedMenu != null && SelectedMenu.PremissionName != "退出")
|
||||
//{
|
||||
// PreSelectedMenu = SelectedMenu;
|
||||
//}
|
||||
//if (_socketHelper.OpenStatus)
|
||||
//{
|
||||
// if (PreSelectedMenu != null)
|
||||
// {
|
||||
// SelectedMenu = PreSelectedMenu;
|
||||
// }
|
||||
//}
|
||||
//SelectedMenu = viewName.SelectedItem as PremissionDm;
|
||||
//if (SelectedMenu.PremissionName == "退出")
|
||||
//{
|
||||
|
@ -290,31 +321,19 @@ namespace DM_Weight.ViewModels
|
|||
//bool[] boolArrs = ModbusHelper.GetInstance().GetAllBoxState();
|
||||
//bool allTrue = Array.TrueForAll(boolArrs, b => b);
|
||||
//false是关着,true是开着
|
||||
if (!_socketHelper.OpenStatus)
|
||||
//if (ModbusHelper.BoxOperate)
|
||||
{
|
||||
logger.Info($"用户【{Operator?.Nickname}】退出登录");
|
||||
Operator = null;
|
||||
Reviewer = null;
|
||||
_regionManager.RequestNavigate("MainRegion", "LoginWindow");
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
//还有药箱开着不能退出
|
||||
ModbusHelper.SpeakAsync("请关闭药箱后再退出");
|
||||
SelectedMenu = _premissionDmList[0];
|
||||
}
|
||||
logger.Info($"用户【{Operator?.Nickname}】退出登录");
|
||||
Operator = null;
|
||||
Reviewer = null;
|
||||
_regionManager.RequestNavigate("MainRegion", "LoginWindow");
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
//SelectedMenu.Children = SelectedMenu.Children;
|
||||
//SelectedChildMenu = SelectedMenu.Children[0];
|
||||
//if (!_portUtil.Operate)
|
||||
//{
|
||||
_regionManager.RequestNavigate("ContentRegion", SelectedMenu.Children[0].PremissionPath);
|
||||
//}
|
||||
if (!_socketHelper.OpenStatus)
|
||||
{
|
||||
_regionManager.RequestNavigate("ContentRegion", SelectedMenu.Children[0].PremissionPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
#region 子菜单点击
|
||||
|
@ -347,6 +366,8 @@ namespace DM_Weight.ViewModels
|
|||
IEventAggregator _eventAggregator;
|
||||
//private ModbusHelper _modbusHelper;
|
||||
SocketHelper _socketHelper;
|
||||
//System.Timers.Timer timer;
|
||||
//DispatcherTimer timerNew;
|
||||
public HomeWindowViewModel(IRegionManager iRegionManager, PortUtil portUtil, IUnityContainer container, IDialogService dialogService, IEventAggregator eventAggregator, SocketHelper socketHelper)
|
||||
{
|
||||
_portUtil = portUtil;
|
||||
|
@ -355,8 +376,84 @@ namespace DM_Weight.ViewModels
|
|||
_container = container;
|
||||
this._eventAggregator = eventAggregator;
|
||||
_socketHelper = socketHelper;
|
||||
//_chkFunction = cHKFunction;
|
||||
//_modbusHelper = modbusHelper;
|
||||
//timerNew = new DispatcherTimer();
|
||||
//int autoExit = Convert.ToInt32(ConfigurationManager.AppSettings["autoExit"] ?? "0");
|
||||
//if (autoExit > 0)
|
||||
//{
|
||||
// timerNew.Interval =new TimeSpan(0, 0, 0, 1, 0); //autoExit * 1000;
|
||||
// timerNew.Tick += (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(() =>
|
||||
// //{
|
||||
// //System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() =>
|
||||
// //{
|
||||
// _regionManager.RequestNavigate("MainRegion", "LoginWindow");
|
||||
// //}));
|
||||
// //});
|
||||
// timerNew.Stop();
|
||||
// //timer.Dispose();
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// _socketHelper.dateTime = DateTime.Now;
|
||||
// }
|
||||
|
||||
|
||||
// };
|
||||
// timerNew.Start();
|
||||
//}
|
||||
int autoExit = Convert.ToInt32(ConfigurationManager.AppSettings["autoExit"] ?? "0");
|
||||
if (autoExit > 0)
|
||||
{
|
||||
int interval= autoExit * 1000;
|
||||
new PromiseUtil<int>().taskAsyncLoop(interval, 0, async (options, next, stop) =>
|
||||
{
|
||||
try
|
||||
{
|
||||
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(() =>
|
||||
//{
|
||||
System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() =>
|
||||
{
|
||||
_regionManager.RequestNavigate("MainRegion", "LoginWindow");
|
||||
}));
|
||||
//});
|
||||
stop();
|
||||
//timer.Dispose();
|
||||
}
|
||||
else
|
||||
{
|
||||
next();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_socketHelper.dateTime = DateTime.Now;
|
||||
next();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.Info($"自动退出异常:{ex.Message}");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public DelegateCommand<string> OpenFingerDialog
|
||||
|
@ -530,7 +627,6 @@ namespace DM_Weight.ViewModels
|
|||
//接收导航传过来的参数
|
||||
public void OnNavigatedTo(NavigationContext navigationContext)
|
||||
{
|
||||
|
||||
_eventAggregator.GetEvent<LoginOutEvent>().Subscribe(SetLoginOut);
|
||||
//_portUtil.dateTime = DateTime.Now;
|
||||
//取出user
|
||||
|
@ -570,32 +666,6 @@ namespace DM_Weight.ViewModels
|
|||
_regionManager.RequestNavigate("ContentRegion", premissions[0].Children[0].PremissionPath);
|
||||
FindDrawerCount();
|
||||
|
||||
int autoExit = Convert.ToInt32(ConfigurationManager.AppSettings["autoExit"] ?? "0");
|
||||
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)
|
||||
|
@ -608,29 +678,7 @@ namespace DM_Weight.ViewModels
|
|||
// //WDTimer.AutoReset = true;
|
||||
// //WDTimer.Enabled = true;
|
||||
//}
|
||||
Task.Factory.StartNew(() =>
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
TemperatureHumidityInfo temp = _portUtil.GetWSD();
|
||||
if (temp != null)
|
||||
{
|
||||
SqlSugarHelper.Db.Insertable(new TemperatureHumidityInfo()
|
||||
{
|
||||
GroupNo = temp.GroupNo,
|
||||
Temp = temp.Temp,
|
||||
Humi = temp.Humi,
|
||||
AddTime = DateTime.Now
|
||||
}).ExecuteCommand();
|
||||
logger.Info($"保存温湿度信息:{temp.Temp},{temp.Humi}");
|
||||
Task.Delay(1200000);//20分钟查一次
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.Info("温湿度信息返回空");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
#endregion
|
||||
//if (stopRecord > 0)
|
||||
//{
|
||||
|
@ -691,7 +739,7 @@ namespace DM_Weight.ViewModels
|
|||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.Info($"自动退出异常:{ex.Message}");
|
||||
logger.Info($"自动退出异常:{ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -120,11 +120,8 @@ namespace DM_Weight.ViewModels
|
|||
_portUtil = portUtil;
|
||||
_regionManager = regionManager;
|
||||
_eventAggregator = eventAggregator;
|
||||
FingerMsg = !_fingerprintUtil.bIsConnected;
|
||||
//FingerMsg = !FingerprintUtil.bIsConnected;
|
||||
_eventAggregator.GetEvent<FingerprintEvent>().Subscribe(LoginEvent);
|
||||
logger.Info($"LoginWindowViewModel;FingerMsg:{_fingerprintUtil.bIsConnected}");
|
||||
_fingerprintUtil.FingerDisconnect();
|
||||
}
|
||||
private DelegateCommand? _loginCommand;
|
||||
|
||||
|
@ -262,10 +259,10 @@ _exitCommand ??= new DelegateCommand(Exit);
|
|||
{
|
||||
//添加参数,键值对格式
|
||||
keys.Add("operator", user);
|
||||
//System.Windows.Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() =>
|
||||
//{
|
||||
System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() =>
|
||||
{
|
||||
_regionManager.RequestNavigate("MainRegion", "HomeWindow", keys);
|
||||
//}));
|
||||
}));
|
||||
}
|
||||
// 双人登录模式
|
||||
else
|
||||
|
@ -278,10 +275,10 @@ _exitCommand ??= new DelegateCommand(Exit);
|
|||
keys.Add("reviewer", user);
|
||||
Reviewer = user;
|
||||
RaisePropertyChanged("Reviewer");
|
||||
//System.Windows.Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() =>
|
||||
//{
|
||||
System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() =>
|
||||
{
|
||||
_regionManager.RequestNavigate("MainRegion", "HomeWindow", keys);
|
||||
//}));
|
||||
}));
|
||||
|
||||
}
|
||||
else
|
||||
|
@ -302,10 +299,10 @@ _exitCommand ??= new DelegateCommand(Exit);
|
|||
keys.Add("operator", user);
|
||||
Operator = user;
|
||||
RaisePropertyChanged("Operator");
|
||||
//System.Windows.Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() =>
|
||||
//{
|
||||
System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() =>
|
||||
{
|
||||
_regionManager.RequestNavigate("MainRegion", "HomeWindow", keys);
|
||||
//}));
|
||||
}));
|
||||
|
||||
}
|
||||
else
|
||||
|
@ -451,6 +448,9 @@ _exitCommand ??= new DelegateCommand(Exit);
|
|||
{
|
||||
//FingerMsg = !_fingerprintUtil.bIsConnected;
|
||||
//_eventAggregator.GetEvent<FingerprintEvent>().Subscribe(LoginEvent);
|
||||
//logger.Info($"LoginWindowViewModel;FingerMsg:{_fingerprintUtil.bIsConnected}");
|
||||
//_fingerprintUtil.FingerDisconnect();
|
||||
//FingerMsg = !_fingerprintUtil.bIsConnected;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@ using DM_Weight.HIKVISION;
|
|||
using log4net.Repository.Hierarchy;
|
||||
using log4net;
|
||||
using System.Windows;
|
||||
using DM_Weight.Models;
|
||||
|
||||
namespace DM_Weight.ViewModels
|
||||
{
|
||||
|
@ -67,11 +68,12 @@ namespace DM_Weight.ViewModels
|
|||
IRegionManager _regionManager;
|
||||
IUnityContainer _container;
|
||||
//private CHKFunction _cHKFunction;
|
||||
private readonly ILog logger = LogManager.GetLogger(typeof(PortUtil));
|
||||
private readonly ILog logger = LogManager.GetLogger(typeof(MainWindowViewModel));
|
||||
SocketHelper _socketHelper;
|
||||
public MainWindowViewModel(IRegionManager regionManager, IUnityContainer container, IEventAggregator eventAggregator, FingerprintUtil fingerprintUtil, SocketHelper socketHelper)
|
||||
private PortUtil _portUtil;
|
||||
public MainWindowViewModel(IRegionManager regionManager, IUnityContainer container, IEventAggregator eventAggregator, FingerprintUtil fingerprintUtil, SocketHelper socketHelper, PortUtil portUtil)
|
||||
{
|
||||
//_portUtil = portUtil;
|
||||
_portUtil = portUtil;
|
||||
this.eventAggregator = eventAggregator;
|
||||
this.eventAggregator.GetEvent<SnackbarEvent>().Subscribe(doMyPrismEvent2);
|
||||
_fingerprintUtil = fingerprintUtil;
|
||||
|
@ -85,6 +87,59 @@ namespace DM_Weight.ViewModels
|
|||
_container.RegisterType<object, LoginWindow>("LoginWindow");
|
||||
_regionManager.RegisterViewWithRegion("MainRegion", "LoginWindow");
|
||||
_socketHelper = socketHelper;
|
||||
new PromiseUtil<int>().taskAsyncLoop(1200000, 0, async (options, next, stop) =>
|
||||
{
|
||||
_socketHelper.IsMultiThread = true;
|
||||
try
|
||||
{
|
||||
TemperatureHumidityInfo temp = _portUtil.GetWSD();
|
||||
if (temp != null)
|
||||
{
|
||||
SqlSugarHelper.Db.Insertable(new TemperatureHumidityInfo()
|
||||
{
|
||||
GroupNo = temp.GroupNo,
|
||||
Temp = temp.Temp,
|
||||
Humi = temp.Humi,
|
||||
AddTime = DateTime.Now
|
||||
}).ExecuteCommand();
|
||||
logger.Info($"保存温湿度信息:{temp.Temp},{temp.Humi}");
|
||||
Task.Delay(1200000);//20分钟查一次
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.Info("温湿度信息返回空");
|
||||
}
|
||||
next();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.Info($"保存温湿度异常:{ex.Message}");
|
||||
next();
|
||||
}
|
||||
});
|
||||
//Task.Factory.StartNew(() =>
|
||||
//{
|
||||
// while (true)
|
||||
// {
|
||||
// TemperatureHumidityInfo temp = _portUtil.GetWSD();
|
||||
// if (temp != null)
|
||||
// {
|
||||
// SqlSugarHelper.Db.Insertable(new TemperatureHumidityInfo()
|
||||
// {
|
||||
// GroupNo = temp.GroupNo,
|
||||
// Temp = temp.Temp,
|
||||
// Humi = temp.Humi,
|
||||
// AddTime = DateTime.Now
|
||||
// }).ExecuteCommand();
|
||||
// logger.Info($"保存温湿度信息:{temp.Temp},{temp.Humi}");
|
||||
// Task.Delay(1200000);//20分钟查一次
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// logger.Info("温湿度信息返回空");
|
||||
// }
|
||||
// }
|
||||
//});
|
||||
|
||||
//}));
|
||||
|
||||
|
@ -106,7 +161,7 @@ namespace DM_Weight.ViewModels
|
|||
}
|
||||
if (_socketHelper.IsMultiThread)
|
||||
{
|
||||
Application.Current.Dispatcher.BeginInvoke(new Action(() => {
|
||||
Application.Current.Dispatcher.Invoke(new Action(() => {
|
||||
this.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c"));
|
||||
SnackbarMessageQueue.Enqueue(msg.Message);
|
||||
}));
|
||||
|
|
|
@ -739,16 +739,16 @@ namespace DM_Weight.ViewModels
|
|||
else
|
||||
{
|
||||
_socketHelper.IsMultiThread = false;
|
||||
_socketHelper.OpenStatus = false;
|
||||
_socketHelper.dateTime=DateTime.Now;
|
||||
//_socketHelper.OpenStatus = false;
|
||||
stop();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_socketHelper.IsMultiThread = false;
|
||||
_socketHelper.OpenStatus = false;
|
||||
_socketHelper.dateTime = DateTime.Now;
|
||||
//_socketHelper.OpenStatus = false;
|
||||
stop();
|
||||
}
|
||||
iException = 0;
|
||||
|
@ -766,6 +766,7 @@ namespace DM_Weight.ViewModels
|
|||
Type = MsgType.ERROR,
|
||||
};
|
||||
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
|
||||
logger.Info($"网口连接异常,正在重试{ex.Message}");
|
||||
next();
|
||||
}
|
||||
});
|
||||
|
|
|
@ -130,6 +130,5 @@
|
|||
|
||||
</Grid>
|
||||
|
||||
|
||||
</Grid>
|
||||
</UserControl>
|
||||
|
|
Loading…
Reference in New Issue