Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
张东亮
/
AGV_3D_Line
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit c0fb8714
由
张东亮
编写于
2021-06-08 11:23:29 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
日志记录格式变更
1 个父辈
810d0935
全部展开
显示空白字符变更
内嵌
并排
正在显示
13 个修改的文件
包含
327 行增加
和
66 行删除
DeviceLibrary/Control.cs
DeviceLibrary/bean/Agv_Info.cs
DeviceLibrary/bean/Job.cs
DeviceLibrary/bean/JobStep.cs
DeviceLibrary/bean/job/ChargeJob.cs
DeviceLibrary/bean/job/EmptyAGVBackJob.cs
DeviceLibrary/bean/job/EmptyShelfBackJob.cs
DeviceLibrary/bean/job/EnterLeaveShelfJob.cs
DeviceLibrary/bean/job/GoEmptyShelfLineJob.cs
DeviceLibrary/bean/job/GoFullShelfStationJob.cs
DeviceLibrary/bean/job/SendFullShelfToLineJob.cs
DeviceLibrary/bean/job/StandyJob.cs
DeviceLibrary/manager/AGVManager.cs
DeviceLibrary/Control.cs
查看文件 @
c0fb871
...
@@ -14,7 +14,6 @@ namespace DeviceLibrary
...
@@ -14,7 +14,6 @@ namespace DeviceLibrary
public
class
Control
public
class
Control
{
{
private
static
log4net
.
ILog
log
=
log4net
.
LogManager
.
GetLogger
(
"Control"
);
private
static
log4net
.
ILog
log
=
log4net
.
LogManager
.
GetLogger
(
"Control"
);
static
log4net
.
ILog
runLog
=
log4net
.
LogManager
.
GetLogger
(
"RunLog"
);
static
Dictionary
<
string
,
RunInfo
>
runInfoMap
=
new
Dictionary
<
string
,
RunInfo
>();
static
Dictionary
<
string
,
RunInfo
>
runInfoMap
=
new
Dictionary
<
string
,
RunInfo
>();
private
System
.
Timers
.
Timer
AgvCallTimer
;
private
System
.
Timers
.
Timer
AgvCallTimer
;
...
@@ -124,7 +123,7 @@ namespace DeviceLibrary
...
@@ -124,7 +123,7 @@ namespace DeviceLibrary
bool
rtn
;
bool
rtn
;
if
(
AgvStateInProcess
)
return
;
if
(
AgvStateInProcess
)
return
;
AgvStateInProcess
=
true
;
AgvStateInProcess
=
true
;
List
<
AlarmMsg
>
msglist
=
new
List
<
AlarmMsg
>();
//
List<AlarmMsg> msglist = new List<AlarmMsg>();
for
(
int
i
=
0
;
i
<
AGVManager
.
agvInfo
.
Count
;
i
++)
for
(
int
i
=
0
;
i
<
AGVManager
.
agvInfo
.
Count
;
i
++)
{
{
//上报异常
//上报异常
...
@@ -144,44 +143,6 @@ namespace DeviceLibrary
...
@@ -144,44 +143,6 @@ namespace DeviceLibrary
{
{
AgvChanged
?.
Invoke
(
i
);
AgvChanged
?.
Invoke
(
i
);
}
}
Thread
.
Sleep
(
50
);
if
(
stateText
.
Equals
(
"Error"
)
||
stateText
.
Equals
(
"EmergencyStop"
)
||
stateText
.
Equals
(
"Pause"
))
{
isAlarm
=
true
;
msglist
.
Add
(
new
AlarmMsg
(
AGVManager
.
agvInfo
[
i
].
Name
,
"lineAgv."
+
AGVManager
.
agvInfo
[
i
].
Name
+
".Msg"
,
"状态:"
+
stateText
+
""
));
}
if
(!
isAlarm
&&
AGVManager
.
agvInfo
[
i
].
StandTimeOut
)
{
isAlarm
=
true
;
msglist
.
Add
(
new
AlarmMsg
(
AGVManager
.
agvInfo
[
i
].
Name
,
"lineAgv."
+
AGVManager
.
agvInfo
[
i
].
Name
+
".Msg"
,
"在"
+
AGVManager
.
agvInfo
[
i
].
PlaceAliceName
+
"停留超时"
+
(
DateTime
.
Now
-
AGVManager
.
agvInfo
[
i
].
StandStartTime
).
TotalMinutes
.
ToString
(
"f2"
)
+
"分钟"
));
}
if
(!
isAlarm
)
{
try
{
if
(!
AGVManager
.
agvInfo
[
i
].
Msg
.
Equals
(
""
))
{
RunLogInfo
(
new
RunInfo
(
AGVManager
.
agvInfo
[
i
].
Name
,
AGVManager
.
agvInfo
[
i
].
Msg
));
msglist
.
Add
(
new
AlarmMsg
(
AGVManager
.
agvInfo
[
i
].
Name
,
"lineAgv."
+
AGVManager
.
agvInfo
[
i
].
Name
+
".Msg"
,
AGVManager
.
agvInfo
[
i
].
Msg
,
1
));
}
else
{
if
((
AGVManager
.
agvInfo
[
i
].
Place
.
Contains
(
SettingString
.
AutoCharge
)
||
AGVManager
.
agvInfo
[
i
].
Place
.
Contains
(
SettingString
.
Standby
)))
{
msglist
.
Add
(
new
AlarmMsg
(
AGVManager
.
agvInfo
[
i
].
Name
,
"lineAgv."
+
AGVManager
.
agvInfo
[
i
].
Name
+
".Place"
,
AGVManager
.
agvInfo
[
i
].
Place
,
1
));
}
}
}
catch
(
Exception
ex
)
{
log
.
Error
(
AGVManager
.
agvInfo
[
i
].
Name
+
"上报小车运行步骤失败"
+
ex
.
Message
+
ex
.
StackTrace
);
}
}
HttpManager
.
updateDeviceAlarmMsg
(
msglist
);
}
}
catch
(
Exception
ex
)
catch
(
Exception
ex
)
{
{
...
@@ -191,23 +152,6 @@ namespace DeviceLibrary
...
@@ -191,23 +152,6 @@ namespace DeviceLibrary
AgvStateInProcess
=
false
;
AgvStateInProcess
=
false
;
}
}
public
static
void
RunLogInfo
(
RunInfo
info
)
{
if
(
runInfoMap
==
null
)
return
;
if
(
runInfoMap
.
Keys
.
Contains
(
info
.
AGVNum
))
{
if
(!
runInfoMap
[
info
.
AGVNum
].
Equals
(
info
))
{
runLog
.
Info
(
info
.
ToString
());
}
}
else
{
runInfoMap
.
Add
(
info
.
AGVNum
,
info
);
runLog
.
Info
(
info
.
ToString
());
}
}
/// <summary>
/// <summary>
/// 从节点获取任务
/// 从节点获取任务
/// </summary>
/// </summary>
...
...
DeviceLibrary/bean/Agv_Info.cs
查看文件 @
c0fb871
...
@@ -144,7 +144,30 @@ namespace DeviceLibrary
...
@@ -144,7 +144,30 @@ namespace DeviceLibrary
/// 当前料架的工单信息
/// 当前料架的工单信息
/// </summary>
/// </summary>
public
string
BoxDestInfo
{
get
;
set
;
}
=
""
;
public
string
BoxDestInfo
{
get
;
set
;
}
=
""
;
/// <summary>
/// 错误消息
/// </summary>
public
string
ErrorMsg
{
get
;
set
;
}
=
""
;
public
string
ErrorLastTime
{
get
;
set
;
}
=
""
;
/// <summary>
/// 任务期间是否有错误
/// </summary>
public
bool
HasError
{
get
;
set
;
}
=
false
;
public
DateTime
errStartTime
=
DateTime
.
Now
;
public
void
SetErrorMsg
(
string
msg
,
string
lastTime
)
{
if
(
ErrorMsg
.
Equals
(
""
))
{
ErrorMsg
=
msg
;
ErrorLastTime
=
lastTime
;
errStartTime
=
DateTime
.
Now
;
}
}
public
void
ClearErrorMsg
()
{
ErrorLastTime
=
""
;
ErrorMsg
=
""
;
}
/// <summary>
/// <summary>
/// 任务重发
/// 任务重发
/// </summary>
/// </summary>
...
@@ -266,10 +289,68 @@ namespace DeviceLibrary
...
@@ -266,10 +289,68 @@ namespace DeviceLibrary
MissionText
=
missionText
;
MissionText
=
missionText
;
StateKanban
.
ShowInfo
(
"AGV运行信息"
,
missionText
);
StateKanban
.
ShowInfo
(
"AGV运行信息"
,
missionText
);
}
}
CheckErrorState
();
CheckOfflineTimeOut
();
CheckStandTimeOut
(
position
);
CheckStandTimeOut
(
position
);
UpdateDisplayBoard
();
return
isChange
;
return
isChange
;
}
}
DateTime
agvErrorStartTime
=
DateTime
.
MaxValue
;
DateTime
offlineStartTime
=
DateTime
.
MaxValue
;
bool
errorState
=
false
;
int
OfflineLastTimeSeconds
=
30
;
/// <summary>
/// 检查小车是否报错
/// </summary>
/// <returns></returns>
private
void
CheckErrorState
()
{
if
(
StateID
.
Equals
(
eAGVState
.
Error
)
||
StateID
.
Equals
(
eAGVState
.
EmergencyStop
)
||
StateID
.
Equals
(
eAGVState
.
Pause
))
{
//满足条件,计算持续时间
if
(
agvErrorStartTime
==
DateTime
.
MaxValue
)
{
agvErrorStartTime
=
DateTime
.
Now
;
}
TimeSpan
lastTimeSpan
=
DateTime
.
Now
-
agvErrorStartTime
;
errorState
=
(
lastTimeSpan
.
TotalSeconds
>=
OfflineLastTimeSeconds
);
}
else
{
errorState
=
false
;
if
((
DateTime
.
Now
-
agvErrorStartTime
).
TotalSeconds
>
OfflineLastTimeSeconds
)
agvErrorStartTime
=
DateTime
.
Now
;
}
}
/// <summary>
/// 离线超时
/// </summary>
private
bool
offlineTimeOut
=
false
;
/// <summary>
/// 检查小车是否离线超时
/// </summary>
/// <returns></returns>
private
void
CheckOfflineTimeOut
()
{
if
(
CurJob
!=
null
&&
!(
CurJob
is
ChargeJob
)
&&
!
IsCon
)
{
//满足条件,计算持续时间
if
(
offlineStartTime
==
DateTime
.
MaxValue
)
{
offlineStartTime
=
DateTime
.
Now
;
}
TimeSpan
lastTimeSpan
=
DateTime
.
Now
-
offlineStartTime
;
offlineTimeOut
=
(
lastTimeSpan
.
TotalSeconds
>=
OfflineLastTimeSeconds
);
}
else
{
offlineTimeOut
=
false
;
if
((
DateTime
.
Now
-
offlineStartTime
).
TotalSeconds
>
OfflineLastTimeSeconds
)
//LogUtil.error(string.Format("{0} 在{1}离线{2}秒", Name, PlaceAliceName, (DateTime.Now - offlineStartTime).TotalSeconds.ToString("f2")));
offlineStartTime
=
DateTime
.
Now
;
}
}
/// <summary>
/// <summary>
/// 检查小车是否在原地停留超时
/// 检查小车是否在原地停留超时
/// </summary>
/// </summary>
...
@@ -309,6 +390,70 @@ namespace DeviceLibrary
...
@@ -309,6 +390,70 @@ namespace DeviceLibrary
}
}
Position
=
position
;
Position
=
position
;
}
}
private
void
UpdateDisplayBoard
()
{
bool
isAlarm
=
false
;
List
<
AlarmMsg
>
msglist
=
new
List
<
AlarmMsg
>();
try
{
if
(
offlineTimeOut
)
{
isAlarm
=
true
;
SetErrorMsg
(
"在"
+
PlaceAliceName
+
"离线"
,
(
DateTime
.
Now
-
offlineStartTime
).
TotalMinutes
.
ToString
(
"f2"
));
msglist
.
Add
(
new
AlarmMsg
(
Name
,
"lineAgv."
+
Name
+
".Msg"
,
"在"
+
PlaceAliceName
+
"离线"
+
(
DateTime
.
Now
-
offlineStartTime
).
TotalSeconds
.
ToString
(
"f2"
)
+
"秒"
));
}
if
(!
isAlarm
&&
errorState
)
{
isAlarm
=
true
;
SetErrorMsg
(
"状态:"
+
StateID
.
ToString
(),
(
DateTime
.
Now
-
offlineStartTime
).
TotalMinutes
.
ToString
(
"f2"
));
msglist
.
Add
(
new
AlarmMsg
(
Name
,
"lineAgv."
+
Name
+
".Msg"
,
"状态:"
+
StateID
.
ToString
()));
}
if
(!
isAlarm
&&
StandTimeOut
)
{
isAlarm
=
true
;
msglist
.
Add
(
new
AlarmMsg
(
Name
,
"lineAgv."
+
Name
+
".Msg"
,
"在"
+
PlaceAliceName
+
"停留超时"
+
(
DateTime
.
Now
-
StandStartTime
).
TotalMinutes
.
ToString
(
"f2"
)
+
"分钟"
));
}
else
if
(!
isAlarm
&&
HasError
)
{
isAlarm
=
true
;
msglist
.
Add
(
new
AlarmMsg
(
Name
,
"lineAgv."
+
Name
+
".Msg"
,
Msg
));
}
if
(!
isAlarm
)
{
try
{
if
(!
ErrorMsg
.
Equals
(
""
))
//异常消除后正常,打印异常
{
AGVManager
.
ErrorLogRecord
(
new
ErrorInfo
(
this
));
ClearErrorMsg
();
}
if
(!
Msg
.
Equals
(
""
))
{
msglist
.
Add
(
new
AlarmMsg
(
Name
,
"lineAgv."
+
Name
+
".Msg"
,
Msg
,
1
));
}
else
{
if
((
Place
.
Contains
(
SettingString
.
AutoCharge
)
||
Place
.
Contains
(
SettingString
.
Standby
)))
{
msglist
.
Add
(
new
AlarmMsg
(
Name
,
"lineAgv."
+
Name
+
".Place"
,
Place
,
1
));
}
}
}
catch
(
Exception
ex
)
{
Common
.
LogUtil
.
error
(
Name
+
"上报小车运行步骤失败"
+
ex
.
Message
+
ex
.
StackTrace
);
}
}
HttpManager
.
updateDeviceAlarmMsg
(
msglist
);
}
catch
(
Exception
ex
)
{
LogUtil
.
error
(
Name
+
"上报小车信息失败"
+
ex
.
Message
+
ex
.
StackTrace
);
}
}
}
}
}
}
DeviceLibrary/bean/Job.cs
查看文件 @
c0fb871
using
Common
;
using
Common
;
using
System
;
namespace
DeviceLibrary
namespace
DeviceLibrary
{
{
public
abstract
class
Job
public
abstract
class
Job
...
@@ -12,6 +14,7 @@ namespace DeviceLibrary
...
@@ -12,6 +14,7 @@ namespace DeviceLibrary
/// 运行信息
/// 运行信息
/// </summary>
/// </summary>
public
abstract
string
RunInfo
{
get
;
}
public
abstract
string
RunInfo
{
get
;
}
public
string
runInfo
=
""
;
/// <summary>
/// <summary>
/// 根据任务状态继续执行任务
/// 根据任务状态继续执行任务
/// </summary>
/// </summary>
...
@@ -27,7 +30,19 @@ namespace DeviceLibrary
...
@@ -27,7 +30,19 @@ namespace DeviceLibrary
/// 当前任务的执行状态
/// 当前任务的执行状态
/// </summary>
/// </summary>
public
string
CurTaskState
{
get
;
set
;
}
=
"Wait"
;
public
string
CurTaskState
{
get
;
set
;
}
=
"Wait"
;
/// <summary>
/// Job开始时间
/// </summary>
public
DateTime
StartJobTime
{
get
;
set
;
}
=
DateTime
.
Now
;
/// <summary>
/// Job名称
/// </summary>
public
string
JobName
{
get
;
set
;
}
=
""
;
protected
void
RecordRunLog
(
Agv_Info
agv
,
string
JobStep
,
string
runInfo
,
string
targetPlace
)
{
AGVManager
.
RunLogInfo
(
new
RunInfo
(
agv
.
Name
.
PadLeft
(
4
,
'0'
),
JobName
,
targetPlace
,
JobStep
,
runInfo
,
StartJobTime
));
}
/// <summary>
/// <summary>
/// 更新任务信息
/// 更新任务信息
/// </summary>
/// </summary>
...
...
DeviceLibrary/bean/JobStep.cs
查看文件 @
c0fb871
...
@@ -22,7 +22,7 @@ namespace DeviceLibrary
...
@@ -22,7 +22,7 @@ namespace DeviceLibrary
//不为空,且与上一个消息不一样才打印
//不为空,且与上一个消息不一样才打印
if
(!
value
.
Equals
(
msg
))
if
(!
value
.
Equals
(
msg
))
{
{
LogUtil
.
info
(
value
);
//
LogUtil.info(value);
}
}
}
}
msg
=
value
;
msg
=
value
;
...
@@ -53,13 +53,12 @@ namespace DeviceLibrary
...
@@ -53,13 +53,12 @@ namespace DeviceLibrary
/// </summary>
/// </summary>
/// <param name="timeOutMilliseconds"></param>
/// <param name="timeOutMilliseconds"></param>
/// <returns></returns>
/// <returns></returns>
public
bool
IsTimeOut
(
int
timeOutMilliseconds
,
out
double
timeOutValue
)
public
bool
IsTimeOut
(
int
timeOutMilliseconds
,
out
TimeSpan
timeOutValue
)
{
{
timeOutValue
=
0
;
TimeSpan
span
=
DateTime
.
Now
-
startTime
;
TimeSpan
span
=
DateTime
.
Now
-
startTime
;
timeOutValue
=
span
;
if
(
span
.
TotalMilliseconds
>
timeOutMilliseconds
)
if
(
span
.
TotalMilliseconds
>
timeOutMilliseconds
)
{
{
timeOutValue
=
span
.
TotalSeconds
;
return
true
;
return
true
;
}
}
return
false
;
return
false
;
...
...
DeviceLibrary/bean/job/ChargeJob.cs
查看文件 @
c0fb871
此文件的差异被折叠,
点击展开。
DeviceLibrary/bean/job/EmptyAGVBackJob.cs
查看文件 @
c0fb871
此文件的差异被折叠,
点击展开。
DeviceLibrary/bean/job/EmptyShelfBackJob.cs
查看文件 @
c0fb871
此文件的差异被折叠,
点击展开。
DeviceLibrary/bean/job/EnterLeaveShelfJob.cs
查看文件 @
c0fb871
using
Common
;
using
Common
;
using
System
;
namespace
DeviceLibrary
namespace
DeviceLibrary
{
{
/// <summary>
/// <summary>
...
@@ -104,7 +106,7 @@ namespace DeviceLibrary
...
@@ -104,7 +106,7 @@ namespace DeviceLibrary
MissionSys
.
AssignMission
(
agv
,
SettingString
.
Leave
);
MissionSys
.
AssignMission
(
agv
,
SettingString
.
Leave
);
UpdateJobTaskInfo
(
agv
);
UpdateJobTaskInfo
(
agv
);
}
}
else
if
(
jobStep
.
IsTimeOut
(
15000
,
out
double
timeOutValue
))
else
if
(
jobStep
.
IsTimeOut
(
15000
,
out
TimeSpan
timeOutValue
))
{
{
jobStep
.
ToNextStep
(
ENTER_LEAVE_SHELF_STEP
.
NONE
);
jobStep
.
ToNextStep
(
ENTER_LEAVE_SHELF_STEP
.
NONE
);
runInfo
=
"AGV到达 "
+
LineName
+
",15秒后重新向产线发送入料架请求[ReadyEnter]"
;
runInfo
=
"AGV到达 "
+
LineName
+
",15秒后重新向产线发送入料架请求[ReadyEnter]"
;
...
@@ -125,7 +127,7 @@ namespace DeviceLibrary
...
@@ -125,7 +127,7 @@ namespace DeviceLibrary
MissionSys
.
AssignMission
(
agv
,
SettingString
.
Enter
);
MissionSys
.
AssignMission
(
agv
,
SettingString
.
Enter
);
UpdateJobTaskInfo
(
agv
);
UpdateJobTaskInfo
(
agv
);
}
}
else
if
(
jobStep
.
IsTimeOut
(
15000
,
out
double
timeOutValue
))
else
if
(
jobStep
.
IsTimeOut
(
15000
,
out
TimeSpan
timeOutValue
))
{
{
jobStep
.
ToNextStep
(
ENTER_LEAVE_SHELF_STEP
.
NONE
);
jobStep
.
ToNextStep
(
ENTER_LEAVE_SHELF_STEP
.
NONE
);
runInfo
=
"AGV到达 "
+
LineName
+
",15秒后重新向产线发送入料架请求[ReadyLeave]"
;
runInfo
=
"AGV到达 "
+
LineName
+
",15秒后重新向产线发送入料架请求[ReadyLeave]"
;
...
@@ -147,7 +149,7 @@ namespace DeviceLibrary
...
@@ -147,7 +149,7 @@ namespace DeviceLibrary
return
new
EmptyAGVBackJob
(
LineName
);
return
new
EmptyAGVBackJob
(
LineName
);
}
}
else
if
(
jobStep
.
IsTimeOut
(
60000
,
out
double
timeOutValue
))
else
if
(
jobStep
.
IsTimeOut
(
60000
,
out
TimeSpan
timeOutValue
))
{
{
//链条停止
//链条停止
runInfo
=
"料架在["
+
LineName
+
"]离开小车超时["
+
timeOutValue
.
ToString
(
"f1"
)
+
"秒],请检查料架离开小车的情况"
;
runInfo
=
"料架在["
+
LineName
+
"]离开小车超时["
+
timeOutValue
.
ToString
(
"f1"
)
+
"秒],请检查料架离开小车的情况"
;
...
@@ -169,7 +171,7 @@ namespace DeviceLibrary
...
@@ -169,7 +171,7 @@ namespace DeviceLibrary
AGVManager
.
unlockManager
.
DelMission
(
LineName
,
RFID
);
AGVManager
.
unlockManager
.
DelMission
(
LineName
,
RFID
);
return
new
EmptyShelfBackJob
(
LineName
,
eShelfType
.
BigShelf
);
return
new
EmptyShelfBackJob
(
LineName
,
eShelfType
.
BigShelf
);
}
}
else
if
(
jobStep
.
IsTimeOut
(
60000
,
out
double
timeOutValue
))
else
if
(
jobStep
.
IsTimeOut
(
60000
,
out
TimeSpan
timeOutValue
))
{
{
//链条停止
//链条停止
runInfo
=
"料架在["
+
LineName
+
"]进入小车超时["
+
timeOutValue
.
ToString
(
"f1"
)
+
"秒],请检查料架进入小车的情况"
;
runInfo
=
"料架在["
+
LineName
+
"]进入小车超时["
+
timeOutValue
.
ToString
(
"f1"
)
+
"秒],请检查料架进入小车的情况"
;
...
...
DeviceLibrary/bean/job/GoEmptyShelfLineJob.cs
查看文件 @
c0fb871
此文件的差异被折叠,
点击展开。
DeviceLibrary/bean/job/GoFullShelfStationJob.cs
查看文件 @
c0fb871
此文件的差异被折叠,
点击展开。
DeviceLibrary/bean/job/SendFullShelfToLineJob.cs
查看文件 @
c0fb871
此文件的差异被折叠,
点击展开。
DeviceLibrary/bean/job/StandyJob.cs
查看文件 @
c0fb871
...
@@ -14,6 +14,7 @@ namespace DeviceLibrary
...
@@ -14,6 +14,7 @@ namespace DeviceLibrary
public
StandyJob
(
string
agvPlae
)
public
StandyJob
(
string
agvPlae
)
{
{
this
.
agvPlace
=
agvPlae
;
this
.
agvPlace
=
agvPlae
;
JobName
=
"待机任务"
;
}
}
...
@@ -107,9 +108,11 @@ namespace DeviceLibrary
...
@@ -107,9 +108,11 @@ namespace DeviceLibrary
runInfo
=
"在待机位检测到任务,执行任务"
;
runInfo
=
"在待机位检测到任务,执行任务"
;
msg
+=
runInfo
;
msg
+=
runInfo
;
curJobStep
.
Msg
=
msg
;
curJobStep
.
Msg
=
msg
;
RecordRunLog
(
agv
,
curJobStep
.
CurStep
(),
runInfo
,
agv
.
Place
);
return
job
;
return
job
;
}
}
}
}
RecordRunLog
(
agv
,
curJobStep
.
CurStep
(),
runInfo
,
agv
.
Place
);
return
this
;
return
this
;
}
}
...
...
DeviceLibrary/manager/AGVManager.cs
查看文件 @
c0fb871
using
System
;
using
System
;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
System.IO
;
using
System.IO
;
using
System.Linq
;
using
System.Net.Sockets
;
using
System.Net.Sockets
;
using
System.Runtime.InteropServices
;
using
System.Runtime.InteropServices
;
using
System.Text
;
using
System.Text
;
...
@@ -31,7 +32,33 @@ namespace DeviceLibrary
...
@@ -31,7 +32,33 @@ namespace DeviceLibrary
//public static StandbyManager Standby;
//public static StandbyManager Standby;
public
static
List
<
JobType
>
jobTypes
;
public
static
List
<
JobType
>
jobTypes
;
public
static
readonly
string
CONFIG_PATH
=
AppDomain
.
CurrentDomain
.
BaseDirectory
+
"Config\\"
;
public
static
readonly
string
CONFIG_PATH
=
AppDomain
.
CurrentDomain
.
BaseDirectory
+
"Config\\"
;
#
region
任务日志
static
log4net
.
ILog
runLog
=
log4net
.
LogManager
.
GetLogger
(
"RunLog"
);
static
Dictionary
<
string
,
RunInfo
>
runInfoMap
=
new
Dictionary
<
string
,
RunInfo
>();
public
static
void
RunLogInfo
(
RunInfo
info
)
{
if
(
runInfoMap
==
null
)
return
;
if
(
runInfoMap
.
Keys
.
Contains
(
info
.
AGVNum
))
{
if
(!
runInfoMap
[
info
.
AGVNum
].
Equals
(
info
))
{
runLog
.
Info
(
info
.
ToString
());
}
}
else
{
runInfoMap
.
Add
(
info
.
AGVNum
,
info
);
runLog
.
Info
(
info
.
ToString
());
}
}
public
static
void
ErrorLogRecord
(
ErrorInfo
errorInfo
)
{
runLog
.
Info
(
errorInfo
.
ToString
());
}
#
endregion
/// <summary>
/// <summary>
/// 初始化配置
/// 初始化配置
/// </summary>
/// </summary>
...
@@ -833,6 +860,132 @@ namespace DeviceLibrary
...
@@ -833,6 +860,132 @@ namespace DeviceLibrary
}
}
}
}
public
class
RunInfo
{
/// <summary>
/// AGV编号
/// </summary>
public
string
AGVNum
{
get
;
set
;
}
=
""
;
/// <summary>
/// 任务名称
/// </summary>
public
string
TaskName
{
get
;
set
;
}
=
""
;
/// <summary>
/// 目的地
/// </summary>
public
string
TargetPlace
{
get
;
set
;
}
=
""
;
/// <summary>
/// 任务步骤
/// </summary>
public
string
TaskStep
{
get
;
set
;
}
=
""
;
/// <summary>
/// 任务内容
/// </summary>
public
string
MissionInfo
{
get
;
set
;
}
=
""
;
/// <summary>
/// 开始时间
/// </summary>
public
string
DateTime
{
get
;
set
;
}
=
""
;
/// <summary>
/// 结束时间
/// </summary>
public
string
EndDateTime
{
get
;
set
;
}
=
""
;
/// <summary>
/// 任务运行时长
/// </summary>
public
string
TaskRunTime
{
get
;
set
;
}
=
""
;
/// <summary>
/// 类型
/// </summary>
public
string
Type
{
get
;
set
;
}
=
"Task"
;
public
RunInfo
(
string
AGVNum
,
string
taskName
,
string
targetPlace
,
string
taskStep
,
string
missionInfo
,
DateTime
startTime
)
{
//开始时间 2006-01-02 15:04:05
DateTime
=
startTime
.
ToString
(
"yyyy-MM-dd HH:mm:ss"
);
EndDateTime
=
System
.
DateTime
.
Now
.
ToString
(
"yyyy-MM-dd HH:mm:ss"
);
this
.
AGVNum
=
AGVNum
;
MissionInfo
=
missionInfo
;
TaskName
=
taskName
;
TaskRunTime
=
(
System
.
DateTime
.
Now
-
startTime
).
TotalMinutes
.
ToString
(
"f2"
);
TargetPlace
=
targetPlace
;
TaskStep
=
taskStep
;
}
public
RunInfo
()
{
}
public
override
bool
Equals
(
object
obj
)
{
if
(
obj
is
RunInfo
)
{
RunInfo
info
=
(
RunInfo
)
obj
;
if
(
this
.
MissionInfo
.
Equals
(
info
.
MissionInfo
))
return
true
;
this
.
MissionInfo
=
info
.
MissionInfo
;
}
return
false
;
}
public
override
string
ToString
()
{
return
JsonHelper
.
SerializeObject
(
this
);
}
}
public
class
ErrorInfo
{
/// <summary>
/// AGV编号
/// </summary>
public
string
AGVNum
{
get
;
set
;
}
=
""
;
/// <summary>
/// 开始时间
/// </summary>
public
string
DateTime
{
get
;
set
;
}
=
""
;
/// <summary>
/// 结束时间
/// </summary>
public
string
EndDateTime
{
get
;
set
;
}
=
""
;
/// <summary>
/// 异常信息
/// </summary>
public
string
ErrorMsg
{
get
;
set
;
}
=
""
;
public
string
ErrorLastTime
{
get
;
set
;
}
=
""
;
/// <summary>
/// 任务名称
/// </summary>
public
string
TaskName
{
get
;
set
;
}
=
""
;
/// <summary>
/// AGV的当前任务
/// </summary>
public
string
AGVMissionName
{
get
;
set
;
}
=
""
;
public
string
MissionInfo
{
get
;
set
;
}
=
""
;
/// <summary>
/// 目的地
/// </summary>
public
string
TargetPlace
{
get
;
set
;
}
=
""
;
/// <summary>
/// 类型
/// </summary>
public
string
Type
{
get
;
set
;
}
=
"Error"
;
public
ErrorInfo
(
Agv_Info
agv
)
{
DateTime
=
agv
.
errStartTime
.
ToString
(
"yyyy-MM-dd HH:mm:ss"
);
AGVNum
=
agv
.
Name
;
EndDateTime
=
System
.
DateTime
.
Now
.
ToString
(
"yyyy-MM-dd HH:mm:ss"
);
ErrorMsg
=
agv
.
ErrorMsg
;
ErrorLastTime
=
(
System
.
DateTime
.
Now
-
agv
.
errStartTime
).
TotalMinutes
.
ToString
(
"f2"
);
if
(
agv
.
CurJob
!=
null
)
{
TaskName
=
agv
.
CurJob
.
JobName
;
MissionInfo
=
agv
.
CurJob
.
runInfo
;
}
AGVMissionName
=
agv
.
CurTarName
;
TargetPlace
=
agv
.
Place
;
}
public
override
string
ToString
()
{
return
JsonHelper
.
SerializeObject
(
this
);
}
}
public
static
class
Window_API
public
static
class
Window_API
{
{
[
DllImport
(
"user32.dll"
,
EntryPoint
=
"ShowWindow"
,
CharSet
=
CharSet
.
Auto
)]
[
DllImport
(
"user32.dll"
,
EntryPoint
=
"ShowWindow"
,
CharSet
=
CharSet
.
Auto
)]
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论