Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
张东亮
/
SO1057-XLRStore
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit 42bd8880
由
张东亮
编写于
2023-02-24 15:49:00 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
温湿度处理逻辑和入库验证
1 个父辈
ea96d462
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
53 行增加
和
43 行删除
source/DeviceLibrary/storeBean/boxBean/BoxEquip_ConnectServerTimer.cs
source/DeviceLibrary/storeBean/boxBean/Humiture/HumitureBean.cs
source/DeviceLibrary/storeBean/boxBean/Humiture/HumitureController.cs
source/DeviceLibrary/storeBean/boxBean/BoxEquip_ConnectServerTimer.cs
查看文件 @
42bd888
...
...
@@ -280,7 +280,7 @@ namespace OnlineStore.DeviceLibrary
LogUtil
.
info
(
logName
+
"服务器反馈 :"
+
resultOperation
.
msg
);
continue
;
}
else
if
(
resultOperation
.
op
.
Equals
(
1
))
else
if
(
resultOperation
.
op
.
Equals
(
1
)
&&
operation
.
seq
.
Equals
(
resultOperation
.
seq
)
)
{
LogUtil
.
info
(
logName
+
" 成功"
+
$
"【{JsonHelper.SerializeObject(resultOperation)}】"
);
return
true
;
...
...
source/DeviceLibrary/storeBean/boxBean/Humiture/HumitureBean.cs
查看文件 @
42bd888
...
...
@@ -13,7 +13,7 @@ namespace OnlineStore.DeviceLibrary
{
private
string
PortName
=
""
;
private
string
Name
=
""
;
public
HumitureParam
LastData
=
new
HumitureParam
(
0
,
0
,
0
);
public
static
List
<
HumitureParam
>
LastData
=
new
List
<
HumitureParam
>(
);
static
List
<
HumitureBean
>
humitureBeans
=
new
List
<
HumitureBean
>();
internal
HumitureBean
(
string
port
,
string
deviceName
)
{
...
...
@@ -26,15 +26,29 @@ namespace OnlineStore.DeviceLibrary
for
(
int
i
=
0
;
i
<
ports
.
Length
;
i
++)
{
humitureBeans
.
Add
(
new
HumitureBean
(
ports
[
i
],
deviceName
+
(
i
+
1
)));
HumitureParam
param
=
new
HumitureParam
(
0
,
0
,
100
);
param
.
DeviceAddress
=
ports
[
i
];
LastData
.
Add
(
param
);
}
}
public
HumitureParam
QueryData
()
{
HumitureParam
param
=
HumitureController
.
QueryData
(
PortName
);
LastData
=
param
;
return
LastData
;
updateData
(
PortName
,
param
)
;
return
param
;
}
static
void
updateData
(
string
port
,
HumitureParam
param
)
{
var
find
=
LastData
.
Find
(
s
=>
port
.
Equals
(
s
.
DeviceAddress
));
if
(
find
!=
null
)
{
find
.
Temperate
=
param
.
Temperate
;
find
.
UpdateTime
=
param
.
UpdateTime
;
find
.
Humidity
=
param
.
Humidity
;
find
.
OxygenV
=
param
.
OxygenV
;
}
}
public
static
double
GetMinOxygenV
()
{
double
maxV
=
0.0
;
...
...
@@ -79,34 +93,40 @@ namespace OnlineStore.DeviceLibrary
/// 温度标准,超过后需要报警
/// </summary>
static
float
Max_Temperature
=
0
;
private
bool
IsInBlowing
=
false
;
private
DateTime
LastBeginBlowTime
=
DateTime
.
Now
;
private
DateTime
LastEndBlowTime
=
new
DateTime
(
1997
,
1
,
1
);
private
DateTime
preLogTime
=
DateTime
.
Now
;
private
static
bool
IsInBlowing
=
false
;
private
static
DateTime
LastBeginBlowTime
=
DateTime
.
Now
;
private
static
DateTime
LastEndBlowTime
=
new
DateTime
(
1997
,
1
,
1
);
static
DateTime
preLogTime
=
DateTime
.
Now
;
public
bool
TempOrHumidityIsAlarm
=
false
;
public
DateTime
TempAlarmTime
=
DateTime
.
Now
;
public
static
bool
TempOrHumidityIsAlarm
=
false
;
public
static
DateTime
TempAlarmTime
=
DateTime
.
Now
;
private
float
StartBlowValue
=
(
float
)
ConfigAppSettings
.
GetNumValue
(
Setting_Init
.
StartBlowValue
);
private
float
StopBlowValue
=
(
float
)
ConfigAppSettings
.
GetNumValue
(
Setting_Init
.
StopBlowValue
);
public
string
currTempStr
=
""
;
private
static
float
StartBlowValue
=
(
float
)
ConfigAppSettings
.
GetNumValue
(
Setting_Init
.
StartBlowValue
);
private
static
float
StopBlowValue
=
(
float
)
ConfigAppSettings
.
GetNumValue
(
Setting_Init
.
StopBlowValue
);
public
st
atic
st
ring
currTempStr
=
""
;
public
static
void
ProcessAllHumidity
(
BoxEquip
box
)
{
double
curMaxHumidity
=
double
.
MinValue
;
double
curMinTemp
=
double
.
MaxValue
;
foreach
(
var
item
in
humitureBeans
)
{
item
.
HumidityProcess
(
box
);
HumitureParam
param
=
item
.
QueryData
();
if
(
param
.
Humidity
>
curMaxHumidity
)
{
curMaxHumidity
=
param
.
Humidity
;
}
if
(
param
.
Temperate
<
curMinTemp
)
{
curMinTemp
=
param
.
Temperate
;
}
}
HumidityProcess
(
box
,
curMaxHumidity
,
curMinTemp
);
}
public
static
List
<
HumitureParam
>
GetHumitureParams
()
{
List
<
HumitureParam
>
humitureParams
=
new
List
<
HumitureParam
>();
foreach
(
var
item
in
humitureBeans
)
{
humitureParams
.
Add
(
item
.
LastData
);
}
return
humitureParams
;
return
LastData
;
}
internal
void
HumidityProcess
(
BoxEquip
box
)
internal
static
void
HumidityProcess
(
BoxEquip
box
,
double
currMaxHumidity
,
double
curMinTemp
)
{
if
(
IOManager
.
IOValue
(
IO_Type
.
Air_OpenValve
,
1
).
Equals
(
IO_VALUE
.
HIGH
)
||
IOManager
.
IOValue
(
IO_Type
.
LeftDoor_Limit
,
2
).
Equals
(
IO_VALUE
.
LOW
)
||
IOManager
.
IOValue
(
IO_Type
.
RightDoor_Limit
,
2
).
Equals
(
IO_VALUE
.
LOW
)
||
IOManager
.
IOValue
(
IO_Type
.
BackDoor_Limit
,
2
).
Equals
(
IO_VALUE
.
LOW
))
{
...
...
@@ -121,17 +141,7 @@ namespace OnlineStore.DeviceLibrary
//用最大的湿度判断是否需要吹气,开始吹气的值=发过来的值-4
//温湿度
//ASTemperateParam param = HumitureServer.GetTemperateParam(Config.GetTempAddrList());
HumitureParam
param
=
QueryData
();
double
humidity
=
0
;
double
temp
=
0
;
if
(
param
!=
null
)
{
humidity
=
param
.
Humidity
;
temp
=
param
.
Temperate
;
currTempStr
=
Name
+
(
"湿度:"
+
humidity
.
ToString
()
+
",温度:"
+
temp
);
}
//double currMaxHumidity = HumitureServer.GetMaxHumidity(Config.GetTempAddrList());
double
currMaxHumidity
=
param
.
Humidity
;
//HumitureParam param = QueryData();
float
startBlowHumidity
=
Max_Humidity
-
StartBlowValue
;
float
stopBlowHumidity
=
Max_Humidity
-
StopBlowValue
;
...
...
@@ -143,7 +153,7 @@ namespace OnlineStore.DeviceLibrary
TimeSpan
span
=
DateTime
.
Now
-
LastEndBlowTime
;
if
(
span
.
TotalMinutes
>
box
.
Config
.
BlowAir_Interval
)
{
LogUtil
.
info
(
Name
+
"当前最大湿度:"
+
currMaxHumidity
.
ToString
()
+
",开始吹气湿度:"
+
startBlowHumidity
+
",当前不在吹气中,且间隔超过"
+
box
.
Config
.
BlowAir_Interval
+
"分钟,开始吹气!"
);
LogUtil
.
info
(
"当前最大湿度:"
+
currMaxHumidity
.
ToString
()
+
",开始吹气湿度:"
+
startBlowHumidity
+
",当前不在吹气中,且间隔超过"
+
box
.
Config
.
BlowAir_Interval
+
"分钟,开始吹气!"
);
IsInBlowing
=
true
;
//Thread.Sleep(100);
StoreManager
.
XLRStore
.
IOMove
(
IO_Type
.
Nitrogen_OpenValve
,
IO_VALUE
.
HIGH
);
...
...
@@ -154,7 +164,7 @@ namespace OnlineStore.DeviceLibrary
if
(
IsInBlowing
&&
stopBlowHumidity
>
currMaxHumidity
)
{
LogUtil
.
info
(
Name
+
"当前最大湿度:"
+
currMaxHumidity
.
ToString
()
+
",停止吹气湿度:"
+
stopBlowHumidity
+
",停止吹气!"
);
LogUtil
.
info
(
"当前最大湿度:"
+
currMaxHumidity
.
ToString
()
+
",停止吹气湿度:"
+
stopBlowHumidity
+
",停止吹气!"
);
IsInBlowing
=
false
;
StoreManager
.
XLRStore
.
IOMove
(
IO_Type
.
Nitrogen_OpenValve
,
IO_VALUE
.
LOW
);
LastEndBlowTime
=
DateTime
.
Now
;
...
...
@@ -165,7 +175,7 @@ namespace OnlineStore.DeviceLibrary
TimeSpan
span
=
DateTime
.
Now
-
LastBeginBlowTime
;
if
(
span
.
TotalMinutes
>
box
.
Config
.
BlowAir_Time
)
{
LogUtil
.
info
(
Name
+
"已经吹气"
+
span
.
TotalMinutes
+
"分钟,超过配置的吹气时间"
+
box
.
Config
.
BlowAir_Time
+
"分钟,停止吹气!"
);
LogUtil
.
info
(
"已经吹气"
+
span
.
TotalMinutes
+
"分钟,超过配置的吹气时间"
+
box
.
Config
.
BlowAir_Time
+
"分钟,停止吹气!"
);
IsInBlowing
=
false
;
//Thread.Sleep(100);
StoreManager
.
XLRStore
.
IOMove
(
IO_Type
.
Nitrogen_OpenValve
,
IO_VALUE
.
LOW
);
...
...
@@ -174,23 +184,23 @@ namespace OnlineStore.DeviceLibrary
}
bool
needAlarm
=
false
;
//如果开始吹气并且当前达到报警值
if
(
IsInBlowing
&&
h
umidity
>
Max_Humidity
)
if
(
IsInBlowing
&&
currMaxH
umidity
>
Max_Humidity
)
{
needAlarm
=
true
;
}
else
if
(
t
emp
>
Max_Temperature
&&
Max_Temperature
>
0
)
else
if
(
curMinT
emp
>
Max_Temperature
&&
Max_Temperature
>
0
)
{
LogUtil
.
info
(
Name
+
"当前温度【"
+
param
.
Temperate
+
"】超过最高温度【"
+
Max_Temperature
+
"】,开始报警!"
);
LogUtil
.
info
(
"当前温度【"
+
curMinTemp
+
"】超过最高温度【"
+
Max_Temperature
+
"】,开始报警!"
);
needAlarm
=
true
;
//Thread.Sleep(100);
StoreManager
.
XLRStore
.
IOMove
(
IO_Type
.
Nitrogen_OpenValve
,
IO_VALUE
.
LOW
);
}
else
if
(
t
emp
<
Max_Temperature
)
else
if
(
curMinT
emp
<
Max_Temperature
)
{
if
(
IsInBlowing
.
Equals
(
false
)
&&
TempOrHumidityIsAlarm
)
{
LogUtil
.
info
(
Name
+
"不在吹气中,且当前温度【"
+
param
.
Temperate
+
"】低于【"
+
Max_Temperature
+
"】,关闭报警!"
);
LogUtil
.
info
(
"不在吹气中,且当前温度【"
+
curMinTemp
+
"】低于【"
+
Max_Temperature
+
"】,关闭报警!"
);
TempOrHumidityIsAlarm
=
false
;
//Thread.Sleep(100);
StoreManager
.
XLRStore
.
IOMove
(
IO_Type
.
Nitrogen_OpenValve
,
IO_VALUE
.
LOW
);
...
...
@@ -208,10 +218,10 @@ namespace OnlineStore.DeviceLibrary
}
catch
(
Exception
ex
)
{
LogUtil
.
error
(
Name
+
"HumidityProcess出错:"
+
ex
.
ToString
());
LogUtil
.
error
(
"HumidityProcess出错:"
+
ex
.
ToString
());
}
}
private
void
HTAlarm
()
static
void
HTAlarm
()
{
if
(
TempOrHumidityIsAlarm
)
{
...
...
source/DeviceLibrary/storeBean/boxBean/Humiture/HumitureController.cs
查看文件 @
42bd888
...
...
@@ -101,7 +101,7 @@ namespace OnlineStore.DeviceLibrary
// public static ASTemperateParam LastData = new ASTemperateParam(0, 0);
public
static
HumitureParam
QueryData
(
string
port
)
{
HumitureParam
param
=
new
HumitureParam
(
0
,
0
,
0
);
HumitureParam
param
=
new
HumitureParam
(
0
,
0
,
10
0
);
param
.
DeviceAddress
=
port
;
List
<
double
>
data
=
queryData
(
port
);
if
(
data
.
Count
.
Equals
(
3
))
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论