From 86f06ce19195b888eef6f8f815a06b819f512165 Mon Sep 17 00:00:00 2001
From: maqiao <625215135@qq.com>
Date: Tue, 8 Apr 2025 09:06:27 +0800
Subject: [PATCH] =?UTF-8?q?=E7=A7=B0=E9=87=8D=E6=8A=BD=E5=B1=89=E6=8F=90?=
=?UTF-8?q?=E7=A4=BA=E4=B8=B2=E5=8F=A3=E4=BA=A4=E4=BA=92=E8=B6=85=E6=97=B6?=
=?UTF-8?q?=E5=BC=82=E5=B8=B8=E4=BF=AE=E5=A4=8D?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
DM_Weight/App.config | 4 +-
DM_Weight/Converter/StatusConverter.cs | 4 +-
DM_Weight/Port/PortUtil.cs | 46 ++-
.../ViewModels/BiaoDingDialogViewModel.cs | 203 +++++++++++--
.../ViewModels/BiaoDingWindowViewModel.cs | 11 +
.../BindingChannelDialogViewModel.cs | 10 +-
.../BindingChannelNewDialogViewModel.cs | 20 +-
.../DrawerAddDrugWindowViewModel.cs | 281 ++++++++++++++----
.../DrawerTakeDrugWindowViewModel.cs | 275 +++++++++++++----
DM_Weight/ViewModels/MainWindowViewModel.cs | 36 +--
.../OrderTakeDrugWindowViewModel.cs | 18 +-
.../ViewModels/SelfTakeDialogViewModel.cs | 2 +-
DM_Weight/Views/BiaoDingWindow.xaml | 4 +-
DM_Weight/Views/Dialog/BiaoDingDialog.xaml | 18 +-
DM_Weight/Views/DrawerAddDrugWindow.xaml | 3 +-
DM_Weight/Views/DrawerTakeDrugWindow.xaml | 37 ++-
16 files changed, 750 insertions(+), 222 deletions(-)
diff --git a/DM_Weight/App.config b/DM_Weight/App.config
index dfe1c02..3edb375 100644
--- a/DM_Weight/App.config
+++ b/DM_Weight/App.config
@@ -3,7 +3,7 @@
-
+
-
+
diff --git a/DM_Weight/Converter/StatusConverter.cs b/DM_Weight/Converter/StatusConverter.cs
index a7484e2..46458fb 100644
--- a/DM_Weight/Converter/StatusConverter.cs
+++ b/DM_Weight/Converter/StatusConverter.cs
@@ -76,7 +76,7 @@ namespace DM_Weight.Converter
//清空按钮的显示与隐藏
if(parameter.ToString().Equals("clearVisuability"))
{
- if (status == 1)
+ if (status <= 1)
{
return Visibility.Visible;
}
@@ -88,7 +88,7 @@ namespace DM_Weight.Converter
//清空按钮的操作状态
if(parameter.ToString().Equals("clearBtnLoading"))
{
- if (status == 0)
+ if (status == 1)
{
return true;
}
diff --git a/DM_Weight/Port/PortUtil.cs b/DM_Weight/Port/PortUtil.cs
index a1095a8..a06d4ba 100644
--- a/DM_Weight/Port/PortUtil.cs
+++ b/DM_Weight/Port/PortUtil.cs
@@ -416,7 +416,7 @@ namespace DM_Weight.Port
if (ColNos != null && ColNos.Length > 0 || OpenBoxColNo > 0)
{
//开药盒锁
- if (OpenBoxColNo > 0&&(WindowName== "DrawerTakeDrugWindow" || WindowName== "DrawerAddDrugWindow"))
+ if (OpenBoxColNo > 0 && (WindowName == "DrawerTakeDrugWindow" || WindowName == "DrawerAddDrugWindow"))
{
//开药盒锁前先查数
int beforeQuantity = await CheckQuantityForSingle(OpenBoxColNo);
@@ -759,6 +759,7 @@ namespace DM_Weight.Port
}
if (_length != length)
{
+ logger.Info($"串口【{serialPort.PortName}】交互超时;{_length}-{length};{end.Subtract(start).TotalMilliseconds}-{timeout}");
throw new TimeoutException($"串口【{serialPort.PortName}】交互超时");
}
serialPort.Read(buffer, 0, length);
@@ -790,7 +791,7 @@ namespace DM_Weight.Port
{
try
{
-
+ logger.Info($"开抽屉");
drawerSerial.DiscardInBuffer();
byte[] buffer = new byte[] { 0xaa, 0x41, (byte)DrawerNo, 0xee };
if (_drawerProtocol == 485)
@@ -1185,7 +1186,7 @@ namespace DM_Weight.Port
}
// 清除显示内容
- public void ClearContent(int drawerNo, int colNo)
+ public async Task ClearContent(int drawerNo, int colNo)
{
canBusSerial.DiscardInBuffer();
int channel = (drawerNo * 10 + colNo);
@@ -1193,7 +1194,7 @@ namespace DM_Weight.Port
canBusSerial.Write(buffer, 0, 8);
}
// 刷新显示内容
- public void ShowContent(int drawerNo, int colNo)
+ public async Task ShowContent(int drawerNo, int colNo)
{
try
{
@@ -1283,7 +1284,7 @@ namespace DM_Weight.Port
logger.Info($"清屏指令:{Convert.ToHexString(buffer)}");
}
//刷新内容
- public async void ShowContentMethod(int drawerNo, int colNo)
+ public async Task ShowContentMethod(int drawerNo, int colNo)
{
int channel = Convert.ToInt32((drawerNo * 10 + Math.Ceiling((decimal)colNo / 3)).ToString(), 16);
byte[] buffer = new byte[] { 0xaa, (byte)channel, 0x0c, 0x00, 0x00, 0x00, 0x00, 0xee };
@@ -1291,7 +1292,7 @@ namespace DM_Weight.Port
canBusSerial.Write(buffer, 0, 8);
}
// 基础数据写入方法
- public async void WriteChannelInfoMethod(int type, string content, int drawerNo, int colNo)
+ public async Task WriteChannelInfoMethod(int type, string content, int drawerNo, int colNo)
{
try
{
@@ -1516,7 +1517,7 @@ namespace DM_Weight.Port
int[] res = new int[9];
for (int i = 0; i < ColNoLst.Count; i++)
{
- await Task.Delay(300);
+ Thread.Sleep(200);
canBusSerial.DiscardInBuffer();
int colNo = ColNoLst[i];
int[] iNum = new int[] { 3, 2, 1 };
@@ -1539,7 +1540,7 @@ namespace DM_Weight.Port
hl[0] -= 0x80;
quantity = BitConverter.ToInt16(hl.Reverse().ToArray(), 0);
logger.Info($"获取值为负数{quantity}");
- quantity=0 - quantity;
+ quantity = 0 - quantity;
}
else
{
@@ -1584,7 +1585,7 @@ namespace DM_Weight.Port
hl[0] -= 0x80;
int quantity = BitConverter.ToInt16(hl.Reverse().ToArray(), 0);
logger.Info($"获取值为负数{quantity}");
- return 0-quantity;
+ return 0 - quantity;
}
else
{
@@ -1707,7 +1708,7 @@ namespace DM_Weight.Port
}
}
//计数请零
- public async void ClearCount(int DrawerNo, int ColNo)
+ public async Task ClearCount(int DrawerNo, int ColNo)
{
try
{
@@ -1735,7 +1736,7 @@ namespace DM_Weight.Port
}
- public async void SetNumCount(int DrawerNo, int ColNo, int Quantity)
+ public async Task SetNumCount(int DrawerNo, int ColNo, int Quantity)
{
try
{
@@ -2109,5 +2110,28 @@ namespace DM_Weight.Port
#endregion
#endregion
+ //标定获取药盒数量
+ private byte[] GetBufferByPortForBiaoDing(SerialPort serialPort, int length, int timeout)
+ {
+ byte[] buffer = new byte[length];
+ int _length = 0;
+ DateTime start = DateTime.Now;
+ DateTime end = DateTime.Now;
+ while (_length != length && end.Subtract(start).TotalMilliseconds < timeout)
+ {
+ _length = serialPort.BytesToRead;
+ end = DateTime.Now;
+ }
+
+ if (_length != length)
+ {
+ //throw new TimeoutException($"串口【{serialPort.PortName}】交互超时");
+ //_length = serialPort.BytesToRead;
+ //end = DateTime.Now;
+ //logger.Info($"读到数据{}");
+ }
+ serialPort.Read(buffer, 0, length);
+ return buffer;
+ }
}
}
diff --git a/DM_Weight/ViewModels/BiaoDingDialogViewModel.cs b/DM_Weight/ViewModels/BiaoDingDialogViewModel.cs
index 90e1924..3fc235f 100644
--- a/DM_Weight/ViewModels/BiaoDingDialogViewModel.cs
+++ b/DM_Weight/ViewModels/BiaoDingDialogViewModel.cs
@@ -5,6 +5,7 @@ using DM_Weight.Port;
using DM_Weight.util;
using log4net;
using log4net.Repository.Hierarchy;
+using MaterialDesignThemes.Wpf;
using Prism.Commands;
using Prism.Events;
using Prism.Mvvm;
@@ -17,6 +18,7 @@ using System.Net.NetworkInformation;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
+using System.Windows.Media;
namespace DM_Weight.ViewModels
{
@@ -40,9 +42,24 @@ namespace DM_Weight.ViewModels
get => strMessage;
set => SetProperty(ref strMessage, value);
}
- private int _status = 1;
+ private int _status = 0;
public int Status { get => _status; set => SetProperty(ref _status, value); }
+ private SolidColorBrush _colorBrush;
+
+ public SolidColorBrush SnackbarBackground
+ {
+ get => _colorBrush;
+ set => SetProperty(ref _colorBrush, value);
+ }
+ private ISnackbarMessageQueue _snackbarMessageQueue = new SnackbarMessageQueue(TimeSpan.FromSeconds(3));
+
+ public ISnackbarMessageQueue SnackbarMessageQueue
+ {
+ get => _snackbarMessageQueue;
+ set => SetProperty(ref _snackbarMessageQueue, value);
+ }
+
//标定数量
private int _bdQuantity = 0;
public int BDQuantity
@@ -50,6 +67,28 @@ namespace DM_Weight.ViewModels
get => _bdQuantity;
set => SetProperty(ref _bdQuantity, value);
}
+ ///
+ /// 标定按钮是否可用
+ ///
+ private bool _biaoDingEnable = true;
+ public bool BiaoDingEnable
+ {
+ get => _biaoDingEnable; set
+ {
+ SetProperty(ref _biaoDingEnable, value);
+ }
+ }
+
+ //关闭按钮是否可用
+ private bool _closeIsEnable = true;
+ public bool CloseIsEnable
+ {
+ get => _closeIsEnable;
+ set
+ {
+ SetProperty(ref _closeIsEnable, value);
+ }
+ }
public event Action RequestClose;
@@ -71,16 +110,18 @@ namespace DM_Weight.ViewModels
if (channelStock != null)
{
TitleStr = $"正在标定{channelStock.ColNo}号库位";
+ BiaoDingEnable = false;
if (channelStock.Quantity > 0)
{
StrMessage = "库位库存不为零,请取出药品后点击【清空】按钮,清空完成后输入标定数量并放入对应数量药品并根据下一步提示操作";
+
}
else
{
- StrMessage = "输入标定数量并放入对应数量药品后点击【标定】按钮";
- //无库存发送计数清零指令
- _portUtil.ClearCount(channelStock.DrawerNo, channelStock.ColNo);
- Status = 3;
+ Status = 1;
+ StrMessage = "正在清零,清零完成后输入标定数量并放入对应数量药品后点击【标定】按钮";
+ ClearMethod();
+
}
}
@@ -186,38 +227,50 @@ namespace DM_Weight.ViewModels
{
if (Status == 3)
{
+ CloseIsEnable = false;
//提示输入标定数量,发26指令
- _portUtil.SetNumCount(channelStock.DrawerNo, channelStock.ColNo, BDQuantity);
+ await _portUtil.SetNumCount(channelStock.DrawerNo, channelStock.ColNo, BDQuantity);
Status = 4;
- await Task.Delay(200);
+ Thread.Sleep(200);
+ _portUtil.DrawerNo = channelStock.DrawerNo;
//发27指令查询数量是否写标定时写入的数量一致,一致则标定成功,不一致则标定失败
int stock = await _portUtil.CheckQuantityForBiaoDing(channelStock.ColNo);
if (!(stock == BDQuantity))
{
int i = 1;
- while (i<=50&&i>0)
+ while (i <= 50 && i > 0 && Status > 0)
{
- await Task.Delay(200);
- stock = await _portUtil.CheckQuantityForBiaoDing(channelStock.ColNo);
- if (stock == BDQuantity)
+ try
{
-
- logger.Info($"标定完成{stock},{BDQuantity},{i}"); //标定成功
- AlertMsg alertMsg = new AlertMsg
+ Thread.Sleep(200);
+ stock = await _portUtil.CheckQuantityForBiaoDing(channelStock.ColNo);
+ if (stock == BDQuantity)
{
- Message = "标定成功",
- Type = MsgType.SUCCESS,
- };
- _eventAggregator.GetEvent().Publish(alertMsg);
- i = 0;
- }
- else
- {
- i++;
- logger.Info($"标定数量不一致{stock},{BDQuantity}");
-
- }
+ logger.Info($"标定完成{stock},{BDQuantity},次数{i}"); //标定成功
+ AlertMsg alertMsg = new AlertMsg
+ {
+ Message = "标定成功",
+ Type = MsgType.SUCCESS,
+ };
+ _eventAggregator.GetEvent().Publish(alertMsg);
+ i = 0;
+ // 更新数据 标定状态
+ channelStock.PosNo = 1;
+ SqlSugarHelper.Db.Updateable(channelStock).UpdateColumns(it => it.PosNo).ExecuteCommand();
+ }
+ else
+ {
+ i++;
+ logger.Info($"标定数量不一致{stock},{BDQuantity},次数{i}");
+
+ }
+ }
+ catch (Exception ex)
+ {
+ logger.Error($"标定存在异常{ex.Message}");
+ continue;
+ }
}
RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel));
if (i == 51)
@@ -243,11 +296,18 @@ namespace DM_Weight.ViewModels
_eventAggregator.GetEvent().Publish(alertMsg);
logger.Info($"标定完成{stock},{BDQuantity}");
}
+ CloseIsEnable = true;
}
}
catch (Exception e)
{
logger.Error($"标定异常{e.Message}");
+ AlertMsg alertMsg = new AlertMsg
+ {
+ Message = "标定失败",
+ Type = MsgType.ERROR,
+ };
+ _eventAggregator.GetEvent().Publish(alertMsg);
}
});
}
@@ -256,9 +316,27 @@ namespace DM_Weight.ViewModels
{
get => new DelegateCommand(async () =>
{
- //发计数请零指令
- _portUtil.ClearCount(channelStock.DrawerNo, channelStock.ColNo);
- Status = 3;
+ ////发计数请零指令
+ //await _portUtil.ClearCount(channelStock.DrawerNo, channelStock.ColNo);
+ //Status = 3;
+ //Thread.Sleep(300);
+ ////发查数指令
+ //_portUtil.DrawerNo = channelStock.DrawerNo;
+ //int stock = await _portUtil.CheckQuantityForBiaoDing(channelStock.ColNo);
+ //if (stock != 0)
+ //{
+ // SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#00e676"));
+ // SnackbarMessageQueue.Enqueue("清零成功");
+ // BiaoDingEnable = true;
+ //}
+ //else
+ //{
+ // SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#f44336"));
+ // SnackbarMessageQueue.Enqueue("清零失败");
+ //}
+ //_portUtil.ResetData();
+ Status = 1;
+ ClearMethod();
});
}
//取消
@@ -266,7 +344,8 @@ namespace DM_Weight.ViewModels
{
get => new DelegateCommand(() =>
{
- RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel));
+ logger.Info("取消");
+ Status = 0;
});
}
@@ -275,8 +354,72 @@ namespace DM_Weight.ViewModels
{
get => new DelegateCommand(() =>
{
+ logger.Info("关闭窗口");
+ Status = 0;
RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel));
});
}
+
+ private void ClearMethod()
+ {
+ int i = 0;
+ int iClear = 0;
+ new PromiseUtil().taskAsyncLoop(200, 0, async (options, next, stop) =>
+ {
+ i++;
+ if (Status == 0 || i > 20)
+ {
+ System.Windows.Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() =>
+ {
+ SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#f44336"));
+ SnackbarMessageQueue.Enqueue("清零失败,请重试操作");
+ }));
+ stop();
+ }
+ else
+ {
+ try
+ {
+ if (iClear == 0)
+ {
+ logger.Info($"清零操作{i}");
+ //无库存发送计数清零指令
+ await _portUtil.ClearCount(channelStock.DrawerNo, channelStock.ColNo);
+ iClear += 1;
+ next();
+ }
+ else
+ {
+ logger.Info($"查数操作{i}");
+ //发查数指令
+ _portUtil.DrawerNo = channelStock.DrawerNo;
+ _portUtil.Operate = true;
+ int stock = await _portUtil.CheckQuantityForBiaoDing(channelStock.ColNo);
+ if (stock != 0)
+ {
+ stop();
+ System.Windows.Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() =>
+ {
+ SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#00e676"));
+ SnackbarMessageQueue.Enqueue("清零成功");
+ }));
+ BiaoDingEnable = true;
+ _portUtil.ResetData();
+ Status = 3;
+ }
+ else
+ {
+ next();
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ logger.Error($"清零异常{e.Message}");
+ next();
+ }
+ }
+ });
+ }
}
}
diff --git a/DM_Weight/ViewModels/BiaoDingWindowViewModel.cs b/DM_Weight/ViewModels/BiaoDingWindowViewModel.cs
index c2c5747..9658fb9 100644
--- a/DM_Weight/ViewModels/BiaoDingWindowViewModel.cs
+++ b/DM_Weight/ViewModels/BiaoDingWindowViewModel.cs
@@ -109,6 +109,15 @@ namespace DM_Weight.ViewModels
public bool Is17Drawer { get => _is17Drawer; set => SetProperty(ref _is17Drawer, value); }
+ public DelegateCommand UpdateDrawerNo
+ {
+ get => new DelegateCommand((DrawerNo) =>
+ {
+ this.DrawerNo = Convert.ToInt32(DrawerNo);
+ RequestData();
+ }, (DrawerNo) => Status == 0
+ );
+ }
//打开抽屉
public DelegateCommand OpenDrawer
{
@@ -119,6 +128,7 @@ namespace DM_Weight.ViewModels
if (Status == 0)
{
_portUtil.Operate = true;
+ _portUtil.DrawerNo = DrawerNo;
_portUtil.SpeakAsync("正在打开" + DrawerNo + "号抽屉");
byte[] buffer = await _portUtil.OpenDrawer();
@@ -131,6 +141,7 @@ namespace DM_Weight.ViewModels
{
Status = 1;
// 查询抽屉状态
+ _portUtil.Operate = true;
byte[] buffer = await _portUtil.CheckDrawerStatus();
int[] r = buffer.Select(it => Convert.ToInt32(it)).ToArray();
if (DrawerState(r))
diff --git a/DM_Weight/ViewModels/BindingChannelDialogViewModel.cs b/DM_Weight/ViewModels/BindingChannelDialogViewModel.cs
index 314104f..92d4196 100644
--- a/DM_Weight/ViewModels/BindingChannelDialogViewModel.cs
+++ b/DM_Weight/ViewModels/BindingChannelDialogViewModel.cs
@@ -258,15 +258,15 @@ namespace DM_Weight.ViewModels
{
_portUtil.WindowName = "BindingChannelDialog";
_portUtil.WriteChannelInfoMethod(1, DrugInfo.DrugName, item.DrawerNo, item.ColNo);
- Task.Delay(200);
+ await Task.Delay(200);
_portUtil.WriteChannelInfoMethod(3, DrugInfo.DrugSpec, item.DrawerNo, item.ColNo);
- Task.Delay(200);
+ await Task.Delay(200);
_portUtil.WriteChannelInfoMethod(4, DrugInfo.Manufactory, item.DrawerNo, item.ColNo);
- Task.Delay(200);
+ await Task.Delay(200);
_portUtil.WriteChannelInfoMethod(5, item.EffDate, item.DrawerNo, item.ColNo);
- Task.Delay(200);
+ await Task.Delay(200);
_portUtil.WriteChannelInfoMethod(6, item.ManuNo, item.DrawerNo, item.ColNo);
- Task.Delay(200);
+ await Task.Delay(200);
_portUtil.ShowContentMethod(item.DrawerNo, item.ColNo);
Task.Delay(200);
}
diff --git a/DM_Weight/ViewModels/BindingChannelNewDialogViewModel.cs b/DM_Weight/ViewModels/BindingChannelNewDialogViewModel.cs
index 59f1d56..21e9088 100644
--- a/DM_Weight/ViewModels/BindingChannelNewDialogViewModel.cs
+++ b/DM_Weight/ViewModels/BindingChannelNewDialogViewModel.cs
@@ -306,13 +306,13 @@ namespace DM_Weight.ViewModels
if(item.BoardType==(Int32)BoardTypeEnum.weighSmartBox)
{
_portUtil.WindowName = "BindingChannelDialog";
- _portUtil.WriteChannelInfoMethod(1, DrugInfo.DrugName, item.DrawerNo, item.ColNo);
+ await _portUtil.WriteChannelInfoMethod(1, DrugInfo.DrugName, item.DrawerNo, item.ColNo);
Task.Delay(200);
- _portUtil.WriteChannelInfoMethod(3, DrugInfo.DrugSpec, item.DrawerNo, item.ColNo);
+ await _portUtil.WriteChannelInfoMethod(3, DrugInfo.DrugSpec, item.DrawerNo, item.ColNo);
Task.Delay(200);
- _portUtil.WriteChannelInfoMethod(4, DrugInfo.Manufactory, item.DrawerNo, item.ColNo);
+ await _portUtil.WriteChannelInfoMethod(4, DrugInfo.Manufactory, item.DrawerNo, item.ColNo);
Task.Delay(200);
- _portUtil.ShowContentMethod(item.DrawerNo, item.ColNo);
+ await _portUtil.ShowContentMethod(item.DrawerNo, item.ColNo);
Task.Delay(200);
}
//_screenUtil.SetStockInfo(item, 1);
@@ -393,13 +393,13 @@ namespace DM_Weight.ViewModels
if(item.BoardType == (Int32)BoardTypeEnum.weighSmartBox)
{
_portUtil.WindowName = "BindingChannelDialog";
- _portUtil.WriteChannelInfoMethod(1, DrugInfo.DrugName, item.DrawerNo, item.ColNo);
+ await _portUtil.WriteChannelInfoMethod(1, DrugInfo.DrugName, item.DrawerNo, item.ColNo);
Task.Delay(200);
- _portUtil.WriteChannelInfoMethod(3, DrugInfo.DrugSpec, item.DrawerNo, item.ColNo);
+ await _portUtil.WriteChannelInfoMethod(3, DrugInfo.DrugSpec, item.DrawerNo, item.ColNo);
Task.Delay(200);
- _portUtil.WriteChannelInfoMethod(4, DrugInfo.Manufactory, item.DrawerNo, item.ColNo);
+ await _portUtil.WriteChannelInfoMethod(4, DrugInfo.Manufactory, item.DrawerNo, item.ColNo);
Task.Delay(200);
- _portUtil.ShowContentMethod(item.DrawerNo, item.ColNo);
+ await _portUtil.ShowContentMethod(item.DrawerNo, item.ColNo);
Task.Delay(200);
}
}
@@ -451,9 +451,9 @@ namespace DM_Weight.ViewModels
if (item.BoardType == (Int32)BoardTypeEnum.smart || item.BoardType == (Int32)BoardTypeEnum.weighSmartBox)
{
// 清除显示屏库位信息
- _portUtil.ClearContent(item.DrawerNo, item.ColNo);
+ await _portUtil.ClearContent(item.DrawerNo, item.ColNo);
await Task.Delay(200);
- _portUtil.ShowContent(item.DrawerNo, item.ColNo);
+ await _portUtil.ShowContent(item.DrawerNo, item.ColNo);
}
//_screenUtil.SetStockInfo(item, 1);
diff --git a/DM_Weight/ViewModels/DrawerAddDrugWindowViewModel.cs b/DM_Weight/ViewModels/DrawerAddDrugWindowViewModel.cs
index 0001bde..0a9cd3c 100644
--- a/DM_Weight/ViewModels/DrawerAddDrugWindowViewModel.cs
+++ b/DM_Weight/ViewModels/DrawerAddDrugWindowViewModel.cs
@@ -77,10 +77,13 @@ namespace DM_Weight.ViewModels
}
//是冰箱抽屉则开冰箱抽屉时发送延迟报警指令
CheckIsFridgeClose();
+ //抽屉关闭查询称重稳定数据
+ CompleteIsEnable = true;
+
break;
// 数量变化
case EventType.UPDATEQUANTITY:
- if (Status == 2)
+ if (Status == 2 || Status == 3)
{
ChannelStocks.Where(cs => _portUtil.ColNoLst.Contains(cs.ColNo)).ToList().ForEach(it => it.AddQuantity = msg.Quantitys[it.ColNo - 1]);
}
@@ -133,6 +136,30 @@ namespace DM_Weight.ViewModels
}, (DrawerNo) => Status == 0
);
}
+ ///
+ /// 完成按钮是否可用
+ ///
+ private bool _completeIsEnable = false;
+ public bool CompleteIsEnable
+ {
+ get => _completeIsEnable;
+ set
+ {
+ SetProperty(ref _completeIsEnable, value);
+ }
+ }
+ ///
+ /// 取消按钮是否可用
+ ///
+ private bool _cancleIsEnable = true;
+ public bool CancleIsEnable
+ {
+ get => _cancleIsEnable;
+ set
+ {
+ SetProperty(ref _cancleIsEnable, value);
+ }
+ }
int currentCol = 0;
private int[] BeforeQuantity { get; set; } = new int[9];
private int[] AfterQuantity { get; set; } = new int[9];
@@ -146,7 +173,7 @@ namespace DM_Weight.ViewModels
}
Status = 1;
_portUtil.SpeakAsync("正在打开" + DrawerNo + "号抽屉");
- if (ChannelStocks!=null&& ChannelStocks.Count>0&&(ChannelStocks[0].BoardType == (Int32)BoardTypeEnum.weighSmartBox))
+ if (ChannelStocks != null && ChannelStocks.Count > 0 && (ChannelStocks[0].BoardType == (Int32)BoardTypeEnum.weighSmartBox))
{
try
@@ -155,83 +182,115 @@ namespace DM_Weight.ViewModels
_portUtil.Operate = true;
_portUtil.WindowName = "DrawerAddDrugWindow";
byte[] buffer = await _portUtil.OpenDrawer();
-
+ CancleIsEnable = false;
+ if (buffer == null)
+ {
+ logger.Info("抽屉打开返回空");
+ Status = 0;
+ return;
+ }
int[] r = buffer.Select(it => Convert.ToInt32(it)).ToArray();
logger.Info($"OpenDrawer{string.Join(",", r)}");
if (_portUtil.DrawerState(r))
{
+ _portUtil.ColNoLst.Clear();
new PromiseUtil().taskAsyncLoop(200, 0, async (options, next, stop) =>
{
- if (Status == 3)
+ logger.Info("循环查抽屉状态药盒数量");
+ if (Status == 3 || Status == 0)
{
stop();
}
- try
+ else
{
- // 查询抽屉状态
- byte[] buffer = await _portUtil.CheckDrawerStatus();
- int[] r = buffer.Select(it => Convert.ToInt32(it)).ToArray();
- if (_portUtil.DrawerState(r))
+ try
{
- Status = 2;
- //是冰箱抽屉则开冰箱抽屉时发送延迟报警指令
- CheckIsFridgeOpen();
- if (_portUtil.ColNoLst != null && _portUtil.ColNoLst.Count > 0 || currentCol > 0)
+ // 查询抽屉状态
+ byte[] buffer = await _portUtil.CheckDrawerStatus();
+ int[] r = buffer.Select(it => Convert.ToInt32(it)).ToArray();
+ logger.Info($"抽屉状态返回{Convert.ToHexString(buffer)}");
+ if (_portUtil.DrawerState(r))
{
- //库位列表不为空查数
- if (currentCol > 0)
+ Status = 2;
+ if (_portUtil.ColNoLst != null && _portUtil.ColNoLst.Count > 0 || currentCol > 0)
{
- if (!_portUtil.ColNoLst.Contains(currentCol)) //已经开过一次药盒则不再查开药合前的数量
+ //库位列表不为空查数
+ if (currentCol > 0)
{
- //开药盒锁前先查数
- int beforeQuantity = await _portUtil.CheckQuantityForSingle(currentCol);
- BeforeQuantity[currentCol - 1] = beforeQuantity;
- logger.Info($"BeforeQuantity:{currentCol}-{beforeQuantity}数量{string.Join(",", BeforeQuantity)}");
- await Task.Delay(200);
- _portUtil.ColNoLst.Add(currentCol);
- }
- _portUtil.OpenBoxByColNo(currentCol);
- await Task.Delay(200);
- currentCol = 0;
- }
- // 继续查询抽屉药品数量
- // 查询抽屉药品数量
+ if (!_portUtil.ColNoLst.Contains(currentCol)) //已经开过一次药盒则不再查开药合前的数量
+ {
+ CancleIsEnable = false;
+ //开药盒锁前先查数
+ int beforeQuantity = await _portUtil.CheckQuantityForSingle(currentCol);
+ Thread.Sleep(200);
+ BeforeQuantity[currentCol - 1] = beforeQuantity;
+ logger.Info($"BeforeQuantity:{currentCol}-{beforeQuantity}数量{string.Join(",", BeforeQuantity)}");
- int[] quantity = await _portUtil.CheckQuantityByAddrForMulti();
- AfterQuantity = quantity;
- logger.Info($"AfterQuantity{string.Join(",", AfterQuantity)}");
- int[] Quantitys = new int[BeforeQuantity.Length];
- for (int i = 0; i < BeforeQuantity.Length; i++)
- {
- Quantitys[i] = AfterQuantity[i] - BeforeQuantity[i];
+ _portUtil.ColNoLst.Add(currentCol);
+ }
+ await _portUtil.OpenBoxByColNo(currentCol);
+ Thread.Sleep(200);
+
+ currentCol = 0;
+ }
+ // 继续查询抽屉药品数量
+ // 查询抽屉药品数量
+
+ int[] quantity = await _portUtil.CheckQuantityByAddrForMulti();
+ AfterQuantity = quantity;
+ logger.Info($"AfterQuantity{string.Join(",", AfterQuantity)}");
+ int[] Quantitys = new int[BeforeQuantity.Length];
+ for (int i = 0; i < BeforeQuantity.Length; i++)
+ {
+ Quantitys[i] = AfterQuantity[i] - BeforeQuantity[i];
+ }
+ // 告诉前台数据变化
+ _eventAggregator.GetEvent().Publish(new util.DeviceMsg()
+ {
+ EventType = util.EventType.UPDATEQUANTITY,
+ WindowName = "DrawerAddDrugWindow",
+ Quantitys = Quantitys
+ });
+ logger.Info($"数量变化【{string.Join(",", Quantitys)}】");
}
- // 告诉前台数据变化
- _eventAggregator.GetEvent().Publish(new util.DeviceMsg()
- {
- EventType = util.EventType.UPDATEQUANTITY,
- WindowName = "DrawerAddDrugWindow",
- Quantitys = Quantitys
- });
- logger.Info($"数量变化【{string.Join(",", Quantitys)}】");
+ next();
}
+ else
+ {
+ stop();
+ //关闭抽屉
+ logger.Info($"抽屉【{DrawerNo}】已关闭");
+ // 重新初始化数据
+ //_portUtil.ResetData();
+ if (_portUtil.ColNoLst != null && _portUtil.ColNoLst.Count > 0)
+ {
+ Thread.Sleep(200);
+ //关闭抽屉后获取称重稳定数量
+ GetWeightQuantity();
+ //_portUtil.ColNoLst.Clear();
+ Status = 3;
+ //CancleIsEnable = true;
+ }
+ else
+ {
+ Status = 0;
+ _portUtil.ResetData();
+ }
+ CompleteIsEnable = false;
+ }
+ }
+ catch (Exception ex)
+ {
+ logger.Info($"异常{ex.Message}");
+ //AlertMsg alertMsg = new AlertMsg
+ //{
+ // Message = $"异常{ex.Message}",
+ // Type = MsgType.ERROR,
+ //};
+ //_eventAggregator.GetEvent().Publish(alertMsg);
next();
}
- else
- {
- Status = 3;
- //关闭抽屉
- logger.Info($"抽屉【{DrawerNo}】已关闭");
- // 重新初始化数据
- _portUtil.ResetData();
- //是冰箱抽屉则开冰箱抽屉时发送延迟报警指令
- CheckIsFridgeClose();
- stop();
- }
- }
- catch (Exception ex)
- {
- logger.Info($"异常{ex.Message}");
}
});
}
@@ -259,14 +318,15 @@ namespace DM_Weight.ViewModels
}
}
else
- { List singleChannels = ChannelStocks.FindAll(it => it.BoardType != (Int32)BoardTypeEnum.separation);
+ {
+ List singleChannels = ChannelStocks.FindAll(it => it.BoardType != (Int32)BoardTypeEnum.separation);
_portUtil.WindowName = "DrawerAddDrugWindow";
_portUtil.Operate = true;
_portUtil.BoardType = singleChannels.Count > 0 ? singleChannels[0].BoardType : (Int32)BoardTypeEnum.separation;
_portUtil.ColNos = singleChannels.Select(it => it.ColNo).ToArray();
_portUtil.DrawerNo = DrawerNo;
_portUtil.Start();
-
+
}
}, () => Status == 0).ObservesProperty(() => Status);
@@ -290,6 +350,7 @@ namespace DM_Weight.ViewModels
Type = MsgType.ERROR,
};
_eventAggregator.GetEvent().Publish(alertMsg);
+ logger.Info($"请先开抽屉后再打开药盒");
}
});
}
@@ -368,7 +429,7 @@ namespace DM_Weight.ViewModels
{
singleChannels.ForEach(it =>
{
- _portUtil.WriteQuantityMethod( it.Quantity + it.AddQuantity,it.DrawerNo,it.ColNo);
+ _portUtil.WriteQuantityMethod(it.Quantity + it.AddQuantity, it.DrawerNo, it.ColNo);
Thread.Sleep(200);
});
}
@@ -391,7 +452,7 @@ namespace DM_Weight.ViewModels
}
Status = 0;
_isFinishClick = false;
- _portUtil.ColNoLst = new List();
+ _portUtil.ColNoLst = new List();
}
else
{
@@ -525,5 +586,99 @@ namespace DM_Weight.ViewModels
// 取消消息订阅
_eventAggregator.GetEvent().Unsubscribe(DoMyPrismEvent);
}
+ //关闭抽屉后获取称重稳定数量
+ public void GetWeightQuantity()
+ {
+ List finalyQuantity = new List();
+ new PromiseUtil().taskAsyncLoop(200, 0, async (options, next, stop) =>
+ {
+ if (!_portUtil.Operate|| Status==0)
+ {
+ stop();
+ }
+ else
+ {
+ try
+ {
+
+ logger.Info("关闭抽屉后获取称重稳定数量");
+ if (finalyQuantity.Count >= 10)
+ {
+ for (int i = 0; i < finalyQuantity.Count; i++)
+ {
+ logger.Info($"finalyQuantity{i} {string.Join(",", finalyQuantity[i])}");
+ }
+ if (AreAllArraysEqual(finalyQuantity))
+ {
+ stop();
+ // 告诉前台数据变化
+ _eventAggregator.GetEvent().Publish(new util.DeviceMsg()
+ {
+ EventType = util.EventType.UPDATEQUANTITY,
+ WindowName = "DrawerTakeDrugWindow",
+ Quantitys = finalyQuantity[0]
+ });
+ logger.Info($"数量变化【{string.Join(",", finalyQuantity[0])}】");
+ // 重新初始化数据
+ _portUtil.ResetData();
+ CompleteIsEnable = true;
+ CancleIsEnable = true;
+ }
+ else
+ {
+ finalyQuantity.RemoveAt(0);
+ CancleIsEnable = true;
+ next();
+ }
+ }
+ else
+ {
+ if(finalyQuantity.Count>=9)
+ {
+ CancleIsEnable = true;
+ }
+ else
+ {
+ CancleIsEnable = false;
+ }
+ CompleteIsEnable = false;
+
+ _portUtil.DrawerNo = DrawerNo;
+ _portUtil.Operate = true;
+ int[] quantity = await _portUtil.CheckQuantityByAddrForMulti();
+ AfterQuantity = quantity;
+ int[] Quantitys = new int[BeforeQuantity.Length];
+ for (int i = 0; i < BeforeQuantity.Length; i++)
+ {
+ Quantitys[i] = AfterQuantity[i] - BeforeQuantity[i];
+ }
+ finalyQuantity.Add(Quantitys);
+ logger.Info($"Quantity{string.Join(",", Quantitys)}");
+ // 告诉前台数据变化
+ _eventAggregator.GetEvent().Publish(new util.DeviceMsg()
+ {
+ EventType = util.EventType.UPDATEQUANTITY,
+ WindowName = "DrawerAddDrugWindow",
+ Quantitys = finalyQuantity[0]
+ });
+ next();
+ }
+ }
+ catch (Exception ex)
+ {
+ logger.Info($"关抽屉后获取称重稳定数量异常{ex.Message}");
+ next();
+ }
+ }
+ });
+ }
+ public bool AreAllArraysEqual(List arrays)
+ {
+ if (arrays == null || arrays.Count == 0) return false;
+ // 取第一个数组作为参照进行比较
+ var referenceArray = arrays[0];
+ // 检查列表中除了第一个数组外的所有数组是否与第一个数组相等
+ return arrays.Skip(1).All(array => array.SequenceEqual(referenceArray));
+ }
}
}
diff --git a/DM_Weight/ViewModels/DrawerTakeDrugWindowViewModel.cs b/DM_Weight/ViewModels/DrawerTakeDrugWindowViewModel.cs
index 9841328..cc21fc8 100644
--- a/DM_Weight/ViewModels/DrawerTakeDrugWindowViewModel.cs
+++ b/DM_Weight/ViewModels/DrawerTakeDrugWindowViewModel.cs
@@ -23,6 +23,7 @@ using System.Text.RegularExpressions;
using System.Windows.Controls;
using DM_Weight.Common;
using System.Reflection.Metadata;
+using System.Windows.Documents;
namespace DM_Weight.ViewModels
{
@@ -79,12 +80,21 @@ namespace DM_Weight.ViewModels
{
Status = 3;
}
+ //if (ChannelStocks != null && ChannelStocks.Count > 0 && (ChannelStocks[0].BoardType == (Int32)BoardTypeEnum.weighSmartBox))
+ //{
+ // //关闭抽屉后获取称重稳定数量
+ // GetWeightQuantity();
+ //}
+ //else
+ //{
//是冰箱抽屉则开冰箱抽屉时发送延迟报警指令
CheckIsFridgeClose();
+ CompleteIsEnable = true;
+ //}
break;
// 数量变化
case EventType.UPDATEQUANTITY:
- if (Status == 2)
+ if (Status == 2 || Status == 3)
{
ChannelStocks.Where(cs => _portUtil.ColNoLst.Contains(cs.ColNo)).ToList().ForEach(it => it.TakeQuantity = msg.Quantitys[it.ColNo - 1]);
}
@@ -138,6 +148,30 @@ namespace DM_Weight.ViewModels
);
}
+ ///
+ /// 完成按钮是否可用
+ ///
+ private bool _completeIsEnable = false;
+ public bool CompleteIsEnable
+ {
+ get => _completeIsEnable;
+ set
+ {
+ SetProperty(ref _completeIsEnable, value);
+ }
+ }
+ ///
+ /// 取消按钮是否可用
+ ///
+ private bool _cancleIsEnable = true;
+ public bool CancleIsEnable
+ {
+ get => _cancleIsEnable;
+ set
+ {
+ SetProperty(ref _cancleIsEnable, value);
+ }
+ }
List ColLst = new List();
int currentCol = 0;
private int[] BeforeQuantity { get; set; } = new int[9];
@@ -152,7 +186,7 @@ namespace DM_Weight.ViewModels
}
Status = 1;
_portUtil.SpeakAsync("正在打开" + DrawerNo + "号抽屉");
- if (ChannelStocks!=null&& ChannelStocks .Count>0&& (ChannelStocks[0].BoardType == (Int32)BoardTypeEnum.weighSmartBox))
+ if (ChannelStocks != null && ChannelStocks.Count > 0 && (ChannelStocks[0].BoardType == (Int32)BoardTypeEnum.weighSmartBox))
{
try
{
@@ -160,83 +194,113 @@ namespace DM_Weight.ViewModels
_portUtil.Operate = true;
_portUtil.WindowName = "DrawerTakeDrugWindow";
byte[] buffer = await _portUtil.OpenDrawer();
+ CancleIsEnable = false;
+ if (buffer == null)
+ {
+ logger.Info("抽屉打开返回空");
+ Status = 0;
+ return;
+
+ }
int[] r = buffer.Select(it => Convert.ToInt32(it)).ToArray();
logger.Info($"OpenDrawer{string.Join(",", r)}");
if (_portUtil.DrawerState(r))
{
+ _portUtil.ColNoLst.Clear();
new PromiseUtil().taskAsyncLoop(200, 0, async (options, next, stop) =>
{
- if (Status == 3)
+
+ logger.Info("循环查抽屉状态药盒数量");
+
+ if (Status == 3 || Status == 0)
{
stop();
}
- try
+ else
{
- // 查询抽屉状态
- byte[] buffer = await _portUtil.CheckDrawerStatus();
- int[] r = buffer.Select(it => Convert.ToInt32(it)).ToArray();
- if (_portUtil.DrawerState(r))
+ try
{
- Status = 2;
- //是冰箱抽屉则开冰箱抽屉时发送延迟报警指令
- CheckIsFridgeOpen();
- if (_portUtil.ColNoLst != null && _portUtil.ColNoLst.Count > 0 || currentCol > 0)
+ // 查询抽屉状态
+ byte[] buffer = await _portUtil.CheckDrawerStatus();
+ int[] r = buffer.Select(it => Convert.ToInt32(it)).ToArray();
+ logger.Info($"抽屉状态返回{Convert.ToHexString(buffer)}");
+ if (_portUtil.DrawerState(r))
{
- //库位列表不为空查数
- if (currentCol > 0)
+ Status = 2;
+ if (_portUtil.ColNoLst != null && _portUtil.ColNoLst.Count > 0 || currentCol > 0)
{
- if (!_portUtil.ColNoLst.Contains(currentCol))
+ //库位列表不为空查数
+ if (currentCol > 0)
{
- //开药盒锁前先查数
- int beforeQuantity = await _portUtil.CheckQuantityForSingle(currentCol);
- BeforeQuantity[currentCol - 1] = beforeQuantity;
- logger.Info($"BeforeQuantity:{currentCol}-{beforeQuantity}数量{string.Join(",", BeforeQuantity)}");
- await Task.Delay(200);
- _portUtil.ColNoLst.Add(currentCol);
- }
- _portUtil.OpenBoxByColNo(currentCol);
- await Task.Delay(200);
- currentCol = 0;
- }
- // 继续查询抽屉药品数量
- // 查询抽屉药品数量
+ if (!_portUtil.ColNoLst.Contains(currentCol))
+ {
+ CancleIsEnable = false;
+ //开药盒锁前先查数
+ //Thread.Sleep(200);
+ int beforeQuantity = await _portUtil.CheckQuantityForSingle(currentCol);
+ BeforeQuantity[currentCol - 1] = beforeQuantity;
+ logger.Info($"BeforeQuantity:{currentCol}-{beforeQuantity}数量{string.Join(",", BeforeQuantity)}");
- int[] quantity = await _portUtil.CheckQuantityByAddrForMulti();
- AfterQuantity = quantity;
- logger.Info($"AfterQuantity{string.Join(",", AfterQuantity)}");
- int[] Quantitys = new int[BeforeQuantity.Length];
- for (int i = 0; i < BeforeQuantity.Length; i++)
- {
- Quantitys[i] = BeforeQuantity[i] - AfterQuantity[i];
+ _portUtil.ColNoLst.Add(currentCol);
+ }
+ await _portUtil.OpenBoxByColNo(currentCol);
+
+ currentCol = 0;
+ }
+ // 继续查询抽屉药品数量
+ // 查询抽屉药品数量
+
+ //Thread.Sleep(200);
+ int[] quantity = await _portUtil.CheckQuantityByAddrForMulti();
+ AfterQuantity = quantity;
+ logger.Info($"AfterQuantity{string.Join(",", AfterQuantity)}");
+ int[] Quantitys = new int[BeforeQuantity.Length];
+ for (int i = 0; i < BeforeQuantity.Length; i++)
+ {
+ Quantitys[i] = BeforeQuantity[i] - AfterQuantity[i];
+ }
+ // 告诉前台数据变化
+ _eventAggregator.GetEvent().Publish(new util.DeviceMsg()
+ {
+ EventType = util.EventType.UPDATEQUANTITY,
+ WindowName = "DrawerTakeDrugWindow",
+ Quantitys = Quantitys
+ });
+ logger.Info($"数量变化【{string.Join(",", Quantitys)}】");
}
- // 告诉前台数据变化
- _eventAggregator.GetEvent().Publish(new util.DeviceMsg()
- {
- EventType = util.EventType.UPDATEQUANTITY,
- WindowName = "DrawerTakeDrugWindow",
- Quantitys = Quantitys
- });
- logger.Info($"数量变化【{string.Join(",", Quantitys)}】");
+ next();
}
+ else
+ {
+ stop();
+ //关闭抽屉
+ logger.Info($"抽屉【{DrawerNo}】已关闭");
+ if (_portUtil.ColNoLst.Count > 0)
+ {
+ // 重新初始化数据
+ //_portUtil.ResetData();
+ //关闭抽屉后获取称重稳定数量
+ Thread.Sleep(200);
+ GetWeightQuantity();
+ //_portUtil.ColNoLst.Clear();
+ Status = 3;
+ }
+ else
+ {
+ Status = 0;
+ CancleIsEnable = true;
+ _portUtil.ResetData();
+ }
+ CompleteIsEnable = false;
+ }
+ }
+ catch (Exception ex)
+ {
+ logger.Info($"异常{ex.Message}");
next();
}
- else
- {
- Status = 3;
- //关闭抽屉
- logger.Info($"抽屉【{DrawerNo}】已关闭");
- // 重新初始化数据
- _portUtil.ResetData();
- //是冰箱抽屉则开冰箱抽屉时发送延迟报警指令
- CheckIsFridgeClose();
- stop();
- }
- }
- catch (Exception ex)
- {
- logger.Info($"异常{ex.Message}");
}
});
}
@@ -367,7 +431,7 @@ namespace DM_Weight.ViewModels
{
singleChannels.ForEach(it =>
{
- _portUtil.WriteQuantityMethod(it.Quantity - it.TakeQuantity, it.DrawerNo, it.ColNo );
+ _portUtil.WriteQuantityMethod(it.Quantity - it.TakeQuantity, it.DrawerNo, it.ColNo);
Thread.Sleep(200);
});
@@ -524,5 +588,98 @@ namespace DM_Weight.ViewModels
// 取消消息订阅
_eventAggregator.GetEvent().Unsubscribe(DoMyPrismEvent);
}
+
+ //关闭抽屉后获取称重稳定数量
+ public void GetWeightQuantity()
+ {
+
+ List finalyQuantity = new List();
+ new PromiseUtil().taskAsyncLoop(200, 0, async (options, next, stop) =>
+ {
+ if (!_portUtil.Operate || Status == 0)
+ {
+ stop();
+ }
+ else
+ {
+ try
+ {
+ logger.Info("关闭抽屉后获取称重稳定数量");
+ if (finalyQuantity.Count >= 10)
+ {
+ for (int i = 0; i < finalyQuantity.Count; i++)
+ {
+ logger.Info($"finalyQuantity{i} {string.Join(",", finalyQuantity[i])}");
+ }
+ if (AreAllArraysEqual(finalyQuantity))
+ {
+ stop();
+ // 告诉前台数据变化
+ _eventAggregator.GetEvent().Publish(new util.DeviceMsg()
+ {
+ EventType = util.EventType.UPDATEQUANTITY,
+ WindowName = "DrawerTakeDrugWindow",
+ Quantitys = finalyQuantity[0]
+ });
+ logger.Info($"数量变化【{string.Join(",", finalyQuantity[0])}】");
+ // 重新初始化数据
+ _portUtil.ResetData();
+ CompleteIsEnable = true;
+ CancleIsEnable = true;
+ }
+ else
+ {
+ finalyQuantity.RemoveAt(0);
+ CancleIsEnable = true;
+ next();
+ }
+ }
+ else
+ {
+ if (finalyQuantity.Count >= 9)
+ {
+ CancleIsEnable = true;
+ }
+ else
+ {
+ CancleIsEnable = false;
+ }
+ CompleteIsEnable = false;
+ _portUtil.DrawerNo = DrawerNo;
+ int[] quantity = await _portUtil.CheckQuantityByAddrForMulti();
+ AfterQuantity = quantity;
+ int[] Quantitys = new int[BeforeQuantity.Length];
+ for (int i = 0; i < BeforeQuantity.Length; i++)
+ {
+ Quantitys[i] = BeforeQuantity[i] - AfterQuantity[i];
+ }
+ finalyQuantity.Add(Quantitys);
+ logger.Info($"Quantity{string.Join(",", Quantitys)}");
+ // 告诉前台数据变化
+ _eventAggregator.GetEvent().Publish(new util.DeviceMsg()
+ {
+ EventType = util.EventType.UPDATEQUANTITY,
+ WindowName = "DrawerTakeDrugWindow",
+ Quantitys = finalyQuantity[0]
+ });
+ next();
+ }
+ }
+ catch (Exception ex)
+ {
+ logger.Info($"关闭抽屉后获取称重稳定数量异常{ex.Message}");
+ next();
+ }
+ }
+ });
+ }
+ public bool AreAllArraysEqual(List arrays)
+ {
+ if (arrays == null || arrays.Count == 0) return false;
+ // 取第一个数组作为参照进行比较
+ var referenceArray = arrays[0];
+ // 检查列表中除了第一个数组外的所有数组是否与第一个数组相等
+ return arrays.Skip(1).All(array => array.SequenceEqual(referenceArray));
+ }
}
}
diff --git a/DM_Weight/ViewModels/MainWindowViewModel.cs b/DM_Weight/ViewModels/MainWindowViewModel.cs
index 06c6ea0..d63f0c3 100644
--- a/DM_Weight/ViewModels/MainWindowViewModel.cs
+++ b/DM_Weight/ViewModels/MainWindowViewModel.cs
@@ -83,30 +83,30 @@ namespace DM_Weight.ViewModels
}));
- #region 温度查询定时
- int interval = Convert.ToInt32(ConfigurationManager.AppSettings["Interval"]);
- if (interval > 0)
- {
- System.Timers.Timer doorTimer = new System.Timers.Timer();
+ //#region 温度查询定时
+ //int interval = Convert.ToInt32(ConfigurationManager.AppSettings["Interval"]);
+ //if (interval > 0)
+ //{
+ // System.Timers.Timer doorTimer = new System.Timers.Timer();
- doorTimer.Elapsed += new System.Timers.ElapsedEventHandler(doorStatus);
- doorTimer.Interval = interval;
- doorTimer.Start();
- }
- #endregion
+ // doorTimer.Elapsed += new System.Timers.ElapsedEventHandler(doorStatus);
+ // doorTimer.Interval = interval;
+ // doorTimer.Start();
+ //}
+ //#endregion
}
///
/// 监测后门是否打开
///
- private async void doorStatus(object sender, ElapsedEventArgs e)
- {
- if (!_portUtil.Operate)
- {
- //监测后门是否打开
- _portUtil.GetSingleBoardBackDoorState();
+ //private async void doorStatus(object sender, ElapsedEventArgs e)
+ //{
+ // if (!_portUtil.Operate)
+ // {
+ // //监测后门是否打开
+ // _portUtil.GetSingleBoardBackDoorState();
- }
- }
+ // }
+ //}
void doMyPrismEvent2(AlertMsg msg)
{
switch (msg.Type)
diff --git a/DM_Weight/ViewModels/OrderTakeDrugWindowViewModel.cs b/DM_Weight/ViewModels/OrderTakeDrugWindowViewModel.cs
index a76c0d9..dbed7bf 100644
--- a/DM_Weight/ViewModels/OrderTakeDrugWindowViewModel.cs
+++ b/DM_Weight/ViewModels/OrderTakeDrugWindowViewModel.cs
@@ -245,7 +245,7 @@ namespace DM_Weight.ViewModels
//接收导航传过来的参数 现在是在此处初始化了表格数据
public void OnNavigatedTo(NavigationContext navigationContext)
{
- _eventAggregator.GetEvent().Subscribe(DoMyPrismEvent);
+ //_eventAggregator.GetEvent().Subscribe(DoMyPrismEvent);
RequestData();
}
@@ -260,16 +260,16 @@ namespace DM_Weight.ViewModels
{
// 取消消息订阅
- _eventAggregator.GetEvent().Unsubscribe(DoMyPrismEvent);
+ //_eventAggregator.GetEvent().Unsubscribe(DoMyPrismEvent);
}
- void DoMyPrismEvent(DeviceMsg msg)
- {
- if (msg.EventType == EventType.CODESCAN)
- {
- SearchValue = msg.Code;
- }
+ //void DoMyPrismEvent(DeviceMsg msg)
+ //{
+ // if (msg.EventType == EventType.CODESCAN)
+ // {
+ // SearchValue = msg.Code;
+ // }
- }
+ //}
}
}
diff --git a/DM_Weight/ViewModels/SelfTakeDialogViewModel.cs b/DM_Weight/ViewModels/SelfTakeDialogViewModel.cs
index 6a1d514..8e57348 100644
--- a/DM_Weight/ViewModels/SelfTakeDialogViewModel.cs
+++ b/DM_Weight/ViewModels/SelfTakeDialogViewModel.cs
@@ -101,7 +101,7 @@ namespace DM_Weight.ViewModels
case EventType.UPDATEQUANTITY:
if (Status == 1)
{
- logger.Info($"抽屉【{DrawerNo}】库位药品数量【{msg.Quantitys}】");
+ logger.Info($"抽屉【{DrawerNo}】库位药品数量【{string.Join(",", msg.Quantitys)}】");
}
break;
// 打开失败
diff --git a/DM_Weight/Views/BiaoDingWindow.xaml b/DM_Weight/Views/BiaoDingWindow.xaml
index 62a1f87..999cc43 100644
--- a/DM_Weight/Views/BiaoDingWindow.xaml
+++ b/DM_Weight/Views/BiaoDingWindow.xaml
@@ -302,12 +302,12 @@
Header="库存"
IsReadOnly="True"
ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
-
+
+
+
+
+
+
+
+
+
+
+
+
-->
-