Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
孙克
/
ACSingleStore
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit 5e93ab72
由
LN
编写于
2019-08-20 09:23:13 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
与流水线通信格式修改。
1 个父辈
a8c49f96
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
95 行增加
和
58 行删除
source/ACSingleStore/App.config
source/ACSingleStore/FrmStoreBox.cs
source/Common/util/LogUtil.cs
source/Common/util/TcpClient.cs
source/DeviceLibrary/acSingleStore/AC_SA_BoxBean.cs
source/DeviceLibrary/acSingleStore/AC_SA_BoxBean_Partial.cs
source/DeviceLibrary/lineConnect/LineConnect.cs
source/ACSingleStore/App.config
查看文件 @
5e93ab7
...
...
@@ -32,7 +32,7 @@
<
add
key
=
"HumitureControllerType"
value
=
"0"
/>
<
add
key
=
"UseAIOBOX"
value
=
"1"
/>
<!--流水线地址和端口配置-->
<
add
key
=
"LineServerIp"
value
=
"192.168.1.11
3
"
/>
<
add
key
=
"LineServerIp"
value
=
"192.168.1.11
0
"
/>
<
add
key
=
"LineServerPort"
value
=
"5246"
/>
<!--是否调试状态-->
<
add
key
=
"IsInDebug"
value
=
"1"
/>
...
...
source/ACSingleStore/FrmStoreBox.cs
查看文件 @
5e93ab7
...
...
@@ -1363,7 +1363,8 @@ namespace OnlineStore.ACSingleStore
{
ss
=
StoreStatus
.
Debugging
;
}
LineConnect
.
SendHeart
(
StoreManager
.
Config
.
Id
,
StoreManager
.
Config
.
CID
,
(
int
)
ss
,
(
int
)
StoreRunStatus
.
Runing
,
hasTray
,(
int
)
StoreAlarmType
.
None
);
StoreSendBean
bean
=
new
StoreSendBean
(
StoreManager
.
Config
.
Id
,
StoreManager
.
Config
.
CID
,
(
int
)
ss
,
(
int
)
StoreRunStatus
.
Runing
,
hasTray
,
(
int
)
StoreAlarmType
.
None
);
LineConnect
.
SendHeart
(
bean
);
}
private
void
chbDebug_CheckedChanged
(
object
sender
,
EventArgs
e
)
...
...
source/Common/util/LogUtil.cs
查看文件 @
5e93ab7
...
...
@@ -77,12 +77,12 @@ namespace OnlineStore.Common
private
static
List
<
string
>
lasErrorLogList
=
new
List
<
string
>();
private
static
int
errCount
=
5
;
public
static
void
error
(
ILog
log
,
string
errorMsg
,
int
type
)
public
static
void
error
(
ILog
log
,
string
errorMsg
,
int
type
,
int
spanSeconds
=
10
)
{
if
(
lastErrorLogTime
.
ContainsKey
(
type
))
{
TimeSpan
span
=
DateTime
.
Now
-
lastErrorLogTime
[
type
];
if
(
span
.
TotalSeconds
<
10
)
if
(
span
.
TotalSeconds
<
spanSeconds
)
{
return
;
}
...
...
source/Common/util/TcpClient.cs
查看文件 @
5e93ab7
...
...
@@ -154,7 +154,7 @@ namespace OnlineStore.Common
if
(
m_clientSocket
!=
null
)
{
m_clientSocket
.
Close
();
LogUtil
.
info
(
LOGGER
,
"Socket closed!"
);
LogUtil
.
debug
(
LOGGER
,
"Socket closed!"
);
}
}
catch
(
Exception
ex
)
{
...
...
@@ -176,9 +176,9 @@ namespace OnlineStore.Common
catch
(
Exception
ex
)
{
isInProcess
=
false
;
LogUtil
.
error
(
"重连处理出错:"
+
ex
.
ToString
()
);
LogUtil
.
error
(
LOGGER
,
"重连处理出错:"
+
ex
.
ToString
(),
9
,
180
);
}
}
}
/// <summary>
/// 断开连接
...
...
source/DeviceLibrary/acSingleStore/AC_SA_BoxBean.cs
查看文件 @
5e93ab7
此文件的差异被折叠,
点击展开。
source/DeviceLibrary/acSingleStore/AC_SA_BoxBean_Partial.cs
查看文件 @
5e93ab7
...
...
@@ -654,7 +654,11 @@ namespace OnlineStore.DeviceLibrary
{
ss
=
(
int
)
StoreStatus
.
Debugging
;
}
LineConnect
.
OutStoreEnd
(
Config
.
Id
,
Config
.
CID
,
(
int
)
storeStatus
,
(
int
)
storeRunStatus
,
hasTray
,(
int
)
alarmType
,
StoreMove
.
MoveParam
.
PositionNum
,
StoreMove
.
MoveParam
.
PlateH
,
StoreMove
.
MoveParam
.
PlateW
);
StoreSendBean
store
=
new
StoreSendBean
(
Config
.
Id
,
Config
.
CID
,
(
int
)
storeStatus
,
(
int
)
storeRunStatus
,
hasTray
,
(
int
)
alarmType
);
store
.
PosId
=
StoreMove
.
MoveParam
.
PositionNum
;
store
.
PlateH
=
StoreMove
.
MoveParam
.
PlateH
;
store
.
PlateW
=
StoreMove
.
MoveParam
.
PlateW
;
LineConnect
.
OutStoreEnd
(
store
);
}
else
if
(
StoreMove
.
MoveStep
==
StoreMoveStep
.
SO_13_GoBack
)
{
...
...
source/DeviceLibrary/lineConnect/LineConnect.cs
查看文件 @
5e93ab7
...
...
@@ -9,8 +9,9 @@ namespace OnlineStore.DeviceLibrary
{
public
class
LineConnect
{
private
static
int
ClientKeepSecond
=
10
;
private
static
TcpClient
client
=
null
;
public
static
List
<
string
>
WaitInStoreList
=
new
List
<
string
>();
public
static
void
StartConnect
()
{
string
lineServer
=
ConfigAppSettings
.
GetValue
(
Setting_Init
.
LineServerIp
);
...
...
@@ -21,6 +22,7 @@ namespace OnlineStore.DeviceLibrary
return
;
}
client
=
new
TcpClient
();
bool
result
=
client
.
StartConnect
(
lineServer
,
linePort
,
HandlerMsg
,
2000
);
}
...
...
@@ -45,7 +47,7 @@ namespace OnlineStore.DeviceLibrary
return
seq
;
}
public
static
void
SendHeart
(
int
id
,
string
cid
,
int
ss
,
int
runs
,
int
doorHasTray
,
int
alarmTyp
e
)
public
static
void
SendHeart
(
StoreSendBean
stor
e
)
{
if
(
client
==
null
)
{
...
...
@@ -53,24 +55,16 @@ namespace OnlineStore.DeviceLibrary
}
try
{
List
<
object
>
paramList
=
new
List
<
object
>();
paramList
.
Add
(
cmd_heart
);
paramList
.
Add
(
id
);
paramList
.
Add
(
cid
);
paramList
.
Add
(
nextSeq
());
paramList
.
Add
(
ss
);
paramList
.
Add
(
runs
);
paramList
.
Add
(
doorHasTray
);
paramList
.
Add
(
alarmType
);
string
heartMsg
=
ToParamStr
(
paramList
);
store
.
Cmd
=
cmd_heart
;
string
heartMsg
=
ToParamStr
(
store
);
client
.
send
(
heartMsg
);
}
catch
(
Exception
ex
)
}
catch
(
Exception
ex
)
{
LogUtil
.
error
(
"SendHeart 出错:"
+
ex
.
ToString
());
LogUtil
.
error
(
"SendHeart 出错:"
+
ex
.
ToString
());
}
}
public
static
void
OutStoreEnd
(
int
id
,
string
cid
,
int
ss
,
int
runs
,
int
doorHasTray
,
int
alarmType
,
string
posid
,
string
plateH
,
string
plateW
)
public
static
void
OutStoreEnd
(
StoreSendBean
store
)
{
if
(
client
==
null
)
{
...
...
@@ -78,71 +72,74 @@ namespace OnlineStore.DeviceLibrary
}
try
{
List
<
object
>
paramList
=
new
List
<
object
>();
paramList
.
Add
(
cmd_outend
);
paramList
.
Add
(
id
);
paramList
.
Add
(
cid
);
paramList
.
Add
(
nextSeq
());
paramList
.
Add
(
ss
);
paramList
.
Add
(
runs
);
paramList
.
Add
(
doorHasTray
);
paramList
.
Add
(
alarmType
);
paramList
.
Add
(
posid
);
paramList
.
Add
(
plateH
);
paramList
.
Add
(
plateW
);
//string heartMsg = cmd_outend + cmd_spilt + id + cmd_spilt + cid + cmd_spilt + nextSeq() + cmd_spilt + ss + cmd_spilt + runs + cmd_spilt + doorHasTray+ cmd_spilt + posid + cmd_spilt;
//string msg = heartMsg + posid + cmd_spilt + plateH + cmd_spilt + plateW + cmd_spilt + "\r";
string
msg
=
ToParamStr
(
paramList
);
client
.
send
(
msg
);
store
.
Cmd
=
cmd_outend
;
string
msg
=
ToParamStr
(
store
);
client
.
send
(
msg
);
}
catch
(
Exception
ex
)
{
LogUtil
.
error
(
"OutStoreEnd 出错:"
+
ex
.
ToString
());
}
}
private
static
string
ToParamStr
(
StoreSendBean
store
)
{
return
JsonHelper
.
SerializeObject
(
store
)+
"\r"
;
}
private
static
string
ToParamStr
(
List
<
object
>
paramList
)
{
string
result
=
""
;
foreach
(
object
str
in
paramList
)
foreach
(
object
str
in
paramList
)
{
result
+=
str
+
cmd_spilt
.
ToString
();
}
return
result
+
"\r"
;
return
result
+
"\r"
;
}
private
static
void
HandlerMsg
(
string
message
)
{
try
{
string
[]
msgArray
=
message
.
Split
(
cmd_spilt
);
if
(
msgArray
.
Length
>
2
)
message
=
message
.
Replace
(
"\r"
,
""
);
StoreReviceBean
reviceInfo
=
JsonHelper
.
DeserializeJsonToObject
<
StoreReviceBean
>(
message
);
//string[] msgArray = message.Split(cmd_spilt);
if
(
reviceInfo
==
null
)
{
LogUtil
.
debug
(
"收到消息:"
+
message
+
",解析失败"
);
}
else
{
string
cmd
=
msgArray
[
0
];
int
canStartOut
=
Convert
.
ToInt32
(
msgArray
[
1
]);
CanOutStore
=
canStartOut
.
Equals
(
1
);
string
cmd
=
reviceInfo
.
Cmd
;
CanOutStore
=
reviceInfo
.
CanOutStore
.
Equals
(
1
);
LastUpdateTime
=
DateTime
.
Now
;
if
(
cmd
.
Equals
(
cmd_startIn
))
{
LogUtil
.
info
(
"收到流水线入库消息:"
+
message
);
string
posId
=
msgArray
[
2
]
;
string
plateH
=
msgArray
[
3
];
string
plateW
=
msgArray
[
4
];
string
code
=
msgArray
[
5
];
StoreManager
.
Store
.
ReviceLineInStoreCMD
(
posId
,
plateH
,
plateW
,
code
);
//string posId = reviceInfo.PosId
;
//string plateH = reviceInfo.PlateH
//
string plateW = msgArray[4];
//
string code = msgArray[5];
StoreManager
.
Store
.
ReviceLineInStoreCMD
(
reviceInfo
.
PosId
,
reviceInfo
.
PlateH
,
reviceInfo
.
PlateW
,
reviceInfo
.
WareCode
);
}
else
if
(
cmd
.
Equals
(
cmd_updateDebug
))
{
int
isDebug
=
Convert
.
ToInt32
(
msgArray
[
2
])
;
int
isDebug
=
reviceInfo
.
IsDebug
;
LogUtil
.
info
(
"收到流水线更改调试状态="
+
isDebug
);
StoreManager
.
Store
.
IsDebug
=
isDebug
.
Equals
(
1
)
?
true
:
false
;
ConfigAppSettings
.
SaveValue
(
Setting_Init
.
IsInDebug
,
isDebug
);
LogUtil
.
info
(
"切换调试状态= "
+
isDebug
+
";"
);
}
else
else
if
(
cmd
.
Equals
(
cmd_checStartIn
))
{
LogUtil
.
debug
(
"收到消息:"
+
message
);
LogUtil
.
info
(
"收到流水线入库库位验证消息:"
+
message
);
bool
result
=
StoreManager
.
Store
.
ReviceLineCheckInStoreCMD
(
reviceInfo
.
PosId
,
reviceInfo
.
PlateH
,
reviceInfo
.
PlateW
,
reviceInfo
.
WareCode
);
if
(
result
)
{
LineConnect
.
WaitInStoreList
.
Add
(
reviceInfo
.
PosId
);
}
}
}
}
catch
(
Exception
ex
)
...
...
@@ -151,12 +148,13 @@ namespace OnlineStore.DeviceLibrary
}
}
public
static
char
cmd_spilt
=
';'
;
p
rivate
static
string
cmd_heart
=
"heart"
;
p
ublic
static
string
cmd_heart
=
"heart"
;
private
static
string
cmd_outend
=
"outend"
;
private
static
string
cmd_startIn
=
"starIn"
;
private
static
string
cmd_updateDebug
=
"updateDebug"
;
private
static
bool
CanOutStore
=
false
;
public
static
DateTime
LastUpdateTime
=
new
DateTime
(
0
);
public
static
string
cmd_checStartIn
=
"cmd_checStartIn"
;
public
static
bool
IsConnect
()
{
if
(
client
==
null
)
...
...
@@ -173,11 +171,45 @@ namespace OnlineStore.DeviceLibrary
public
static
bool
CanStartOut
()
{
TimeSpan
span
=
DateTime
.
Now
-
LastUpdateTime
;
if
(
span
.
TotalSeconds
<
3
&&
CanOutStore
)
if
(
span
.
TotalSeconds
<
ClientKeepSecond
&&
CanOutStore
)
{
return
true
;
}
return
false
;
}
}
public
class
StoreReviceBean
{
public
string
Cmd
=
""
;
public
int
CanOutStore
=
0
;
public
string
PosId
=
""
;
public
string
PlateH
=
"0"
;
public
string
PlateW
=
"0"
;
public
string
WareCode
=
""
;
public
int
IsDebug
=
0
;
}
public
class
StoreSendBean
{
public
StoreSendBean
(
int
id
,
string
cid
,
int
ss
,
int
runs
,
int
doorHasTray
,
int
alarmType
)
{
this
.
StoreId
=
id
;
this
.
Cid
=
cid
;
this
.
SStatus
=
ss
;
this
.
SRunStatus
=
runs
;
this
.
DoorHasTray
=
doorHasTray
;
this
.
AlarmType
=
alarmType
;
this
.
Seq
=
LineConnect
.
nextSeq
();
}
public
string
Cmd
=
LineConnect
.
cmd_heart
;
public
int
StoreId
=
0
;
public
string
Cid
=
""
;
public
int
Seq
=
0
;
public
int
SStatus
=
0
;
public
int
SRunStatus
=
0
;
public
int
DoorHasTray
=
0
;
public
int
AlarmType
=
0
;
public
string
PosId
=
""
;
public
string
PlateH
=
"0"
;
public
string
PlateW
=
"0"
;
}
}
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论