更新冰箱功能
This commit is contained in:
parent
24a3002084
commit
716f0a1967
|
|
@ -37,7 +37,7 @@
|
|||
<!-- 按处方还药或者按取药记录还药 1:处方(ReturnDrugWindow2)2:药品(ReturnDrugWindow)-->
|
||||
<add key="returnDrugMode" value="2" />
|
||||
<!-- 自动退出时间,单位秒,为0时不自动退出 -->
|
||||
<add key="autoExit" value="10"/>
|
||||
<add key="autoExit" value="0"/>
|
||||
|
||||
<!-- 无操作退出录像时间,单位秒,为0时不退出录像 -->
|
||||
<add key="stopRecord" value="0"/>
|
||||
|
|
@ -64,7 +64,7 @@
|
|||
<!--是否有冰箱抽屉0无,1有一个,2两个-->
|
||||
<add key="hasFridge" value="1"/>
|
||||
<!-- 冰箱的串口号 -->
|
||||
<add key="FridgePortPath" value="COM12" />
|
||||
<add key="FridgePortPath" value="COM31" />
|
||||
|
||||
<!--冰箱抽屉温度区间-->
|
||||
<add key="temperatureRange" value="2-8"/>
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ using DM_Weight.Common;
|
|||
using System.Net;
|
||||
using System.Text.RegularExpressions;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using OracleInternal.SqlAndPlsqlParser.RuleProcessors;
|
||||
|
||||
namespace DM_Weight.Port
|
||||
{
|
||||
|
|
@ -1887,6 +1888,50 @@ namespace DM_Weight.Port
|
|||
|
||||
|
||||
#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>
|
||||
/// 获取冰箱温度
|
||||
|
|
@ -1907,7 +1952,7 @@ namespace DM_Weight.Port
|
|||
{
|
||||
bAddress = 0x02;
|
||||
}
|
||||
byte[] buffer = new byte[] { bAddress, 0x03, 0x00, 0x03, 0x02 };
|
||||
byte[] buffer = new byte[] { bAddress, 0x03, 0x00, 0x03, 0x00, 0x01 };
|
||||
|
||||
//获取数组CRC校验码
|
||||
byte[] byteDate = CRC16MODBUS.CrcModBus(buffer);
|
||||
|
|
@ -1943,209 +1988,15 @@ namespace DM_Weight.Port
|
|||
return temperature;
|
||||
}
|
||||
/// <summary>
|
||||
/// 冰箱使能
|
||||
/// 冰箱温度设定最低温与最高温
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task FridegOpenForNew(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)
|
||||
public async Task SetFridgeLowHeightForNew(float min,float max, int iIndex)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
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);
|
||||
fridgeSerial.DiscardInBuffer();
|
||||
//byte[] bufferMin = new byte[] { 0x01, 0x06, 0x10, 0xC9, 0x00, 0x15, 0x9C, 0xFB };
|
||||
|
|
@ -2158,18 +2009,18 @@ namespace DM_Weight.Port
|
|||
{
|
||||
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校验码
|
||||
byte[] byteDate = CRC16MODBUS.CrcModBus(bufferMax);
|
||||
byte[] byteDate = CRC16MODBUS.CrcModBus(bufferMin);
|
||||
//Array.Reverse(byteDate);
|
||||
int dataLength = bufferMax.Length;
|
||||
Array.Resize(ref bufferMax, dataLength + byteDate.Length);
|
||||
int dataLength = bufferMin.Length;
|
||||
Array.Resize(ref bufferMin, dataLength + byteDate.Length);
|
||||
for (int i = 0; i < byteDate.Length; i++)
|
||||
{
|
||||
bufferMax[dataLength + i] = byteDate[i];
|
||||
bufferMin[dataLength + i] = byteDate[i];
|
||||
}
|
||||
logger.Info($"冰箱温度设定Max:【{Convert.ToHexString(bufferMax)}】");
|
||||
fridgeSerial.Write(bufferMax, 0, 8);
|
||||
logger.Info($"冰箱温度设定Min:【{Convert.ToHexString(bufferMin)}】");
|
||||
fridgeSerial.Write(bufferMin, 0, 13);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -117,51 +117,51 @@ namespace DM_Weight.ViewModels
|
|||
//{
|
||||
// ConfigurationManager.RefreshSection("FridgeState");
|
||||
//发送冰箱使能/失能指令
|
||||
if (FridgeState)
|
||||
{
|
||||
await _portUtil.FridgeOff(1);
|
||||
Thread.Sleep(100);
|
||||
CommonClass.SaveAppSetting("FridgeState", "1");
|
||||
//if (FridgeState)
|
||||
//{
|
||||
// await _portUtil.FridgeOff(1);
|
||||
// Thread.Sleep(100);
|
||||
// CommonClass.SaveAppSetting("FridgeState", "1");
|
||||
|
||||
//Configuration _configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
|
||||
//_configuration.AppSettings.Settings["FridgeState"].Value = "1";
|
||||
//_configuration.Save();
|
||||
//ConfigurationManager.RefreshSection("FridgeState");
|
||||
}
|
||||
else
|
||||
{
|
||||
await _portUtil.FridegOpen(1);
|
||||
Thread.Sleep(100);
|
||||
CommonClass.SaveAppSetting("FridgeState", "0");
|
||||
//Configuration _configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
|
||||
//_configuration.AppSettings.Settings["FridgeState"].Value = "0";
|
||||
//_configuration.Save();
|
||||
//ConfigurationManager.RefreshSection("FridgeState");
|
||||
//冰箱打开定时获取冰箱温度
|
||||
_eventAggregator.GetEvent<FridgeEvent>().Publish();
|
||||
}
|
||||
//发送警报使能/失能指令
|
||||
if (AlarmState)
|
||||
{
|
||||
await _portUtil.FridgeAlarmOff(1);
|
||||
Thread.Sleep(100);
|
||||
CommonClass.SaveAppSetting("AlarmState", "1");
|
||||
//Configuration _configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
|
||||
//_configuration.AppSettings.Settings["AlarmState"].Value = "1";
|
||||
//_configuration.Save();
|
||||
//ConfigurationManager.RefreshSection("AlarmState");
|
||||
}
|
||||
else
|
||||
{
|
||||
await _portUtil.FridgeAlarmOn(1);
|
||||
Thread.Sleep(100);
|
||||
CommonClass.SaveAppSetting("AlarmState", "0");
|
||||
// //Configuration _configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
|
||||
// //_configuration.AppSettings.Settings["FridgeState"].Value = "1";
|
||||
// //_configuration.Save();
|
||||
// //ConfigurationManager.RefreshSection("FridgeState");
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// await _portUtil.FridegOpen(1);
|
||||
// Thread.Sleep(100);
|
||||
// CommonClass.SaveAppSetting("FridgeState", "0");
|
||||
// //Configuration _configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
|
||||
// //_configuration.AppSettings.Settings["FridgeState"].Value = "0";
|
||||
// //_configuration.Save();
|
||||
// //ConfigurationManager.RefreshSection("FridgeState");
|
||||
// //冰箱打开定时获取冰箱温度
|
||||
// _eventAggregator.GetEvent<FridgeEvent>().Publish();
|
||||
//}
|
||||
////发送警报使能/失能指令
|
||||
//if (AlarmState)
|
||||
//{
|
||||
// await _portUtil.FridgeAlarmOff(1);
|
||||
// Thread.Sleep(100);
|
||||
// CommonClass.SaveAppSetting("AlarmState", "1");
|
||||
// //Configuration _configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
|
||||
// //_configuration.AppSettings.Settings["AlarmState"].Value = "1";
|
||||
// //_configuration.Save();
|
||||
// //ConfigurationManager.RefreshSection("AlarmState");
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// await _portUtil.FridgeAlarmOn(1);
|
||||
// Thread.Sleep(100);
|
||||
// CommonClass.SaveAppSetting("AlarmState", "0");
|
||||
|
||||
//Configuration _configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
|
||||
//_configuration.AppSettings.Settings["AlarmState"].Value = "0";
|
||||
//_configuration.Save();
|
||||
//ConfigurationManager.RefreshSection("AlarmState");
|
||||
}
|
||||
// //Configuration _configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
|
||||
// //_configuration.AppSettings.Settings["AlarmState"].Value = "0";
|
||||
// //_configuration.Save();
|
||||
// //ConfigurationManager.RefreshSection("AlarmState");
|
||||
//}
|
||||
//设定冰箱1温度区间
|
||||
//string[] range = ConfigurationManager.AppSettings["temperatureRange"].Split('-');
|
||||
string[] newRange = TemperatureRange.Split('-');
|
||||
|
|
@ -170,37 +170,34 @@ namespace DM_Weight.ViewModels
|
|||
bool bMix = float.TryParse(newRange[0], out float Min);
|
||||
bool bMax = float.TryParse(newRange[1], out float Max);
|
||||
|
||||
if (bMix && bMax)
|
||||
{
|
||||
if (Min != Convert.ToSingle(newRange[0]))
|
||||
{
|
||||
//设定冰箱温度最小值
|
||||
await _portUtil.FridgeMinSetting(Convert.ToSingle(newRange[0]),1);
|
||||
Thread.Sleep(100);
|
||||
}
|
||||
if (Max != Convert.ToSingle(newRange[1]))
|
||||
{
|
||||
Thread.Sleep(100);
|
||||
//设定冰箱温度最大值
|
||||
await _portUtil.FridgeMaxSetting(Convert.ToSingle(newRange[1]), 1);
|
||||
Thread.Sleep(100);
|
||||
}
|
||||
}
|
||||
//Configuration _configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
|
||||
//_configuration.AppSettings.Settings["TemperatureRange"].Value = c;
|
||||
//_configuration.Save();
|
||||
//ConfigurationManager.RefreshSection("TemperatureRange");
|
||||
//if (bMix && bMax)
|
||||
//{
|
||||
// if (Min != Convert.ToSingle(newRange[0]))
|
||||
// {
|
||||
// //设定冰箱温度最小值
|
||||
// await _portUtil.FridgeMinSetting(Convert.ToSingle(newRange[0]),1);
|
||||
// Thread.Sleep(100);
|
||||
// }
|
||||
// if (Max != Convert.ToSingle(newRange[1]))
|
||||
// {
|
||||
// Thread.Sleep(100);
|
||||
// //设定冰箱温度最大值
|
||||
// await _portUtil.FridgeMaxSetting(Convert.ToSingle(newRange[1]), 1);
|
||||
// Thread.Sleep(100);
|
||||
// }
|
||||
//}
|
||||
await _portUtil.SetFridgeLowHeightForNew(Convert.ToSingle(newRange[0]), Convert.ToSingle(newRange[1]), 1);
|
||||
CommonClass.SaveAppSetting("TemperatureRange", TemperatureRange);
|
||||
}
|
||||
//超时时间
|
||||
if (OutRangeTime != null)
|
||||
{
|
||||
//Configuration _configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
|
||||
//_configuration.AppSettings.Settings["OutRangeTime"].Value = OutRangeTime;
|
||||
//_configuration.Save();
|
||||
//ConfigurationManager.RefreshSection("OutRangeTime");
|
||||
CommonClass.SaveAppSetting("OutRangeTime", OutRangeTime);
|
||||
}
|
||||
////超时时间
|
||||
//if (OutRangeTime != null)
|
||||
//{
|
||||
// //Configuration _configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
|
||||
// //_configuration.AppSettings.Settings["OutRangeTime"].Value = OutRangeTime;
|
||||
// //_configuration.Save();
|
||||
// //ConfigurationManager.RefreshSection("OutRangeTime");
|
||||
// CommonClass.SaveAppSetting("OutRangeTime", OutRangeTime);
|
||||
//}
|
||||
|
||||
|
||||
_portUtil.FridgeOperate = false;
|
||||
|
|
|
|||
|
|
@ -64,8 +64,8 @@ namespace DM_Weight.ViewModels
|
|||
public DateTime? FridgeTime { get; set; }
|
||||
//冰箱是否异常状态:0正常,1异常
|
||||
//public string FridgeWorkingState = ConfigurationManager.AppSettings["FridgeworkingState"].ToString();
|
||||
//冰箱开关状态:0开,1关
|
||||
public string FridgeState = ConfigurationManager.AppSettings["FridgeState"].ToString();
|
||||
//冰箱开关状态:1开,0关
|
||||
public int FridgeState =0;
|
||||
//冰箱渡不在区间超时时间
|
||||
private string _outRangeTime = ConfigurationManager.AppSettings["OutRangeTime"].ToString();
|
||||
public string OutRangeTime { get => _outRangeTime; set => SetProperty(ref _outRangeTime, value); }
|
||||
|
|
@ -447,7 +447,7 @@ namespace DM_Weight.ViewModels
|
|||
{
|
||||
string retStr = string.Empty;
|
||||
byte[] data = null;
|
||||
float retT = await _portUtil.GetFridgeTemperature(1);
|
||||
float retT = await _portUtil.GetFridgeTemperatureForNew(1);
|
||||
Thread.Sleep(80);
|
||||
WD = $"恒温冷藏抽屉当前温度:{Math.Round((retT), 2)}℃";
|
||||
}
|
||||
|
|
@ -455,7 +455,10 @@ namespace DM_Weight.ViewModels
|
|||
|
||||
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;
|
||||
byte[] data = null;
|
||||
|
|
@ -701,8 +704,9 @@ namespace DM_Weight.ViewModels
|
|||
{
|
||||
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;
|
||||
byte[] data = null;
|
||||
|
|
@ -712,116 +716,9 @@ namespace DM_Weight.ViewModels
|
|||
AlertColor = Brushes.White;
|
||||
logger.Info(WD);
|
||||
if (tempRange != null && tempRange.Count() >= 2)
|
||||
{
|
||||
if (retT < Convert.ToSingle(tempRange[0]) || retT > Convert.ToSingle(tempRange[1]))
|
||||
{
|
||||
//查询制冷片温度
|
||||
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
|
||||
{
|
||||
logger.Info($"获取冰箱温度范围有误{TemperatureRange}");
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@
|
|||
</Binding>
|
||||
</TextBox.Text>
|
||||
</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"
|
||||
HorizontalAlignment="Left"
|
||||
x:Name="MaterialDesignFilledTextBoxEnabledComboBox"
|
||||
|
|
@ -65,8 +65,8 @@
|
|||
materialDesign:HintAssist.Hint="超时时间以分钟为单位"
|
||||
Margin="6 0 0 10" Text="{Binding OutRangeTime, UpdateSourceTrigger=PropertyChanged}"
|
||||
Style="{StaticResource MaterialDesignOutlinedTextBox}">
|
||||
</TextBox>
|
||||
<Button Grid.Row="5" Grid.ColumnSpan="2" Content="保存" Command="{Binding SaveCommand}" IsEnabled="{Binding BtnIsEnable}" />
|
||||
</TextBox>-->
|
||||
<Button Grid.Row="3" Grid.ColumnSpan="2" Content="保存" Command="{Binding SaveCommand}" IsEnabled="{Binding BtnIsEnable}" />
|
||||
</Grid>
|
||||
</UserControl>
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue