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