称重抽屉提示串口交互超时异常修复

This commit is contained in:
maqiao 2025-04-08 09:06:27 +08:00
parent d43c7bee54
commit 86f06ce191
16 changed files with 750 additions and 222 deletions

View File

@ -3,7 +3,7 @@
<connectionStrings>
<!-- 数据库连接字符串 -->
<!--<add name="database" connectionString="server=127.0.0.1;database=wpf_dm_program;userid=root;password=qq1223" />-->
<add name="database" connectionString="server=127.0.0.1;port=3306;database=test_db;userid=root;password=root" />
<add name="database" connectionString="server=127.0.0.1;port=3306;database=xichang_db;userid=root;password=root" />
</connectionStrings>
<!--<runtime>
--><!--配置之后Appdomain.CurrentDomain.UnhandledException 事件的 IsTerminating 就变成了 false 啦!也就是说,程序并不会因为这次的异常而崩溃退出。--><!--
@ -12,7 +12,7 @@
<appSettings>
<!-- 设备id -->
<add key="machineId" value="DM2" />
<add key="machineId" value="DM1" />
<!--2023/7/13 药房代码 有则写无则空 -->
<add key="storage" value="" />
<!-- 登录模式 1单人登录2双人登录 -->

View File

@ -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;
}

View File

@ -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;
}
}
}

View File

@ -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);
}
/// <summary>
/// 标定按钮是否可用
/// </summary>
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<IDialogResult> 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<SnackbarEvent>().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<SnackbarEvent>().Publish(alertMsg);
i = 0;
// 更新数据 标定状态
channelStock.PosNo = 1;
SqlSugarHelper.Db.Updateable<ChannelStock>(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<SnackbarEvent>().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<SnackbarEvent>().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<int>().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();
}
}
});
}
}
}

View File

@ -109,6 +109,15 @@ namespace DM_Weight.ViewModels
public bool Is17Drawer { get => _is17Drawer; set => SetProperty(ref _is17Drawer, value); }
public DelegateCommand<string> UpdateDrawerNo
{
get => new DelegateCommand<string>((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))

View File

@ -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);
}

View File

@ -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);

View File

@ -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
);
}
/// <summary>
/// 完成按钮是否可用
/// </summary>
private bool _completeIsEnable = false;
public bool CompleteIsEnable
{
get => _completeIsEnable;
set
{
SetProperty(ref _completeIsEnable, value);
}
}
/// <summary>
/// 取消按钮是否可用
/// </summary>
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<int>().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<PortUtilEvent>().Publish(new util.DeviceMsg()
{
EventType = util.EventType.UPDATEQUANTITY,
WindowName = "DrawerAddDrugWindow",
Quantitys = Quantitys
});
logger.Info($"数量变化【{string.Join(",", Quantitys)}】");
}
// 告诉前台数据变化
_eventAggregator.GetEvent<PortUtilEvent>().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<SnackbarEvent>().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<ChannelStock> singleChannels = ChannelStocks.FindAll(it => it.BoardType != (Int32)BoardTypeEnum.separation);
{
List<ChannelStock> 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<SnackbarEvent>().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<int>();
_portUtil.ColNoLst = new List<int>();
}
else
{
@ -525,5 +586,99 @@ namespace DM_Weight.ViewModels
// 取消消息订阅
_eventAggregator.GetEvent<PortUtilEvent>().Unsubscribe(DoMyPrismEvent);
}
//关闭抽屉后获取称重稳定数量
public void GetWeightQuantity()
{
List<int[]> finalyQuantity = new List<int[]>();
new PromiseUtil<int>().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<PortUtilEvent>().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<PortUtilEvent>().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<int[]> arrays)
{
if (arrays == null || arrays.Count == 0) return false;
// 取第一个数组作为参照进行比较
var referenceArray = arrays[0];
// 检查列表中除了第一个数组外的所有数组是否与第一个数组相等
return arrays.Skip(1).All(array => array.SequenceEqual(referenceArray));
}
}
}

View File

@ -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
);
}
/// <summary>
/// 完成按钮是否可用
/// </summary>
private bool _completeIsEnable = false;
public bool CompleteIsEnable
{
get => _completeIsEnable;
set
{
SetProperty(ref _completeIsEnable, value);
}
}
/// <summary>
/// 取消按钮是否可用
/// </summary>
private bool _cancleIsEnable = true;
public bool CancleIsEnable
{
get => _cancleIsEnable;
set
{
SetProperty(ref _cancleIsEnable, value);
}
}
List<int> ColLst = new List<int>();
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<int>().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<PortUtilEvent>().Publish(new util.DeviceMsg()
{
EventType = util.EventType.UPDATEQUANTITY,
WindowName = "DrawerTakeDrugWindow",
Quantitys = Quantitys
});
logger.Info($"数量变化【{string.Join(",", Quantitys)}】");
}
// 告诉前台数据变化
_eventAggregator.GetEvent<PortUtilEvent>().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<PortUtilEvent>().Unsubscribe(DoMyPrismEvent);
}
//关闭抽屉后获取称重稳定数量
public void GetWeightQuantity()
{
List<int[]> finalyQuantity = new List<int[]>();
new PromiseUtil<int>().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<PortUtilEvent>().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<PortUtilEvent>().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<int[]> arrays)
{
if (arrays == null || arrays.Count == 0) return false;
// 取第一个数组作为参照进行比较
var referenceArray = arrays[0];
// 检查列表中除了第一个数组外的所有数组是否与第一个数组相等
return arrays.Skip(1).All(array => array.SequenceEqual(referenceArray));
}
}
}

View File

@ -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
}
/// <summary>
/// 监测后门是否打开
/// </summary>
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)

View File

@ -245,7 +245,7 @@ namespace DM_Weight.ViewModels
//接收导航传过来的参数 现在是在此处初始化了表格数据
public void OnNavigatedTo(NavigationContext navigationContext)
{
_eventAggregator.GetEvent<PortUtilEvent>().Subscribe(DoMyPrismEvent);
//_eventAggregator.GetEvent<PortUtilEvent>().Subscribe(DoMyPrismEvent);
RequestData();
}
@ -260,16 +260,16 @@ namespace DM_Weight.ViewModels
{
// 取消消息订阅
_eventAggregator.GetEvent<PortUtilEvent>().Unsubscribe(DoMyPrismEvent);
//_eventAggregator.GetEvent<PortUtilEvent>().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;
// }
}
//}
}
}

View File

@ -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;
// 打开失败

View File

@ -302,12 +302,12 @@
Header="库存"
IsReadOnly="True"
ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
<!--<DataGridTextColumn Width="80"
<DataGridTextColumn Width="80"
Binding="{Binding PosNo,Converter={StaticResource BiaoDingStatusConverter},ConverterParameter=BiaoDingStatus}"
Header="状态"
IsReadOnly="True"
ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
<DataGridTemplateColumn Width="100" Header="标定数量">
<!--<DataGridTemplateColumn Width="100" Header="标定数量">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBox IsEnabled="{Binding PosNo,Converter={StaticResource BiaoDingStatusConverter},ConverterParameter=AddQuantityEnabled}" Style="{StaticResource MaterialDesignDataGridTextColumnEditingStyle}">

View File

@ -11,7 +11,7 @@
mc:Ignorable="d"
MinWidth="380" Width="Auto"
Height="Auto">
<UserControl.Resources>
<convert:StatusConverter x:Key="StatusConverter" />
</UserControl.Resources>
@ -29,6 +29,7 @@
Foreground="{DynamicResource PrimaryHueDarkForegroundBrush}"
HorizontalAlignment="Right"
Command="{Binding BtnCloseCommand}"
ToolTip="关闭"
>
<materialDesign:PackIcon Kind="Close" Width="34" Height="34" />
@ -36,7 +37,7 @@
</Grid>
<StackPanel Grid.Row="1" Margin="0">
<TextBlock Text="{Binding StrMessage}" Margin="12" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="14" FontWeight="Bold" />
<TextBlock Text="{Binding StrMessage}" Margin="12" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="14" FontWeight="Bold" />
<TextBox Height="50" Width="200"
Grid.Column="1"
materialDesign:HintAssist.Hint="标定数量"
@ -65,9 +66,17 @@ Style="{StaticResource MaterialDesignOutlinedTextBox}">
Style="{StaticResource MaterialDesignRaisedAccentButton}"
materialDesign:ButtonProgressAssist.IsIndicatorVisible="{Binding Status, Converter={StaticResource StatusConverter}, ConverterParameter=biaoDingBtnLoading}"
materialDesign:ButtonProgressAssist.IsIndeterminate="{Binding Status, Converter={StaticResource StatusConverter}, ConverterParameter=biaoDingBtnLoading}"
Content="标定"
Content="标定" IsEnabled="{Binding BiaoDingEnable}"
Command="{Binding BiaoDingCommand}">
</Button>
<Button
Margin="6"
Visibility="{Binding Status, Converter={StaticResource StatusConverter}, ConverterParameter=CancelBtn}"
Style="{StaticResource MaterialDesignRaisedButton}"
Background="Orange"
BorderBrush="Orange"
Content="取消"
Command="{Binding CancelCommand}" />
<!--<Button
Margin="2"
Visibility="{Binding Status, Converter={StaticResource StatusConverter}, ConverterParameter=CompleteBtn}"
@ -85,6 +94,9 @@ Style="{StaticResource MaterialDesignOutlinedTextBox}">
</StackPanel>
</Grid>
<materialDesign:Snackbar
Background="{Binding SnackbarBackground}"
MessageQueue="{Binding SnackbarMessageQueue}"/>
</Grid>
</materialDesign:Card>
</UserControl>

View File

@ -167,7 +167,7 @@
VerticalAlignment="Center"
Command="{Binding TakeFinish}"
Visibility="{Binding Status, Converter={StaticResource StatusConverter}, ConverterParameter=CompleteBtn}"
Style="{StaticResource MaterialDesignOutlinedLightButton}"
Style="{StaticResource MaterialDesignOutlinedLightButton}" IsEnabled="{Binding CompleteIsEnable}"
Content="完成" />
<Button
@ -176,6 +176,7 @@
Command="{Binding CancleTake}"
Visibility="{Binding Status, Converter={StaticResource StatusConverter}, ConverterParameter=CancelBtn}"
Style="{StaticResource MaterialDesignOutlinedLightButton}"
IsEnabled="{Binding CancleIsEnable}"
Content="取消" />
</StackPanel>
<DataGrid

View File

@ -20,6 +20,7 @@
</UserControl.Resources>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
@ -76,7 +77,7 @@
</Grid>
</Grid>
<Grid Margin="0" Grid.Column="0" Width="300" Height="570" Visibility="{Binding Is16Drawer, Converter={StaticResource BooleanToVisibilityConverter}}">
<Grid Margin="0" Grid.Column="1" Width="300" Height="570" Visibility="{Binding Is16Drawer, Converter={StaticResource BooleanToVisibilityConverter}}">
<Grid.Resources>
<Style TargetType="{x:Type Button}" BasedOn="{StaticResource MaterialDesignPaperLightButton}">
<Setter Property="Foreground" Value="#00a0ea" />
@ -146,7 +147,7 @@
</Grid>
</Grid>
<Grid Grid.Column="1" Margin="6">
<Grid Grid.Column="2" Margin="6">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition />
@ -167,6 +168,7 @@
Command="{Binding TakeFinish}"
Visibility="{Binding Status, Converter={StaticResource StatusConverter}, ConverterParameter=CompleteBtn}"
Style="{StaticResource MaterialDesignOutlinedLightButton}"
IsEnabled="{Binding CompleteIsEnable}"
Content="完成" />
<Button
@ -175,6 +177,7 @@
Command="{Binding CancleTake}"
Visibility="{Binding Status, Converter={StaticResource StatusConverter}, ConverterParameter=CancelBtn}"
Style="{StaticResource MaterialDesignOutlinedLightButton}"
IsEnabled="{Binding CancleIsEnable}"
Content="取消" />
</StackPanel>
<DataGrid
@ -211,7 +214,18 @@
Header="库位"
IsReadOnly="True"
ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
<DataGridTextColumn Width="181"
<DataGridTemplateColumn Header="药品名称">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<StackPanel>
<TextBlock TextAlignment="Center" Text="{Binding DrugInfo.DrugName}"/>
<TextBlock TextAlignment="Center" Text="{Binding DrugInfo.DrugSpec}"/>
</StackPanel>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<!--<DataGridTextColumn
Binding="{Binding DrugInfo.DrugName}"
Header="药品名称"
IsReadOnly="True"
@ -230,8 +244,19 @@
Binding="{Binding EffDate}"
Header="效期"
IsReadOnly="True"
ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
<DataGridTextColumn Width="80"
ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>-->
<DataGridTemplateColumn Header="批次">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<StackPanel>
<TextBlock TextAlignment="Center" Text="{Binding ManuNo}"/>
<TextBlock TextAlignment="Center" Text="{Binding EffDate}"/>
</StackPanel>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTextColumn Width="60"
Binding="{Binding Quantity}"
Header="库存"
IsReadOnly="True"
@ -247,7 +272,7 @@
</Binding>
</DataGridTextColumn.Binding>
</DataGridTextColumn>-->
<DataGridTemplateColumn Width="100"
<DataGridTemplateColumn Width="90"
Header="取出数量">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>