Commit e31bcddb 张东亮

温度后台配置修改

1 个父辈 61eae5e4
...@@ -45,12 +45,12 @@ namespace OnlineStore.DeviceLibrary ...@@ -45,12 +45,12 @@ namespace OnlineStore.DeviceLibrary
{ {
serialBeanMap.Add(port, sb); serialBeanMap.Add(port, sb);
var ht = HumitureController.QueryData(port); var ht = HumitureController.QueryData(port);
LogUtil.info(LogName + "串口" + port + "打开成功!温度:"+ ht.Temperate+",湿度:"+ht.Humidity); LogUtil.info(LogName + "串口" + port + "打开成功!温度:" + ht.Temperate + ",湿度:" + ht.Humidity);
return true; return true;
} }
else else
{ {
LogUtil.error( LogName + "串口" + port + "打开失败!"); LogUtil.error(LogName + "串口" + port + "打开失败!");
return false; return false;
} }
} }
...@@ -101,9 +101,9 @@ namespace OnlineStore.DeviceLibrary ...@@ -101,9 +101,9 @@ namespace OnlineStore.DeviceLibrary
// public static ASTemperateParam LastData = new ASTemperateParam(0, 0); // public static ASTemperateParam LastData = new ASTemperateParam(0, 0);
public static HumitureParam QueryData(string port) public static HumitureParam QueryData(string port)
{ {
HumitureParam param = new HumitureParam(0, 0,100); HumitureParam param = new HumitureParam(0, 0, 100);
param.DeviceAddress = port; param.DeviceAddress = port;
List<double> data = queryData(port ); List<double> data = queryData(port);
if (data.Count.Equals(3)) if (data.Count.Equals(3))
{ {
//double humidityadjust = (double)ConfigAppSettings.GetNumValue(Setting_Init.Device_HumidityAdjust); //double humidityadjust = (double)ConfigAppSettings.GetNumValue(Setting_Init.Device_HumidityAdjust);
...@@ -129,9 +129,12 @@ namespace OnlineStore.DeviceLibrary ...@@ -129,9 +129,12 @@ namespace OnlineStore.DeviceLibrary
// else // else
// data[1] += tempadjust; // data[1] += tempadjust;
//} //}
data[1] = ProcessTemp(data[1]); data[1] = ProcessTemp(port, data[1]);
param = new HumitureParam(data[1], data[0], data[2]); param = new HumitureParam(data[1], data[0], data[2]);
} }
//校准温湿度
return param; return param;
} }
/// <summary> /// <summary>
...@@ -139,7 +142,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -139,7 +142,7 @@ namespace OnlineStore.DeviceLibrary
/// </summary> /// </summary>
/// <param name="nowTemp"></param> /// <param name="nowTemp"></param>
/// <returns></returns> /// <returns></returns>
private static double ProcessTemp(double nowTemp) private static double ProcessTemp(string port, double nowTemp)
{ {
double temp = nowTemp; double temp = nowTemp;
double minVal = 5;//ConfigHelper.Config.Get("TempThreshold_Min", 5); double minVal = 5;//ConfigHelper.Config.Get("TempThreshold_Min", 5);
...@@ -158,7 +161,12 @@ namespace OnlineStore.DeviceLibrary ...@@ -158,7 +161,12 @@ namespace OnlineStore.DeviceLibrary
{ {
temp = (nowTemp - 11) * (nowTemp - 10) / 10 + 11; temp = (nowTemp - 11) * (nowTemp - 10) / 10 + 11;
} }
else
{
var calib = ConfigHelper.Config.Get($"TemptureCalib_{port}", 0);
nowTemp += calib;
return nowTemp;
}
return Math.Round(temp, 1); return Math.Round(temp, 1);
} }
/// <summary> /// <summary>
...@@ -229,7 +237,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -229,7 +237,7 @@ namespace OnlineStore.DeviceLibrary
public static int QueryHistoryCount(string port) public static int QueryHistoryCount(string port)
{ {
AcSerialBean sb = GetSerialBean(port); AcSerialBean sb = GetSerialBean(port);
if (sb == null|| HumitureControllerType.Equals(2).Equals(false)) if (sb == null || HumitureControllerType.Equals(2).Equals(false))
{ {
return -1; return -1;
} }
...@@ -371,7 +379,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -371,7 +379,7 @@ namespace OnlineStore.DeviceLibrary
} }
if (dataArray.Length >= 9) if (dataArray.Length >= 9)
{ {
string data = String.Format("{0:X2}", dataArray[5]) + String.Format("{0:X2}", dataArray[6]+String.Format("{0:X2}", dataArray[3]) + String.Format("{0:X2}", dataArray[4]) ); string data = String.Format("{0:X2}", dataArray[5]) + String.Format("{0:X2}", dataArray[6] + String.Format("{0:X2}", dataArray[3]) + String.Format("{0:X2}", dataArray[4]));
int tempV = Convert.ToInt32(data, 16); int tempV = Convert.ToInt32(data, 16);
return tempV; return tempV;
} }
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!