Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
李娜
/
SO827-AssemblyLine
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
图表
网络
创建新的问题
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit e0d5952c
由
LN
编写于
2021-05-20 09:19:37 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
预扫码增加超时判断
1 个父辈
8a38b111
全部展开
显示空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
11 行增加
和
243 行删除
dll/CodeLibrary.dll
source/DeviceLibrary/agvClient/AgvClient.cs
source/DeviceLibrary/assemblyLine/FeedingEquip_InStore.cs
source/DeviceLibrary/assemblyLine/FeedingEquip_OutStore.cs
dll/CodeLibrary.dll
查看文件 @
e0d5952
此文件类型无法预览
source/DeviceLibrary/agvClient/AgvClient.cs
deleted
100644 → 0
查看文件 @
8a38b11
using
Asa
;
using
OnlineStore.Common
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading
;
using
System.Threading.Tasks
;
namespace
OnlineStore.DeviceLibrary
{
public
class
AgvClient
{
public
static
bool
CurrCancelState
=
true
;
private
static
string
ServerIp
=
ConfigAppSettings
.
GetValue
(
Setting_Init
.
AgvServerIp
);
private
static
Asa
.
AgvClient
agvClient
;
public
static
Dictionary
<
string
,
Asa
.
ClientAction
>
actionMap
=
new
Dictionary
<
string
,
Asa
.
ClientAction
>();
public
static
List
<
string
>
NodeList
=
new
List
<
string
>();
private
static
bool
isInit
=
false
;
public
static
void
Init
()
{
try
{
LogUtil
.
info
(
"开始 Init agvclient"
);
if
(!
isInit
)
{
isInit
=
true
;
agvClient
=
new
Asa
.
AgvClient
(
ServerIp
);
agvClient
.
CancelState
=
true
;
agvClient
.
Log
+=
AgvClient_Log
;
agvClient
.
Arrive
+=
AgvClient_Arrive
;
agvClient
.
Ready
+=
AgvClient_Ready
;
agvClient
.
CloseDoor
+=
AgvClient_CloseDoor
;
}
actionMap
=
new
Dictionary
<
string
,
Asa
.
ClientAction
>();
LogUtil
.
info
(
" 开始 agvClient.Connect"
);
agvClient
.
Connect
();
foreach
(
string
str
in
NodeList
)
{
SetStatus
(
str
);
}
}
catch
(
Exception
ex
)
{
LogUtil
.
error
(
"初始化agvClient "
+
ServerIp
+
" 出错:"
,
ex
);
}
}
public
static
void
SetCancelState
(
bool
isCancel
)
{
if
(
agvClient
==
null
)
{
return
;
}
CurrCancelState
=
isCancel
;
agvClient
.
CancelState
=
isCancel
;
}
public
static
void
SetStatus
(
string
id
,
string
shelfId
=
""
,
ClientAction
action
=
ClientAction
.
None
,
ClientLevel
level
=
ClientLevel
.
Low
,
bool
isMust
=
false
)
{
if
(!
isMust
&&
level
.
Equals
(
ClientLevel
.
Low
))
{
if
(
actionMap
.
ContainsKey
(
id
))
{
ClientAction
currA
=
actionMap
[
id
];
//相同状态就设置一次
if
(
currA
.
Equals
(
action
))
{
return
;
}
}
}
string
mark
=
""
;
if
(
shelfId
!=
""
)
{
int
index
=
shelfId
.
IndexOf
(
','
);
if
(
index
>
0
)
{
//紧急出料模块,料架离开时,mark=紧急料或者分配料,rfid=料架号
mark
=
shelfId
.
Substring
(
index
+
1
,
shelfId
.
Length
-
index
-
1
);
shelfId
=
shelfId
.
Substring
(
0
,
index
);
}
}
agvClient
.
SetStatus
(
id
,
mark
,
shelfId
,
action
,
level
);
UpdateAction
(
id
,
action
);
}
private
static
void
AgvClient_CloseDoor
(
string
id
,
string
rfid
)
{
LogUtil
.
info
(
"收到 AgvClient_CloseDoor ["
+
id
+
"] ["
+
rfid
+
"] 更新状态 "
);
UpdateAction
(
id
,
ClientAction
.
CloseDoor
);
Task
.
Factory
.
StartNew
(
delegate
{
Thread
.
Sleep
(
5000
);
if
(
GetAction
(
id
).
Equals
(
ClientAction
.
CloseDoor
))
{
SetStatus
(
id
);
LogUtil
.
error
(
"收到 AgvClient_CloseDoor ["
+
id
+
"] ["
+
rfid
+
"] 5秒后,更新状态为None "
);
}
});
}
private
static
void
AgvClient_Ready
(
string
id
,
string
rfid
)
{
UpdateAction
(
id
,
ClientAction
.
Ready
);
// RFIDData data = new RFIDData(content);
LogUtil
.
info
(
"收到 AgvClient_Ready ["
+
id
+
"] ["
+
rfid
+
"] "
);
FeedingEquip
equip
=
getFeedEquip
(
id
);
if
(
equip
==
null
)
{
LogUtil
.
error
(
"收到 AgvClient_Ready ["
+
id
+
"] ["
+
rfid
+
"] 未找到对应的设备 ,暂不处理"
);
return
;
}
equip
.
AgvReady
(
id
,
rfid
);
}
private
static
void
AgvClient_Arrive
(
string
id
,
string
rfid
)
{
UpdateAction
(
id
,
ClientAction
.
Arrive
);
// RFIDData data = new RFIDData(content);
LogUtil
.
info
(
"收到 AgvClient_Arrive ["
+
id
+
"] ["
+
rfid
+
"] "
);
FeedingEquip
equip
=
getFeedEquip
(
id
);
if
(
equip
==
null
)
{
LogUtil
.
error
(
"收到 AgvClient_Ready ["
+
id
+
"] ["
+
rfid
+
"] 未找到对应的设备 ,暂不处理 "
);
return
;
}
equip
.
AgvArrive
(
id
,
rfid
);
}
private
static
FeedingEquip
getFeedEquip
(
string
nodeId
)
{
foreach
(
FeedingEquip
feed
in
LineManager
.
Line
.
FeedingEquipMap
.
Values
)
{
if
(
feed
.
Config
.
AgvInName
.
Equals
(
nodeId
)
||
feed
.
Config
.
AgvOutName
.
Equals
(
nodeId
))
{
return
feed
;
}
}
return
null
;
}
internal
static
bool
ISConnected
()
{
if
(
agvClient
==
null
)
{
return
false
;
}
return
agvClient
.
IsConn
;
}
public
static
bool
SetToNone
(
string
id
,
string
shelfId
=
""
)
{
ClientAction
currA
=
GetAction
(
id
);
if
(
currA
.
Equals
(
ClientAction
.
None
)
||
currA
.
Equals
(
ClientAction
.
NeedLeave
)
||
currA
.
Equals
(
ClientAction
.
NeedEnter
))
{
SetStatus
(
id
,
shelfId
,
ClientAction
.
None
);
return
true
;
}
return
false
;
}
public
static
bool
NeedEnter
(
string
id
,
string
shelfId
=
""
,
ClientLevel
level
=
ClientLevel
.
Low
)
{
ClientAction
currA
=
GetAction
(
id
);
if
(
currA
.
Equals
(
ClientAction
.
None
)
||
currA
.
Equals
(
ClientAction
.
NeedLeave
)
||
currA
.
Equals
(
ClientAction
.
NeedEnter
))
{
SetStatus
(
id
,
shelfId
,
ClientAction
.
NeedEnter
,
level
);
return
true
;
}
return
false
;
}
public
static
bool
NeedLeave
(
string
id
,
string
shelfId
=
""
,
ClientLevel
level
=
ClientLevel
.
Low
)
{
ClientAction
currA
=
GetAction
(
id
);
if
(
currA
.
Equals
(
ClientAction
.
None
)
||
currA
.
Equals
(
ClientAction
.
NeedLeave
)
||
currA
.
Equals
(
ClientAction
.
NeedEnter
))
{
SetStatus
(
id
,
shelfId
,
ClientAction
.
NeedLeave
,
level
);
return
true
;
}
return
false
;
}
private
static
bool
isLog
=
ConfigAppSettings
.
GetIntValue
(
Setting_Init
.
Agv_Log_Open
).
Equals
(
1
);
private
static
void
AgvClient_Log
(
string
s
)
{
try
{
if
(
isLog
)
{
LogUtil
.
info
(
" AGV "
+
ServerIp
+
" Log : "
+
s
);
}
}
catch
(
Exception
ex
)
{
LogUtil
.
error
(
"AgvClient_Log 出错:"
+
ex
.
ToString
());
}
}
public
static
Asa
.
ClientAction
GetAction
(
string
NodeName
)
{
if
(
actionMap
.
ContainsKey
(
NodeName
))
{
return
actionMap
[
NodeName
];
}
return
Asa
.
ClientAction
.
None
;
}
public
static
void
UpdateAction
(
string
name
,
Asa
.
ClientAction
action
)
{
if
(
actionMap
.
ContainsKey
(
name
))
{
actionMap
[
name
]
=
action
;
}
else
{
actionMap
.
Add
(
name
,
action
);
}
}
public
static
void
Dispose
()
{
try
{
if
(
agvClient
!=
null
)
{
agvClient
.
Close
();
}
}
catch
(
Exception
ex
)
{
LogUtil
.
error
(
"释放 agvClient "
+
ServerIp
+
" 出错:"
,
ex
);
}
}
}
//public class AGVAction
//{
// public static string None = "None";
// public static string Arrive = "Arrive";
// public static string CanEnter = "CanEnter";
// public static string GetRFID = "GetRFID";
// public static string Ready = "Ready";
//}
}
source/DeviceLibrary/assemblyLine/FeedingEquip_InStore.cs
查看文件 @
e0d5952
...
@@ -879,10 +879,11 @@ namespace OnlineStore.DeviceLibrary
...
@@ -879,10 +879,11 @@ namespace OnlineStore.DeviceLibrary
InLog
(
"料盘移栽"
+
MoveInfo
.
SLog
+
":提升轴下降到料盘不溢出("
+
(
currPositon
-
Config
.
Height_ChangeValue
*
30
)
+
"):"
+
targetPosition
+
",速度"
+
Config
.
BatchAxis_P4Speed
);
InLog
(
"料盘移栽"
+
MoveInfo
.
SLog
+
":提升轴下降到料盘不溢出("
+
(
currPositon
-
Config
.
Height_ChangeValue
*
30
)
+
"):"
+
targetPosition
+
",速度"
+
Config
.
BatchAxis_P4Speed
);
BatchAxis
.
AbsMove
(
MoveInfo
,
targetPosition
,
Config
.
BatchAxis_P4Speed
);
BatchAxis
.
AbsMove
(
MoveInfo
,
targetPosition
,
Config
.
BatchAxis_P4Speed
);
}
}
private
Task
YuScanTask
=
null
;
private
void
YuScanCode
()
private
void
YuScanCode
()
{
{
bool
isScan
=
ConfigAppSettings
.
GetIntValue
(
Setting_Init
.
NeedScanCode
).
Equals
(
1
);
bool
isScan
=
ConfigAppSettings
.
GetIntValue
(
Setting_Init
.
NeedScanCode
).
Equals
(
1
);
YuScanTask
=
null
;
//TODO 此处需要等待空托盘
//TODO 此处需要等待空托盘
if
(
MoveInfo
.
ShelfNoTray
.
Equals
(
false
)
&&
isScan
)
if
(
MoveInfo
.
ShelfNoTray
.
Equals
(
false
)
&&
isScan
)
{
{
...
@@ -892,7 +893,7 @@ namespace OnlineStore.DeviceLibrary
...
@@ -892,7 +893,7 @@ namespace OnlineStore.DeviceLibrary
List
<
string
>
bijiaoList
=
new
List
<
string
>(
LastCodeList
);
List
<
string
>
bijiaoList
=
new
List
<
string
>(
LastCodeList
);
try
try
{
{
Task
<
List
<
string
>>
s
canTask
=
Task
.
Factory
.
StartNew
(
delegate
YuS
canTask
=
Task
.
Factory
.
StartNew
(
delegate
{
{
Thread
.
Sleep
(
100
);
Thread
.
Sleep
(
100
);
NextCodeList
=
CodeManager
.
CameraScan
(
Config
.
GetCameraList
(),
Name
.
Trim
()+
"预扫码"
);
NextCodeList
=
CodeManager
.
CameraScan
(
Config
.
GetCameraList
(),
Name
.
Trim
()+
"预扫码"
);
...
@@ -949,6 +950,9 @@ namespace OnlineStore.DeviceLibrary
...
@@ -949,6 +950,9 @@ namespace OnlineStore.DeviceLibrary
{
{
if
(
CylinderIsOk
(
IO_Type
.
SL_MoveCylinder_Take
,
IO_Type
.
SL_MoveCylinder_Give
))
if
(
CylinderIsOk
(
IO_Type
.
SL_MoveCylinder_Take
,
IO_Type
.
SL_MoveCylinder_Give
))
{
{
if
(
YuScanTask
==
null
||
YuScanTask
.
IsCompleted
)
{
ClearTimeoutAlarm
(
"预扫码结束超时"
);
MoveInfo
.
NextMoveStep
(
LineMoveStep
.
FI_18_ScanCode
);
MoveInfo
.
NextMoveStep
(
LineMoveStep
.
FI_18_ScanCode
);
bool
isScan
=
ConfigAppSettings
.
GetIntValue
(
Setting_Init
.
NeedScanCode
).
Equals
(
1
);
bool
isScan
=
ConfigAppSettings
.
GetIntValue
(
Setting_Init
.
NeedScanCode
).
Equals
(
1
);
...
@@ -1001,6 +1005,11 @@ namespace OnlineStore.DeviceLibrary
...
@@ -1001,6 +1005,11 @@ namespace OnlineStore.DeviceLibrary
InLog
(
"料盘移栽"
+
MoveInfo
.
SLog
+
":不需要扫码"
);
InLog
(
"料盘移栽"
+
MoveInfo
.
SLog
+
":不需要扫码"
);
}
}
}
}
else
if
(
MoveInfo
.
IsTimeOut
(
60
))
{
MoveTimeOut
(
MoveInfo
,
"预扫码结束超时"
);
}
}
else
else
{
{
FI_17_CylinderGive
();
FI_17_CylinderGive
();
...
...
source/DeviceLibrary/assemblyLine/FeedingEquip_OutStore.cs
deleted
100644 → 0
查看文件 @
8a38b11
此文件的差异被折叠,
点击展开。
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论