与板子断连重连间隔时间为2s。添加跳转登录时空页面跳转。交接柜补药开手术间添加检查交接柜状态。
This commit is contained in:
		
							parent
							
								
									4f5fb169d3
								
							
						
					
					
						commit
						5d04921387
					
				| 
						 | 
					@ -291,6 +291,9 @@ namespace DM_Weight
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            containerRegistry.RegisterForNavigation<ShowMessageDialog, ShowMessageDialogViewModel>();
 | 
					            containerRegistry.RegisterForNavigation<ShowMessageDialog, ShowMessageDialogViewModel>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            //空页面,用于跳出登录时跳转以避免不走OnNavigatedFrom情况
 | 
				
			||||||
 | 
					            containerRegistry.RegisterForNavigation<EmptyWindow, EmptyWindowViewModel>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            logger.Info("结束APP-RegisterTypes");
 | 
					            logger.Info("结束APP-RegisterTypes");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -84,6 +84,7 @@ namespace DM_Weight.Port
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                if (i <= 3)
 | 
					                if (i <= 3)
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
 | 
					                    Thread.Sleep(1950);
 | 
				
			||||||
                    //没连上会再连两次
 | 
					                    //没连上会再连两次
 | 
				
			||||||
                    SocketConnect();
 | 
					                    SocketConnect();
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -40,7 +40,12 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
            get => _finishStatus;
 | 
					            get => _finishStatus;
 | 
				
			||||||
            set => SetProperty(ref _finishStatus, value);
 | 
					            set => SetProperty(ref _finishStatus, value);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					        private bool _openStatusBtn =false;
 | 
				
			||||||
 | 
					        public bool OpenStatusBtn
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get => _openStatusBtn;
 | 
				
			||||||
 | 
					            set => SetProperty(ref _openStatusBtn, value);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
        IDialogService _dialogService;
 | 
					        IDialogService _dialogService;
 | 
				
			||||||
        IEventAggregator _eventAggregator;
 | 
					        IEventAggregator _eventAggregator;
 | 
				
			||||||
        //private PortUtil _portUtil;
 | 
					        //private PortUtil _portUtil;
 | 
				
			||||||
| 
						 | 
					@ -114,9 +119,9 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
                                Type = 55,
 | 
					                                Type = 55,
 | 
				
			||||||
                                InvoiceId = "手术间补药",
 | 
					                                InvoiceId = "手术间补药",
 | 
				
			||||||
                            }).ExecuteCommand();
 | 
					                            }).ExecuteCommand();
 | 
				
			||||||
 | 
					                            _socketHelper.OpenStatus = true;
 | 
				
			||||||
                            _socketHelper.speechSynthesizer.SpeakAsyncCancelAll();
 | 
					                            //_socketHelper.speechSynthesizer.SpeakAsyncCancelAll();
 | 
				
			||||||
                            _socketHelper.speechSynthesizer.Resume();
 | 
					                            //_socketHelper.speechSynthesizer.Resume();
 | 
				
			||||||
                            _socketHelper.SpeakAsync($"正在打开{selectedStock[i].DrawerNo}号手术间");
 | 
					                            _socketHelper.SpeakAsync($"正在打开{selectedStock[i].DrawerNo}号手术间");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                            //ModbusHelper.GetInstance().OpenBoxDoor(selectedStock[i].DrawerNo - 1);
 | 
					                            //ModbusHelper.GetInstance().OpenBoxDoor(selectedStock[i].DrawerNo - 1);
 | 
				
			||||||
| 
						 | 
					@ -133,31 +138,81 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
                                };
 | 
					                                };
 | 
				
			||||||
                                _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
					                                _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
				
			||||||
                                logger.Info($"网口连接异常,正在重试{ex.Message}");
 | 
					                                logger.Info($"网口连接异常,正在重试{ex.Message}");
 | 
				
			||||||
 | 
					                                _socketHelper.OpenStatus = false;
 | 
				
			||||||
                                return;
 | 
					                                return;
 | 
				
			||||||
                            }
 | 
					                            }
 | 
				
			||||||
                            Thread.Sleep(100);
 | 
					                            Thread.Sleep(100);
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                    //Task.Factory.StartNew(async () =>
 | 
					                    int iException = 0;
 | 
				
			||||||
                    //{
 | 
					                    Thread.Sleep(200);
 | 
				
			||||||
                    //    bool loop = true;
 | 
					                    new PromiseUtil<int>().taskAsyncLoop(200, 0, async (options, next, stop) =>
 | 
				
			||||||
                    //    while (loop)
 | 
					                    {
 | 
				
			||||||
                    //    {
 | 
					
 | 
				
			||||||
                    //        await Task.Delay(1000);
 | 
					                        _socketHelper.IsMultiThread = true;
 | 
				
			||||||
                    //        bool[] boolsl = ModbusHelper.GetInstance().GetAllBoxState();
 | 
					                        try
 | 
				
			||||||
                    //        bool state = Array.TrueForAll(boolsl, b => b == false);
 | 
					                        {
 | 
				
			||||||
                    //        if (state)
 | 
					                            if (_socketHelper.OpenStatus)
 | 
				
			||||||
                    //        {
 | 
					                            {
 | 
				
			||||||
                    //            loop = false;
 | 
					
 | 
				
			||||||
                    //            ModbusHelper.BoxOperate = false;
 | 
					                                //bool[] boolsl = ModbusHelper.GetInstance().GetAllBoxState();
 | 
				
			||||||
                    //        }
 | 
					                                _socketHelper.SendMessage(new MyBaseMessage() { lockNo = 0x33, functionCode = 4, delay = 2 });
 | 
				
			||||||
                    //        else
 | 
					
 | 
				
			||||||
                    //        {
 | 
					                                //ModbusHelper.SpeakAsync($"i为{i};状态为:{_socketHelper.OpenStatus}");
 | 
				
			||||||
                    //            ModbusHelper.BoxOperate = true;
 | 
					                                //bool state = Array.TrueForAll(boolsl, b => b == false);
 | 
				
			||||||
                    //            //ModbusHelper.SpeakAsync("药箱已打开,请及时关闭");
 | 
					                                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
 | 
					                else
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
| 
						 | 
					@ -169,7 +224,7 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
                    _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
					                    _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
				
			||||||
                    return;
 | 
					                    return;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                FinishStatus = Visibility.Visible;
 | 
					                //FinishStatus = Visibility.Visible;
 | 
				
			||||||
            });
 | 
					            });
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        //完成按钮
 | 
					        //完成按钮
 | 
				
			||||||
| 
						 | 
					@ -227,6 +282,7 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
                });
 | 
					                });
 | 
				
			||||||
                if (f.Data)
 | 
					                if (f.Data)
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
 | 
					                    FinishStatus = Visibility.Collapsed;
 | 
				
			||||||
                    RequestData();
 | 
					                    RequestData();
 | 
				
			||||||
                    AlertMsg alertMsg = new AlertMsg
 | 
					                    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}】退出登录");
 | 
					                logger.Info($"用户【{Operator?.Nickname}】退出登录");
 | 
				
			||||||
                Operator = null;
 | 
					                Operator = null;
 | 
				
			||||||
                Reviewer = null;
 | 
					                Reviewer = null;
 | 
				
			||||||
 | 
					                _regionManager.RequestNavigate("ContentRegion", "EmptyWindow");
 | 
				
			||||||
                _regionManager.RequestNavigate("MainRegion", "LoginWindow");
 | 
					                _regionManager.RequestNavigate("MainRegion", "LoginWindow");
 | 
				
			||||||
                //}
 | 
					                //}
 | 
				
			||||||
                //else
 | 
					                //else
 | 
				
			||||||
| 
						 | 
					@ -570,6 +571,7 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
                Reviewer = null;
 | 
					                Reviewer = null;
 | 
				
			||||||
                //Application.Current.Dispatcher.Invoke(() =>
 | 
					                //Application.Current.Dispatcher.Invoke(() =>
 | 
				
			||||||
                //{
 | 
					                //{
 | 
				
			||||||
 | 
					                _regionManager.RequestNavigate("ContentRegion", "EmptyWindow");
 | 
				
			||||||
                _regionManager.RequestNavigate("MainRegion", "LoginWindow");
 | 
					                _regionManager.RequestNavigate("MainRegion", "LoginWindow");
 | 
				
			||||||
                //});
 | 
					                //});
 | 
				
			||||||
                AlertMsg alertMsg = new AlertMsg
 | 
					                AlertMsg alertMsg = new AlertMsg
 | 
				
			||||||
| 
						 | 
					@ -609,6 +611,7 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
                                stop();
 | 
					                                stop();
 | 
				
			||||||
                                System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() =>
 | 
					                                System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() =>
 | 
				
			||||||
                                {
 | 
					                                {
 | 
				
			||||||
 | 
					                                    _regionManager.RequestNavigate("ContentRegion", "EmptyWindow");
 | 
				
			||||||
                                    _regionManager.RequestNavigate("MainRegion", "LoginWindow");
 | 
					                                    _regionManager.RequestNavigate("MainRegion", "LoginWindow");
 | 
				
			||||||
                                }));
 | 
					                                }));
 | 
				
			||||||
                                //});
 | 
					                                //});
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -63,6 +63,8 @@
 | 
				
			||||||
                    Margin="3 0 3 0"
 | 
					                    Margin="3 0 3 0"
 | 
				
			||||||
                    VerticalAlignment="Center"
 | 
					                    VerticalAlignment="Center"
 | 
				
			||||||
                    Command="{Binding OpenBoxCommand}" 
 | 
					                    Command="{Binding OpenBoxCommand}" 
 | 
				
			||||||
 | 
					                    materialDesign:ButtonProgressAssist.IsIndicatorVisible="{Binding OpenStatusBtn}"
 | 
				
			||||||
 | 
					                    materialDesign:ButtonProgressAssist.IsIndeterminate="{Binding OpenStatusBtn}"
 | 
				
			||||||
                    Style="{StaticResource MaterialDesignOutlinedLightButton}"
 | 
					                    Style="{StaticResource MaterialDesignOutlinedLightButton}"
 | 
				
			||||||
                    Content="开手术间" />
 | 
					                    Content="开手术间" />
 | 
				
			||||||
                <Button
 | 
					                <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