冰箱超温度范围报警提示
This commit is contained in:
parent
29723e1054
commit
34c6cbb69c
|
@ -37,7 +37,7 @@
|
|||
<!-- 按处方还药或者按取药记录还药 1:处方(ReturnDrugWindow2)2:药品(ReturnDrugWindow)-->
|
||||
<add key="returnDrugMode" value="2" />
|
||||
<!-- 自动退出时间,单位秒,为0时不自动退出 -->
|
||||
<add key="autoExit" value="3"/>
|
||||
<add key="autoExit" value="0"/>
|
||||
|
||||
<!-- 无操作退出录像时间,单位秒,为0时不退出录像 -->
|
||||
<add key="stopRecord" value="0"/>
|
||||
|
@ -76,6 +76,10 @@
|
|||
<add key="FridgeState" value="0"/>
|
||||
<!--报警状态1关闭;0打开-->
|
||||
<add key="AlarmState" value="0"/>
|
||||
<!--冰箱不在区间超时时间(超过指定的时间仍不在区间则提示)单位分-->
|
||||
<add key="OutRangeTime" value="20"/>
|
||||
<!--冰箱是否异常状态,0正常1异常--><!--
|
||||
<add key="FridgeworkingState" value="0"/>-->
|
||||
|
||||
|
||||
<!--冰箱2抽屉温度区间-->
|
||||
|
|
|
@ -1756,6 +1756,44 @@ namespace DM_Weight.Port
|
|||
}
|
||||
return temperature;
|
||||
}
|
||||
//读制冷片温度
|
||||
public async Task<float> GetFridgeTemperature2()
|
||||
{
|
||||
float temperature = 0.0f;
|
||||
try
|
||||
{
|
||||
fridgeSerial.DiscardInBuffer();
|
||||
byte bAddress;
|
||||
byte[] buffer = new byte[] { 0x01, 0x03, 0x10, 0x0C, 0x00, 0x01, 0x40, 0xC9 };
|
||||
//byte[] buffer = new byte[] { 0x01, 0x03, 0x10, 0x02, 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);
|
||||
byte[] retByte = await GetBufferByPort(fridgeSerial, 7);
|
||||
logger.Info($"获取制冷片温度返回【{Convert.ToHexString(retByte)}】");
|
||||
if (retByte != null && retByte.Length >= 7)
|
||||
{
|
||||
var hight = retByte[3];
|
||||
var low = retByte[4];
|
||||
int iHight = Convert.ToInt32(hight << 8);
|
||||
int iLow = Convert.ToInt32(retByte[4]);
|
||||
temperature = Convert.ToSingle(iHight + iLow) / 10;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.Info($"获取制冷片温度发生异常:ex:{ex.Message}");
|
||||
}
|
||||
return temperature;
|
||||
}
|
||||
/// <summary>
|
||||
/// 设置冰箱温度
|
||||
/// </summary>
|
||||
|
|
|
@ -30,7 +30,19 @@ namespace DM_Weight.ViewModels
|
|||
//更新配置文件中冰箱温度区间
|
||||
CommonClass.SaveAppSetting("temperatureRange", _temperatureRange);
|
||||
}
|
||||
}
|
||||
}
|
||||
//温度不在范围超时时间
|
||||
private string _outRangeTime = ConfigurationManager.AppSettings["OutRangeTime"].ToString();
|
||||
public string OutRangeTime
|
||||
{
|
||||
get => _outRangeTime; set
|
||||
{
|
||||
SetProperty(ref _outRangeTime, value);
|
||||
//更新配置文件中冰箱温度区间
|
||||
CommonClass.SaveAppSetting("OutRangeTime", _outRangeTime);
|
||||
}
|
||||
}
|
||||
|
||||
private float defaultValue = Convert.ToSingle(CommonClass.ReadAppSetting("temperatureValue"));
|
||||
//温度值
|
||||
private float _temperatureValue = Convert.ToSingle(CommonClass.ReadAppSetting("temperatureValue"));
|
||||
|
|
|
@ -24,6 +24,7 @@ using Newtonsoft.Json.Linq;
|
|||
using DM_Weight.msg;
|
||||
using System.Threading;
|
||||
using DM_Weight.Common;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace DM_Weight.ViewModels
|
||||
{
|
||||
|
@ -41,7 +42,13 @@ namespace DM_Weight.ViewModels
|
|||
/// </summary>
|
||||
private string _wd = "恒温冷藏抽屉当前温度2.8(非真实数据)";
|
||||
public string WD { get => _wd; set => SetProperty(ref _wd, value); }
|
||||
System.Timers.Timer WDTimer;
|
||||
|
||||
private SolidColorBrush _alertColor=Brushes.White;
|
||||
public SolidColorBrush AlertColor
|
||||
{
|
||||
get=> _alertColor;
|
||||
set => SetProperty(ref _alertColor, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否有冰箱抽屉
|
||||
|
@ -49,6 +56,18 @@ namespace DM_Weight.ViewModels
|
|||
private string hasFridge = ConfigurationManager.AppSettings["hasFridge"].ToString().Equals("1") ? "Visible" : "Collapsed";
|
||||
public string HasFridge { get => hasFridge; set => SetProperty(ref hasFridge, value); }
|
||||
|
||||
//温度区间
|
||||
private string TemperatureRange = CommonClass.ReadAppSetting("temperatureRange").ToString();
|
||||
//温度不在区间计时器(超过配置文件中的时间后要报警)
|
||||
public DateTime? FridgeTime { get; set; }
|
||||
//冰箱是否异常状态:0正常,1异常
|
||||
//public string FridgeWorkingState = ConfigurationManager.AppSettings["FridgeworkingState"].ToString();
|
||||
//冰箱开关状态:0开,1关
|
||||
public string FridgeState = ConfigurationManager.AppSettings["FridgeState"].ToString();
|
||||
//冰箱渡不在区间超时时间
|
||||
private string _outRangeTime = ConfigurationManager.AppSettings["OutRangeTime"].ToString();
|
||||
public string OutRangeTime { get => _outRangeTime; set => SetProperty(ref _outRangeTime, value); }
|
||||
|
||||
private int loginMode = Convert.ToInt32(ConfigurationManager.AppSettings["loginMode"]?.ToString() ?? "1");
|
||||
public bool MultiLogin
|
||||
{
|
||||
|
@ -651,36 +670,141 @@ namespace DM_Weight.ViewModels
|
|||
////获取录像机的时间
|
||||
//_chkFunction.HIK_DVR_TIME();
|
||||
//_chkFunction.HIKStartDVRRecord();
|
||||
|
||||
new PromiseUtil<int>().taskAsyncLoop(60000, 0, async (options, next, stop) =>
|
||||
string[] tempRange = TemperatureRange.Split('-');
|
||||
new PromiseUtil<int>().taskAsyncLoop(10000, 0, async (options, next, stop) =>
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!_portUtil.FridgeOperate)
|
||||
if (!_portUtil.FridgeOperate && FridgeState.Equals("0"))
|
||||
{
|
||||
string retStr = string.Empty;
|
||||
byte[] data = null;
|
||||
float retT = await _portUtil.GetFridgeTemperature(1);
|
||||
Thread.Sleep(80);
|
||||
WD = $"恒温冷藏抽屉当前温度:{Math.Round((retT), 2)}℃";
|
||||
WD = $"恒温冷藏抽屉当前温度:{Math.Round((retT), 2)}℃;";
|
||||
logger.Info(WD);
|
||||
//if (Convert.ToInt32(ConfigurationManager.AppSettings["hasFridge"]) > 1)
|
||||
//{
|
||||
// float retTemp = await _portUtil.GetFridgeTemperature(2);
|
||||
// Thread.Sleep(80);
|
||||
// WD += $"{retTemp}℃";
|
||||
//}
|
||||
if (IsLeave)
|
||||
if (tempRange != null && tempRange.Count() >= 2)
|
||||
{
|
||||
stop();
|
||||
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);
|
||||
}
|
||||
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);
|
||||
FridgeTime = null;
|
||||
stop();
|
||||
}
|
||||
else
|
||||
{
|
||||
//温度不在范围,但没有超过时间
|
||||
if (IsLeave)
|
||||
{
|
||||
FridgeTime = null;
|
||||
stop();
|
||||
}
|
||||
else
|
||||
{
|
||||
next();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (IsLeave)
|
||||
{
|
||||
FridgeTime = null;
|
||||
stop();
|
||||
}
|
||||
else
|
||||
{
|
||||
next();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
next();
|
||||
logger.Info($"获取冰箱温度范围有误{TemperatureRange}");
|
||||
|
||||
//if (Convert.ToInt32(ConfigurationManager.AppSettings["hasFridge"]) > 1)
|
||||
//{
|
||||
// float retTemp = await _portUtil.GetFridgeTemperature(2);
|
||||
// Thread.Sleep(80);
|
||||
// WD += $"{retTemp}℃";
|
||||
//}
|
||||
if (IsLeave)
|
||||
{
|
||||
FridgeTime = null;
|
||||
stop();
|
||||
}
|
||||
else
|
||||
{
|
||||
next();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
WD = $"恒温冷藏抽屉串口关闭或冰箱制冷异常制冷关闭!!!";
|
||||
AlertColor = Brushes.Red;
|
||||
FridgeTime = null;
|
||||
stop();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,7 +23,8 @@
|
|||
<RowDefinition Height="1.2*"/>
|
||||
<RowDefinition Height="2*"/>
|
||||
<RowDefinition Height="2*"/>
|
||||
<RowDefinition Height="2*"/>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
|
@ -58,8 +59,14 @@
|
|||
ToolTip="报警状态"
|
||||
Content="打开"
|
||||
materialDesign:ToggleButtonAssist.OnContent="关闭" />
|
||||
|
||||
<Button Grid.Row="4" Grid.ColumnSpan="2" Content="保存" Command="{Binding SaveCommand}" IsEnabled="{Binding BtnIsEnable}" />
|
||||
<TextBlock Grid.Column="0" Grid.Row="4" Text="冰箱不在区间超时时间:" Margin="0 18 0 0" HorizontalAlignment="Right" VerticalAlignment="Center" FontSize="14" FontWeight="Bold" />
|
||||
<TextBox Grid.Row="4"
|
||||
Grid.Column="1"
|
||||
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}" />
|
||||
</Grid>
|
||||
</UserControl>
|
||||
|
||||
|
|
|
@ -123,7 +123,7 @@
|
|||
<Grid Grid.Column="2">
|
||||
<StackPanel Margin="6" Orientation="Horizontal" HorizontalAlignment="Right">
|
||||
<Button Content="储物箱" Command="{Binding OpenRecoverCommand}" Visibility="{Binding Is16Drawer, Converter={StaticResource BooleanToVisibilityConverter}}" Style="{StaticResource MaterialDesignFlatSecondaryLightButton}" />
|
||||
<TextBlock Margin="0,10,10,0" Text="{Binding WD}" Foreground="White" FontWeight="Bold" FontSize="14"/>
|
||||
<TextBlock Margin="0,10,10,0" Text="{Binding WD}" Foreground="{Binding AlertColor}" FontWeight="Bold" FontSize="14"/>
|
||||
<Button Content="查看冰箱温度" Visibility="{Binding HasFridge}" Command="{Binding CheckWDCommand}" Style="{StaticResource MaterialDesignFlatSecondaryLightButton}"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
|
|
Loading…
Reference in New Issue