与板子断连重连间隔时间为2s。添加跳转登录时空页面跳转。交接柜补药开手术间添加检查交接柜状态。
This commit is contained in:
parent
4f5fb169d3
commit
5d04921387
|
|
@ -291,6 +291,9 @@ namespace DM_Weight
|
|||
|
||||
containerRegistry.RegisterForNavigation<ShowMessageDialog, ShowMessageDialogViewModel>();
|
||||
|
||||
//空页面,用于跳出登录时跳转以避免不走OnNavigatedFrom情况
|
||||
containerRegistry.RegisterForNavigation<EmptyWindow, EmptyWindowViewModel>();
|
||||
|
||||
logger.Info("结束APP-RegisterTypes");
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -84,6 +84,7 @@ namespace DM_Weight.Port
|
|||
{
|
||||
if (i <= 3)
|
||||
{
|
||||
Thread.Sleep(1950);
|
||||
//没连上会再连两次
|
||||
SocketConnect();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,7 +40,12 @@ namespace DM_Weight.ViewModels
|
|||
get => _finishStatus;
|
||||
set => SetProperty(ref _finishStatus, value);
|
||||
}
|
||||
|
||||
private bool _openStatusBtn =false;
|
||||
public bool OpenStatusBtn
|
||||
{
|
||||
get => _openStatusBtn;
|
||||
set => SetProperty(ref _openStatusBtn, value);
|
||||
}
|
||||
IDialogService _dialogService;
|
||||
IEventAggregator _eventAggregator;
|
||||
//private PortUtil _portUtil;
|
||||
|
|
@ -114,9 +119,9 @@ namespace DM_Weight.ViewModels
|
|||
Type = 55,
|
||||
InvoiceId = "手术间补药",
|
||||
}).ExecuteCommand();
|
||||
|
||||
_socketHelper.speechSynthesizer.SpeakAsyncCancelAll();
|
||||
_socketHelper.speechSynthesizer.Resume();
|
||||
_socketHelper.OpenStatus = true;
|
||||
//_socketHelper.speechSynthesizer.SpeakAsyncCancelAll();
|
||||
//_socketHelper.speechSynthesizer.Resume();
|
||||
_socketHelper.SpeakAsync($"正在打开{selectedStock[i].DrawerNo}号手术间");
|
||||
|
||||
//ModbusHelper.GetInstance().OpenBoxDoor(selectedStock[i].DrawerNo - 1);
|
||||
|
|
@ -133,31 +138,81 @@ namespace DM_Weight.ViewModels
|
|||
};
|
||||
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
|
||||
logger.Info($"网口连接异常,正在重试{ex.Message}");
|
||||
_socketHelper.OpenStatus = false;
|
||||
return;
|
||||
}
|
||||
Thread.Sleep(100);
|
||||
}
|
||||
}
|
||||
//Task.Factory.StartNew(async () =>
|
||||
//{
|
||||
// bool loop = true;
|
||||
// while (loop)
|
||||
// {
|
||||
// await Task.Delay(1000);
|
||||
// bool[] boolsl = ModbusHelper.GetInstance().GetAllBoxState();
|
||||
// bool state = Array.TrueForAll(boolsl, b => b == false);
|
||||
// if (state)
|
||||
// {
|
||||
// loop = false;
|
||||
// ModbusHelper.BoxOperate = false;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// ModbusHelper.BoxOperate = true;
|
||||
// //ModbusHelper.SpeakAsync("药箱已打开,请及时关闭");
|
||||
// }
|
||||
// }
|
||||
//});
|
||||
int iException = 0;
|
||||
Thread.Sleep(200);
|
||||
new PromiseUtil<int>().taskAsyncLoop(200, 0, async (options, next, stop) =>
|
||||
{
|
||||
|
||||
_socketHelper.IsMultiThread = true;
|
||||
try
|
||||
{
|
||||
if (_socketHelper.OpenStatus)
|
||||
{
|
||||
|
||||
//bool[] boolsl = ModbusHelper.GetInstance().GetAllBoxState();
|
||||
_socketHelper.SendMessage(new MyBaseMessage() { lockNo = 0x33, functionCode = 4, delay = 2 });
|
||||
|
||||
//ModbusHelper.SpeakAsync($"i为{i};状态为:{_socketHelper.OpenStatus}");
|
||||
//bool state = Array.TrueForAll(boolsl, b => b == false);
|
||||
if (_socketHelper.OpenStatus)
|
||||
{
|
||||
logger.Info($"OpenStatus:{_socketHelper.OpenStatus}");
|
||||
//if (i == 0)
|
||||
//{
|
||||
// //ModbusHelper.SpeakAsync("请及时关闭药箱");
|
||||
// i = 10;
|
||||
//}
|
||||
OpenStatusBtn =true;
|
||||
next();
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.Info($"OpenStatus:{_socketHelper.OpenStatus}");
|
||||
|
||||
_socketHelper.dateTime = DateTime.Now;
|
||||
_socketHelper.IsMultiThread = false;
|
||||
FinishStatus = Visibility.Visible;
|
||||
OpenStatusBtn = false;
|
||||
stop();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_socketHelper.dateTime = DateTime.Now;
|
||||
_socketHelper.IsMultiThread = false;
|
||||
FinishStatus = Visibility.Visible;
|
||||
OpenStatusBtn = false;
|
||||
stop();
|
||||
}
|
||||
|
||||
iException = 0;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
iException++;
|
||||
if (iException >= 3)
|
||||
{
|
||||
_socketHelper.OpenStatus = false;
|
||||
FinishStatus = Visibility.Visible;
|
||||
OpenStatusBtn = false;
|
||||
}
|
||||
// _socketHelper.OpenStatus = false;
|
||||
AlertMsg alertMsg = new AlertMsg
|
||||
{
|
||||
Message = $"网口连接异常,正在重试{ex.Message}",
|
||||
Type = MsgType.ERROR,
|
||||
};
|
||||
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
|
||||
logger.Info($"网口连接异常,正在重试{ex.Message}");
|
||||
next();
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -169,7 +224,7 @@ namespace DM_Weight.ViewModels
|
|||
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
|
||||
return;
|
||||
}
|
||||
FinishStatus = Visibility.Visible;
|
||||
//FinishStatus = Visibility.Visible;
|
||||
});
|
||||
}
|
||||
//完成按钮
|
||||
|
|
@ -227,6 +282,7 @@ namespace DM_Weight.ViewModels
|
|||
});
|
||||
if (f.Data)
|
||||
{
|
||||
FinishStatus = Visibility.Collapsed;
|
||||
RequestData();
|
||||
AlertMsg alertMsg = new AlertMsg
|
||||
{
|
||||
|
|
|
|||
|
|
@ -0,0 +1,12 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DM_Weight.ViewModels
|
||||
{
|
||||
internal class EmptyWindowViewModel
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
@ -316,6 +316,7 @@ namespace DM_Weight.ViewModels
|
|||
logger.Info($"用户【{Operator?.Nickname}】退出登录");
|
||||
Operator = null;
|
||||
Reviewer = null;
|
||||
_regionManager.RequestNavigate("ContentRegion", "EmptyWindow");
|
||||
_regionManager.RequestNavigate("MainRegion", "LoginWindow");
|
||||
//}
|
||||
//else
|
||||
|
|
@ -570,6 +571,7 @@ namespace DM_Weight.ViewModels
|
|||
Reviewer = null;
|
||||
//Application.Current.Dispatcher.Invoke(() =>
|
||||
//{
|
||||
_regionManager.RequestNavigate("ContentRegion", "EmptyWindow");
|
||||
_regionManager.RequestNavigate("MainRegion", "LoginWindow");
|
||||
//});
|
||||
AlertMsg alertMsg = new AlertMsg
|
||||
|
|
@ -609,6 +611,7 @@ namespace DM_Weight.ViewModels
|
|||
stop();
|
||||
System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() =>
|
||||
{
|
||||
_regionManager.RequestNavigate("ContentRegion", "EmptyWindow");
|
||||
_regionManager.RequestNavigate("MainRegion", "LoginWindow");
|
||||
}));
|
||||
//});
|
||||
|
|
|
|||
|
|
@ -62,7 +62,9 @@
|
|||
<Button
|
||||
Margin="3 0 3 0"
|
||||
VerticalAlignment="Center"
|
||||
Command="{Binding OpenBoxCommand}"
|
||||
Command="{Binding OpenBoxCommand}"
|
||||
materialDesign:ButtonProgressAssist.IsIndicatorVisible="{Binding OpenStatusBtn}"
|
||||
materialDesign:ButtonProgressAssist.IsIndeterminate="{Binding OpenStatusBtn}"
|
||||
Style="{StaticResource MaterialDesignOutlinedLightButton}"
|
||||
Content="开手术间" />
|
||||
<Button
|
||||
|
|
|
|||
|
|
@ -0,0 +1,12 @@
|
|||
<UserControl x:Class="DM_Weight.Views.EmptyWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:DM_Weight.Views"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
<Grid>
|
||||
|
||||
</Grid>
|
||||
</UserControl>
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace DM_Weight.Views
|
||||
{
|
||||
/// <summary>
|
||||
/// EmptyWindow.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class EmptyWindow : UserControl
|
||||
{
|
||||
public EmptyWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue