去掉冰箱及录像机相关信息
This commit is contained in:
parent
190e04b07b
commit
44215a008b
|
@ -99,7 +99,7 @@
|
||||||
<!-- 指纹机号码 -->
|
<!-- 指纹机号码 -->
|
||||||
<add key="machineNumber" value="1"/>
|
<add key="machineNumber" value="1"/>
|
||||||
<!-- 指纹机ip -->
|
<!-- 指纹机ip -->
|
||||||
<add key="fingerIp" value="192.168.1.201"/>
|
<add key="fingerIp" value="192.168.50.201"/>
|
||||||
|
|
||||||
<!-- 多处方取药 0:不启用 1:启用-->
|
<!-- 多处方取药 0:不启用 1:启用-->
|
||||||
<add key="MultiOrder" value="1"/>
|
<add key="MultiOrder" value="1"/>
|
||||||
|
|
|
@ -97,7 +97,7 @@ namespace DM_Weight
|
||||||
// 组态屏工具
|
// 组态屏工具
|
||||||
containerRegistry.RegisterSingleton<ScreenUtil>();
|
containerRegistry.RegisterSingleton<ScreenUtil>();
|
||||||
// 录像机
|
// 录像机
|
||||||
containerRegistry.RegisterSingleton<CHKFunction>();
|
//containerRegistry.RegisterSingleton<CHKFunction>();
|
||||||
|
|
||||||
containerRegistry.Register<IDialogService, MaterialDialogService>();
|
containerRegistry.Register<IDialogService, MaterialDialogService>();
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>WinExe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net6.0-windows</TargetFramework>
|
<TargetFramework>net6.0-windows</TargetFramework>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<UseWPF>true</UseWPF>
|
<UseWPF>true</UseWPF>
|
||||||
|
|
|
@ -23,19 +23,19 @@ namespace DM_Weight.Finger
|
||||||
public zkemkeeper.CZKEMClass axCZKEM1;// = new zkemkeeper.CZKEMClass();
|
public zkemkeeper.CZKEMClass axCZKEM1;// = new zkemkeeper.CZKEMClass();
|
||||||
public bool bIsConnected = false;
|
public bool bIsConnected = false;
|
||||||
|
|
||||||
private string fingerIp = ConfigurationManager.AppSettings["fingerIp"].ToString();
|
private string fingerIp = ConfigurationManager.AppSettings["fingerIp"]?.ToString() ?? "";
|
||||||
private int fingerPort = 4370;
|
private int fingerPort = 4370;
|
||||||
private int machineNumber = Convert.ToInt32(ConfigurationManager.AppSettings["machineNumber"].ToString());
|
private int machineNumber = Convert.ToInt32(ConfigurationManager.AppSettings["machineNumber"]?.ToString() ?? "0");
|
||||||
private int machineType = Convert.ToInt32(ConfigurationManager.AppSettings["machineType"].ToString());
|
private int machineType = Convert.ToInt32(ConfigurationManager.AppSettings["machineType"]?.ToString() ?? "0");
|
||||||
private readonly IEventAggregator _eventAggregator;
|
private readonly IEventAggregator _eventAggregator;
|
||||||
public FingerprintUtil(IEventAggregator eventAggregator)
|
public FingerprintUtil(IEventAggregator eventAggregator)
|
||||||
{
|
{
|
||||||
_eventAggregator = eventAggregator;
|
_eventAggregator = eventAggregator;
|
||||||
logger.Info($"进入构造器,开始连接指纹机");
|
logger.Info($"进入构造器,开始连接指纹机");
|
||||||
Task.Run(() =>
|
// Task.Factory.StartNew(() =>
|
||||||
{
|
//{
|
||||||
ConnectionMain();
|
ConnectionMain();
|
||||||
});
|
//});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ConnectionMain()
|
public void ConnectionMain()
|
||||||
|
@ -47,7 +47,7 @@ namespace DM_Weight.Finger
|
||||||
logger.Info($"连接指纹机,IP:{fingerIp},端口:{fingerPort},机器号:{machineNumber},连接结果:{bIsConnected}");
|
logger.Info($"连接指纹机,IP:{fingerIp},端口:{fingerPort},机器号:{machineNumber},连接结果:{bIsConnected}");
|
||||||
if (bIsConnected)
|
if (bIsConnected)
|
||||||
{
|
{
|
||||||
if (axCZKEM1.RegEvent(machineNumber, 65535))
|
if (axCZKEM1.RegEvent(machineNumber, 9))
|
||||||
{
|
{
|
||||||
this.axCZKEM1.OnAttTransactionEx += new zkemkeeper._IZKEMEvents_OnAttTransactionExEventHandler(axCZKEM1_OnAttTransactionEx);
|
this.axCZKEM1.OnAttTransactionEx += new zkemkeeper._IZKEMEvents_OnAttTransactionExEventHandler(axCZKEM1_OnAttTransactionEx);
|
||||||
//this.axCZKEM1.OnEnrollFinger += new zkemkeeper._IZKEMEvents_OnEnrollFingerEventHandler(axCZKEM1_OnEnrollFinger);
|
//this.axCZKEM1.OnEnrollFinger += new zkemkeeper._IZKEMEvents_OnEnrollFingerEventHandler(axCZKEM1_OnEnrollFinger);
|
||||||
|
|
|
@ -44,7 +44,7 @@ namespace DM_Weight.Port
|
||||||
public SerialPort scanCodeSerial;
|
public SerialPort scanCodeSerial;
|
||||||
|
|
||||||
// 冰箱串口
|
// 冰箱串口
|
||||||
public SerialPort fridgeSerial;
|
//public SerialPort fridgeSerial;
|
||||||
|
|
||||||
|
|
||||||
// 抽屉串口协议232 | 485
|
// 抽屉串口协议232 | 485
|
||||||
|
@ -236,7 +236,7 @@ namespace DM_Weight.Port
|
||||||
logger.Info($"进行抽屉操作抽屉号【{DrawerNo}】类型【{BoardType}】库位【{string.Join(",", ColNos)}】窗口【{WindowName}】");
|
logger.Info($"进行抽屉操作抽屉号【{DrawerNo}】类型【{BoardType}】库位【{string.Join(",", ColNos)}】窗口【{WindowName}】");
|
||||||
Operate = true;
|
Operate = true;
|
||||||
//开始录像
|
//开始录像
|
||||||
_chkFunction.HIKStartDVRRecord();
|
//_chkFunction.HIKStartDVRRecord();
|
||||||
logger.Info($"时间:{DateTime.Now}");
|
logger.Info($"时间:{DateTime.Now}");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -695,8 +695,8 @@ namespace DM_Weight.Port
|
||||||
|
|
||||||
|
|
||||||
private readonly IEventAggregator _eventAggregator;
|
private readonly IEventAggregator _eventAggregator;
|
||||||
private CHKFunction _chkFunction;
|
//private CHKFunction _chkFunction;
|
||||||
public PortUtil(IEventAggregator eventAggregator, CHKFunction chkFunction)
|
public PortUtil(IEventAggregator eventAggregator)
|
||||||
{
|
{
|
||||||
_eventAggregator = eventAggregator;
|
_eventAggregator = eventAggregator;
|
||||||
try
|
try
|
||||||
|
@ -733,18 +733,18 @@ namespace DM_Weight.Port
|
||||||
{
|
{
|
||||||
logger.Error("条码枪串口打开错误" + e.Message);
|
logger.Error("条码枪串口打开错误" + e.Message);
|
||||||
}
|
}
|
||||||
try
|
//try
|
||||||
{
|
//{
|
||||||
string FridgePortPath = ConfigurationManager.AppSettings["FridgePortPath"];
|
// string FridgePortPath = ConfigurationManager.AppSettings["FridgePortPath"];
|
||||||
logger.Info($"打开冰箱串口【{FridgePortPath}】");
|
// logger.Info($"打开冰箱串口【{FridgePortPath}】");
|
||||||
fridgeSerial = new SerialPort(FridgePortPath, 9600, Parity.None, 8);
|
// fridgeSerial = new SerialPort(FridgePortPath, 9600, Parity.None, 8);
|
||||||
fridgeSerial.Open();
|
// fridgeSerial.Open();
|
||||||
logger.Info($"冰箱串口打开结果【{fridgeSerial.IsOpen}】");
|
// logger.Info($"冰箱串口打开结果【{fridgeSerial.IsOpen}】");
|
||||||
}
|
//}
|
||||||
catch (Exception e)
|
//catch (Exception e)
|
||||||
{
|
//{
|
||||||
logger.Error("冰箱串口打开错误" + e.Message);
|
// logger.Error("冰箱串口打开错误" + e.Message);
|
||||||
}
|
//}
|
||||||
if (_canBusExsit)
|
if (_canBusExsit)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@ -761,7 +761,7 @@ namespace DM_Weight.Port
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
_chkFunction = chkFunction;
|
//_chkFunction = chkFunction;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1546,385 +1546,385 @@ namespace DM_Weight.Port
|
||||||
|
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
/// <summary>
|
///// <summary>
|
||||||
/// 冰箱使能
|
///// 冰箱使能
|
||||||
/// </summary>
|
///// </summary>
|
||||||
/// <returns></returns>
|
///// <returns></returns>
|
||||||
public async Task FridegOpen(int iIndex)
|
//public async Task FridegOpen(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, 0x10, 0xD4, 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];
|
// try
|
||||||
//}
|
|
||||||
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 FridgeOff(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, 0x10, 0xD4, 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];
|
// fridgeSerial.DiscardInBuffer();
|
||||||
//}
|
// byte bAddress;
|
||||||
logger.Info($"冰箱失能【{Convert.ToHexString(buffer)}】");
|
// if (iIndex == 1)
|
||||||
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 FridgeAlarmOn(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, 0x06, 0x10, 0xD5, 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];
|
// bAddress = 0x01;
|
||||||
// }
|
// }
|
||||||
logger.Info($"冰箱报警使能【{Convert.ToHexString(buffer)}】");
|
// else
|
||||||
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 FridgeAlarmOff(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, 0x06, 0x10, 0xD5, 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];
|
// bAddress = 0x02;
|
||||||
// }
|
// }
|
||||||
logger.Info($"冰箱报警失能【{Convert.ToHexString(buffer)}】");
|
// byte[] buffer = new byte[] { bAddress, 0x06, 0x10, 0xD4, 0x00, 0x01, 0x0C, 0xF2 };
|
||||||
fridgeSerial.Write(buffer, 0, 8);
|
// //byte[] buffer = new byte[] { 0x01, 0x06, 0x10, 0xD4, 0x00, 0x01 };
|
||||||
await Task.Delay(80);
|
// ////获取数组CRC校验码
|
||||||
}
|
// //byte[] byteDate = CRC16MODBUS.CrcModBus(buffer);
|
||||||
catch (Exception ex)
|
// ////Array.Reverse(byteDate);
|
||||||
{
|
// //int dataLength = buffer.Length;
|
||||||
logger.Info($"冰箱报警失能发生异常:ex:{ex.Message}");
|
// //Array.Resize(ref buffer, dataLength + byteDate.Length);
|
||||||
}
|
// //for (int i = 0; i < byteDate.Length; i++)
|
||||||
FridgeOperate = false;
|
// //{
|
||||||
}
|
// // buffer[dataLength + i] = byteDate[i];
|
||||||
/// <summary>
|
// //}
|
||||||
/// 冰箱温度设定最小
|
// logger.Info($"冰箱使能【{Convert.ToHexString(buffer)}】");
|
||||||
/// </summary>
|
// fridgeSerial.Write(buffer, 0, 8);
|
||||||
/// <returns></returns>
|
// await Task.Delay(80);
|
||||||
public async Task FridgeMinSetting(float min, int iIndex)
|
// }
|
||||||
{
|
// catch (Exception ex)
|
||||||
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 FridgeMaxSetting(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 };
|
|
||||||
byte bAddress;
|
|
||||||
if (iIndex == 1)
|
|
||||||
{
|
|
||||||
bAddress = 0x01;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
bAddress = 0x02;
|
|
||||||
}
|
|
||||||
byte[] bufferMax = new byte[] { bAddress, 0x06, 0x10, 0xC8, 0x00, (byte)(iMax & 0xff) };
|
|
||||||
//获取数组CRC校验码
|
|
||||||
byte[] byteDate = CRC16MODBUS.CrcModBus(bufferMax);
|
|
||||||
//Array.Reverse(byteDate);
|
|
||||||
int dataLength = bufferMax.Length;
|
|
||||||
Array.Resize(ref bufferMax, dataLength + byteDate.Length);
|
|
||||||
for (int i = 0; i < byteDate.Length; i++)
|
|
||||||
{
|
|
||||||
bufferMax[dataLength + i] = byteDate[i];
|
|
||||||
}
|
|
||||||
logger.Info($"冰箱温度设定Max:【{Convert.ToHexString(bufferMax)}】");
|
|
||||||
fridgeSerial.Write(bufferMax, 0, 8);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
logger.Info($"获取冰箱温度发生异常:ex:{ex.Message}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// 获取冰箱温度
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
public async Task<float> GetFridgeTemperature(int iIndex)
|
|
||||||
{
|
|
||||||
float temperature = 0.0f;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
fridgeSerial.DiscardInBuffer();
|
|
||||||
byte bAddress;
|
|
||||||
if (iIndex == 1)
|
|
||||||
{
|
|
||||||
bAddress = 0x01;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
bAddress = 0x02;
|
|
||||||
}
|
|
||||||
byte[] buffer = new byte[] { bAddress, 0x03, 0x10, 0x02, 0x00, 0x01, 0x21, 0x0A };
|
|
||||||
//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($"冰箱使能发生异常:ex:{ex.Message}");
|
||||||
// }
|
// }
|
||||||
|
|
||||||
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>
|
|
||||||
/// <returns></returns>
|
|
||||||
public async Task<float> SetFridgeTemperature(float temperature, int iIndex)
|
|
||||||
{
|
|
||||||
int tpt = (int)temperature * 10;
|
|
||||||
byte Temperature = (byte)(tpt & 0xff);
|
|
||||||
try
|
|
||||||
{
|
|
||||||
//if (!FridgeOperate)
|
|
||||||
{
|
|
||||||
fridgeSerial.DiscardInBuffer();
|
|
||||||
byte bAddress;
|
|
||||||
if (iIndex == 1)
|
|
||||||
{
|
|
||||||
bAddress = 0x01;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
bAddress = 0x02;
|
|
||||||
}
|
|
||||||
//byte[] buffer = new byte[] { 0x01, 0x03, 0x10, 0x02, 0x00, 0x01, 0x21,0x0A };
|
|
||||||
byte[] buffer = new byte[] { bAddress, 0x06, 0x10, 0x02, 0x00, (byte)Temperature };
|
|
||||||
|
|
||||||
//获取数组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 GetBufferByPort(fridgeSerial, 8);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
|
|
||||||
logger.Info($"获取冰箱温度发生异常:ex:{ex.Message}");
|
|
||||||
}
|
|
||||||
return temperature;
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// 冰箱延迟报警
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
public async Task FridgeDelayWarm(int iIndex)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
//if (!FridgeOperate)
|
|
||||||
{
|
|
||||||
fridgeSerial.DiscardInBuffer();
|
|
||||||
byte bAddress;
|
|
||||||
if (iIndex == 1)
|
|
||||||
{
|
|
||||||
bAddress = 0x01;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
bAddress = 0x02;
|
|
||||||
}
|
|
||||||
byte[] buffer = new byte[] { bAddress, 0x06, 0x10, 0xCD, 0x00, 0x01, 0xDD, 0x35 };
|
|
||||||
//byte[] buffer = new byte[] { 0x01, 0x06, 0x10, 0xCD, 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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
|
|
||||||
logger.Info($"获取冰箱温度发生异常:ex:{ex.Message}");
|
|
||||||
}
|
|
||||||
// FridgeOperate = false;
|
// FridgeOperate = false;
|
||||||
}
|
//}
|
||||||
|
///// <summary>
|
||||||
|
///// 冰箱失能
|
||||||
|
///// </summary>
|
||||||
|
///// <returns></returns>
|
||||||
|
//public async Task FridgeOff(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, 0x10, 0xD4, 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 FridgeAlarmOn(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, 0x06, 0x10, 0xD5, 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 FridgeAlarmOff(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, 0x06, 0x10, 0xD5, 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 FridgeMinSetting(float min, 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 FridgeMaxSetting(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 };
|
||||||
|
// byte bAddress;
|
||||||
|
// if (iIndex == 1)
|
||||||
|
// {
|
||||||
|
// bAddress = 0x01;
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// bAddress = 0x02;
|
||||||
|
// }
|
||||||
|
// byte[] bufferMax = new byte[] { bAddress, 0x06, 0x10, 0xC8, 0x00, (byte)(iMax & 0xff) };
|
||||||
|
// //获取数组CRC校验码
|
||||||
|
// byte[] byteDate = CRC16MODBUS.CrcModBus(bufferMax);
|
||||||
|
// //Array.Reverse(byteDate);
|
||||||
|
// int dataLength = bufferMax.Length;
|
||||||
|
// Array.Resize(ref bufferMax, dataLength + byteDate.Length);
|
||||||
|
// for (int i = 0; i < byteDate.Length; i++)
|
||||||
|
// {
|
||||||
|
// bufferMax[dataLength + i] = byteDate[i];
|
||||||
|
// }
|
||||||
|
// logger.Info($"冰箱温度设定Max:【{Convert.ToHexString(bufferMax)}】");
|
||||||
|
// fridgeSerial.Write(bufferMax, 0, 8);
|
||||||
|
// }
|
||||||
|
// catch (Exception ex)
|
||||||
|
// {
|
||||||
|
// logger.Info($"获取冰箱温度发生异常:ex:{ex.Message}");
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
///// <summary>
|
||||||
|
///// 获取冰箱温度
|
||||||
|
///// </summary>
|
||||||
|
///// <returns></returns>
|
||||||
|
//public async Task<float> GetFridgeTemperature(int iIndex)
|
||||||
|
//{
|
||||||
|
// float temperature = 0.0f;
|
||||||
|
// try
|
||||||
|
// {
|
||||||
|
// fridgeSerial.DiscardInBuffer();
|
||||||
|
// byte bAddress;
|
||||||
|
// if (iIndex == 1)
|
||||||
|
// {
|
||||||
|
// bAddress = 0x01;
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// bAddress = 0x02;
|
||||||
|
// }
|
||||||
|
// byte[] buffer = new byte[] { bAddress, 0x03, 0x10, 0x02, 0x00, 0x01, 0x21, 0x0A };
|
||||||
|
// //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>
|
||||||
|
///// <returns></returns>
|
||||||
|
//public async Task<float> SetFridgeTemperature(float temperature, int iIndex)
|
||||||
|
//{
|
||||||
|
// int tpt = (int)temperature * 10;
|
||||||
|
// byte Temperature = (byte)(tpt & 0xff);
|
||||||
|
// try
|
||||||
|
// {
|
||||||
|
// //if (!FridgeOperate)
|
||||||
|
// {
|
||||||
|
// fridgeSerial.DiscardInBuffer();
|
||||||
|
// byte bAddress;
|
||||||
|
// if (iIndex == 1)
|
||||||
|
// {
|
||||||
|
// bAddress = 0x01;
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// bAddress = 0x02;
|
||||||
|
// }
|
||||||
|
// //byte[] buffer = new byte[] { 0x01, 0x03, 0x10, 0x02, 0x00, 0x01, 0x21,0x0A };
|
||||||
|
// byte[] buffer = new byte[] { bAddress, 0x06, 0x10, 0x02, 0x00, (byte)Temperature };
|
||||||
|
|
||||||
|
// //获取数组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 GetBufferByPort(fridgeSerial, 8);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// catch (Exception ex)
|
||||||
|
// {
|
||||||
|
|
||||||
|
// logger.Info($"获取冰箱温度发生异常:ex:{ex.Message}");
|
||||||
|
// }
|
||||||
|
// return temperature;
|
||||||
|
//}
|
||||||
|
///// <summary>
|
||||||
|
///// 冰箱延迟报警
|
||||||
|
///// </summary>
|
||||||
|
///// <returns></returns>
|
||||||
|
//public async Task FridgeDelayWarm(int iIndex)
|
||||||
|
//{
|
||||||
|
// try
|
||||||
|
// {
|
||||||
|
// //if (!FridgeOperate)
|
||||||
|
// {
|
||||||
|
// fridgeSerial.DiscardInBuffer();
|
||||||
|
// byte bAddress;
|
||||||
|
// if (iIndex == 1)
|
||||||
|
// {
|
||||||
|
// bAddress = 0x01;
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// bAddress = 0x02;
|
||||||
|
// }
|
||||||
|
// byte[] buffer = new byte[] { bAddress, 0x06, 0x10, 0xCD, 0x00, 0x01, 0xDD, 0x35 };
|
||||||
|
// //byte[] buffer = new byte[] { 0x01, 0x06, 0x10, 0xCD, 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);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// catch (Exception ex)
|
||||||
|
// {
|
||||||
|
|
||||||
|
// logger.Info($"获取冰箱温度发生异常:ex:{ex.Message}");
|
||||||
|
// }
|
||||||
|
// //FridgeOperate = false;
|
||||||
|
//}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -92,94 +92,94 @@ namespace DM_Weight.ViewModels
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 保存按钮
|
/// 保存按钮
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public DelegateCommand SaveCommand { get => new DelegateCommand(SaveAction, () => !IsInvalid); }
|
//public DelegateCommand SaveCommand { get => new DelegateCommand(SaveAction, () => !IsInvalid); }
|
||||||
|
|
||||||
public bool KeepAlive => false;
|
public bool KeepAlive => false;
|
||||||
|
|
||||||
private async void SaveAction()
|
//private async void SaveAction()
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_portUtil.FridgeOperate = true;
|
|
||||||
|
|
||||||
//设置温度值验证不通过则直接返回不保存
|
|
||||||
//获取冰箱温度
|
|
||||||
//if (_fridgeState != _defaultLoginMode.Equals(1))
|
|
||||||
//{
|
//{
|
||||||
// ConfigurationManager.RefreshSection("FridgeState");
|
// try
|
||||||
//发送冰箱使能/失能指令
|
// {
|
||||||
if (_fridgeState)
|
// _portUtil.FridgeOperate = true;
|
||||||
{
|
|
||||||
await _portUtil.FridgeOff(1);
|
|
||||||
Thread.Sleep(100);
|
|
||||||
CommonClass.SaveAppSetting("FridgeState", "0");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
await _portUtil.FridegOpen(1);
|
|
||||||
Thread.Sleep(100);
|
|
||||||
CommonClass.SaveAppSetting("FridgeState", "1");
|
|
||||||
}
|
|
||||||
//发送警报使能/失能指令
|
|
||||||
if (_alarmState)
|
|
||||||
{
|
|
||||||
await _portUtil.FridgeAlarmOff(1);
|
|
||||||
Thread.Sleep(100);
|
|
||||||
CommonClass.SaveAppSetting("AlarmState", "0");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
await _portUtil.FridgeAlarmOn(1);
|
|
||||||
Thread.Sleep(100);
|
|
||||||
CommonClass.SaveAppSetting("AlarmState", "1");
|
|
||||||
}
|
|
||||||
//设定冰箱1温度区间
|
|
||||||
string[] range = ConfigurationManager.AppSettings["temperatureRange"].Split('-');
|
|
||||||
string[] newRange = TemperatureRange.Split('-');
|
|
||||||
if (range.Length >= 2)
|
|
||||||
{
|
|
||||||
bool bMix = float.TryParse(range[0], out float Min);
|
|
||||||
bool bMax = float.TryParse(range[1], out float Max);
|
|
||||||
|
|
||||||
if (bMix && bMax)
|
// //设置温度值验证不通过则直接返回不保存
|
||||||
{
|
// //获取冰箱温度
|
||||||
if (Min != Convert.ToSingle(newRange[0]))
|
// //if (_fridgeState != _defaultLoginMode.Equals(1))
|
||||||
{
|
// //{
|
||||||
//设定冰箱温度最小值
|
// // ConfigurationManager.RefreshSection("FridgeState");
|
||||||
await _portUtil.FridgeMinSetting(Convert.ToSingle(newRange[0]), 1);
|
// //发送冰箱使能/失能指令
|
||||||
Thread.Sleep(100);
|
// if (_fridgeState)
|
||||||
}
|
// {
|
||||||
if (Max != Convert.ToSingle(newRange[1]))
|
// await _portUtil.FridgeOff(1);
|
||||||
{
|
// Thread.Sleep(100);
|
||||||
Thread.Sleep(100);
|
// CommonClass.SaveAppSetting("FridgeState", "0");
|
||||||
//设定冰箱温度最大值
|
// }
|
||||||
await _portUtil.FridgeMaxSetting(Convert.ToSingle(newRange[1]), 1);
|
// else
|
||||||
Thread.Sleep(100);
|
// {
|
||||||
}
|
// await _portUtil.FridegOpen(1);
|
||||||
}
|
// Thread.Sleep(100);
|
||||||
}
|
// CommonClass.SaveAppSetting("FridgeState", "1");
|
||||||
|
// }
|
||||||
|
// //发送警报使能/失能指令
|
||||||
|
// if (_alarmState)
|
||||||
|
// {
|
||||||
|
// await _portUtil.FridgeAlarmOff(1);
|
||||||
|
// Thread.Sleep(100);
|
||||||
|
// CommonClass.SaveAppSetting("AlarmState", "0");
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// await _portUtil.FridgeAlarmOn(1);
|
||||||
|
// Thread.Sleep(100);
|
||||||
|
// CommonClass.SaveAppSetting("AlarmState", "1");
|
||||||
|
// }
|
||||||
|
// //设定冰箱1温度区间
|
||||||
|
// string[] range = ConfigurationManager.AppSettings["temperatureRange"].Split('-');
|
||||||
|
// string[] newRange = TemperatureRange.Split('-');
|
||||||
|
// if (range.Length >= 2)
|
||||||
|
// {
|
||||||
|
// bool bMix = float.TryParse(range[0], out float Min);
|
||||||
|
// bool bMax = float.TryParse(range[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);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
_portUtil.FridgeOperate = false;
|
// _portUtil.FridgeOperate = false;
|
||||||
AlertMsg alertMsg = new AlertMsg
|
// AlertMsg alertMsg = new AlertMsg
|
||||||
{
|
// {
|
||||||
Message = $"保存成功",
|
// Message = $"保存成功",
|
||||||
Type = MsgType.SUCCESS
|
// Type = MsgType.SUCCESS
|
||||||
};
|
// };
|
||||||
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
|
// _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
|
||||||
}
|
// }
|
||||||
catch (Exception ex)
|
// catch (Exception ex)
|
||||||
{
|
// {
|
||||||
|
|
||||||
AlertMsg alertMsg = new AlertMsg
|
// AlertMsg alertMsg = new AlertMsg
|
||||||
{
|
// {
|
||||||
Message = $"保存异常{ex.ToString}",
|
// Message = $"保存异常{ex.ToString}",
|
||||||
Type = MsgType.ERROR
|
// Type = MsgType.ERROR
|
||||||
};
|
// };
|
||||||
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
|
// _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
|
||||||
_portUtil.FridgeOperate = false;
|
// _portUtil.FridgeOperate = false;
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
//手动实现调用配置的逻辑 规避修改配置文件后不起作用的问题
|
//手动实现调用配置的逻辑 规避修改配置文件后不起作用的问题
|
||||||
public int ReadAppSetting(string key)
|
public int ReadAppSetting(string key)
|
||||||
{
|
{
|
||||||
|
|
|
@ -121,167 +121,167 @@ namespace DM_Weight.ViewModels
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 保存按钮
|
/// 保存按钮
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public DelegateCommand SaveCommand { get => new DelegateCommand(SaveAction, () => !IsInvalid); }
|
//public DelegateCommand SaveCommand { get => new DelegateCommand(SaveAction, () => !IsInvalid); }
|
||||||
|
|
||||||
public bool KeepAlive => false;
|
public bool KeepAlive => false;
|
||||||
|
|
||||||
private async void SaveAction()
|
//private async void SaveAction()
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_portUtil.FridgeOperate = true;
|
|
||||||
|
|
||||||
//设置温度值验证不通过则直接返回不保存
|
|
||||||
//获取冰箱温度
|
|
||||||
//if (_fridgeState != _defaultLoginMode.Equals(1))
|
|
||||||
//{
|
//{
|
||||||
// ConfigurationManager.RefreshSection("FridgeState");
|
// try
|
||||||
//发送冰箱使能/失能指令
|
// {
|
||||||
if (_fridgeState)
|
// _portUtil.FridgeOperate = true;
|
||||||
{
|
|
||||||
await _portUtil.FridgeOff(1);
|
|
||||||
Thread.Sleep(100);
|
|
||||||
CommonClass.SaveAppSetting("FridgeState", "0");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
await _portUtil.FridegOpen(1);
|
|
||||||
Thread.Sleep(100);
|
|
||||||
CommonClass.SaveAppSetting("FridgeState", "1");
|
|
||||||
}
|
|
||||||
|
|
||||||
//冰箱2 发送冰箱使能/失能指令
|
// //设置温度值验证不通过则直接返回不保存
|
||||||
if (_fridgeState2)
|
// //获取冰箱温度
|
||||||
{
|
// //if (_fridgeState != _defaultLoginMode.Equals(1))
|
||||||
await _portUtil.FridgeOff(2);
|
// //{
|
||||||
Thread.Sleep(100);
|
// // ConfigurationManager.RefreshSection("FridgeState");
|
||||||
CommonClass.SaveAppSetting("FridgeState2", "0");
|
// //发送冰箱使能/失能指令
|
||||||
}
|
// if (_fridgeState)
|
||||||
else
|
// {
|
||||||
{
|
// await _portUtil.FridgeOff(1);
|
||||||
await _portUtil.FridegOpen(2);
|
// Thread.Sleep(100);
|
||||||
Thread.Sleep(100);
|
// CommonClass.SaveAppSetting("FridgeState", "0");
|
||||||
CommonClass.SaveAppSetting("FridgeState2", "1");
|
|
||||||
}
|
|
||||||
// }
|
// }
|
||||||
//温度报警设定
|
// else
|
||||||
//if (AlarmState != _defaultAlarmMode.Equals(1))
|
|
||||||
// {
|
// {
|
||||||
//发送警报使能/失能指令
|
// await _portUtil.FridegOpen(1);
|
||||||
if (_alarmState)
|
// Thread.Sleep(100);
|
||||||
{
|
// CommonClass.SaveAppSetting("FridgeState", "1");
|
||||||
await _portUtil.FridgeAlarmOff(1);
|
|
||||||
Thread.Sleep(100);
|
|
||||||
CommonClass.SaveAppSetting("AlarmState", "0");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
await _portUtil.FridgeAlarmOn(1);
|
|
||||||
Thread.Sleep(100);
|
|
||||||
CommonClass.SaveAppSetting("AlarmState", "1");
|
|
||||||
}
|
|
||||||
|
|
||||||
//冰箱2 发送警报使能/失能指令
|
|
||||||
if (_alarmState2)
|
|
||||||
{
|
|
||||||
await _portUtil.FridgeAlarmOff(2);
|
|
||||||
Thread.Sleep(100);
|
|
||||||
CommonClass.SaveAppSetting("AlarmState2", "0");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
await _portUtil.FridgeAlarmOn(2);
|
|
||||||
Thread.Sleep(100);
|
|
||||||
CommonClass.SaveAppSetting("AlarmState2", "1");
|
|
||||||
}
|
|
||||||
// }
|
// }
|
||||||
|
|
||||||
//if (retTemperature != TemperatureValue)
|
// //冰箱2 发送冰箱使能/失能指令
|
||||||
|
// if (_fridgeState2)
|
||||||
// {
|
// {
|
||||||
// //设定冰箱温度
|
// await _portUtil.FridgeOff(2);
|
||||||
// await _portUtil.SetFridgeTemperature(TemperatureValue);
|
// Thread.Sleep(100);
|
||||||
|
// CommonClass.SaveAppSetting("FridgeState2", "0");
|
||||||
// CommonClass.SaveAppSetting("temperatureValue", TemperatureValue.ToString());
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// await _portUtil.FridegOpen(2);
|
||||||
|
// Thread.Sleep(100);
|
||||||
|
// CommonClass.SaveAppSetting("FridgeState2", "1");
|
||||||
|
// }
|
||||||
|
// //}
|
||||||
|
// //温度报警设定
|
||||||
|
// //if (AlarmState != _defaultAlarmMode.Equals(1))
|
||||||
|
// //{
|
||||||
|
// //发送警报使能/失能指令
|
||||||
|
// if (_alarmState)
|
||||||
|
// {
|
||||||
|
// await _portUtil.FridgeAlarmOff(1);
|
||||||
|
// Thread.Sleep(100);
|
||||||
|
// CommonClass.SaveAppSetting("AlarmState", "0");
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// await _portUtil.FridgeAlarmOn(1);
|
||||||
|
// Thread.Sleep(100);
|
||||||
|
// CommonClass.SaveAppSetting("AlarmState", "1");
|
||||||
// }
|
// }
|
||||||
//设定冰箱1温度区间
|
|
||||||
string[] range = ConfigurationManager.AppSettings["temperatureRange"].Split('-');
|
|
||||||
string[] newRange = TemperatureRange.Split('-');
|
|
||||||
if (range.Length >= 2)
|
|
||||||
{
|
|
||||||
bool bMix = float.TryParse(range[0], out float Min);
|
|
||||||
bool bMax = float.TryParse(range[1], out float Max);
|
|
||||||
|
|
||||||
if (bMix && bMax)
|
// //冰箱2 发送警报使能/失能指令
|
||||||
{
|
// if (_alarmState2)
|
||||||
if (Min != Convert.ToSingle(newRange[0]))
|
// {
|
||||||
{
|
// await _portUtil.FridgeAlarmOff(2);
|
||||||
//设定冰箱温度最小值
|
// Thread.Sleep(100);
|
||||||
await _portUtil.FridgeMinSetting(Convert.ToSingle(newRange[0]),1);
|
// CommonClass.SaveAppSetting("AlarmState2", "0");
|
||||||
Thread.Sleep(100);
|
// }
|
||||||
}
|
// else
|
||||||
if (Max != Convert.ToSingle(newRange[1]))
|
// {
|
||||||
{
|
// await _portUtil.FridgeAlarmOn(2);
|
||||||
Thread.Sleep(100);
|
// Thread.Sleep(100);
|
||||||
//设定冰箱温度最大值
|
// CommonClass.SaveAppSetting("AlarmState2", "1");
|
||||||
await _portUtil.FridgeMaxSetting(Convert.ToSingle(newRange[1]), 1);
|
// }
|
||||||
Thread.Sleep(100);
|
// //}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//设定冰箱2温度区间
|
// //if (retTemperature != TemperatureValue)
|
||||||
string[] range2 = ConfigurationManager.AppSettings["temperatureRange2"].Split('-');
|
// //{
|
||||||
string[] newRange2 = TemperatureRange2.Split('-');
|
// // //设定冰箱温度
|
||||||
if (range2.Length >= 2)
|
// // await _portUtil.SetFridgeTemperature(TemperatureValue);
|
||||||
{
|
|
||||||
bool bMix = float.TryParse(range2[0], out float Min);
|
|
||||||
bool bMax = float.TryParse(range2[1], out float Max);
|
|
||||||
|
|
||||||
if (bMix && bMax)
|
// // CommonClass.SaveAppSetting("temperatureValue", TemperatureValue.ToString());
|
||||||
{
|
// //}
|
||||||
if (Min != Convert.ToSingle(newRange2[0]))
|
// //设定冰箱1温度区间
|
||||||
{
|
// string[] range = ConfigurationManager.AppSettings["temperatureRange"].Split('-');
|
||||||
//设定冰箱温度最小值
|
// string[] newRange = TemperatureRange.Split('-');
|
||||||
await _portUtil.FridgeMinSetting(Convert.ToSingle(newRange2[0]), 2);
|
// if (range.Length >= 2)
|
||||||
Thread.Sleep(100);
|
// {
|
||||||
}
|
// bool bMix = float.TryParse(range[0], out float Min);
|
||||||
if (Max != Convert.ToSingle(newRange2[1]))
|
// bool bMax = float.TryParse(range[1], out float Max);
|
||||||
{
|
|
||||||
Thread.Sleep(100);
|
|
||||||
//设定冰箱温度最大值
|
|
||||||
await _portUtil.FridgeMaxSetting(Convert.ToSingle(newRange2[1]), 2);
|
|
||||||
Thread.Sleep(100);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_portUtil.FridgeOperate = false;
|
// if (bMix && bMax)
|
||||||
AlertMsg alertMsg = new AlertMsg
|
// {
|
||||||
{
|
// if (Min != Convert.ToSingle(newRange[0]))
|
||||||
Message = $"保存成功",
|
// {
|
||||||
Type = MsgType.SUCCESS
|
// //设定冰箱温度最小值
|
||||||
};
|
// await _portUtil.FridgeMinSetting(Convert.ToSingle(newRange[0]),1);
|
||||||
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
|
// Thread.Sleep(100);
|
||||||
|
// }
|
||||||
|
// if (Max != Convert.ToSingle(newRange[1]))
|
||||||
|
// {
|
||||||
|
// Thread.Sleep(100);
|
||||||
|
// //设定冰箱温度最大值
|
||||||
|
// await _portUtil.FridgeMaxSetting(Convert.ToSingle(newRange[1]), 1);
|
||||||
|
// Thread.Sleep(100);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
//_fridgeState = ReadAppSetting("FridgeState").Equals(1);
|
// //设定冰箱2温度区间
|
||||||
//_defaultLoginMode = ReadAppSetting("FridgeState");
|
// string[] range2 = ConfigurationManager.AppSettings["temperatureRange2"].Split('-');
|
||||||
//_defaultAlarmMode = ReadAppSetting("AlarmState");
|
// string[] newRange2 = TemperatureRange2.Split('-');
|
||||||
//_alarmState = ReadAppSetting("AlarmState").Equals(1);
|
// if (range2.Length >= 2)
|
||||||
//_temperatureRange = CommonClass.ReadAppSetting("temperatureRange");
|
// {
|
||||||
//_temperatureValue = Convert.ToSingle(CommonClass.ReadAppSetting("temperatureValue"));
|
// bool bMix = float.TryParse(range2[0], out float Min);
|
||||||
}
|
// bool bMax = float.TryParse(range2[1], out float Max);
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
|
|
||||||
AlertMsg alertMsg = new AlertMsg
|
// if (bMix && bMax)
|
||||||
{
|
// {
|
||||||
Message = $"保存异常{ex.ToString}",
|
// if (Min != Convert.ToSingle(newRange2[0]))
|
||||||
Type = MsgType.ERROR
|
// {
|
||||||
};
|
// //设定冰箱温度最小值
|
||||||
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
|
// await _portUtil.FridgeMinSetting(Convert.ToSingle(newRange2[0]), 2);
|
||||||
_portUtil.FridgeOperate = false;
|
// Thread.Sleep(100);
|
||||||
}
|
// }
|
||||||
}
|
// if (Max != Convert.ToSingle(newRange2[1]))
|
||||||
|
// {
|
||||||
|
// Thread.Sleep(100);
|
||||||
|
// //设定冰箱温度最大值
|
||||||
|
// await _portUtil.FridgeMaxSetting(Convert.ToSingle(newRange2[1]), 2);
|
||||||
|
// Thread.Sleep(100);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// _portUtil.FridgeOperate = false;
|
||||||
|
// AlertMsg alertMsg = new AlertMsg
|
||||||
|
// {
|
||||||
|
// Message = $"保存成功",
|
||||||
|
// Type = MsgType.SUCCESS
|
||||||
|
// };
|
||||||
|
// _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
|
||||||
|
|
||||||
|
// //_fridgeState = ReadAppSetting("FridgeState").Equals(1);
|
||||||
|
// //_defaultLoginMode = ReadAppSetting("FridgeState");
|
||||||
|
// //_defaultAlarmMode = ReadAppSetting("AlarmState");
|
||||||
|
// //_alarmState = ReadAppSetting("AlarmState").Equals(1);
|
||||||
|
// //_temperatureRange = CommonClass.ReadAppSetting("temperatureRange");
|
||||||
|
// //_temperatureValue = Convert.ToSingle(CommonClass.ReadAppSetting("temperatureValue"));
|
||||||
|
// }
|
||||||
|
// catch (Exception ex)
|
||||||
|
// {
|
||||||
|
|
||||||
|
// AlertMsg alertMsg = new AlertMsg
|
||||||
|
// {
|
||||||
|
// Message = $"保存异常{ex.ToString}",
|
||||||
|
// Type = MsgType.ERROR
|
||||||
|
// };
|
||||||
|
// _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
|
||||||
|
// _portUtil.FridgeOperate = false;
|
||||||
|
// }
|
||||||
|
//}
|
||||||
public FridgeWindowViewModel()
|
public FridgeWindowViewModel()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
|
@ -214,8 +214,12 @@ namespace DM_Weight.ViewModels
|
||||||
logger.Info($"用户【{Operator?.Nickname}】退出登录");
|
logger.Info($"用户【{Operator?.Nickname}】退出登录");
|
||||||
Operator = null;
|
Operator = null;
|
||||||
Reviewer = null;
|
Reviewer = null;
|
||||||
|
System.Windows.Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() =>
|
||||||
|
{
|
||||||
_regionManager.RequestNavigate("MainRegion", "LoginWindow");
|
_regionManager.RequestNavigate("MainRegion", "LoginWindow");
|
||||||
_regionManager.RequestNavigate("MainRegion", "BeforeLogin");
|
}));
|
||||||
|
//_regionManager.RequestNavigate("MainRegion", "BeforeLogin");
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -338,16 +342,16 @@ namespace DM_Weight.ViewModels
|
||||||
public bool Is16Drawer { get => _is16Drawer; set => SetProperty(ref _is16Drawer, value); }
|
public bool Is16Drawer { get => _is16Drawer; set => SetProperty(ref _is16Drawer, value); }
|
||||||
public bool KeepAlive => false;
|
public bool KeepAlive => false;
|
||||||
private PortUtil _portUtil;
|
private PortUtil _portUtil;
|
||||||
private CHKFunction _chkFunction;
|
//private CHKFunction _chkFunction;
|
||||||
IEventAggregator _eventAggregator;
|
IEventAggregator _eventAggregator;
|
||||||
public HomeWindowViewModel(IRegionManager iRegionManager, PortUtil portUtil, IDialogService dialogService, IUnityContainer container, IEventAggregator eventAggregator, CHKFunction cHKFunction)
|
public HomeWindowViewModel(IRegionManager iRegionManager, PortUtil portUtil, IDialogService dialogService, IUnityContainer container, IEventAggregator eventAggregator)
|
||||||
{
|
{
|
||||||
_portUtil = portUtil;
|
_portUtil = portUtil;
|
||||||
_regionManager = iRegionManager;
|
_regionManager = iRegionManager;
|
||||||
_dialogService = dialogService;
|
_dialogService = dialogService;
|
||||||
_container = container;
|
_container = container;
|
||||||
this._eventAggregator = eventAggregator;
|
this._eventAggregator = eventAggregator;
|
||||||
_chkFunction = cHKFunction;
|
//_chkFunction = cHKFunction;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DelegateCommand<string> OpenFingerDialog
|
public DelegateCommand<string> OpenFingerDialog
|
||||||
|
@ -417,35 +421,35 @@ namespace DM_Weight.ViewModels
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取温度信息
|
/// 获取温度信息
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private async void GetWD(object sender, ElapsedEventArgs e)
|
//private async void GetWD(object sender, ElapsedEventArgs e)
|
||||||
{
|
//{
|
||||||
if (!_portUtil.FridgeOperate)
|
// if (!_portUtil.FridgeOperate)
|
||||||
{
|
// {
|
||||||
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 - 1.5), 2)}℃";
|
// WD = $"恒温冷藏抽屉当前温度:{Math.Round((retT - 1.5), 2)}℃";
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
||||||
private async void GetWD()
|
//private async void GetWD()
|
||||||
{
|
//{
|
||||||
if (!_portUtil.FridgeOperate)
|
// if (!_portUtil.FridgeOperate)
|
||||||
{
|
// {
|
||||||
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 - 1.5), 2)}℃;";
|
// WD = $"恒温冷藏抽屉当前温度:{Math.Round((retT - 1.5), 2)}℃;";
|
||||||
if (Convert.ToInt32(ConfigurationManager.AppSettings["hasFridge"]) > 1)
|
// if (Convert.ToInt32(ConfigurationManager.AppSettings["hasFridge"]) > 1)
|
||||||
{
|
// {
|
||||||
float retTemp = await _portUtil.GetFridgeTemperature(2);
|
// float retTemp = await _portUtil.GetFridgeTemperature(2);
|
||||||
Thread.Sleep(80);
|
// Thread.Sleep(80);
|
||||||
WD += $"{retTemp}℃";
|
// WD += $"{retTemp}℃";
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 将收到的返回转换成具体温度数值
|
/// 将收到的返回转换成具体温度数值
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -482,11 +486,11 @@ namespace DM_Weight.ViewModels
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 查看冰箱温度
|
/// 查看冰箱温度
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public DelegateCommand CheckWDCommand { get => new DelegateCommand(CheckAction); }
|
//public DelegateCommand CheckWDCommand { get => new DelegateCommand(CheckAction); }
|
||||||
private void CheckAction()
|
//private void CheckAction()
|
||||||
{
|
//{
|
||||||
GetWD();
|
//GetWD();
|
||||||
}
|
//}
|
||||||
|
|
||||||
|
|
||||||
//这个方法用于拦截请求,continuationCallback(true)就是不拦截,continuationCallback(false)拦截本次操作
|
//这个方法用于拦截请求,continuationCallback(true)就是不拦截,continuationCallback(false)拦截本次操作
|
||||||
|
@ -550,7 +554,7 @@ namespace DM_Weight.ViewModels
|
||||||
if ((DateTime.Now - _portUtil.dateTime).TotalSeconds > autoExit && CheckComputerFreeState.GetLastInputTime() > autoExit)
|
if ((DateTime.Now - _portUtil.dateTime).TotalSeconds > autoExit && CheckComputerFreeState.GetLastInputTime() > autoExit)
|
||||||
{
|
{
|
||||||
logger.Info($"设备30秒内无人操作,用户【{Operator?.Nickname}】自动退出登录");
|
logger.Info($"设备30秒内无人操作,用户【{Operator?.Nickname}】自动退出登录");
|
||||||
_chkFunction.HIKStopDVRRecord();
|
//_chkFunction.HIKStopDVRRecord();
|
||||||
Operator = null;
|
Operator = null;
|
||||||
Reviewer = null;
|
Reviewer = null;
|
||||||
Application.Current.Dispatcher.Invoke(() =>
|
Application.Current.Dispatcher.Invoke(() =>
|
||||||
|
@ -577,25 +581,25 @@ namespace DM_Weight.ViewModels
|
||||||
//}
|
//}
|
||||||
//#endregion
|
//#endregion
|
||||||
//GetWD();
|
//GetWD();
|
||||||
if (stopRecord > 0)
|
//if (stopRecord > 0)
|
||||||
{
|
//{
|
||||||
System.Timers.Timer timer = new System.Timers.Timer();
|
// System.Timers.Timer timer = new System.Timers.Timer();
|
||||||
timer.Interval = 1000;
|
// timer.Interval = 1000;
|
||||||
timer.Elapsed += (sender, e) =>
|
// timer.Elapsed += (sender, e) =>
|
||||||
{
|
// {
|
||||||
|
|
||||||
//指定时间内无人操作鼠标键盘则停止录像
|
// //指定时间内无人操作鼠标键盘则停止录像
|
||||||
if (!_portUtil.Operate && CheckComputerFreeState.GetLastInputTime() > stopRecord)
|
// if (!_portUtil.Operate && CheckComputerFreeState.GetLastInputTime() > stopRecord)
|
||||||
{
|
// {
|
||||||
_chkFunction.HIKStopDVRRecord();
|
// _chkFunction.HIKStopDVRRecord();
|
||||||
}
|
// }
|
||||||
};
|
// };
|
||||||
timer.Start();
|
// timer.Start();
|
||||||
}
|
//}
|
||||||
logger.Info($"当前时间:{DateTime.Now}\r\n获取录像机的时间");
|
logger.Info($"当前时间:{DateTime.Now}\r\n获取录像机的时间");
|
||||||
//获取录像机的时间
|
//获取录像机的时间
|
||||||
_chkFunction.HIK_DVR_TIME();
|
//_chkFunction.HIK_DVR_TIME();
|
||||||
_chkFunction.HIKStartDVRRecord();
|
//_chkFunction.HIKStartDVRRecord();
|
||||||
}
|
}
|
||||||
|
|
||||||
//每次导航的时候,该实列用不用重新创建,true是不重新创建,false是重新创建
|
//每次导航的时候,该实列用不用重新创建,true是不重新创建,false是重新创建
|
||||||
|
|
|
@ -65,7 +65,7 @@ namespace DM_Weight.ViewModels
|
||||||
private FingerprintUtil _fingerprintUtil;
|
private FingerprintUtil _fingerprintUtil;
|
||||||
|
|
||||||
private PortUtil _portUtil;
|
private PortUtil _portUtil;
|
||||||
private CHKFunction _chkFunction;
|
//private CHKFunction _chkFunction;
|
||||||
|
|
||||||
public Boolean LoginBtnEnable { get { return _loginBtnEnable; } set { SetProperty(ref _loginBtnEnable, value); } }
|
public Boolean LoginBtnEnable { get { return _loginBtnEnable; } set { SetProperty(ref _loginBtnEnable, value); } }
|
||||||
public string Password { get { return password; } set { SetProperty(ref password, value); } }
|
public string Password { get { return password; } set { SetProperty(ref password, value); } }
|
||||||
|
@ -84,17 +84,17 @@ namespace DM_Weight.ViewModels
|
||||||
get => _portUtil._canBusExsit && !_portUtil.canBusSerial.IsOpen;
|
get => _portUtil._canBusExsit && !_portUtil.canBusSerial.IsOpen;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool _fingerMsg= CHKFunction.HKUserId>=0;
|
private bool _fingerMsg;
|
||||||
|
|
||||||
public bool FingerMsg
|
public bool FingerMsg
|
||||||
{
|
{
|
||||||
get => _fingerMsg;
|
get => _fingerMsg;
|
||||||
set => SetProperty(ref _fingerMsg, value);
|
set => SetProperty(ref _fingerMsg, value);
|
||||||
}
|
}
|
||||||
public bool FridgePortMsg
|
//public bool FridgePortMsg
|
||||||
{
|
//{
|
||||||
get => !_portUtil.fridgeSerial.IsOpen;
|
// get => !_portUtil.fridgeSerial.IsOpen;
|
||||||
}
|
//}
|
||||||
//录像机登录状态
|
//录像机登录状态
|
||||||
private bool _hikMsg;
|
private bool _hikMsg;
|
||||||
public bool HIKMsg
|
public bool HIKMsg
|
||||||
|
@ -110,13 +110,14 @@ namespace DM_Weight.ViewModels
|
||||||
// _regionManager = regionManager;
|
// _regionManager = regionManager;
|
||||||
// _eventAggregator = eventAggregator;
|
// _eventAggregator = eventAggregator;
|
||||||
//}
|
//}
|
||||||
public LoginWindowViewModel(IRegionManager regionManager, IEventAggregator eventAggregator, PortUtil portUtil, CHKFunction chcFunction)
|
public LoginWindowViewModel(IRegionManager regionManager, IEventAggregator eventAggregator, PortUtil portUtil, FingerprintUtil fingerprintUtil)
|
||||||
{
|
{
|
||||||
//_fingerprintUtil = fingerprintUtil;
|
_fingerprintUtil = fingerprintUtil;
|
||||||
_portUtil = portUtil;
|
_portUtil = portUtil;
|
||||||
_chkFunction= chcFunction;
|
//_chkFunction= chcFunction;
|
||||||
_regionManager = regionManager;
|
_regionManager = regionManager;
|
||||||
_eventAggregator = eventAggregator;
|
_eventAggregator = eventAggregator;
|
||||||
|
_eventAggregator.GetEvent<FingerprintEvent>().Subscribe(LoginEvent);
|
||||||
}
|
}
|
||||||
private DelegateCommand? _loginCommand;
|
private DelegateCommand? _loginCommand;
|
||||||
|
|
||||||
|
@ -355,7 +356,7 @@ _exitCommand ??= new DelegateCommand(Exit);
|
||||||
|
|
||||||
void Exit()
|
void Exit()
|
||||||
{
|
{
|
||||||
_chkFunction.HIKLoginOut();
|
//_chkFunction.HIKLoginOut();
|
||||||
Process.GetCurrentProcess().Kill();
|
Process.GetCurrentProcess().Kill();
|
||||||
Environment.Exit(0);
|
Environment.Exit(0);
|
||||||
}
|
}
|
||||||
|
@ -363,18 +364,22 @@ _exitCommand ??= new DelegateCommand(Exit);
|
||||||
void LoginEvent(FingerprintMsg msg)
|
void LoginEvent(FingerprintMsg msg)
|
||||||
{
|
{
|
||||||
logger.Info(msg.ToString());
|
logger.Info(msg.ToString());
|
||||||
if (msg.Message.Equals("CONNECT"))
|
//if (msg.Message.Equals("CONNECT"))
|
||||||
{
|
//{
|
||||||
FingerMsg = !msg.Result;
|
// FingerMsg = !msg.Result;
|
||||||
}
|
//}
|
||||||
if (LoginBtnEnable)
|
if (LoginBtnEnable)
|
||||||
{
|
{
|
||||||
if (msg.Message.Equals("LOGIN"))
|
if (msg.Message.Equals("LOGIN"))
|
||||||
{
|
{
|
||||||
UserList userList = SqlSugarHelper.Db.Queryable<UserList>()
|
UserList userList = new UserList();
|
||||||
|
userList = SqlSugarHelper.Db.Queryable<UserList>()
|
||||||
.Includes<RoleDm>(u => u.Role)
|
.Includes<RoleDm>(u => u.Role)
|
||||||
.First(u => u.Id == msg.Id);
|
.Where(u => u.Id == msg.Id && u.MachineId == ConfigurationManager.AppSettings["machineId"].ToString())
|
||||||
|
.WithCacheIF(false).First();
|
||||||
|
//.First(u => u.Id == msg.Id && u.MachineId == ConfigurationManager.AppSettings["machineId"].ToString());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (userList == null)
|
if (userList == null)
|
||||||
{
|
{
|
||||||
|
@ -441,7 +446,7 @@ _exitCommand ??= new DelegateCommand(Exit);
|
||||||
//接收导航传过来的参数 现在是在此处初始化了表格数据
|
//接收导航传过来的参数 现在是在此处初始化了表格数据
|
||||||
public void OnNavigatedTo(NavigationContext navigationContext)
|
public void OnNavigatedTo(NavigationContext navigationContext)
|
||||||
{
|
{
|
||||||
FingerMsg = false;// !_fingerprintUtil.bIsConnected;
|
FingerMsg = !_fingerprintUtil.bIsConnected;
|
||||||
_eventAggregator.GetEvent<FingerprintEvent>().Subscribe(LoginEvent);
|
_eventAggregator.GetEvent<FingerprintEvent>().Subscribe(LoginEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -60,20 +60,20 @@ namespace DM_Weight.ViewModels
|
||||||
// this.eventAggregator.GetEvent<SnackbarEvent>().Subscribe(doMyPrismEvent2);
|
// this.eventAggregator.GetEvent<SnackbarEvent>().Subscribe(doMyPrismEvent2);
|
||||||
// _screenUtil = screenUtil;
|
// _screenUtil = screenUtil;
|
||||||
//}
|
//}
|
||||||
private FingerprintUtil _fingerprintUtil;
|
//private FingerprintUtil _fingerprintUtil;
|
||||||
IRegionManager _regionManager;
|
IRegionManager _regionManager;
|
||||||
IUnityContainer _container;
|
IUnityContainer _container;
|
||||||
private CHKFunction _cHKFunction;
|
//private CHKFunction _cHKFunction;
|
||||||
public MainWindowViewModel(IRegionManager regionManager, IUnityContainer container, IEventAggregator eventAggregator, FingerprintUtil fingerprintUtil, ScreenUtil screenUtil, CHKFunction cHKFunction)
|
public MainWindowViewModel(IRegionManager regionManager, IUnityContainer container, IEventAggregator eventAggregator, ScreenUtil screenUtil)
|
||||||
{
|
{
|
||||||
//_portUtil = portUtil;
|
//_portUtil = portUtil;
|
||||||
this.eventAggregator = eventAggregator;
|
this.eventAggregator = eventAggregator;
|
||||||
this.eventAggregator.GetEvent<SnackbarEvent>().Subscribe(doMyPrismEvent2);
|
this.eventAggregator.GetEvent<SnackbarEvent>().Subscribe(doMyPrismEvent2);
|
||||||
_screenUtil = screenUtil;
|
_screenUtil = screenUtil;
|
||||||
_fingerprintUtil = fingerprintUtil;
|
//_fingerprintUtil = fingerprintUtil;
|
||||||
_regionManager = regionManager;
|
_regionManager = regionManager;
|
||||||
_container = container;
|
_container = container;
|
||||||
_cHKFunction = cHKFunction;
|
//_cHKFunction = cHKFunction;
|
||||||
System.Windows.Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() =>
|
System.Windows.Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() =>
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
|
@ -123,7 +123,7 @@
|
||||||
<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="White" 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>
|
||||||
|
|
||||||
|
|
|
@ -198,8 +198,8 @@
|
||||||
<TextBlock Visibility="{Binding DrawerPortMsg, Converter={StaticResource BooleanToVisibilityConverter}}" Text="抽屉串口连接失败" />
|
<TextBlock Visibility="{Binding DrawerPortMsg, Converter={StaticResource BooleanToVisibilityConverter}}" Text="抽屉串口连接失败" />
|
||||||
<TextBlock Visibility="{Binding CanBusPortMsg, Converter={StaticResource BooleanToVisibilityConverter}}" Text="can总线串口连接失败" />
|
<TextBlock Visibility="{Binding CanBusPortMsg, Converter={StaticResource BooleanToVisibilityConverter}}" Text="can总线串口连接失败" />
|
||||||
<TextBlock Visibility="{Binding FingerMsg, Converter={StaticResource BooleanToVisibilityConverter}}" Text="指纹机连接失败" />
|
<TextBlock Visibility="{Binding FingerMsg, Converter={StaticResource BooleanToVisibilityConverter}}" Text="指纹机连接失败" />
|
||||||
<TextBlock Visibility="{Binding HIKMsg, Converter={StaticResource BooleanToVisibilityConverter}}" Text="录像机登录失败" />
|
<!--<TextBlock Visibility="{Binding HIKMsg, Converter={StaticResource BooleanToVisibilityConverter}}" Text="录像机登录失败" />-->
|
||||||
<TextBlock Visibility="{Binding FridgePortMsg, Converter={StaticResource BooleanToVisibilityConverter}}" Text="冰箱串口连接失败" />
|
<!--<TextBlock Visibility="{Binding FridgePortMsg, Converter={StaticResource BooleanToVisibilityConverter}}" Text="冰箱串口连接失败" />-->
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Grid>
|
</Grid>
|
||||||
</UserControl>
|
</UserControl>
|
||||||
|
|
|
@ -12,6 +12,7 @@ namespace DM_Weight.util
|
||||||
ConnectionString = ConfigurationManager.ConnectionStrings["database"].ToString(),
|
ConnectionString = ConfigurationManager.ConnectionStrings["database"].ToString(),
|
||||||
DbType = DbType.MySql,
|
DbType = DbType.MySql,
|
||||||
IsAutoCloseConnection = true
|
IsAutoCloseConnection = true
|
||||||
|
|
||||||
},
|
},
|
||||||
db =>
|
db =>
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue