更新冰箱功能

This commit is contained in:
maqiao 2025-10-30 14:09:44 +08:00
parent 24a3002084
commit 716f0a1967
5 changed files with 142 additions and 397 deletions

View File

@ -37,7 +37,7 @@
<!-- 按处方还药或者按取药记录还药 1:处方ReturnDrugWindow22药品ReturnDrugWindow--> <!-- 按处方还药或者按取药记录还药 1:处方ReturnDrugWindow22药品ReturnDrugWindow-->
<add key="returnDrugMode" value="2" /> <add key="returnDrugMode" value="2" />
<!-- 自动退出时间单位秒为0时不自动退出 --> <!-- 自动退出时间单位秒为0时不自动退出 -->
<add key="autoExit" value="10"/> <add key="autoExit" value="0"/>
<!-- 无操作退出录像时间单位秒为0时不退出录像 --> <!-- 无操作退出录像时间单位秒为0时不退出录像 -->
<add key="stopRecord" value="0"/> <add key="stopRecord" value="0"/>
@ -64,7 +64,7 @@
<!--是否有冰箱抽屉0无1有一个2两个--> <!--是否有冰箱抽屉0无1有一个2两个-->
<add key="hasFridge" value="1"/> <add key="hasFridge" value="1"/>
<!-- 冰箱的串口号 --> <!-- 冰箱的串口号 -->
<add key="FridgePortPath" value="COM12" /> <add key="FridgePortPath" value="COM31" />
<!--冰箱抽屉温度区间--> <!--冰箱抽屉温度区间-->
<add key="temperatureRange" value="2-8"/> <add key="temperatureRange" value="2-8"/>

View File

@ -29,6 +29,7 @@ using DM_Weight.Common;
using System.Net; using System.Net;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
using OracleInternal.SqlAndPlsqlParser.RuleProcessors;
namespace DM_Weight.Port namespace DM_Weight.Port
{ {
@ -1887,6 +1888,50 @@ namespace DM_Weight.Port
#region #region
/// <summary>
/// 查询冰箱继电器状态
/// </summary>
/// <param name="iIndex"></param>
/// <returns></returns>
public async Task<int> GetFridgeState(int iIndex)
{
int frodgeState = 0;
try
{
fridgeSerial.DiscardInBuffer();
byte bAddress;
if( iIndex == 1)
{
bAddress = 0x01;
}
else
{
bAddress = 0x02;
}
byte[] buffer = new byte[] { bAddress, 0x03, 0x00, 0x00, 0x00, 0x01 };
//获取数组CRC校验码
byte[] byteDate = CRC16MODBUS.CrcModBus(buffer);
int dataLength = buffer.Length;
Array.Resize(ref buffer, dataLength + byteDate.Length);
for (int i = 0; i < byteDate.Length; i++)
{
buffer[dataLength + i] = byteDate[i];
}
logger.Info($"获取冰箱继电器状态【{Convert.ToHexString(buffer)}】");
fridgeSerial.Write(buffer, 0, 8);
byte[] retByte = await GetBufferByPort(fridgeSerial, 7);
logger.Info($"获取冰箱继电器状态返回【{Convert.ToHexString(retByte)}】");
if (retByte != null && retByte.Length >= 7)
{
frodgeState = Convert.ToInt32(retByte[4]);
}
}
catch (Exception ex)
{
logger.Info($"检测冰箱继电器状态发生异常ex:{ex.Message}");
}
return frodgeState;
}
/// <summary> /// <summary>
/// 获取冰箱温度 /// 获取冰箱温度
@ -1907,7 +1952,7 @@ namespace DM_Weight.Port
{ {
bAddress = 0x02; bAddress = 0x02;
} }
byte[] buffer = new byte[] { bAddress, 0x03, 0x00, 0x03, 0x02 }; byte[] buffer = new byte[] { bAddress, 0x03, 0x00, 0x03, 0x00, 0x01 };
//获取数组CRC校验码 //获取数组CRC校验码
byte[] byteDate = CRC16MODBUS.CrcModBus(buffer); byte[] byteDate = CRC16MODBUS.CrcModBus(buffer);
@ -1943,209 +1988,15 @@ namespace DM_Weight.Port
return temperature; return temperature;
} }
/// <summary> /// <summary>
/// 冰箱使能 /// 冰箱温度设定最低温与最高温
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public async Task FridegOpenForNew(int iIndex) public async Task SetFridgeLowHeightForNew(float min,float max, int iIndex)
{
try
{
fridgeSerial.DiscardInBuffer();
byte bAddress;
if (iIndex == 1)
{
bAddress = 0x01;
}
else
{
bAddress = 0x02;
}
//byte[] buffer = new byte[] { bAddress, 0x06, 0x10, 0xD4, 0x00, 0x01, 0x0C, 0xF2 };
byte[] buffer = new byte[] { 0x01, 0x06, 0x00, 0x10,0x00, 0x01 };
//获取数组CRC校验码
byte[] byteDate = CRC16MODBUS.CrcModBus(buffer);
//Array.Reverse(byteDate);
int dataLength = buffer.Length;
Array.Resize(ref buffer, dataLength + byteDate.Length);
for (int i = 0; i < byteDate.Length; i++)
{
buffer[dataLength + i] = byteDate[i];
}
logger.Info($"冰箱使能【{Convert.ToHexString(buffer)}】");
fridgeSerial.Write(buffer, 0, 8);
await Task.Delay(80);
}
catch (Exception ex)
{
logger.Info($"冰箱使能发生异常ex:{ex.Message}");
}
FridgeOperate = false;
}
/// <summary>
/// 冰箱失能
/// </summary>
/// <returns></returns>
public async Task FridgeOffForNew(int iIndex)
{
try
{
fridgeSerial.DiscardInBuffer();
byte bAddress;
if (iIndex == 1)
{
bAddress = 0x01;
}
else
{
bAddress = 0x02;
}
//byte[] buffer = new byte[] { bAddress, 0x06, 0x10, 0xD4, 0x00, 0x00, 0xCD, 0x32 };
byte[] buffer = new byte[] { 0x01, 0x06, 0x00, 0x11, 0x00, 0x02 };
//获取数组CRC校验码
byte[] byteDate = CRC16MODBUS.CrcModBus(buffer);
//Array.Reverse(byteDate);
int dataLength = buffer.Length;
Array.Resize(ref buffer, dataLength + byteDate.Length);
for (int i = 0; i < byteDate.Length; i++)
{
buffer[dataLength + i] = byteDate[i];
}
logger.Info($"冰箱失能【{Convert.ToHexString(buffer)}】");
fridgeSerial.Write(buffer, 0, 8);
await Task.Delay(80);
}
catch (Exception ex)
{
logger.Info($"冰箱失能发生异常ex:{ex.Message}");
}
FridgeOperate = false;
} /// <summary>
/// 冰箱报警使能
/// </summary>
/// <returns></returns>
public async Task FridgeAlarmOnForNew(int iIndex)
{
try
{
fridgeSerial.DiscardInBuffer();
byte bAddress;
if (iIndex == 1)
{
bAddress = 0x01;
}
else
{
bAddress = 0x02;
}
//byte[] buffer = new byte[] { bAddress, 0x06, 0x10, 0xD5, 0x00, 0x01, 0x5D, 0x32 };
byte[] buffer = new byte[] { 0x01, 0x10, 0x00, 0x0E, 0x00, 0x02,0x04,0x00,0x00 };
//获取数组CRC校验码
byte[] byteDate = CRC16MODBUS.CrcModBus(buffer);
//Array.Reverse(byteDate);
int dataLength = buffer.Length;
Array.Resize(ref buffer, dataLength + byteDate.Length);
for (int i = 0; i < byteDate.Length; i++)
{
buffer[dataLength + i] = byteDate[i];
}
logger.Info($"冰箱报警使能【{Convert.ToHexString(buffer)}】");
fridgeSerial.Write(buffer, 0, 8);
await Task.Delay(80);
}
catch (Exception ex)
{
logger.Info($"冰箱报警使能发生异常ex:{ex.Message}");
}
FridgeOperate = false;
}
/// <summary>
/// 冰箱报警失能
/// </summary>
/// <returns></returns>
public async Task FridgeAlarmOffForNew(int iIndex)
{
try
{
fridgeSerial.DiscardInBuffer();
byte bAddress;
if (iIndex == 1)
{
bAddress = 0x01;
}
else
{
bAddress = 0x02;
}
//byte[] buffer = new byte[] { bAddress, 0x06, 0x10, 0xD5, 0x00, 0x00, 0x9C, 0xF2 };
byte[] buffer = new byte[] { 0x01, 0x10, 0x00, 0x0E, 0x00, 0x02, 0x04, 0x00, 0x00 };
//获取数组CRC校验码
byte[] byteDate = CRC16MODBUS.CrcModBus(buffer);
//Array.Reverse(byteDate);
int dataLength = buffer.Length;
Array.Resize(ref buffer, dataLength + byteDate.Length);
for (int i = 0; i < byteDate.Length; i++)
{
buffer[dataLength + i] = byteDate[i];
}
logger.Info($"冰箱报警失能【{Convert.ToHexString(buffer)}】");
fridgeSerial.Write(buffer, 0, 8);
await Task.Delay(80);
}
catch (Exception ex)
{
logger.Info($"冰箱报警失能发生异常ex:{ex.Message}");
}
FridgeOperate = false;
}
/// <summary>
/// 冰箱温度设定最小
/// </summary>
/// <returns></returns>
public async Task FridgeMinSettingForNew(float min, int iIndex)
{ {
try try
{ {
int iMix = Convert.ToInt32(min * 10); int iMix = Convert.ToInt32(min * 10);
fridgeSerial.DiscardInBuffer();
//byte[] bufferMin = new byte[] { 0x01, 0x06, 0x10, 0xC9, 0x00, 0x15, 0x9C, 0xFB };
byte bAddress;
if (iIndex == 1)
{
bAddress = 0x01;
}
else
{
bAddress = 0x02;
}
byte[] bufferMin = new byte[] { bAddress, 0x06, 0x10, 0xC9, 0x00, (byte)(iMix & 0xff) };
//获取数组CRC校验码
byte[] byteDate = CRC16MODBUS.CrcModBus(bufferMin);
//Array.Reverse(byteDate);
int dataLength = bufferMin.Length;
Array.Resize(ref bufferMin, dataLength + byteDate.Length);
for (int i = 0; i < byteDate.Length; i++)
{
bufferMin[dataLength + i] = byteDate[i];
}
logger.Info($"冰箱温度设定Min:【{Convert.ToHexString(bufferMin)}】");
fridgeSerial.Write(bufferMin, 0, 8);
}
catch (Exception ex)
{
logger.Info($"获取冰箱温度发生异常ex:{ex.Message}");
}
}
/// <summary>
/// 冰箱温度设定最大
/// </summary>
/// <returns></returns>
public async Task FridgeMaxSettingForNew(float max, int iIndex)
{
try
{
int iMax = Convert.ToInt32(max * 10); int iMax = Convert.ToInt32(max * 10);
fridgeSerial.DiscardInBuffer(); fridgeSerial.DiscardInBuffer();
//byte[] bufferMin = new byte[] { 0x01, 0x06, 0x10, 0xC9, 0x00, 0x15, 0x9C, 0xFB }; //byte[] bufferMin = new byte[] { 0x01, 0x06, 0x10, 0xC9, 0x00, 0x15, 0x9C, 0xFB };
@ -2158,18 +2009,18 @@ namespace DM_Weight.Port
{ {
bAddress = 0x02; bAddress = 0x02;
} }
byte[] bufferMax = new byte[] { bAddress, 0x06, 0x10, 0xC8, 0x00, (byte)(iMax & 0xff) }; byte[] bufferMin = new byte[] { bAddress, 0x10, 0x00, 0x06, 0x00,0x02,0x04, (byte)(iMix >>8), (byte)(iMix & 0xff), (byte)(iMax >>8), (byte)(iMax & 0xff) };
//获取数组CRC校验码 //获取数组CRC校验码
byte[] byteDate = CRC16MODBUS.CrcModBus(bufferMax); byte[] byteDate = CRC16MODBUS.CrcModBus(bufferMin);
//Array.Reverse(byteDate); //Array.Reverse(byteDate);
int dataLength = bufferMax.Length; int dataLength = bufferMin.Length;
Array.Resize(ref bufferMax, dataLength + byteDate.Length); Array.Resize(ref bufferMin, dataLength + byteDate.Length);
for (int i = 0; i < byteDate.Length; i++) for (int i = 0; i < byteDate.Length; i++)
{ {
bufferMax[dataLength + i] = byteDate[i]; bufferMin[dataLength + i] = byteDate[i];
} }
logger.Info($"冰箱温度设定Max:【{Convert.ToHexString(bufferMax)}】"); logger.Info($"冰箱温度设定Min:【{Convert.ToHexString(bufferMin)}】");
fridgeSerial.Write(bufferMax, 0, 8); fridgeSerial.Write(bufferMin, 0, 13);
} }
catch (Exception ex) catch (Exception ex)
{ {

View File

@ -117,51 +117,51 @@ namespace DM_Weight.ViewModels
//{ //{
// ConfigurationManager.RefreshSection("FridgeState"); // ConfigurationManager.RefreshSection("FridgeState");
//发送冰箱使能/失能指令 //发送冰箱使能/失能指令
if (FridgeState) //if (FridgeState)
{ //{
await _portUtil.FridgeOff(1); // await _portUtil.FridgeOff(1);
Thread.Sleep(100); // Thread.Sleep(100);
CommonClass.SaveAppSetting("FridgeState", "1"); // CommonClass.SaveAppSetting("FridgeState", "1");
//Configuration _configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); // //Configuration _configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
//_configuration.AppSettings.Settings["FridgeState"].Value = "1"; // //_configuration.AppSettings.Settings["FridgeState"].Value = "1";
//_configuration.Save(); // //_configuration.Save();
//ConfigurationManager.RefreshSection("FridgeState"); // //ConfigurationManager.RefreshSection("FridgeState");
} //}
else //else
{ //{
await _portUtil.FridegOpen(1); // await _portUtil.FridegOpen(1);
Thread.Sleep(100); // Thread.Sleep(100);
CommonClass.SaveAppSetting("FridgeState", "0"); // CommonClass.SaveAppSetting("FridgeState", "0");
//Configuration _configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); // //Configuration _configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
//_configuration.AppSettings.Settings["FridgeState"].Value = "0"; // //_configuration.AppSettings.Settings["FridgeState"].Value = "0";
//_configuration.Save(); // //_configuration.Save();
//ConfigurationManager.RefreshSection("FridgeState"); // //ConfigurationManager.RefreshSection("FridgeState");
//冰箱打开定时获取冰箱温度 // //冰箱打开定时获取冰箱温度
_eventAggregator.GetEvent<FridgeEvent>().Publish(); // _eventAggregator.GetEvent<FridgeEvent>().Publish();
} //}
//发送警报使能/失能指令 ////发送警报使能/失能指令
if (AlarmState) //if (AlarmState)
{ //{
await _portUtil.FridgeAlarmOff(1); // await _portUtil.FridgeAlarmOff(1);
Thread.Sleep(100); // Thread.Sleep(100);
CommonClass.SaveAppSetting("AlarmState", "1"); // CommonClass.SaveAppSetting("AlarmState", "1");
//Configuration _configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); // //Configuration _configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
//_configuration.AppSettings.Settings["AlarmState"].Value = "1"; // //_configuration.AppSettings.Settings["AlarmState"].Value = "1";
//_configuration.Save(); // //_configuration.Save();
//ConfigurationManager.RefreshSection("AlarmState"); // //ConfigurationManager.RefreshSection("AlarmState");
} //}
else //else
{ //{
await _portUtil.FridgeAlarmOn(1); // await _portUtil.FridgeAlarmOn(1);
Thread.Sleep(100); // Thread.Sleep(100);
CommonClass.SaveAppSetting("AlarmState", "0"); // CommonClass.SaveAppSetting("AlarmState", "0");
//Configuration _configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); // //Configuration _configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
//_configuration.AppSettings.Settings["AlarmState"].Value = "0"; // //_configuration.AppSettings.Settings["AlarmState"].Value = "0";
//_configuration.Save(); // //_configuration.Save();
//ConfigurationManager.RefreshSection("AlarmState"); // //ConfigurationManager.RefreshSection("AlarmState");
} //}
//设定冰箱1温度区间 //设定冰箱1温度区间
//string[] range = ConfigurationManager.AppSettings["temperatureRange"].Split('-'); //string[] range = ConfigurationManager.AppSettings["temperatureRange"].Split('-');
string[] newRange = TemperatureRange.Split('-'); string[] newRange = TemperatureRange.Split('-');
@ -170,37 +170,34 @@ namespace DM_Weight.ViewModels
bool bMix = float.TryParse(newRange[0], out float Min); bool bMix = float.TryParse(newRange[0], out float Min);
bool bMax = float.TryParse(newRange[1], out float Max); bool bMax = float.TryParse(newRange[1], out float Max);
if (bMix && bMax) //if (bMix && bMax)
{ //{
if (Min != Convert.ToSingle(newRange[0])) // if (Min != Convert.ToSingle(newRange[0]))
{ // {
//设定冰箱温度最小值 // //设定冰箱温度最小值
await _portUtil.FridgeMinSetting(Convert.ToSingle(newRange[0]),1); // await _portUtil.FridgeMinSetting(Convert.ToSingle(newRange[0]),1);
Thread.Sleep(100); // Thread.Sleep(100);
} // }
if (Max != Convert.ToSingle(newRange[1])) // if (Max != Convert.ToSingle(newRange[1]))
{ // {
Thread.Sleep(100); // Thread.Sleep(100);
//设定冰箱温度最大值 // //设定冰箱温度最大值
await _portUtil.FridgeMaxSetting(Convert.ToSingle(newRange[1]), 1); // await _portUtil.FridgeMaxSetting(Convert.ToSingle(newRange[1]), 1);
Thread.Sleep(100); // Thread.Sleep(100);
} // }
} //}
//Configuration _configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); await _portUtil.SetFridgeLowHeightForNew(Convert.ToSingle(newRange[0]), Convert.ToSingle(newRange[1]), 1);
//_configuration.AppSettings.Settings["TemperatureRange"].Value = c;
//_configuration.Save();
//ConfigurationManager.RefreshSection("TemperatureRange");
CommonClass.SaveAppSetting("TemperatureRange", TemperatureRange); CommonClass.SaveAppSetting("TemperatureRange", TemperatureRange);
} }
//超时时间 ////超时时间
if (OutRangeTime != null) //if (OutRangeTime != null)
{ //{
//Configuration _configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); // //Configuration _configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
//_configuration.AppSettings.Settings["OutRangeTime"].Value = OutRangeTime; // //_configuration.AppSettings.Settings["OutRangeTime"].Value = OutRangeTime;
//_configuration.Save(); // //_configuration.Save();
//ConfigurationManager.RefreshSection("OutRangeTime"); // //ConfigurationManager.RefreshSection("OutRangeTime");
CommonClass.SaveAppSetting("OutRangeTime", OutRangeTime); // CommonClass.SaveAppSetting("OutRangeTime", OutRangeTime);
} //}
_portUtil.FridgeOperate = false; _portUtil.FridgeOperate = false;

View File

@ -64,8 +64,8 @@ namespace DM_Weight.ViewModels
public DateTime? FridgeTime { get; set; } public DateTime? FridgeTime { get; set; }
//冰箱是否异常状态:0正常1异常 //冰箱是否异常状态:0正常1异常
//public string FridgeWorkingState = ConfigurationManager.AppSettings["FridgeworkingState"].ToString(); //public string FridgeWorkingState = ConfigurationManager.AppSettings["FridgeworkingState"].ToString();
//冰箱开关状态:0开1 //冰箱开关状态:1开0
public string FridgeState = ConfigurationManager.AppSettings["FridgeState"].ToString(); public int FridgeState =0;
//冰箱渡不在区间超时时间 //冰箱渡不在区间超时时间
private string _outRangeTime = ConfigurationManager.AppSettings["OutRangeTime"].ToString(); private string _outRangeTime = ConfigurationManager.AppSettings["OutRangeTime"].ToString();
public string OutRangeTime { get => _outRangeTime; set => SetProperty(ref _outRangeTime, value); } public string OutRangeTime { get => _outRangeTime; set => SetProperty(ref _outRangeTime, value); }
@ -447,7 +447,7 @@ namespace DM_Weight.ViewModels
{ {
string retStr = string.Empty; string retStr = string.Empty;
byte[] data = null; byte[] data = null;
float retT = await _portUtil.GetFridgeTemperature(1); float retT = await _portUtil.GetFridgeTemperatureForNew(1);
Thread.Sleep(80); Thread.Sleep(80);
WD = $"恒温冷藏抽屉当前温度:{Math.Round((retT), 2)}℃"; WD = $"恒温冷藏抽屉当前温度:{Math.Round((retT), 2)}℃";
} }
@ -455,7 +455,10 @@ namespace DM_Weight.ViewModels
private async void GetWD() private async void GetWD()
{ {
if (!_portUtil.FridgeOperate && FridgeState.Equals("0")) //查询冰箱继电器状态
FridgeState =await _portUtil.GetFridgeState(1);
if (!_portUtil.FridgeOperate && FridgeState.Equals(1))
{ {
string retStr = string.Empty; string retStr = string.Empty;
byte[] data = null; byte[] data = null;
@ -532,7 +535,7 @@ namespace DM_Weight.ViewModels
//接收导航传过来的参数 //接收导航传过来的参数
public void OnNavigatedTo(NavigationContext navigationContext) public void OnNavigatedTo(NavigationContext navigationContext)
{ {
_portUtil.dateTime = DateTime.Now; _portUtil.dateTime = DateTime.Now;
//取出user //取出user
UserList = navigationContext.Parameters.GetValue<UserList>("operator"); UserList = navigationContext.Parameters.GetValue<UserList>("operator");
Operator = UserList; Operator = UserList;
@ -700,9 +703,10 @@ namespace DM_Weight.ViewModels
new PromiseUtil<int>().taskAsyncLoop(10000, 0, async (options, next, stop) => new PromiseUtil<int>().taskAsyncLoop(10000, 0, async (options, next, stop) =>
{ {
try try
{ {
FridgeState = CommonClass.ReadAppSetting("FridgeState"); //查询冰箱继电器状态
if (!_portUtil.FridgeOperate && FridgeState.Equals("0")) FridgeState = await _portUtil.GetFridgeState(1);
if (!_portUtil.FridgeOperate && FridgeState.Equals(1))
{ {
string retStr = string.Empty; string retStr = string.Empty;
byte[] data = null; byte[] data = null;
@ -713,114 +717,7 @@ namespace DM_Weight.ViewModels
logger.Info(WD); logger.Info(WD);
if (tempRange != null && tempRange.Count() >= 2) if (tempRange != null && tempRange.Count() >= 2)
{ {
if (retT < Convert.ToSingle(tempRange[0]) || retT > Convert.ToSingle(tempRange[1])) next();
{
//查询制冷片温度
float retT2 = await _portUtil.GetFridgeTemperature2();
if (retT2 > 65)
{
if (!FridgeState.Equals("1"))
{
//停掉冰箱
await _portUtil.FridgeOff(1);
CommonClass.SaveAppSetting("FridgeState", "1");
//AlertMsg alertMsg = new AlertMsg
//{
// Message = $"冰箱制冷片温度超过65度已关闭冰箱制冷功能!!!",
// Type = MsgType.ERROR
//};
//_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
System.Windows.Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() =>
{
DialogParameters dialogParameters = new DialogParameters();
dialogParameters.Add("warnMessage", "冰箱制冷片温度超过65度已关闭冰箱制冷功能!!!");
DialogServiceExtensions.ShowDialogHost(_dialogService, "WarnDialog", dialogParameters, DoDialogResult, "RootDialog");
}));
}
logger.Info($"制冷片温度超过65度");
Thread.Sleep(100);
//给出提示
WD += "冰箱温度异常,已关闭冰箱制冷功能";
AlertColor = Brushes.Red;
FridgeTime = null;
stop();
}
else
{
if (FridgeTime == null)
{
FridgeTime = DateTime.Now;
//温度不在范围,但没有超过时间
if (IsLeave)
{
FridgeTime = null;
stop();
}
else
{
next();
}
}
else
{
if ((DateTime.Now - FridgeTime.Value).TotalMinutes > Convert.ToInt32(OutRangeTime))
{
logger.Info($"冰箱温度不在范围内,超过{OutRangeTime}分钟");
//停掉冰箱
await _portUtil.FridgeOff(1);
Thread.Sleep(100);
CommonClass.SaveAppSetting("FridgeState", "0");
//给出提示
WD += "冰箱温度异常,已关闭冰箱制冷功能;";
AlertColor = Brushes.Red;
FridgeState = "1";
CommonClass.SaveAppSetting("FridgeState", "1");
//AlertMsg alertMsg = new AlertMsg
//{
// Message = $"冰箱温度异常,已关闭冰箱制冷功能!!!",
// Type = MsgType.ERROR
//};
//_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
System.Windows.Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() =>
{
DialogParameters dialogParameters = new DialogParameters();
dialogParameters.Add("warnMessage", "冰箱温度异常,已关闭冰箱制冷功能!!!");
DialogServiceExtensions.ShowDialogHost(_dialogService, "WarnDialog", dialogParameters, DoDialogResult, "RootDialog");
}));
FridgeTime = null;
stop();
}
else
{
//温度不在范围,但没有超过时间
if (IsLeave)
{
FridgeTime = null;
stop();
}
else
{
next();
}
}
}
}
}
else
{
if (IsLeave)
{
FridgeTime = null;
stop();
}
else
{
next();
}
}
} }
else else
{ {

View File

@ -42,7 +42,7 @@
</Binding> </Binding>
</TextBox.Text> </TextBox.Text>
</TextBox> </TextBox>
<TextBlock Text="冰箱状态:" Margin="0 18 0 0" Grid.Row="2" Grid.Column="0" HorizontalAlignment="Right" VerticalAlignment="Center" FontSize="14" FontWeight="Bold" /> <!--<TextBlock Text="冰箱状态:" Margin="0 18 0 0" Grid.Row="2" Grid.Column="0" HorizontalAlignment="Right" VerticalAlignment="Center" FontSize="14" FontWeight="Bold" />
<ToggleButton Grid.Row="2" Grid.Column="1" Width="38" Height="38" Margin="6 18 0 0" <ToggleButton Grid.Row="2" Grid.Column="1" Width="38" Height="38" Margin="6 18 0 0"
HorizontalAlignment="Left" HorizontalAlignment="Left"
x:Name="MaterialDesignFilledTextBoxEnabledComboBox" x:Name="MaterialDesignFilledTextBoxEnabledComboBox"
@ -65,8 +65,8 @@
materialDesign:HintAssist.Hint="超时时间以分钟为单位" materialDesign:HintAssist.Hint="超时时间以分钟为单位"
Margin="6 0 0 10" Text="{Binding OutRangeTime, UpdateSourceTrigger=PropertyChanged}" Margin="6 0 0 10" Text="{Binding OutRangeTime, UpdateSourceTrigger=PropertyChanged}"
Style="{StaticResource MaterialDesignOutlinedTextBox}"> Style="{StaticResource MaterialDesignOutlinedTextBox}">
</TextBox> </TextBox>-->
<Button Grid.Row="5" Grid.ColumnSpan="2" Content="保存" Command="{Binding SaveCommand}" IsEnabled="{Binding BtnIsEnable}" /> <Button Grid.Row="3" Grid.ColumnSpan="2" Content="保存" Command="{Binding SaveCommand}" IsEnabled="{Binding BtnIsEnable}" />
</Grid> </Grid>
</UserControl> </UserControl>