Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
张东亮
/
NS200
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
图表
网络
创建新的问题
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit 46aa9c56
由
张东亮
编写于
2024-11-25 21:43:50 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
发送状态死锁造成离线
1 个父辈
e950f5cc
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
101 行增加
和
84 行删除
DeviceLibrary/AutoScanAndLabel/LabelParam.cs
DeviceLibrary/DeviceLibrary/ServerCommunication.cs
DeviceLibrary/AutoScanAndLabel/LabelParam.cs
查看文件 @
46aa9c5
...
...
@@ -105,13 +105,13 @@ namespace DeviceLibrary
}
bool
isnglog
=
false
;
public
void
LogNgInfo
(
ServerCommunication
server
)
{
//
public void LogNgInfo(ServerCommunication server)
//
{
if
(!
isnglog
&&
IsNg
)
{
isnglog
=
server
.
SendNGInfo
(
NgMsg
);
}
}
//
if (!isnglog && IsNg)
//
{
//
isnglog = server.SendNGInfo(NgMsg);
//
}
//
}
}
}
DeviceLibrary/DeviceLibrary/ServerCommunication.cs
查看文件 @
46aa9c5
...
...
@@ -44,7 +44,7 @@ namespace DeviceLibrary
string
WarnMsg
=
""
;
private
System
.
Timers
.
Timer
serverConnectTimer
=
new
System
.
Timers
.
Timer
();
public
object
serverclock
=
new
object
();
public
object
serverclock
=
new
object
();
public
ServerCommunication
()
{
serverConnectTimer
.
Interval
=
1000
;
...
...
@@ -73,7 +73,7 @@ namespace DeviceLibrary
LogUtil
.
error
(
"上传SendLineStatus超时"
);
}
}
}
public
void
ProcessMsg
(
List
<
Msg
>
msg
)
...
...
@@ -158,7 +158,7 @@ namespace DeviceLibrary
}
else
if
(!
RobotManage
.
isRunning
)
{
sendmsg
=
"I="
+
crc
.
GetString
(
"Res0127.a5affabf"
,
"设备未启动"
);
sendmsg
=
"I="
+
crc
.
GetString
(
"Res0127.a5affabf"
,
"设备未启动"
);
}
lineOperation
.
msg
=
sendmsg
;
...
...
@@ -168,9 +168,9 @@ namespace DeviceLibrary
lineOperation
.
msgJp
=
lineOperation
.
msg
;
//lineOperation.boxStatus.Add(StoreID, boxStatus);
lineOperation
.
data
=
lineOperation
.
data
.
Union
(
UnifiedDataHandler
.
PrintNgMESData
()).
ToDictionary
(
x
=>
x
.
Key
,
x
=>
x
.
Value
);
lineOperation
.
showLogs
=
StepInformation
(
out
Dictionary
<
string
,
string
>
dic
);
lineOperation
.
data
=
lineOperation
.
data
.
Union
(
dic
).
ToDictionary
(
x
=>
x
.
Key
,
x
=>
x
.
Value
);
lineOperation
.
data
=
lineOperation
.
data
.
Union
(
UnifiedDataHandler
.
PrintNgMESData
()).
ToDictionary
(
x
=>
x
.
Key
,
x
=>
x
.
Value
);
lineOperation
.
showLogs
=
StepInformation
(
out
Dictionary
<
string
,
string
>
dic
);
lineOperation
.
data
=
lineOperation
.
data
.
Union
(
dic
).
ToDictionary
(
x
=>
x
.
Key
,
x
=>
x
.
Value
);
return
lineOperation
;
}
private
static
string
api_communication
=
"service/equipment/communication"
;
//流水线状态通信接口
...
...
@@ -207,7 +207,7 @@ namespace DeviceLibrary
{
try
{
lock
(
serverclock
)
//
lock (serverclock)
{
bool
printlog
=
false
;
DateTime
time
=
DateTime
.
Now
;
...
...
@@ -232,38 +232,46 @@ namespace DeviceLibrary
}
catch
(
Exception
ex
)
{
LogUtil
.
error
(
"SendLineStatus"
,
ex
);
LogUtil
.
error
(
"SendLineStatus"
,
ex
);
}
finally
{
Monitor
.
Exit
(
serverclock
);
}
}
public
bool
SendAgvLog
(
string
msg
)
{
if
(
Monitor
.
TryEnter
(
serverclock
,
TimeSpan
.
FromSeconds
(
5
)))
{
if
(!
server
.
ToLower
().
StartsWith
(
"http"
))
{
return
false
;
}
lock
(
serverclock
)
try
{
Operation
operation
=
getLineBoxStatus
();
if
(!
server
.
ToLower
().
StartsWith
(
"http"
))
{
return
false
;
}
//lock (serverclock)
{
Operation
operation
=
getLineBoxStatus
();
//operation.logList = new List<AgvLogInfo>
//{
// new AgvLogInfo(msg)
//};
//LogUtil.info(JsonHelper.SerializeObject(operation));
//operation.logList = new List<AgvLogInfo>
//{
// new AgvLogInfo(msg)
//};
//LogUtil.info(JsonHelper.SerializeObject(operation));
Operation
resultOperation
=
HttpHelper
.
Post
(
GetPostApi
(),
operation
,
5000
);
Operation
resultOperation
=
HttpHelper
.
Post
(
GetPostApi
(),
operation
,
5000
);
if
(
resultOperation
==
null
)
{
LogUtil
.
info
(
$
"SendAgvLog error:{msg}"
);
return
false
;
if
(
resultOperation
==
null
)
{
LogUtil
.
info
(
$
"SendAgvLog error:{msg}"
);
return
false
;
}
LogUtil
.
info
(
$
"SendAgvLog success:{msg}"
);
}
LogUtil
.
info
(
$
"SendAgvLog success:{msg}"
)
;
return
true
;
}
return
true
;
finally
{
Monitor
.
Exit
(
serverclock
);
}
}
else
{
...
...
@@ -276,34 +284,42 @@ namespace DeviceLibrary
{
if
(
Monitor
.
TryEnter
(
serverclock
,
TimeSpan
.
FromSeconds
(
5
)))
{
if
(!
server
.
ToLower
().
StartsWith
(
"http"
))
{
return
false
;
}
lock
(
serverclock
)
try
{
Operation
operation
=
getLineBoxStatus
();
if
(!
server
.
ToLower
().
StartsWith
(
"http"
))
{
return
false
;
}
// lock (serverclock)
{
Operation
operation
=
getLineBoxStatus
();
//operation.mimoOpMap = new Dictionary<string, Dictionary<string, string>>();
//Dictionary<string, string> op = new Dictionary<string, string>
//{
// { "Y10", "open" }
//};
//operation.mimoOpMap.Add("1", op);
//operation.mimoOpMap = new Dictionary<string, Dictionary<string, string>>();
//Dictionary<string, string> op = new Dictionary<string, string>
//{
// { "Y10", "open" }
//};
//operation.mimoOpMap.Add("1", op);
//operation.mimoOpMap.Add(mimoCid, operate);
LogUtil
.
info
(
JsonHelper
.
SerializeObject
(
operation
));
//operation.mimoOpMap.Add(mimoCid, operate);
LogUtil
.
info
(
JsonHelper
.
SerializeObject
(
operation
));
Operation
resultOperation
=
HttpHelper
.
Post
(
GetPostApi
(),
operation
,
1000
);
Operation
resultOperation
=
HttpHelper
.
Post
(
GetPostApi
(),
operation
,
1000
);
if
(
resultOperation
==
null
)
{
LogUtil
.
info
(
$
"OpMIMO error:{msg}"
);
return
false
;
if
(
resultOperation
==
null
)
{
LogUtil
.
info
(
$
"OpMIMO error:{msg}"
);
return
false
;
}
LogUtil
.
info
(
$
"OpMIMO success:{msg}"
);
}
LogUtil
.
info
(
$
"OpMIMO success:{msg}"
)
;
return
true
;
}
return
true
;
finally
{
Monitor
.
Exit
(
serverclock
);
}
}
else
{
...
...
@@ -455,9 +471,9 @@ namespace DeviceLibrary
/// 获取模板信息
/// </summary>
/// <returns></returns>
public
List
<
EquipMsg
>
StepInformation
(
out
Dictionary
<
string
,
string
>
dic
)
public
List
<
EquipMsg
>
StepInformation
(
out
Dictionary
<
string
,
string
>
dic
)
{
dic
=
new
Dictionary
<
string
,
string
>();
dic
=
new
Dictionary
<
string
,
string
>();
List
<
EquipMsg
>
equipMsgs
=
new
List
<
EquipMsg
>();
try
{
...
...
@@ -477,12 +493,12 @@ namespace DeviceLibrary
//msg.msgParams = new string[] { addressValue.GetStateStr() };
msg
.
msg
=
addressValue
.
GetStateStr
();
equipMsgs
.
Add
(
msg
);
if
(
addressValue
.
Name
==
crc
.
GetString
(
"Res0039"
,
"右侧取料"
))
if
(
addressValue
.
Name
==
crc
.
GetString
(
"Res0039"
,
"右侧取料"
))
{
dic
.
Add
(
"inShelfType"
,
ShelfType
.
smallReel
.
ToString
());
dic
.
Add
(
"inShelfStatus"
,
UnifiedDataHandler
.
ShelfStatus
(
true
,
Convert
.
ToInt32
(
addressValue
.
MoveStep
)));
dic
.
Add
(
"inShelfStatus"
,
UnifiedDataHandler
.
ShelfStatus
(
true
,
Convert
.
ToInt32
(
addressValue
.
MoveStep
)));
}
if
(
addressValue
.
Name
==
crc
.
GetString
(
"Res0051"
,
"左侧放料"
))
if
(
addressValue
.
Name
==
crc
.
GetString
(
"Res0051"
,
"左侧放料"
))
{
dic
.
Add
(
"outShelfType"
,
ShelfType
.
smallReel
.
ToString
());
dic
.
Add
(
"outShelfStatus"
,
UnifiedDataHandler
.
ShelfStatus
(
false
,
Convert
.
ToInt32
(
addressValue
.
MoveStep
)));
...
...
@@ -497,7 +513,7 @@ namespace DeviceLibrary
module
=
crc
.
GetString
(
"Res0216"
,
"打印机"
),
msg
=
(
printstatus
==
CustPrinterStatus
.
Unknown
)
?
"Wait"
:
printstatus
.
ToString
(),
};
};
}
catch
(
Exception
ex
)
{
...
...
@@ -509,12 +525,10 @@ namespace DeviceLibrary
public
bool
SendNGInfo
(
string
ngmsg
)
{
lock
(
serverclock
)
try
{
try
{
Operation
operation
=
getLineBoxStatus
();
operation
.
msgList
=
new
List
<
MsgInfo
>
Operation
operation
=
getLineBoxStatus
();
operation
.
msgList
=
new
List
<
MsgInfo
>
{
new
MsgInfo
{
...
...
@@ -523,30 +537,33 @@ namespace DeviceLibrary
msg
=
ngmsg
}
};
//operation.boxStatus[StoreID].status = (int)storeStatus;
//operation.boxStatus[StoreID].status = (int)storeStatus;
//LogUtil.Log.Info(JsonHelper.SerializeObject(operation));
Operation
resultOperation
=
HttpHelper
.
Post
(
GetPostApi
(),
operation
,
5000
);
//LogUtil.Log.Info(JsonHelper.SerializeObject(operation));
if
(
resultOperation
==
null
)
{
LogUtil
.
error
(
$
"SendNGInfo error,ngmsg={ngmsg}"
);
return
false
;
}
if
(
operation
.
seq
!=
resultOperation
.
seq
)
{
LogUtil
.
error
(
$
"SendNGInfo seq error,ngmsg={ngmsg},cseq={operation.seq},rseq={resultOperation.seq}"
);
return
false
;
}
Operation
resultOperation
=
HttpHelper
.
Post
(
GetPostApi
(),
operation
,
5000
);
LogUtil
.
info
(
$
"SendNGInfo success,ngmsg={ngmsg}"
);
ResultProcess
(
resultOperation
);
if
(
resultOperation
==
null
)
{
LogUtil
.
error
(
$
"SendNGInfo error,ngmsg={ngmsg}"
);
return
false
;
}
catch
(
Exception
ex
)
if
(
operation
.
seq
!=
resultOperation
.
seq
)
{
LogUtil
.
error
(
$
"SendNGInfo error:{ngmsg}"
,
ex
);
LogUtil
.
error
(
$
"SendNGInfo seq error,ngmsg={ngmsg},cseq={operation.seq},rseq={resultOperation.seq}"
);
return
false
;
}
LogUtil
.
info
(
$
"SendNGInfo success,ngmsg={ngmsg}"
);
ResultProcess
(
resultOperation
);
}
catch
(
Exception
ex
)
{
LogUtil
.
error
(
$
"SendNGInfo error:{ngmsg}"
,
ex
);
}
finally
{
Monitor
.
Exit
(
serverclock
);
}
return
true
;
}
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论