查药盒状态返回改为bool

This commit is contained in:
maqiao 2025-10-24 14:29:56 +08:00
parent 3554a2e824
commit 2132e14676
5 changed files with 55 additions and 12 deletions

View File

@ -297,9 +297,17 @@
{
//药盒抽屉,开药盒
if (currentCol > 0)
{
bool boxStatus =await PortUtil.BoxLockStateForErZhong(drawerNo, currentCol);
if (boxStatus)
{
logger.Info("药盒已打开,无需再开药盒");
}
else
{
await PortUtil.OpenBoxByColNoForErZhong(currentCol);
}
}
currentCol = 0;
}
@ -515,6 +523,8 @@
PortUtil.speechSynthesizer.SpeakAsyncCancelAll();
PortUtil.SpeakAsync("请先点取药按钮打开抽屉");
}
currentCol = args.Data.ColNo;
grid.EditRow(args.Data);
}

View File

@ -553,9 +553,17 @@
}
//药盒抽屉,开药盒
if (currentCol > 0)
{
bool boxStatus = await PortUtil.BoxLockStateForErZhong(drawerNo, currentCol);
if (boxStatus)
{
logger.Info("药盒已打开,无需再开药盒");
}
else
{
await PortUtil.OpenBoxByColNoForErZhong(currentCol);
}
}
currentCol = 0;
}
@ -786,7 +794,7 @@
grid.Reload();
}
void OnCellClick(DataGridCellMouseEventArgs<ChannelStock> args)
async Task OnCellClick(DataGridCellMouseEventArgs<ChannelStock> args)
{
// if (args.Data.BoardType.ToString().Contains("3"))
// {
@ -805,7 +813,22 @@
PortUtil.speechSynthesizer.SpeakAsyncCancelAll();
PortUtil.SpeakAsync("请先点取药按钮打开抽屉");
}
if (setting.Value.box.Contains(args.Data.DrawerNo))
{
bool boxStatus=await PortUtil.BoxLockStateForErZhong(args.Data.DrawerNo, args.Data.ColNo);
if(boxStatus)
{
logger.Info("药盒已打开,无需再开药盒");
}
else
{
currentCol = args.Data.ColNo;
}
}
else
{
currentCol = args.Data.ColNo;
}
grid.EditRow(args.Data);
}
private IDisposable? registration;

View File

@ -1696,14 +1696,24 @@ namespace MasaBlazorApp3.Port
#region
// 指定药盒状态查询
public async Task<byte[]> BoxLockStateForErZhong(int DrawerNo, int ColNo)
public async Task<bool> BoxLockStateForErZhong(int DrawerNo, int ColNo)
{
canBusSerial.DiscardInBuffer();
var channel = Convert.ToInt32(((DrawerNo == 1 ? 22 : 25) + Math.Ceiling((decimal)ColNo / (decimal)3)).ToString(), 16);
byte[] buffer = new byte[] { 0xaa, (byte)channel, 0x02, 0x00, 0x00, 0x00, 0x00, 0xee };
canBusSerial.Write(buffer, 0, 8);
return await GetBufferByPort(canBusSerial, 8);
byte[] retBuffer = await GetBufferByPort(canBusSerial, 8);
logger.Info($"查询药盒状态返回{ColNo}【{Convert.ToHexString(retBuffer)}】");
int[] r = retBuffer.Select(it => Convert.ToInt32(it)).ToArray();
if (r[4] > 0)
{
return true;
}
else
{
return false;
}
}
/// <summary>

View File

@ -24,14 +24,14 @@
//"drawerProtocol": 485,
"scanCodePortPath": "COM1",
"canBusExsit": true,
"canBusPortPath": "COM2",
"canBusPortPath": "COM9",
"totalDrawerCount": 16,
"canBusTwoExsit": true,
"StorageCan": 1,
//can线
//"canBusPortPathTwo": "COM9",
//"doorAddr": 0,
//"storageBoxAddr": 0,
"storageBoxAddr": 0,
//"fridgePortExist": false,
//"fridgePortPath": "COM3"
},