Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
李娜
/
SO664-HCSingleStore
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit 40e0cf04
由
LN
编写于
2021-09-29 14:15:55 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
修改服务器通信代码
1 个父辈
cc75828e
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
129 行增加
和
54 行删除
source/Common/util/HttpHelper.cs
source/DeviceLibrary/StoreConfig/BoxConfig_2.csv
source/DeviceLibrary/acSingleStore/BoxBean.cs
source/DeviceLibrary/acSingleStore/StoreBean.cs
source/Common/util/HttpHelper.cs
查看文件 @
40e0cf0
...
...
@@ -19,6 +19,17 @@ namespace OnlineStore.Common
{
public
class
HttpHelper
{
private
static
int
seq
=
1
;
public
static
int
nextSeq
()
{
if
(
seq
.
Equals
(
Int32
.
MaxValue
))
{
LogUtil
.
info
(
"seq当前值:"
+
seq
+
",重置seq=0"
);
seq
=
0
;
}
Interlocked
.
Increment
(
ref
seq
);
return
seq
;
}
public
static
string
LastSend
=
""
;
public
static
string
LastRevice
=
""
;
...
...
@@ -30,23 +41,33 @@ namespace OnlineStore.Common
isTimeOut
=
false
;
//if (Monitor.TryEnter(lockObj, lockTime))
//{
try
try
{
string
json
=
JsonHelper
.
SerializeObject
(
operation
);
string
result
=
PostJson
(
url
,
json
,
Encoding
.
UTF8
,
out
isTimeOut
);
if
(!
string
.
IsNullOrEmpty
(
result
))
{
string
json
=
JsonHelper
.
SerializeObject
(
operation
);
string
result
=
PostJson
(
url
,
json
,
Encoding
.
UTF8
,
out
isTimeOut
);
if
(!
string
.
IsNullOrEmpty
(
result
))
Operation
resultOP
=
JsonHelper
.
DeserializeJsonToObject
<
Operation
>(
result
);
if
(
resultOP
!=
null
&&
(!
operation
.
seq
.
Equals
(
resultOP
.
seq
)))
{
return
JsonHelper
.
DeserializeJsonToObject
<
Operation
>(
result
);
LogUtil
.
error
(
" seq error : send 【"
+
json
+
"】 "
+
",receive 【 "
+
result
+
"】"
);
}
if
(
resultOP
!=
null
&&
(!
operation
.
cid
.
Equals
(
resultOP
.
cid
)))
{
LogUtil
.
error
(
" cid error : send 【"
+
json
+
"】 "
+
",receive 【 "
+
result
+
"】,return null"
);
return
null
;
}
return
resultOP
;
}
catch
(
Exception
ex
)
{
LogUtil
.
error
(
"Post 出错【operation.op="
+
operation
.
op
+
"】:"
+
ex
);
}
//finally
//{
// Monitor.Exit(lockObj);
//}
}
catch
(
Exception
ex
)
{
LogUtil
.
error
(
"Post 出错【operation.op="
+
operation
.
op
+
"】:"
+
ex
);
}
//finally
//{
// Monitor.Exit(lockObj);
//}
//}
//else if (lockTime > 10)
//{
...
...
source/DeviceLibrary/StoreConfig/BoxConfig_2.csv
查看文件 @
40e0cf0
...
...
@@ -36,6 +36,6 @@ PRO,0,是否调试状态,ISDebug,0,,,,,,,,,,,,
PRO,,每次吹气的时间(分钟),BlowAir_Time,10,,,,,,,,,,,,
PRO,,两次吹气间隔(分钟),BlowAir_Interval,10,,, ,,,,,,,,,
PRO,,温湿度端口号,Humiture_Port,COM5,,,,,,,,,,,,
PRO,,仓门口相机名称,Camera_Name,
monitor
,,,,,,,,,,,,
PRO,,拍照相机名称,PhotoCamera_Name,
monitor
,,,,,,,,,,,,
PRO,,仓门口相机名称,Camera_Name,,,,,,,,,,,,,
PRO,,拍照相机名称,PhotoCamera_Name,,,,,,,,,,,,,
PRO,0,压紧轴(轴4)P2压紧点列表,CompAxis_P2_List,8=385001;,,,,,,,,,,,,
source/DeviceLibrary/acSingleStore/BoxBean.cs
查看文件 @
40e0cf0
...
...
@@ -1229,22 +1229,22 @@ namespace OnlineStore.DeviceLibrary
StoreSendBean
store
=
lineConnect
.
GetBean
((
int
)
ss
,
(
int
)
storeRunStatus
,
hasTray
,
(
int
)
alarmType
);
lineConnect
.
SendHeart
(
store
);
}
if
(
StoreManager
.
IsConnectServer
)
{
try
{
SendLineStatus
();
}
catch
(
Exception
ex
)
{
LogUtil
.
error
(
Name
+
"定时给服务器发送消息出错:"
+
ex
.
ToString
());
}
}
}
if
(
StoreManager
.
Store
.
UseTemp
)
{
humBean
.
HumidityProcess
(
this
);
//if (StoreManager.IsConnectServer)
//{
// try
// {
// SendLineStatus();
// }
// catch (Exception ex)
// {
// LogUtil.error(Name + "定时给服务器发送消息出错:" + ex.ToString());
// }
//}
}
//if (StoreManager.Store.UseTemp)
//{
// humBean.HumidityProcess(this);
//}
}
catch
(
Exception
ex
)
{
...
...
@@ -1255,17 +1255,7 @@ namespace OnlineStore.DeviceLibrary
isInProcess
=
false
;
}
}
private
int
seq
=
1
;
public
int
nextSeq
()
{
if
(
seq
.
Equals
(
Int32
.
MaxValue
))
{
LogUtil
.
info
(
"seq当前值:"
+
seq
+
",重置seq=0"
);
seq
=
0
;
}
Interlocked
.
Increment
(
ref
seq
);
return
seq
;
}
public
Operation
getLineBoxStatus
()
{
//构建发送给服务器的对象
...
...
@@ -1273,7 +1263,7 @@ namespace OnlineStore.DeviceLibrary
lineOperation
.
msg
=
""
;
lineOperation
.
alarmList
=
new
List
<
AlarmInfo
>();
lineOperation
.
cid
=
CID
;
lineOperation
.
seq
=
nextSeq
();
lineOperation
.
seq
=
HttpHelper
.
nextSeq
();
lineOperation
.
status
=
1
;
if
(
WarnMsg
!=
""
)
{
...
...
@@ -1371,6 +1361,11 @@ namespace OnlineStore.DeviceLibrary
//发送状态信息到服务器
if
(
resultOperation
==
null
||
(
resultOperation
.
op
<=
0
))
{
TimeSpan
span1
=
DateTime
.
Now
-
time
;
if
(
span1
.
TotalMilliseconds
>
100
)
{
LogInfo
(
"执行 SendLineStatus PostOP 共【"
+
span1
.
TotalMilliseconds
+
"】毫秒"
);
}
//判断服务端是否返回出库操作
return
;
}
...
...
source/DeviceLibrary/acSingleStore/StoreBean.cs
查看文件 @
40e0cf0
...
...
@@ -21,6 +21,7 @@ namespace OnlineStore.DeviceLibrary
public
Asa
.
Camera
.
VisionLib
vision
;
private
System
.
Timers
.
Timer
ledProcessTimer
=
null
;
private
System
.
Timers
.
Timer
serverConnectTimer
=
new
System
.
Timers
.
Timer
();
public
Dictionary
<
int
,
BoxConfig
>
BoxConfigMap
{
get
;
set
;
}
public
Dictionary
<
int
,
BoxBean
>
BoxMap
=
new
Dictionary
<
int
,
BoxBean
>();
public
bool
UseBuzzer
=
true
;
...
...
@@ -74,7 +75,8 @@ namespace OnlineStore.DeviceLibrary
mainTimer
.
Enabled
=
true
;
ledProcessTimer
.
Enabled
=
true
;
InitVisionLib
();
canStart
=
true
;
canStart
=
true
;
serverConnectTimer
.
Enabled
=
true
;
});
}
...
...
@@ -85,10 +87,12 @@ namespace OnlineStore.DeviceLibrary
ledProcessTimer
.
Elapsed
+=
LedProcess
;
ledProcessTimer
.
AutoReset
=
true
;
ledProcessTimer
.
Enabled
=
false
;
}
private
void
IoCheckTimerProcess
(
object
sender
,
ElapsedEventArgs
e
)
{
serverConnectTimer
=
new
System
.
Timers
.
Timer
();
serverConnectTimer
.
Interval
=
1000
;
serverConnectTimer
.
AutoReset
=
true
;
serverConnectTimer
.
Enabled
=
false
;
serverConnectTimer
.
Elapsed
+=
server_connect_timer_Tick
;
}
#
endregion
...
...
@@ -128,7 +132,7 @@ namespace OnlineStore.DeviceLibrary
{
box
.
StartRun
();
}
serverConnectTimer
.
Enabled
=
true
;
ledProcessTimer
.
Enabled
=
true
;
mainTimer
.
Enabled
=
true
;
return
true
;
...
...
@@ -386,9 +390,7 @@ namespace OnlineStore.DeviceLibrary
}
}
public
override
void
StopMove
()
{
foreach
(
BoxBean
equip
in
this
.
BoxMap
.
Values
)
...
...
@@ -430,10 +432,7 @@ namespace OnlineStore.DeviceLibrary
LogUtil
.
info
(
Name
+
"所有设备重置完成"
);
}
}
public
override
void
Alarm
(
StoreAlarmType
alarmType
,
string
alarmDetial
,
string
alarmMsg
,
StoreMoveType
storeMoveType
)
{
...
...
@@ -460,5 +459,65 @@ namespace OnlineStore.DeviceLibrary
#
endregion
#
region
与服务器通信
private
bool
isInProcess
=
false
;
private
DateTime
lastConTime
=
DateTime
.
Now
;
public
void
server_connect_timer_Tick
(
object
sender
,
EventArgs
e
)
{
if
(
isInProcess
)
{
TimeSpan
span
=
DateTime
.
Now
-
lastConTime
;
if
(
span
.
TotalSeconds
<
10
)
{
return
;
}
else
{
LogUtil
.
error
(
$
"{Name}server_connect_timer_Tick 已耗时{span.TotalSeconds}秒,重新处理"
);
}
}
isInProcess
=
true
;
lastConTime
=
DateTime
.
Now
;
try
{
foreach
(
BoxBean
box
in
BoxMap
.
Values
)
{
if
(
box
.
storeRunStatus
.
Equals
(
StoreRunStatus
.
Wait
))
{
continue
;
}
if
((!
box
.
IsDebug
)
&&
StoreManager
.
IsConnectServer
)
{
try
{
box
.
SendLineStatus
();
}
catch
(
Exception
ex
)
{
LogUtil
.
error
(
Name
+
"定时给服务器发送消息出错:"
+
ex
.
ToString
());
}
}
if
(
StoreManager
.
Store
.
UseTemp
)
{
box
.
humBean
.
HumidityProcess
(
box
);
}
}
}
catch
(
Exception
ex
)
{
LogUtil
.
error
(
Name
+
"server_connect_timer_Tick出错:"
+
ex
.
ToString
());
}
finally
{
isInProcess
=
false
;
}
}
#
endregion
}
}
\ No newline at end of file
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论