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