添加可设置抽屉报警开关功能

This commit is contained in:
maqiao 2025-10-16 09:14:04 +08:00
parent e003226392
commit 89ada2c5d9
4 changed files with 58 additions and 4 deletions

View File

@ -33,6 +33,17 @@
</RadzenRadioButtonList> </RadzenRadioButtonList>
</RadzenStack> *@ </RadzenStack> *@
</RadzenStack> </RadzenStack>
<RadzenStack Orientation="Orientation.Horizontal" AlignItems="AlignItems.Start" Wrap="FlexWrap.Wrap">
<RadzenStack Orientation="Orientation.Vertical" Gap="4px">
抽屉报警
<RadzenRadioButtonList Value=@alert TValue="int" Change=@(args => alert = args)>
<Items>
<RadzenRadioButtonListItem Text="开启" Value="1" />
<RadzenRadioButtonListItem Text="关闭" Value="0" />
</Items>
</RadzenRadioButtonList>
</RadzenStack>
</RadzenStack>
</RadzenCard> </RadzenCard>
</div> </div>
</div> </div>
@ -40,12 +51,15 @@
@inject Microsoft.Extensions.Options.IOptions<Pojo.Config.setting> setting; @inject Microsoft.Extensions.Options.IOptions<Pojo.Config.setting> setting;
@inject Microsoft.Extensions.Options.IOptions<Pojo.Config.SettingConfig> setting; @inject Microsoft.Extensions.Options.IOptions<Pojo.Config.SettingConfig> setting;
@inject NotificationService _message @inject NotificationService _message
@inject PortUtil PortUtil;
@code { @code {
private readonly ILog logger = LogManager.GetLogger(typeof(LoginDialog)); private readonly ILog logger = LogManager.GetLogger(typeof(LoginDialog));
int loginValue = 1; int loginValue = 1;
//报警
int alert = 0;
// int preValue = 1; // int preValue = 1;
protected override void OnInitialized() protected override void OnInitialized()
{ {
@ -55,6 +69,15 @@
//保存 //保存
async Task SaveMethod() async Task SaveMethod()
{ {
//开抽屉时报警状态,发送指令
if(alert==0)
{
await PortUtil.AlertClose();
}
else
{
await PortUtil.AlertOpen();
}
// 获取当前工作目录 // 获取当前工作目录
string currentDirectory = Directory.GetCurrentDirectory(); string currentDirectory = Directory.GetCurrentDirectory();
// setting.Value.fridgeState = fridgeStateValue; // setting.Value.fridgeState = fridgeStateValue;
@ -64,6 +87,7 @@
string jsonString = File.ReadAllText(filePath); string jsonString = File.ReadAllText(filePath);
var jsonNode = JObject.Parse(jsonString); var jsonNode = JObject.Parse(jsonString);
jsonNode["setting"]["loginMode"] = loginValue; jsonNode["setting"]["loginMode"] = loginValue;
jsonNode["setting"]["alert"] = alert;
var options = new JsonSerializerOptions { WriteIndented = true }; var options = new JsonSerializerOptions { WriteIndented = true };
File.WriteAllText(filePath, jsonNode.ToString(Newtonsoft.Json.Formatting.Indented)); File.WriteAllText(filePath, jsonNode.ToString(Newtonsoft.Json.Formatting.Indented));
_message.Notify( _message.Notify(

View File

@ -23,6 +23,8 @@ namespace MasaBlazorApp3.Pojo.Config
//麻醉医师姓名 //麻醉医师姓名
public string anaesthetist_name { get; set; } public string anaesthetist_name { get; set; }
public string boxColor { get; set; } public string boxColor { get; set; }
//报警
public int alert { get; set; }
} }
} }

View File

@ -1560,5 +1560,31 @@ namespace MasaBlazorApp3.Port
} }
#endregion #endregion
#region
//抽屉报警开启
public async Task AlertOpen()
{
drawerSerial.DiscardInBuffer();
byte[] buffer = new byte[] { 0xAA, 0x13, 0xA, 0xEE };
logger.Info($"打开抽屉报警1{Convert.ToHexString(buffer)}");
drawerSerial.Write(buffer, 0, 4);
await Task.Delay(20);
byte[] buffer2 = new byte[] { 0xAA, 0x23, 0xA, 0xEE };
logger.Info($"打开抽屉报警2{Convert.ToHexString(buffer2)}");
drawerSerial.Write(buffer2, 0, 4);
}
//抽屉报警关闭
public async Task AlertClose()
{
drawerSerial.DiscardInBuffer();
byte[] buffer = new byte[] { 0xAA, 0x13, 0x0, 0xEE };
logger.Info($"关闭抽屉报警1{Convert.ToHexString(buffer)}");
drawerSerial.Write(buffer, 0, 4);
await Task.Delay(20);
byte[] buffer2 = new byte[] { 0xAA, 0x23, 0x0, 0xEE };
logger.Info($"关闭抽屉报警2{Convert.ToHexString(buffer2)}");
drawerSerial.Write(buffer2, 0, 4);
}
#endregion
} }
} }

View File

@ -19,14 +19,16 @@
"autoOutLog": 0, "autoOutLog": 0,
"boxMachineId": "DM5", "boxMachineId": "DM5",
"anaesthetist_name": "未选择,杨俊哲,周丹,刘方,罗丁,陈晓龙,杜金菊,季楠,王彩红,凌娜佳,汪宏,谈世刚,罗中兵,郭慧,廖家涛,殷国江,李坤,周翔,秦明哲,王庆利,张燕辉,姜佳佳,宋晓阳,胡晓", "anaesthetist_name": "未选择,杨俊哲,周丹,刘方,罗丁,陈晓龙,杜金菊,季楠,王彩红,凌娜佳,汪宏,谈世刚,罗中兵,郭慧,廖家涛,殷国江,李坤,周翔,秦明哲,王庆利,张燕辉,姜佳佳,宋晓阳,胡晓",
"boxColor": "白,绿" "boxColor": "白,绿",
//01
"alert": 0
}, },
"port": { "port": {
"drawerPortPath": "COM2", "drawerPortPath": "COM5",
"drawerProtocol": 485, "drawerProtocol": 485,
"scanCodePortPath": "COM1", "scanCodePortPath": "COM3",
"canBusExsit": true, "canBusExsit": true,
"canBusPortPath": "COM5", "canBusPortPath": "COM6",
"totalDrawerCount": 16, "totalDrawerCount": 16,
"canBusTwoExsit": true, "canBusTwoExsit": true,
"StorageCan": 1, "StorageCan": 1,