Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
李娜
/
SO664-HCSingleStore
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit 05711223
由
LN
编写于
2021-03-05 14:06:11 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
温湿度bug修改
1 个父辈
09172170
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
25 行增加
和
44 行删除
source/Common/util/HumitureController.cs
source/DeviceLibrary/acSingleStore/BoxBean.cs
source/DeviceLibrary/acSingleStore/HumitureBean.cs
source/Common/util/HumitureController.cs
查看文件 @
0571122
using
log4net
;
using
log4net
;
using
System
;
using
System
;
using
System.Collections.Concurrent
;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
System.IO.Ports
;
using
System.IO.Ports
;
using
System.Linq
;
using
System.Linq
;
...
@@ -21,6 +22,8 @@ namespace OnlineStore.Common
...
@@ -21,6 +22,8 @@ namespace OnlineStore.Common
private
static
string
LogName
=
""
;
private
static
string
LogName
=
""
;
private
static
Dictionary
<
string
,
AcSerialBean
>
serialBeanMap
=
new
Dictionary
<
string
,
AcSerialBean
>();
private
static
Dictionary
<
string
,
AcSerialBean
>
serialBeanMap
=
new
Dictionary
<
string
,
AcSerialBean
>();
private
static
ConcurrentDictionary
<
string
,
HumitureParam
>
lastDataMap
=
new
ConcurrentDictionary
<
string
,
HumitureParam
>();
public
static
int
HumitureControllerType
=
ConfigAppSettings
.
GetIntValue
(
Setting_Init
.
HumitureControllerType
);
public
static
int
HumitureControllerType
=
ConfigAppSettings
.
GetIntValue
(
Setting_Init
.
HumitureControllerType
);
public
static
bool
Init
(
string
port
)
public
static
bool
Init
(
string
port
)
{
{
...
@@ -93,15 +96,29 @@ namespace OnlineStore.Common
...
@@ -93,15 +96,29 @@ namespace OnlineStore.Common
}
}
return
null
;
return
null
;
}
}
// public static ASTemperateParam LastData = new ASTemperateParam(0, 0);
public
static
HumitureParam
QueryData
(
string
port
)
public
static
HumitureParam
QueryData
(
string
port
)
{
{
if
(
lastDataMap
.
TryGetValue
(
port
,
out
HumitureParam
lastparam
))
{
//1秒以内不需要重新查询
TimeSpan
span
=
DateTime
.
Now
-
lastparam
.
UpdateTime
;
if
(
span
.
TotalSeconds
<=
5
)
{
return
lastparam
;
}
else
{
lastDataMap
.
TryRemove
(
port
,
out
lastparam
);
}
}
HumitureParam
param
=
new
HumitureParam
(
0
,
0
);
HumitureParam
param
=
new
HumitureParam
(
0
,
0
);
List
<
double
>
data
=
queryData
(
port
);
List
<
double
>
data
=
queryData
(
port
);
if
(
data
.
Count
.
Equals
(
2
))
if
(
data
.
Count
.
Equals
(
2
))
{
{
param
=
new
HumitureParam
(
data
[
1
],
data
[
0
]);
param
=
new
HumitureParam
(
data
[
1
],
data
[
0
]);
}
}
lastDataMap
.
TryAdd
(
port
,
param
);
return
param
;
return
param
;
}
}
/// <summary>
/// <summary>
...
...
source/DeviceLibrary/acSingleStore/BoxBean.cs
查看文件 @
0571122
...
@@ -1048,10 +1048,14 @@ namespace OnlineStore.DeviceLibrary
...
@@ -1048,10 +1048,14 @@ namespace OnlineStore.DeviceLibrary
if
(
isInProcess
)
if
(
isInProcess
)
{
{
TimeSpan
span
=
DateTime
.
Now
-
lastConTime
;
TimeSpan
span
=
DateTime
.
Now
-
lastConTime
;
if
(
span
.
TotalSeconds
<
60
)
if
(
span
.
TotalSeconds
<
3
)
{
{
return
;
return
;
}
}
else
{
LogUtil
.
error
(
$
"{Name}server_connect_timer_Tick 已耗时{span.TotalSeconds}秒,重新处理"
);
}
}
}
isInProcess
=
true
;
isInProcess
=
true
;
lastConTime
=
DateTime
.
Now
;
lastConTime
=
DateTime
.
Now
;
...
...
source/DeviceLibrary/acSingleStore/HumitureBean.cs
查看文件 @
0571122
...
@@ -72,12 +72,10 @@ namespace OnlineStore.DeviceLibrary
...
@@ -72,12 +72,10 @@ namespace OnlineStore.DeviceLibrary
{
{
try
try
{
{
if
((
DateTime
.
Now
-
preLogTime
).
TotalSeconds
>
(
8
+
box
.
DeviceID
))
if
((
DateTime
.
Now
-
preLogTime
).
TotalSeconds
>
(
5
+
box
.
DeviceID
))
{
{
preLogTime
=
DateTime
.
Now
;
preLogTime
=
DateTime
.
Now
;
//用最大的湿度判断是否需要吹气,开始吹气的值=发过来的值-4
//温湿度
//ASTemperateParam param = HumitureServer.GetTemperateParam(Config.GetTempAddrList());
HumitureParam
param
=
QueryData
();
HumitureParam
param
=
QueryData
();
double
humidity
=
0
;
double
humidity
=
0
;
double
temp
=
0
;
double
temp
=
0
;
...
@@ -87,48 +85,10 @@ namespace OnlineStore.DeviceLibrary
...
@@ -87,48 +85,10 @@ namespace OnlineStore.DeviceLibrary
temp
=
param
.
Temperate
;
temp
=
param
.
Temperate
;
currTempStr
=
Name
+
(
"湿度:"
+
humidity
.
ToString
()
+
",温度:"
+
temp
);
currTempStr
=
Name
+
(
"湿度:"
+
humidity
.
ToString
()
+
",温度:"
+
temp
);
}
}
//double currMaxHumidity = HumitureServer.GetMaxHumidity(Config.GetTempAddrList());
double
currMaxHumidity
=
param
.
Humidity
;
double
currMaxHumidity
=
param
.
Humidity
;
float
startBlowHumidity
=
Max_Humidity
-
StartBlowValue
;
float
startBlowHumidity
=
Max_Humidity
-
StartBlowValue
;
float
stopBlowHumidity
=
Max_Humidity
-
StopBlowValue
;
float
stopBlowHumidity
=
Max_Humidity
-
StopBlowValue
;
////判断是否需要吹气
//if (startBlowHumidity > 0 && startBlowHumidity < currMaxHumidity && IsInBlowing.Equals(false))
//{
// //判断是否距离上次结束指定的时间
// TimeSpan span = DateTime.Now - LastEndBlowTime;
// if (span.TotalMinutes > box.Config.BlowAir_Interval)
// {
// LogUtil.info(Name + "当前最大湿度:" + currMaxHumidity.ToString() + ",开始吹气湿度:" + startBlowHumidity + ",当前不在吹气中,且间隔超过" + box.Config.BlowAir_Interval + "分钟,开始吹气!");
// IsInBlowing = true;
// //Thread.Sleep(100);
// box.IOMove(IO_Type.StartOrStopBlow, IO_VALUE.HIGH);
// LastBeginBlowTime = DateTime.Now;
// LastEndBlowTime = DateTime.Now;
// }
//}
//if (IsInBlowing && stopBlowHumidity > currMaxHumidity)
//{
// LogUtil.info(Name + "当前最大湿度:" + currMaxHumidity.ToString() + ",停止吹气湿度:" + stopBlowHumidity + ",停止吹气!");
// IsInBlowing = false;
// box.IOMove(IO_Type.StartOrStopBlow, IO_VALUE.LOW);
// LastEndBlowTime = DateTime.Now;
//}
//if (IsInBlowing)
//{
// //判断是否需要结束吹气
// TimeSpan span = DateTime.Now - LastBeginBlowTime;
// if (span.TotalMinutes > box.Config.BlowAir_Time)
// {
// LogUtil.info(Name + "已经吹气" + span.TotalMinutes + "分钟,超过配置的吹气时间" + box.Config.BlowAir_Time + "分钟,停止吹气!");
// IsInBlowing = false;
// //Thread.Sleep(100);
// box.IOMove(IO_Type.StartOrStopBlow, IO_VALUE.LOW);
// LastEndBlowTime = DateTime.Now;
// }
//}
bool
needAlarm
=
false
;
bool
needAlarm
=
false
;
//如果开始吹气并且当前达到报警值
//如果开始吹气并且当前达到报警值
if
(
IsInBlowing
&&
humidity
>
Max_Humidity
)
if
(
IsInBlowing
&&
humidity
>
Max_Humidity
)
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论