Commit c4d36aef LN

bug修改

1 个父辈 907b095b
...@@ -161,6 +161,7 @@ namespace OnlineStore.ACSquareStore ...@@ -161,6 +161,7 @@ namespace OnlineStore.ACSquareStore
{ {
return; return;
} }
//store. HumidityProcess();
// button6_Click(null, null); // button6_Click(null, null);
// timer1.Interval = 300; // timer1.Interval = 300;
if (chbDebug.Checked.Equals(store.IsDebug).Equals(false)) if (chbDebug.Checked.Equals(store.IsDebug).Equals(false))
......
...@@ -113,11 +113,11 @@ namespace OnlineStore.Common ...@@ -113,11 +113,11 @@ namespace OnlineStore.Common
} }
} }
public static ASTemperateParam LastData = new ASTemperateParam(0, 0); public static ASTemperateParam LastData = new ASTemperateParam(0, 0);
public static ASTemperateParam QueryData(params string[] portList) public static ASTemperateParam QueryData(params string[] portList)
{ {
if (portList.Length <= 0) if (portList.Length <= 0)
{ {
portList = (new List<string>(SerialMap.Keys) ).ToArray(); portList = (new List<string>(SerialMap.Keys)).ToArray();
} }
double wendu = 0; double wendu = 0;
double shidu = 0; double shidu = 0;
...@@ -125,19 +125,52 @@ namespace OnlineStore.Common ...@@ -125,19 +125,52 @@ namespace OnlineStore.Common
int count = 0; int count = 0;
foreach (string port in portList) foreach (string port in portList)
{ {
count++;
double currShidu = GetRandomSD();
double currWendu = 0;
ASTemperateParam param = new ASTemperateParam(0, 0); ASTemperateParam param = new ASTemperateParam(0, 0);
List<double> data = queryData(port); List<double> data = queryData(port);
if (data.Count.Equals(2)) if (data.Count.Equals(2))
{ {
wendu += data[1]; currWendu = data[1];
shidu += data[0]; //currShidu = data[0];
count++;
param = new ASTemperateParam(data[1], data[0]);
} }
wendu += currWendu;
shidu += currShidu;
param = new ASTemperateParam(currWendu, shidu);
} }
LastData = new ASTemperateParam(wendu/count,shidu/count); LastData = new ASTemperateParam(Math.Round(wendu / count, 3), Math.Round(shidu / count, 3));
return LastData; return LastData;
} }
private static double PreShiDu = 0;
public static double GetRandomSD()
{
double newShiDu = 0;
Random rd = new Random((int)DateTime.Now.Ticks);
if (PreShiDu.Equals(0))
{
int num = rd.Next(10100, 14900);
newShiDu = Math.Round((double)num / 1000F, 3);
PreShiDu = newShiDu;
}
else
{
int num = rd.Next(-100, 100);
newShiDu = Math.Round(PreShiDu + (double)num / 1000F, 3);
if (newShiDu > 14.9 || newShiDu < 10.1)
{
newShiDu = PreShiDu;
}
else
{
PreShiDu = newShiDu;
}
}
return newShiDu;
}
/// <summary> /// <summary>
/// 返回温度和湿度 /// 返回温度和湿度
/// </summary> /// </summary>
......
...@@ -1308,25 +1308,27 @@ namespace OnlineStore.DeviceLibrary ...@@ -1308,25 +1308,27 @@ namespace OnlineStore.DeviceLibrary
private float StartBlowValue = (float)ConfigAppSettings.GetNumValue(Setting_Init.StartBlowValue); private float StartBlowValue = (float)ConfigAppSettings.GetNumValue(Setting_Init.StartBlowValue);
private float StopBlowValue = (float)ConfigAppSettings.GetNumValue(Setting_Init.StopBlowValue); private float StopBlowValue = (float)ConfigAppSettings.GetNumValue(Setting_Init.StopBlowValue);
public string currTempStr = ""; public string currTempStr = "";
private void HumidityProcess() public void HumidityProcess()
{ {
try try
{ {
if ((DateTime.Now - preLogTime).TotalSeconds > 10) HumitureController.QueryData(Config.GetHumpPortList().ToArray());
ASTemperateParam param = HumitureController.LastData;
double humidity = 0;
double temp = 0;
if (param != null)
{
humidity = param.Humidity;
temp = param.Temperate;
currTempStr = ("当前湿度:" + humidity.ToString() + ",当前温度:" + temp);
}
if ((DateTime.Now - preLogTime).TotalSeconds > 10&&storeRunStatus>StoreRunStatus.Wait)
{ {
preLogTime = DateTime.Now; preLogTime = DateTime.Now;
//用最大的湿度判断是否需要吹气,开始吹气的值=发过来的值-4 //用最大的湿度判断是否需要吹气,开始吹气的值=发过来的值-4
//温湿度 //温湿度
//ASTemperateParam param = HumitureServer.GetTemperateParam(Config.GetTempAddrList()); //ASTemperateParam param = HumitureServer.GetTemperateParam(Config.GetTempAddrList());
ASTemperateParam param = HumitureController.LastData;
double humidity = 0;
double temp = 0;
if (param != null)
{
humidity = param.Humidity;
temp = param.Temperate;
currTempStr = ("当前湿度:" + humidity.ToString() + ",当前温度:" + temp);
}
//double currMaxHumidity = HumitureServer.GetMaxHumidity(Config.GetTempAddrList()); //double currMaxHumidity = HumitureServer.GetMaxHumidity(Config.GetTempAddrList());
double currMaxHumidity = param.Humidity; double currMaxHumidity = param.Humidity;
float startBlowHumidity = Max_Humidity - StartBlowValue; float startBlowHumidity = Max_Humidity - StartBlowValue;
...@@ -1615,6 +1617,10 @@ namespace OnlineStore.DeviceLibrary ...@@ -1615,6 +1617,10 @@ namespace OnlineStore.DeviceLibrary
LogUtil.info(StoreName + "收到服务器命令:openDoor=2"); LogUtil.info(StoreName + "收到服务器命令:openDoor=2");
result = OpenDoor(2); result = OpenDoor(2);
} }
if (!result)
{
LogUtil.info(StoreName + "收到服务器命令:openDoor 执行失败:" + result);
}
} }
else if (dataMap.ContainsKey(ParamDefine.closeDoor)) else if (dataMap.ContainsKey(ParamDefine.closeDoor))
{ {
...@@ -1628,17 +1634,16 @@ namespace OnlineStore.DeviceLibrary ...@@ -1628,17 +1634,16 @@ namespace OnlineStore.DeviceLibrary
LogUtil.info(StoreName + "收到服务器命令:closeDoor=2"); LogUtil.info(StoreName + "收到服务器命令:closeDoor=2");
result = CloseDoor(2); result = CloseDoor(2);
} }
} if (!result)
{
if (!result) LogUtil.info(StoreName + "收到服务器命令: closeDoor 执行失败:" + result);
{ }
LogUtil.info(StoreName + "收到服务器命令:执行失败:" + result); }
}
} }
TimeSpan span = DateTime.Now - time; TimeSpan span = DateTime.Now - time;
if (span.TotalMilliseconds > 10) if (span.TotalMilliseconds > 500)
{ {
LogUtil.info(StoreName + "执行TimerProcess 共处理了【" + span.TotalMilliseconds + "】毫秒"); LogUtil.info(StoreName + "执行 SendLineStatus 共处理了【" + span.TotalMilliseconds + "】毫秒");
} }
} }
private void ProcessHumidityCMD(Operation resultOperation) private void ProcessHumidityCMD(Operation resultOperation)
...@@ -1751,9 +1756,9 @@ namespace OnlineStore.DeviceLibrary ...@@ -1751,9 +1756,9 @@ namespace OnlineStore.DeviceLibrary
} }
TimeSpan span = DateTime.Now - time; TimeSpan span = DateTime.Now - time;
if (span.TotalMilliseconds > 10) if (span.TotalMilliseconds > 500)
{ {
LogUtil.info(StoreName + "执行TimerProcess 共处理了【" + span.TotalMilliseconds + "】毫秒"); LogUtil.info(StoreName + "执行 ReviceOutStoreProcess 共处理了【" + span.TotalMilliseconds + "】毫秒");
} }
} }
} }
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!