Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
刘韬
/
1053_CycleLine
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit 63f15d87
由
刘韬
编写于
2023-03-15 15:48:06 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
1
1 个父辈
e9c35325
显示空白字符变更
内嵌
并排
正在显示
25 个修改的文件
包含
345 行增加
和
199 行删除
DeviceLibrary/DeviceLibrary.csproj
DeviceLibrary/DeviceLibrary/AxisBean.cs
DeviceLibrary/DeviceLibrary/RobotMoveHelper.cs
DeviceLibrary/DeviceLibrary/ServerCommunication.cs
DeviceLibrary/VirtuallyStore/VServerComm.cs
DeviceLibrary/VirtuallyStore/VStore.cs
DeviceLibrary/theMachine/DeviceBase.cs
DeviceLibrary/theMachine/DeviceRunControl.cs
DeviceLibrary/theMachine/MainMachine _IOMonitor.cs
DeviceLibrary/theMachine/MainMachine.cs
DeviceLibrary/theMachine/MoveInfo.cs
DeviceLibrary/theMachine/RemoteService.cs
DeviceLibrary/theMachine/RobotManage.cs
DeviceLibrary/theMachine/TrayManager.cs
DeviceLibrary/theMachine/sub/MI.cs
DeviceLibrary/theMachine/sub/TrayStop.cs
DeviceLibrary/userControl/AxisMoveControl.Designer.cs
DeviceLibrary/userControl/ToucDownBtn.cs
LoadCVSLibrary/G.cs
LoadCVSLibrary/LoadCSVLibrary.csproj
RemoteSheardObject/Class1.cs
RemoteSheardObject/RemoteClient.cs
RemoteSheardObject/TheLine.cs
TheMachine/Program.cs
TheMachine/TheMachine.csproj
DeviceLibrary/DeviceLibrary.csproj
查看文件 @
63f15d8
...
@@ -156,6 +156,9 @@
...
@@ -156,6 +156,9 @@
<Compile Include="userControl\FixtureSizeConfigControl.Designer.cs">
<Compile Include="userControl\FixtureSizeConfigControl.Designer.cs">
<DependentUpon>FixtureSizeConfigControl.cs</DependentUpon>
<DependentUpon>FixtureSizeConfigControl.cs</DependentUpon>
</Compile>
</Compile>
<Compile Include="userControl\ToucDownBtn.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="VirtuallyStore\BufferSlotsManger.cs" />
<Compile Include="VirtuallyStore\BufferSlotsManger.cs" />
<Compile Include="VirtuallyStore\CommandList.cs" />
<Compile Include="VirtuallyStore\CommandList.cs" />
<Compile Include="VirtuallyStore\Reference.cs" />
<Compile Include="VirtuallyStore\Reference.cs" />
...
...
DeviceLibrary/DeviceLibrary/AxisBean.cs
查看文件 @
63f15d8
...
@@ -54,66 +54,24 @@ namespace DeviceLibrary
...
@@ -54,66 +54,24 @@ namespace DeviceLibrary
Msg
+=
string
.
Format
(
"...伺服忙碌,急停{0}次"
,
openretry
);
Msg
+=
string
.
Format
(
"...伺服忙碌,急停{0}次"
,
openretry
);
Thread
.
Sleep
(
100
);
Thread
.
Sleep
(
100
);
}
}
//if (AxisManager.GetAlarmStatus(portName, slvAddr) != 0)
//{
// AxisManager.AlarmClear(portName, slvAddr);
// Msg += string.Format("...尝试清除报警第(0)次", openretry);
// Thread.Sleep(100);
//}
AxisManager
.
ServoOn
(
portName
,
slvAddr
);
AxisManager
.
ServoOn
(
portName
,
slvAddr
);
Thread
.
Sleep
(
200
);
Thread
.
Sleep
(
200
);
if
(
AxisManager
.
IsServeoOn
(
portName
,
slvAddr
))
if
(
AxisManager
.
IsServeoOn
(
portName
,
slvAddr
))
{
{
Msg
+=
"...使能成功"
;
Msg
+=
"...
"
+
"
使能成功"
;
openretry
=
0
;
openretry
=
0
;
return
true
;
return
true
;
}
}
else
else
Msg
+=
"...尝试使能失败"
;
Msg
+=
"...
"
+
"
尝试使能失败"
;
Thread
.
Sleep
(
1000
);
Thread
.
Sleep
(
1000
);
if
(
openretry
<
5
)
if
(
openretry
<
5
)
Msg
=
"伺服连接中..."
;
Msg
=
"伺服连接中"
+
"..."
;
}
return
false
;
}
/// <summary>
/// 打开所有轴
/// </summary>
/// <returns></returns>
private
bool
OpenAxis
(
out
string
msg
)
{
msg
=
""
;
//判断轴是否正常
string
portName
=
Config
.
DeviceName
;
short
slvAddr
=
Config
.
GetAxisValue
();
if
(
AxisManager
.
IsServeoOn
(
portName
,
slvAddr
))
{
LogUtil
.
info
(
AxisName
+
"成功打开"
);
}
}
else
{
//清理报警,再重新打开一次
LogUtil
.
info
(
AxisName
+
"第一次打开失败,先清理一下报警,再重新打开一次"
);
AxisManager
.
AlarmClear
(
portName
,
slvAddr
);
System
.
Threading
.
Thread
.
Sleep
(
1000
);
AxisManager
.
ServoOn
(
portName
,
slvAddr
);
System
.
Threading
.
Thread
.
Sleep
(
100
);
if
(
AxisManager
.
IsServeoOn
(
portName
,
slvAddr
))
{
LogUtil
.
info
(
AxisName
+
"清理报警后重新打卡轴成功:"
+
Config
.
Explain
);
}
else
{
AxisManager
.
ServoOff
(
portName
,
slvAddr
);
msg
=
"打开轴"
+
Config
.
Explain
+
"失败 "
;
LogUtil
.
info
(
AxisName
+
msg
);
return
false
;
return
false
;
}
}
}
return
true
;
}
public
void
ServoOff
()
public
void
ServoOff
()
{
{
LogUtil
.
info
(
"ServoOff【"
+
AxisName
+
"】"
);
LogUtil
.
info
(
"ServoOff【"
+
AxisName
+
"】"
);
...
@@ -204,7 +162,7 @@ namespace DeviceLibrary
...
@@ -204,7 +162,7 @@ namespace DeviceLibrary
int
isAlarm
=
AxisManager
.
GetAlarmStatus
(
deviceName
,
axisNo
);
int
isAlarm
=
AxisManager
.
GetAlarmStatus
(
deviceName
,
axisNo
);
if
(
isAlarm
.
Equals
(
1
))
if
(
isAlarm
.
Equals
(
1
))
{
{
clearMsg
=
"清理报警,"
;
clearMsg
=
"清理报警
"
+
"
,"
;
AxisManager
.
AlarmClear
(
deviceName
,
axisNo
);
AxisManager
.
AlarmClear
(
deviceName
,
axisNo
);
Thread
.
Sleep
(
200
);
Thread
.
Sleep
(
200
);
AxisManager
.
ServoOn
(
deviceName
,
axisNo
);
AxisManager
.
ServoOn
(
deviceName
,
axisNo
);
...
@@ -225,7 +183,7 @@ namespace DeviceLibrary
...
@@ -225,7 +183,7 @@ namespace DeviceLibrary
}
}
else
else
{
{
msg
=
$
"{MoveInfo.Name} {MoveInfo.MoveStep} {axis.DisplayStr},
目标位置{targetPosition},当前位置{outCount}
,误差过大,需要报警"
;
msg
=
$
"{MoveInfo.Name} {MoveInfo.MoveStep} {axis.DisplayStr},
"
+
"目标位置"
+
$
"{targetPosition},"
+
"当前位置"
+
$
"{outCount}"
+
"
,误差过大,需要报警"
;
MoveInfo
.
error
(
msg
);
MoveInfo
.
error
(
msg
);
}
}
}
}
...
@@ -253,7 +211,7 @@ namespace DeviceLibrary
...
@@ -253,7 +211,7 @@ namespace DeviceLibrary
}
}
else
else
{
{
msg
=
MoveInfo
.
Name
+
" "
+
MoveInfo
.
MoveStep
+
axis
.
DisplayStr
+
",
收到原点完成信号,当前位置["
+
outCount
+
"],
误差过大,需要报警"
;
msg
=
MoveInfo
.
Name
+
" "
+
MoveInfo
.
MoveStep
+
axis
.
DisplayStr
+
",
"
+
"收到原点完成信号,当前位置"
+
"["
+
outCount
+
"],"
+
"
误差过大,需要报警"
;
MoveInfo
.
error
(
msg
);
MoveInfo
.
error
(
msg
);
}
}
}
}
...
...
DeviceLibrary/DeviceLibrary/RobotMoveHelper.cs
查看文件 @
63f15d8
...
@@ -42,12 +42,14 @@ namespace DeviceLibrary
...
@@ -42,12 +42,14 @@ namespace DeviceLibrary
if
(
robot
.
CurDashboardReponse
.
Contains
(
"PROTECTIVE_STOP"
))
if
(
robot
.
CurDashboardReponse
.
Contains
(
"PROTECTIVE_STOP"
))
{
{
robot
.
SendCMD
(
"unlock protective stop"
,
0
);
robot
.
SendCMD
(
"unlock protective stop"
,
0
);
return
;
}
}
return
;
}
}
robot
.
SendCMD
(
"programState"
,
0
);
robot
.
SendCMD
(
"programState"
,
0
);
Thread
.
Sleep
(
3
00
);
Thread
.
Sleep
(
7
00
);
if
(!
robot
.
CurDashboardReponse
.
Contains
(
"PLAYING"
))
if
(!
robot
.
CurDashboardReponse
.
Contains
(
"PLAYING"
))
{
{
RobotStatus
=
false
;
RobotStatus
=
false
;
...
...
DeviceLibrary/DeviceLibrary/ServerCommunication.cs
查看文件 @
63f15d8
...
@@ -54,6 +54,11 @@ namespace DeviceLibrary
...
@@ -54,6 +54,11 @@ namespace DeviceLibrary
OutMaterialTaskCount
=
data
[
"pizzaBox"
]
+
data
[
"pcb"
]
+
data
[
"tray"
];
OutMaterialTaskCount
=
data
[
"pizzaBox"
]
+
data
[
"pcb"
]
+
data
[
"tray"
];
OutReelTaskCount
=
data
[
"reel"
];
OutReelTaskCount
=
data
[
"reel"
];
}
}
var
remoteLoad
=
new
RemoteLoad
();
remoteLoad
.
RequestLoadInfo
=
new
RequestLoadInfo
();
remoteLoad
.
RequestLoadInfo
.
TrayType
=
TrayTypeE
.
MTP1
.
ToString
();
var
r
=
TrayManager
.
IsNeedProcessNG
(
remoteLoad
);
TheLine
.
UploadCustData
(
"IsNeedProcessNG"
,
r
?
"true"
:
"false"
);
//if (!RobotManage.isRunning)
//if (!RobotManage.isRunning)
// ProcessMsg(MsgService.MSList);
// ProcessMsg(MsgService.MSList);
//if (!string.IsNullOrWhiteSpace(server))
//if (!string.IsNullOrWhiteSpace(server))
...
...
DeviceLibrary/VirtuallyStore/VServerComm.cs
查看文件 @
63f15d8
...
@@ -70,7 +70,7 @@ namespace DeviceLibrary
...
@@ -70,7 +70,7 @@ namespace DeviceLibrary
{
{
if
(
RobotManage
.
isRunning
)
if
(
RobotManage
.
isRunning
)
{
{
ProcessMsg
(
VMsg
.
msg
);
//
ProcessMsg(VMsg.msg);
SendLineStatus
();
SendLineStatus
();
}
}
}
}
...
@@ -83,16 +83,34 @@ namespace DeviceLibrary
...
@@ -83,16 +83,34 @@ namespace DeviceLibrary
}
}
}
}
public
void
ProcessMsg
(
List
<
Msg
>
msg
)
{
public
void
ProcessMsg
(
List
<
Msg
>
msg
)
WarnMsg
=
string
.
Join
(
","
,
msg
.
Select
(
x
=>
{
if
(
msg
==
null
)
return
;
WarnMsg
=
string
.
Join
(
"\r\n"
,
msg
.
Select
(
x
=>
{
{
if
(
x
.
msgLevel
==
MsgLevel
.
warning
||
x
.
msgLevel
==
MsgLevel
.
alarm
)
if
(
x
.
msgLevel
==
MsgLevel
.
warning
||
x
.
msgLevel
==
MsgLevel
.
alarm
)
{
{
return
x
.
msgtxt
;
return
GetMsgPrefix
(
x
.
msgLevel
)
+
x
.
msgtxt
;
}
}
return
null
;
return
null
;
}
}
).
Where
(
x
=>!
string
.
IsNullOrEmpty
(
x
)));
).
Where
(
x
=>
!
string
.
IsNullOrEmpty
(
x
)));
}
string
GetMsgPrefix
(
MsgLevel
msgLevel
)
{
switch
(
msgLevel
)
{
case
MsgLevel
.
info
:
return
"I="
;
case
MsgLevel
.
warning
:
return
"W="
;
case
MsgLevel
.
alarm
:
return
"A="
;
}
return
""
;
}
}
...
...
DeviceLibrary/VirtuallyStore/VStore.cs
查看文件 @
63f15d8
...
@@ -103,22 +103,23 @@ namespace DeviceLibrary
...
@@ -103,22 +103,23 @@ namespace DeviceLibrary
else
if
((
DateTime
.
Now
-
LastStatusTime
).
TotalSeconds
>
30
)
else
if
((
DateTime
.
Now
-
LastStatusTime
).
TotalSeconds
>
30
)
{
{
TerminalError
=
true
;
TerminalError
=
true
;
if
(
InStoreJobInfo
!=
null
)
if
(
InStoreJobInfo
!=
null
)
CurrentTerminalReelID
=
InStoreJobInfo
.
WareNum
;
CurrentTerminalReelID
=
InStoreJobInfo
.
WareNum
;
if
(
RTStoreStatus
==
RTStoreStatus
.
InStoreReady
)
if
(
RTStoreStatus
==
RTStoreStatus
.
InStoreReady
)
{
{
VLog
.
Error
(
$
"入库超时出错,没有执行入库过程,RTStoreStatus={RTStoreStatus}:"
+
InStoreJobInfo
?.
ToStr
());
VLog
.
Error
(
$
"入库超时出错,没有执行入库过程,RTStoreStatus={RTStoreStatus}:"
+
InStoreJobInfo
?.
ToStr
());
CurrentTowerStatusText
=
crc
.
GetString
(
"Res0065"
,
"入库错误,没有执行入库过程"
);
CurrentTowerStatusText
=
crc
.
GetString
(
"Res0065"
,
"入库错误,没有执行入库过程"
);
}
}
else
if
(
RTStoreStatus
==
RTStoreStatus
.
LockToInStore
)
else
if
(
RTStoreStatus
==
RTStoreStatus
.
LockToInStore
)
{
{
VLog
.
Error
(
$
"入库超时出错,没有检测到料盘,RTStoreStatus={RTStoreStatus}:"
+
InStoreJobInfo
?.
ToStr
());
VLog
.
Error
(
$
"入库超时出错,没有检测到料盘,RTStoreStatus={RTStoreStatus}:"
+
InStoreJobInfo
?.
ToStr
());
CurrentTowerStatusText
=
crc
.
GetString
(
"Res0065"
,
"入库错误,没有执行入库过程"
);
CurrentTowerStatusText
=
crc
.
GetString
(
"Res0065"
,
"入库错误,没有执行入库过程"
);
}
}
else
else
{
{
VLog
.
Error
(
$
"未知状态超时,RTStoreStatus={RTStoreStatus}:"
+
InStoreJobInfo
?.
ToStr
());
VLog
.
Error
(
$
"未知状态超时,RTStoreStatus={RTStoreStatus}:"
+
InStoreJobInfo
?.
ToStr
());
}
}
Msg
.
add
(
$
"TerminalError"
+
"入库超时"
,
MsgLevel
.
warning
);
}
}
}
}
else
if
(
ti
.
StatusCode
==
1031
)
else
if
(
ti
.
StatusCode
==
1031
)
...
@@ -144,7 +145,7 @@ namespace DeviceLibrary
...
@@ -144,7 +145,7 @@ namespace DeviceLibrary
if
(!
ServerCM
.
BeginInStore
(
CID
,
InStoreJobInfo
,
VLog
))
if
(!
ServerCM
.
BeginInStore
(
CID
,
InStoreJobInfo
,
VLog
))
{
{
RTStoreStatus
=
RTStoreStatus
.
LockToInStore
;
RTStoreStatus
=
RTStoreStatus
.
LockToInStore
;
Msg
.
add
(
CID
+
crc
.
GetString
(
"Res0051"
,
"无法入库"
),
MsgLevel
.
alarm
);
//
Msg.add(CID + crc.GetString("Res0051", "无法入库"), MsgLevel.alarm);
VLog
.
Info
(
"入库指令失败:"
+
InStoreJobInfo
.
ToStr
());
VLog
.
Info
(
"入库指令失败:"
+
InStoreJobInfo
.
ToStr
());
}
}
CurrentTerminalReelID
=
InStoreJobInfo
.
WareNum
;
CurrentTerminalReelID
=
InStoreJobInfo
.
WareNum
;
...
@@ -179,8 +180,9 @@ namespace DeviceLibrary
...
@@ -179,8 +180,9 @@ namespace DeviceLibrary
}
}
else
if
(
ti
.
StatusCode
==
310117
||
ti
.
StatusCode
==
310249
)
else
if
(
ti
.
StatusCode
==
310117
||
ti
.
StatusCode
==
310249
)
{
{
Msg
.
add
(
$
"StatusCode:{ti.StatusCode},StatusText:{ti.StatusText},OnlineStatus:{ti.OnlineStatus}"
,
MsgLevel
.
warning
);
RTStoreStatus
=
RTStoreStatus
.
InStoreError
;
RTStoreStatus
=
RTStoreStatus
.
InStoreError
;
ServerCM
.
storeStatus
=
StoreStatus
.
InStore
Error
;
ServerCM
.
storeStatus
=
StoreStatus
.
InStore
Faild
;
InStoreJobInfo
=
null
;
InStoreJobInfo
=
null
;
}
}
else
if
(
ti
.
StatusCode
<
10000
)
else
if
(
ti
.
StatusCode
<
10000
)
...
@@ -188,10 +190,12 @@ namespace DeviceLibrary
...
@@ -188,10 +190,12 @@ namespace DeviceLibrary
RTStoreStatus
=
RTStoreStatus
.
Busy
;
RTStoreStatus
=
RTStoreStatus
.
Busy
;
ServerCM
.
storeStatus
=
StoreStatus
.
None
;
ServerCM
.
storeStatus
=
StoreStatus
.
None
;
//VLog.Info($"StatusCode:{ti.StatusCode},StatusText:{ti.StatusText},OnlineStatus:{ti.OnlineStatus}");
//VLog.Info($"StatusCode:{ti.StatusCode},StatusText:{ti.StatusText},OnlineStatus:{ti.OnlineStatus}");
Msg
.
add
(
$
"StatusCode:{ti.StatusCode},StatusText:{ti.StatusText},OnlineStatus:{ti.OnlineStatus}"
,
MsgLevel
.
alarm
);
}
}
else
else
{
{
//VLog.Error($"StatusCode:{ti.StatusCode},StatusText:{ti.StatusText},OnlineStatus:{ti.OnlineStatus}");
//VLog.Error($"StatusCode:{ti.StatusCode},StatusText:{ti.StatusText},OnlineStatus:{ti.OnlineStatus}");
Msg
.
add
(
$
"StatusCode:{ti.StatusCode},StatusText:{ti.StatusText},OnlineStatus:{ti.OnlineStatus}"
,
MsgLevel
.
alarm
);
ServerCM
.
storeStatus
=
StoreStatus
.
InTrouble
;
ServerCM
.
storeStatus
=
StoreStatus
.
InTrouble
;
RTStoreStatus
=
RTStoreStatus
.
Error
;
RTStoreStatus
=
RTStoreStatus
.
Error
;
}
}
...
@@ -239,8 +243,14 @@ namespace DeviceLibrary
...
@@ -239,8 +243,14 @@ namespace DeviceLibrary
SlotsInfo
[
$
"{w}x{h}"
]
=
$
"{ti.Slots[i].Slots_used}/{ti.Slots[i].Slots_free}"
;
SlotsInfo
[
$
"{w}x{h}"
]
=
$
"{ti.Slots[i].Slots_used}/{ti.Slots[i].Slots_free}"
;
}
}
}
}
catch
(
Exception
ex
)
{
catch
(
Exception
ex
)
VLog
.
Error
(
"VStore Error:"
+
ex
);
{
VLog
.
Error
(
"VStore Error:"
+
ex
);
}
finally
{
ServerCM
.
ProcessMsg
(
Msg
.
msg
);
Msg
.
clear
();
}
}
}
}
public
Dictionary
<
string
,
string
>
SlotsInfo
=
new
Dictionary
<
string
,
string
>();
public
Dictionary
<
string
,
string
>
SlotsInfo
=
new
Dictionary
<
string
,
string
>();
...
@@ -266,6 +276,8 @@ namespace DeviceLibrary
...
@@ -266,6 +276,8 @@ namespace DeviceLibrary
public
volatile
JobInfo
InStoreJobInfo
;
public
volatile
JobInfo
InStoreJobInfo
;
StoreJobList
OutStoreJobList
;
StoreJobList
OutStoreJobList
;
public
void
RequestInStore
(
JobInfo
jobInfo
)
{
public
void
RequestInStore
(
JobInfo
jobInfo
)
{
LastStatusTime
=
DateTime
.
Now
;
TerminalError
=
false
;
InStoreJobInfo
=
jobInfo
.
Clone
();
InStoreJobInfo
=
jobInfo
.
Clone
();
//return vc.BeginInStore(CID, jobInfo);
//return vc.BeginInStore(CID, jobInfo);
}
}
...
...
DeviceLibrary/theMachine/DeviceBase.cs
查看文件 @
63f15d8
...
@@ -148,15 +148,17 @@ namespace DeviceLibrary
...
@@ -148,15 +148,17 @@ namespace DeviceLibrary
{
{
WarnMsg
=
MoveInfo
.
Name
+
"["
+
MoveInfo
.
MoveStep
+
"] "
+
crc
.
GetString
(
"Res0157"
,
"等待"
)
+
"("
+
io
.
DisplayStr
+
"="
+
wait
.
IoValue
+
$
")"
+
crc
.
GetString
(
"Res0158"
,
"超时"
);
WarnMsg
=
MoveInfo
.
Name
+
"["
+
MoveInfo
.
MoveStep
+
"] "
+
crc
.
GetString
(
"Res0157"
,
"等待"
)
+
"("
+
io
.
DisplayStr
+
"="
+
wait
.
IoValue
+
$
")"
+
crc
.
GetString
(
"Res0158"
,
"超时"
);
Msg
.
add
(
WarnMsg
,
wait
.
NeedAlarm
?
MsgLevel
.
alarm
:
MsgLevel
.
warning
);
if
(
wait
.
NeedAlarm
)
if
(
wait
.
NeedAlarm
)
{
Msg
.
add
(
WarnMsg
,
wait
.
NeedAlarm
?
MsgLevel
.
alarm
:
MsgLevel
.
warning
);
RobotManage
.
UserPause
(
WarnMsg
);
RobotManage
.
UserPause
(
WarnMsg
);
return
true
;
}
if
(
NoAlarm
())
if
(
NoAlarm
())
{
{
//Alarm(AlarmType.IoSingleTimeOut, WarnMsg);
//Alarm(AlarmType.IoSingleTimeOut, WarnMsg);
MoveInfo
.
error
(
WarnMsg
);
//
MoveInfo.error(WarnMsg);
//MoveInfo.errlog(WarnMsg);
//MoveInfo.errlog(WarnMsg);
if
(!
MoveInfo
.
OneWaitCanEndStep
)
if
(!
MoveInfo
.
OneWaitCanEndStep
)
{
{
...
...
DeviceLibrary/theMachine/DeviceRunControl.cs
查看文件 @
63f15d8
...
@@ -15,6 +15,7 @@ namespace DeviceLibrary
...
@@ -15,6 +15,7 @@ namespace DeviceLibrary
public
class
DeviceRunControl
public
class
DeviceRunControl
{
{
public
static
List
<
ManualResetEvent
>
manualResets
=
new
List
<
ManualResetEvent
>();
public
static
List
<
ManualResetEvent
>
manualResets
=
new
List
<
ManualResetEvent
>();
public
static
List
<
DeviceRunControl
>
DeviceRunControlList
=
new
List
<
DeviceRunControl
>();
List
<
IDevice
>
DevicesList
;
List
<
IDevice
>
DevicesList
;
string
DeviceListName
;
string
DeviceListName
;
ManualResetEvent
resetEvent
=
new
ManualResetEvent
(
false
);
ManualResetEvent
resetEvent
=
new
ManualResetEvent
(
false
);
...
@@ -31,15 +32,19 @@ namespace DeviceLibrary
...
@@ -31,15 +32,19 @@ namespace DeviceLibrary
resetEvent
.
Reset
();
resetEvent
.
Reset
();
}
}
void
Run
()
{
void
Run
()
{
LogUtil
.
info
(
$
"{DeviceListName}设备线程启动"
);
LogUtil
.
info
(
$
"{DeviceListName}
设备线程启动"
);
while
(
RobotManage
.
mainMachine
.
mstart
)
while
(
RobotManage
.
mainMachine
.
mstart
)
{
{
Thread
.
Sleep
(
150
);
try
{
Thread
.
Sleep
(
200
);
ManualResetEvent
.
WaitAll
(
new
ManualResetEvent
[]
{
RobotManage
.
mainMachine
.
ResetEvent
});
ManualResetEvent
.
WaitAll
(
new
ManualResetEvent
[]
{
RobotManage
.
mainMachine
.
ResetEvent
});
Debug
.
WriteLine
(
$
"DeviceRunControl canRunning:{RobotManage.mainMachine.canRunning}, mstart:{RobotManage.mainMachine.mstart}"
);
Debug
.
WriteLine
(
$
"DeviceRunControl:{DeviceListName} canRunning:{RobotManage.mainMachine.canRunning}, mstart:{RobotManage.mainMachine.mstart}"
);
if
(!
RobotManage
.
mainMachine
.
canRunning
||
!
RobotManage
.
mainMachine
.
mstart
)
if
(!
RobotManage
.
mainMachine
.
canRunning
||
!
RobotManage
.
mainMachine
.
mstart
)
{
{
if
(
RobotManage
.
mainMachine
.
mstart
)
{
if
(
RobotManage
.
mainMachine
.
mstart
)
{
DevicesList
.
ForEach
(
x
=>
DevicesList
.
ForEach
(
x
=>
{
{
x
.
FrontStopProcess
();
x
.
FrontStopProcess
();
...
@@ -55,9 +60,9 @@ namespace DeviceLibrary
...
@@ -55,9 +60,9 @@ namespace DeviceLibrary
}
}
catch
(
Exception
ex
)
catch
(
Exception
ex
)
{
{
LogUtil
.
error
(
$
"{DeviceListName} 出错:"
+
ex
);
MsgService
.
MSList
[
x
.
GroupName
].
add
(
ex
.
ToString
(),
MsgLevel
.
warning
);
MsgService
.
MSList
[
x
.
GroupName
].
add
(
ex
.
ToString
(),
MsgLevel
.
warning
);
MsgService
.
MSList
[
x
.
GroupName
].
setlogones
();
MsgService
.
MSList
[
x
.
GroupName
].
setlogones
();
LogUtil
.
error
(
$
"{DeviceListName} 出错:"
+
ex
);
}
}
finally
finally
{
{
...
@@ -65,7 +70,6 @@ namespace DeviceLibrary
...
@@ -65,7 +70,6 @@ namespace DeviceLibrary
}
}
});
});
//ProcessMoveinfoEvent?.Invoke(MoveInfo.List);
if
(!
RobotManage
.
mainMachine
.
UserPause
&&
RobotManage
.
mainMachine
.
mstart
)
if
(!
RobotManage
.
mainMachine
.
UserPause
&&
RobotManage
.
mainMachine
.
mstart
)
{
{
DevicesList
.
ForEach
(
x
=>
DevicesList
.
ForEach
(
x
=>
...
@@ -73,10 +77,26 @@ namespace DeviceLibrary
...
@@ -73,10 +77,26 @@ namespace DeviceLibrary
MsgService
.
MSList
[
x
.
GroupName
].
clear
();
MsgService
.
MSList
[
x
.
GroupName
].
clear
();
});
});
}
}
}
catch
(
Exception
ex
)
{
LogUtil
.
error
(
$
"{DeviceListName} 设备线程出错:"
+
ex
);
}
finally
{
resetEvent
.
Set
();
resetEvent
.
Set
();
}
}
LogUtil
.
info
(
$
"{DeviceListName} 设备线程已退出."
);
}
public
static
void
AddDevice
(
string
name
,
List
<
IDevice
>
devices
)
{
DeviceRunControlList
.
Add
(
new
DeviceRunControl
(
name
,
devices
));
}
}
LogUtil
.
info
(
$
"{DeviceListName}设备线程已退出."
);
public
static
void
StartAll
()
{
DeviceRunControlList
.
ForEach
(
x
=>
{
x
.
Start
();
});
}
}
}
}
}
}
\ No newline at end of file
\ No newline at end of file
DeviceLibrary/theMachine/MainMachine _IOMonitor.cs
查看文件 @
63f15d8
...
@@ -16,7 +16,7 @@ namespace DeviceLibrary
...
@@ -16,7 +16,7 @@ namespace DeviceLibrary
{
{
void
ioMonitor
()
void
ioMonitor
()
{
{
if
(
IOValue
(
IO_Type
.
Airpressure_Check
).
Equals
(
IO_VALUE
.
LOW
))
{
if
(
IOValue
(
IO_Type
.
Airpressure_Check
).
Equals
(
IO_VALUE
.
LOW
)
&&
!
G
.
simulate
)
{
Msg
.
add
(
crc
.
GetString
(
"Res0166"
,
"未检测到气压信号."
),
MsgLevel
.
warning
);
Msg
.
add
(
crc
.
GetString
(
"Res0166"
,
"未检测到气压信号."
),
MsgLevel
.
warning
);
}
}
}
}
...
...
DeviceLibrary/theMachine/MainMachine.cs
查看文件 @
63f15d8
...
@@ -230,20 +230,23 @@ namespace DeviceLibrary
...
@@ -230,20 +230,23 @@ namespace DeviceLibrary
internal
DateTime
checkAlarmTime
=
DateTime
.
Now
;
internal
DateTime
checkAlarmTime
=
DateTime
.
Now
;
public
bool
DeviceCheck
()
{
public
bool
DeviceCheck
()
{
bool
ok
=
true
;
bool
ok
=
true
;
isInSuddenDown
=
IOValue
(
IO_Type
.
SuddenStop_BTN
).
Equals
(
IO_VALUE
.
LOW
);
if
(
IOValue
(
IO_Type
.
AutoRun_Single
).
Equals
(
IO_VALUE
.
LOW
))
{
if
(
UserPause
)
Msg
.
add
(
crc
.
GetString
(
"Res0001"
,
"自动运行开关未开"
),
MsgLevel
.
warning
);
{
Msg
.
add
(
crc
.
GetString
(
"Res0175"
,
"系统暂停"
),
MsgLevel
.
warning
);
DeviceSuddenStop
();
DeviceSuddenStop
();
lastSafeCheckStatus
=
false
;
lastSafeCheckStatus
=
false
;
ok
=
false
;
ok
=
false
;
return
ok
;
}
}
else
if
(
UserPause
)
if
(
G
.
simulate
)
{
return
true
;
Msg
.
add
(
crc
.
GetString
(
"Res0175"
,
"系统暂停"
),
MsgLevel
.
warning
);
isInSuddenDown
=
IOValue
(
IO_Type
.
SuddenStop_BTN
).
Equals
(
IO_VALUE
.
LOW
);
if
(
IOValue
(
IO_Type
.
AutoRun_Single
).
Equals
(
IO_VALUE
.
LOW
))
{
Msg
.
add
(
crc
.
GetString
(
"Res0001"
,
"自动运行开关未开"
),
MsgLevel
.
warning
);
DeviceSuddenStop
();
DeviceSuddenStop
();
lastSafeCheckStatus
=
false
;
lastSafeCheckStatus
=
false
;
ok
=
false
;
ok
=
false
;
return
ok
;
}
}
else
if
(
isInSuddenDown
)
else
if
(
isInSuddenDown
)
{
{
...
@@ -255,7 +258,7 @@ namespace DeviceLibrary
...
@@ -255,7 +258,7 @@ namespace DeviceLibrary
Msg
.
add
(
crc
.
GetString
(
"Res0177"
,
"系统需要重置"
),
MsgLevel
.
alarm
);
Msg
.
add
(
crc
.
GetString
(
"Res0177"
,
"系统需要重置"
),
MsgLevel
.
alarm
);
ok
=
false
;
ok
=
false
;
}
}
if
(
IOValue
(
IO_Type
.
Airpressure_Check
).
Equals
(
IO_VALUE
.
LOW
))
if
(
IOValue
(
IO_Type
.
Airpressure_Check
).
Equals
(
IO_VALUE
.
LOW
)
&&
!
G
.
simulate
)
{
{
if
(
lastAirCloseTime
==
DateTime
.
MinValue
)
if
(
lastAirCloseTime
==
DateTime
.
MinValue
)
lastAirCloseTime
=
DateTime
.
Now
;
lastAirCloseTime
=
DateTime
.
Now
;
...
...
DeviceLibrary/theMachine/MoveInfo.cs
查看文件 @
63f15d8
...
@@ -262,32 +262,28 @@ namespace DeviceLibrary
...
@@ -262,32 +262,28 @@ namespace DeviceLibrary
{
{
if
(
IsHomeMove
)
if
(
IsHomeMove
)
{
{
return
"轴
【"
+
AxisInfo
.
DisplayStr
+
"】
原点返回"
;
return
"轴
"
+
"【"
+
AxisInfo
.
DisplayStr
+
"】"
+
"
原点返回"
;
}
}
else
else
{
{
return
"轴
【"
+
AxisInfo
.
DisplayStr
+
"】绝对运动,目标位置
【"
+
TargetPosition
+
"】"
;
return
"轴
"
+
"【"
+
AxisInfo
.
DisplayStr
+
"】"
+
"绝对运动,目标位置"
+
"
【"
+
TargetPosition
+
"】"
;
}
}
}
}
else
if
(
WaitType
.
Equals
(
WaitEnum
.
W002_IOValue
))
else
if
(
WaitType
.
Equals
(
WaitEnum
.
W002_IOValue
))
{
{
return
"等待【"
+
IoType
+
"】=【"
+
IoValue
+
"】"
;
return
"等待
"
+
"
【"
+
IoType
+
"】=【"
+
IoValue
+
"】"
;
}
}
else
if
(
WaitType
.
Equals
(
WaitEnum
.
W003_Time
))
else
if
(
WaitType
.
Equals
(
WaitEnum
.
W003_Time
))
{
{
return
"时间等待:【"
+
TimeMSeconds
+
"】毫秒"
;
return
"时间等待"
+
":【"
+
TimeMSeconds
+
"】"
+
"毫秒"
;
}
else
if
(
WaitType
.
Equals
(
WaitEnum
.
W005_ShuoKe
))
{
return
"硕科电机目标位置:【"
+
TargetPosition
+
"】 "
;
}
}
else
if
(
WaitType
.
Equals
(
WaitEnum
.
W006_AxisOrg
))
else
if
(
WaitType
.
Equals
(
WaitEnum
.
W006_AxisOrg
))
{
{
return
"轴
【"
+
AxisInfo
.
DisplayStr
+
"】ORG信号:【"
+
IoValue
+
"】
"
;
return
"轴
"
+
"【"
+
AxisInfo
.
DisplayStr
+
"】"
+
"ORG信号"
+
":【"
+
IoValue
+
"】
"
;
}
}
else
if
(
WaitType
.
Equals
(
WaitEnum
.
W007_ReelHeight
))
else
if
(
WaitType
.
Equals
(
WaitEnum
.
W007_ReelHeight
))
{
{
return
"料盘高度
【"
+
TargetPosition
+
"】
"
;
return
"料盘高度
"
+
"【"
+
TargetPosition
+
"】
"
;
}
}
else
if
(
WaitType
.
Equals
(
WaitEnum
.
W008_BatchAxis
))
else
if
(
WaitType
.
Equals
(
WaitEnum
.
W008_BatchAxis
))
{
{
...
@@ -303,7 +299,7 @@ namespace DeviceLibrary
...
@@ -303,7 +299,7 @@ namespace DeviceLibrary
}
}
else
else
{
{
return
"Wait
位置类型:Wait
Type=【"
+
WaitType
+
"】"
;
return
"WaitType=【"
+
WaitType
+
"】"
;
}
}
}
}
/// <summary>
/// <summary>
...
...
DeviceLibrary/theMachine/RemoteService.cs
查看文件 @
63f15d8
...
@@ -59,7 +59,9 @@ namespace DeviceLibrary
...
@@ -59,7 +59,9 @@ namespace DeviceLibrary
{
{
var
remoteLoad
=
JsonConvert
.
DeserializeObject
<
RemoteLoad
>(
message
);
var
remoteLoad
=
JsonConvert
.
DeserializeObject
<
RemoteLoad
>(
message
);
Seq
=
remoteLoad
.
Seq
;
Seq
=
remoteLoad
.
Seq
;
lock
(
lastresult
)
{
lastresult
[
Seq
]
=
RemoteResult
.
None
;
lastresult
[
Seq
]
=
RemoteResult
.
None
;
}
switch
(
remoteLoad
.
Action
)
switch
(
remoteLoad
.
Action
)
{
{
case
"SetTrayRequest"
:
case
"SetTrayRequest"
:
...
@@ -77,9 +79,15 @@ namespace DeviceLibrary
...
@@ -77,9 +79,15 @@ namespace DeviceLibrary
case
"IsNeedProcessNG"
:
case
"IsNeedProcessNG"
:
isok
=
TrayManager
.
IsNeedProcessNG
(
remoteLoad
);
isok
=
TrayManager
.
IsNeedProcessNG
(
remoteLoad
);
break
;
break
;
case
"Heartbeats"
:
//客户端心跳包
isok
=
true
;
break
;
case
"OK"
:
case
"OK"
:
case
"FAIL"
:
case
"FAIL"
:
lock
(
lastresult
)
{
lastresult
[
Seq
]
=
remoteLoad
.
Action
==
"OK"
?
RemoteResult
.
True
:
RemoteResult
.
False
;
lastresult
[
Seq
]
=
remoteLoad
.
Action
==
"OK"
?
RemoteResult
.
True
:
RemoteResult
.
False
;
}
LogUtil
.
info
(
$
"[{remoteLoad.GroupName}] Revice Command Callback:"
+
remoteLoad
.
Action
);
LogUtil
.
info
(
$
"[{remoteLoad.GroupName}] Revice Command Callback:"
+
remoteLoad
.
Action
);
return
;
return
;
default
:
default
:
...
@@ -113,7 +121,10 @@ namespace DeviceLibrary
...
@@ -113,7 +121,10 @@ namespace DeviceLibrary
if
(
remoteLoad
.
RequestLoadInfo
!=
null
&&
string
.
IsNullOrEmpty
(
remoteLoad
.
RequestLoadInfo
.
DeviceGroupName
))
if
(
remoteLoad
.
RequestLoadInfo
!=
null
&&
string
.
IsNullOrEmpty
(
remoteLoad
.
RequestLoadInfo
.
DeviceGroupName
))
remoteLoad
.
RequestLoadInfo
.
DeviceGroupName
=
GroupName
;
remoteLoad
.
RequestLoadInfo
.
DeviceGroupName
=
GroupName
;
LogUtil
.
info
(
$
"[{GroupName}],发送:{remoteLoad.Action},Seq:{remoteLoad.Seq}"
);
LogUtil
.
info
(
$
"[{GroupName}],发送:{remoteLoad.Action},Seq:{remoteLoad.Seq}"
);
lock
(
lastresult
)
{
lastresult
[
remoteLoad
.
Seq
]
=
RemoteResult
.
None
;
lastresult
[
remoteLoad
.
Seq
]
=
RemoteResult
.
None
;
}
SendMessage
(
GroupName
,
remoteLoad
);
SendMessage
(
GroupName
,
remoteLoad
);
return
WaitResult
(
GroupName
,
remoteLoad
.
Seq
,
waittime
);
return
WaitResult
(
GroupName
,
remoteLoad
.
Seq
,
waittime
);
}
}
...
...
DeviceLibrary/theMachine/RobotManage.cs
查看文件 @
63f15d8
...
@@ -54,9 +54,10 @@ namespace DeviceLibrary
...
@@ -54,9 +54,10 @@ namespace DeviceLibrary
{
{
LogUtil
.
info
(
"加载位置文件:"
+
configFile
);
LogUtil
.
info
(
"加载位置文件:"
+
configFile
);
}
}
else
{
else
{
IsLoadOk
=
false
;
IsLoadOk
=
false
;
msg
+=
crc
.
GetString
(
"Res0180"
,
"找不到库位配置文件"
)
+
"\n"
;
msg
+=
crc
.
GetString
(
"Res0180"
,
"找不到库位配置文件"
)
+
"\n"
;
}
}
string
MI1PostionFile
=
"config\\MI1Postion.csv"
;
string
MI1PostionFile
=
"config\\MI1Postion.csv"
;
...
@@ -76,34 +77,12 @@ namespace DeviceLibrary
...
@@ -76,34 +77,12 @@ namespace DeviceLibrary
Robot_CI
.
SetSpeedRate
(
Setting_Init
.
URRobot_CI_Speed_Rate
);
Robot_CI
.
SetSpeedRate
(
Setting_Init
.
URRobot_CI_Speed_Rate
);
VStoreCollection
=
new
VStoreCollection
();
VStoreCollection
=
new
VStoreCollection
();
//if (Robot_MI1.StartRobot()) {
// LogUtil.info("MI1 UR机器人启动成功,"+ Robot_MI1.GetStatus());
//} else {
// IsLoadOk = false;
// msg += "MI1 UR机器人启动失败" + "\n";
//}
//if (Robot_MI2.StartRobot())
//{
// LogUtil.info("MI2 UR机器人启动成功," + Robot_MI2.GetStatus());
//}
//else
//{
// IsLoadOk = false;
// msg += "MI2 UR机器人启动失败" + "\n";
//}
//if (Robot_CI.StartRobot())
//{
// LogUtil.info("CI UR机器人启动成功," + Robot_CI.GetStatus());
//}
//else
//{
// IsLoadOk = false;
// msg += "CI UR机器人启动失败" + "\n";
//}
CodeManager
.
LoadConfig
();
CodeManager
.
LoadConfig
();
RemoteService
.
Init
();
RemoteService
.
Init
();
mainMachine
=
new
MainMachine
(
out
string
m
);
mainMachine
=
new
MainMachine
(
out
string
m
);
if
(!
string
.
IsNullOrWhiteSpace
(
m
))
{
if
(!
string
.
IsNullOrWhiteSpace
(
m
))
{
IsLoadOk
=
false
;
IsLoadOk
=
false
;
msg
+=
m
;
msg
+=
m
;
}
}
...
@@ -111,14 +90,20 @@ namespace DeviceLibrary
...
@@ -111,14 +90,20 @@ namespace DeviceLibrary
if
(!
IOManager
.
ConnectionIOList
(
new
List
<
string
>()))
if
(!
IOManager
.
ConnectionIOList
(
new
List
<
string
>()))
{
{
IsLoadOk
=
false
;
IsLoadOk
=
false
;
msg
+=
crc
.
GetString
(
"Res0181"
,
"IO板卡初始化失败"
)
+
"\n"
;
msg
+=
crc
.
GetString
(
"Res0181"
,
"IO板卡初始化失败"
)
+
"\n"
;
}
}
DeviceRunControl
.
AddDevice
(
"SideMove"
,
SideMove
.
DeviceList
.
Values
.
ToList
<
IDevice
>());
DeviceRunControl
.
AddDevice
(
"TransplantMove"
,
TransplantMove
.
DeviceList
.
Values
.
ToList
<
IDevice
>());
//DeviceRunControl.AddDevice("TrayStop", TrayStop.DeviceList.Values.ToList<IDevice>());
DeviceRunControl
.
AddDevice
(
"MI"
,
MI
.
DeviceList
.
Values
.
ToList
<
IDevice
>());
TrayStop
.
DeviceList
.
Values
.
ToList
<
IDevice
>().
ForEach
(
device
=>
{
DeviceRunControl
.
AddDevice
(
device
.
GroupName
,
new
List
<
IDevice
>()
{
device
});
});
//IsLoadOk = true;
if
(
G
.
simulate
)
IsLoadOk
=
true
;
}
}
catch
(
Exception
ex
)
{
catch
(
Exception
ex
)
{
LogUtil
.
error
(
ex
.
ToString
());
LogUtil
.
error
(
ex
.
ToString
());
MessageBox
.
Show
(
ex
.
ToString
());
MessageBox
.
Show
(
ex
.
ToString
());
LoadFinishEvent
?.
Invoke
(
false
,
ex
.
Message
);
LoadFinishEvent
?.
Invoke
(
false
,
ex
.
Message
);
...
@@ -142,20 +127,12 @@ namespace DeviceLibrary
...
@@ -142,20 +127,12 @@ namespace DeviceLibrary
mainThread
.
Start
();
mainThread
.
Start
();
VStoreCollection
.
Start
();
VStoreCollection
.
Start
();
Thread
.
Sleep
(
50
);
Thread
.
Sleep
(
50
);
var
d1
=
new
DeviceRunControl
(
"SideMove"
,
SideMove
.
DeviceList
.
Values
.
ToList
<
IDevice
>());
var
d2
=
new
DeviceRunControl
(
"TransplantMove"
,
TransplantMove
.
DeviceList
.
Values
.
ToList
<
IDevice
>());
var
d3
=
new
DeviceRunControl
(
"TrayStop"
,
TrayStop
.
DeviceList
.
Values
.
ToList
<
IDevice
>());
var
d4
=
new
DeviceRunControl
(
"MI"
,
MI
.
DeviceList
.
Values
.
ToList
<
IDevice
>());
isRunning
=
true
;
isRunning
=
true
;
GC
.
KeepAlive
(
mainThread
);
GC
.
KeepAlive
(
mainThread
);
mainMachine
.
BeginHomeReset
(
true
);
mainMachine
.
BeginHomeReset
(
true
);
d1
.
Start
();
DeviceRunControl
.
StartAll
();
d2
.
Start
();
d3
.
Start
();
d4
.
Start
();
}
}
public
static
void
Stop
()
public
static
void
Stop
()
...
...
DeviceLibrary/theMachine/TrayManager.cs
查看文件 @
63f15d8
...
@@ -27,12 +27,13 @@ namespace DeviceLibrary
...
@@ -27,12 +27,13 @@ namespace DeviceLibrary
public
static
bool
Process
(
MoveInfo
moveInfo
,
string
rfid
,
int
addr
,
int
reelcheck
,
out
TrayInfo
trayInfo
)
{
public
static
bool
Process
(
MoveInfo
moveInfo
,
string
rfid
,
int
addr
,
int
reelcheck
,
out
TrayInfo
trayInfo
)
{
lock
(
Traylist
)
lock
(
Traylist
)
{
{
moveInfo
.
log
(
$
"处理RFID:{rfid},地址{addr},设备:{(AddrDesc.ContainsKey(addr)? AddrDesc[addr]:"")}"
);
if
(!
Traylist
.
ContainsKey
(
rfid
))
if
(!
Traylist
.
ContainsKey
(
rfid
))
{
{
Traylist
.
Add
(
rfid
,
new
TrayInfo
());
Traylist
.
Add
(
rfid
,
new
TrayInfo
());
Traylist
[
rfid
].
RFID
=
rfid
;
Traylist
[
rfid
].
RFID
=
rfid
;
}
}
moveInfo
.
log
(
$
"处理RFID:{rfid},地址{addr},设备:{(AddrDesc.ContainsKey(addr) ? AddrDesc[addr] : "")},{(Traylist[rfid].HasLoad? Traylist[rfid].TrayParam?.ToStr():"
no
metrial
")}"
);
Traylist
[
rfid
].
LastUpdateTime
=
DateTime
.
Now
;
Traylist
[
rfid
].
LastUpdateTime
=
DateTime
.
Now
;
Traylist
[
rfid
].
LastAddr
=
addr
;
Traylist
[
rfid
].
LastAddr
=
addr
;
Traylist
[
rfid
].
Destination
=
TrayManager
.
AddrDesc
[
Traylist
[
rfid
].
DestinationAddr
];
Traylist
[
rfid
].
Destination
=
TrayManager
.
AddrDesc
[
Traylist
[
rfid
].
DestinationAddr
];
...
@@ -56,7 +57,7 @@ namespace DeviceLibrary
...
@@ -56,7 +57,7 @@ namespace DeviceLibrary
{
{
lock
(
Traylist
)
lock
(
Traylist
)
{
{
LogUtil
.
info
(
$
"SetTrayLoadInfo:{rfid},{requestLoadInfo?.
LoadParam?.ToStr()},{requestLoadInfo?.DeviceGroupName
}"
);
LogUtil
.
info
(
$
"SetTrayLoadInfo:{rfid},{requestLoadInfo?.
DeviceGroupName},{requestLoadInfo?.LoadParam?.ToStr()
}"
);
if
(!
Traylist
.
ContainsKey
(
rfid
))
{
if
(!
Traylist
.
ContainsKey
(
rfid
))
{
Traylist
.
Add
(
rfid
,
new
TrayInfo
());
Traylist
.
Add
(
rfid
,
new
TrayInfo
());
Traylist
[
rfid
].
RFID
=
rfid
;
Traylist
[
rfid
].
RFID
=
rfid
;
...
@@ -73,7 +74,7 @@ namespace DeviceLibrary
...
@@ -73,7 +74,7 @@ namespace DeviceLibrary
Traylist
[
rfid
].
TrayParam
=
requestLoadInfo
.
LoadParam
.
clone
();
Traylist
[
rfid
].
TrayParam
=
requestLoadInfo
.
LoadParam
.
clone
();
Traylist
[
rfid
].
DestinationAddr
=
GetAddrByGroupName
(
requestLoadInfo
.
DeviceGroupName
);
Traylist
[
rfid
].
DestinationAddr
=
GetAddrByGroupName
(
requestLoadInfo
.
DeviceGroupName
);
Traylist
[
rfid
].
HasLoadCheck
=
1
;
Traylist
[
rfid
].
HasLoadCheck
=
1
;
LogUtil
.
info
(
"设置托盘信息:"
+
Traylist
[
rfid
].
LoadType
+
","
+
Traylist
[
rfid
].
TrayParam
.
ToStr
()
+
","
+
requestLoadInfo
.
DeviceGroupName
);
LogUtil
.
info
(
"设置托盘信息:"
+
rfid
+
","
+
requestLoadInfo
.
DeviceGroupName
+
","
+
Traylist
[
rfid
].
LoadType
+
","
+
Traylist
[
rfid
].
TrayParam
.
ToStr
()
);
}
}
SaveTrayInfo
();
SaveTrayInfo
();
}
}
...
@@ -275,7 +276,7 @@ namespace DeviceLibrary
...
@@ -275,7 +276,7 @@ namespace DeviceLibrary
public
static
bool
IsNeedProcessNG
(
RemoteLoad
remoteLoad
)
public
static
bool
IsNeedProcessNG
(
RemoteLoad
remoteLoad
)
{
{
var
requestLoadInfo
=
remoteLoad
.
RequestLoadInfo
;
var
requestLoadInfo
=
remoteLoad
.
RequestLoadInfo
;
var
xx
=
TrayManager
.
Traylist
.
Values
.
ToList
().
Where
(
t
=>
t
.
HasLoad
&&
t
.
LoadType
==
requestLoadInfo
.
GetTrayType
&&
(
t
.
LastAddr
>=
20
||
t
.
LastAddr
<
2
));
var
xx
=
TrayManager
.
Traylist
.
Values
.
ToList
().
Where
(
t
=>
t
.
HasLoad
&&
t
.
LoadType
==
requestLoadInfo
.
GetTrayType
&&
(
t
.
LastAddr
>=
20
||
t
.
LastAddr
<
=
3
));
return
xx
.
Count
()
>
0
;
return
xx
.
Count
()
>
0
;
}
}
...
@@ -350,7 +351,7 @@ namespace DeviceLibrary
...
@@ -350,7 +351,7 @@ namespace DeviceLibrary
public
DirectionE
Direction
{
get
=>
(
Destination
==
StoreCID
.
AMH_ML5_1
||
Destination
==
StoreCID
.
AMH_ML5_2
)
?
DirectionE
.
Out
:
DirectionE
.
In
;
}
public
DirectionE
Direction
{
get
=>
(
Destination
==
StoreCID
.
AMH_ML5_1
||
Destination
==
StoreCID
.
AMH_ML5_2
)
?
DirectionE
.
Out
:
DirectionE
.
In
;
}
public
bool
isOnline
=
true
;
public
bool
isOnline
=
true
;
public
void
SetToEmpty
()
{
public
void
SetToEmpty
()
{
LogUtil
.
info
(
"清空托盘信息,原信息:"
+
Direction
+
","
+
TrayParam
?.
ToStr
()+
","
+
LoadType
+
","
+
LoadType
+
","
);
LogUtil
.
info
(
"清空托盘信息,原信息:"
+
RFID
+
","
+
Direction
+
","
+
TrayParam
?.
ToStr
()+
","
+
LoadType
+
","
+
LoadType
+
","
);
LoadType
=
TrayTypeE
.
None
;
LoadType
=
TrayTypeE
.
None
;
DestinationAddr
=
-
1
;
DestinationAddr
=
-
1
;
TrayParam
=
new
ReelParam
();
TrayParam
=
new
ReelParam
();
...
...
DeviceLibrary/theMachine/sub/MI.cs
查看文件 @
63f15d8
...
@@ -88,8 +88,9 @@ namespace DeviceLibrary
...
@@ -88,8 +88,9 @@ namespace DeviceLibrary
{
{
try
try
{
{
LogUtil
.
OutputDebugString
(
$
"{GroupName} DeviceState:"
+
DeviceState
.
ToString
());
MsgService
.
MSList
[
GroupName
+
"-T"
].
clear
();
MsgService
.
MSList
[
GroupName
+
"-T"
].
clear
();
LogUtil
.
OutputDebugString
(
"DeviceState:"
+
DeviceState
.
ToString
());
if
(!
DeviceCheck
())
if
(!
DeviceCheck
())
{
{
...
@@ -118,11 +119,11 @@ namespace DeviceLibrary
...
@@ -118,11 +119,11 @@ namespace DeviceLibrary
private
bool
DeviceCheck
()
private
bool
DeviceCheck
()
{
{
if
(!
Robot
.
ClientIsConnected
)
//
if (!Robot.ClientIsConnected)
{
//
{
Msg
.
add
(
POS_Start
+
crc
.
GetString
(
"Res0011"
,
"机器人未连接MT,无法操作."
),
MsgLevel
.
alarm
);
//
Msg.add(POS_Start + crc.GetString("Res0011", "机器人未连接MT,无法操作."), MsgLevel.alarm);
return
false
;
//
return false;
}
//
}
if
(!
robotHelper
.
RobotStatus
)
{
if
(!
robotHelper
.
RobotStatus
)
{
Msg
.
add
(
POS_Start
+
crc
.
GetString
(
"Res0058"
,
"机器人当前不可用"
),
MsgLevel
.
alarm
);
Msg
.
add
(
POS_Start
+
crc
.
GetString
(
"Res0058"
,
"机器人当前不可用"
),
MsgLevel
.
alarm
);
return
false
;
return
false
;
...
@@ -179,9 +180,9 @@ namespace DeviceLibrary
...
@@ -179,9 +180,9 @@ namespace DeviceLibrary
MoveInfo
.
log
(
"机器人开始取料"
);
MoveInfo
.
log
(
"机器人开始取料"
);
break
;
break
;
case
MoveStep
.
MI_02
:
case
MoveStep
.
MI_02
:
if
(
RoboMoveInfo
.
MoveStep
==
MoveStep
.
MI_ReelTacked
)
if
(
RoboMoveInfo
.
MoveStep
>=
MoveStep
.
MI_08
)
{
{
MoveInfo
.
NextMoveStep
(
MoveStep
.
MI_0
4
);
MoveInfo
.
NextMoveStep
(
MoveStep
.
MI_0
3
);
if
(
FromPos
.
PositionNum
.
EndsWith
(
"MT"
))
if
(
FromPos
.
PositionNum
.
EndsWith
(
"MT"
))
{
{
RemoteLoad
remoteLoad
=
new
RemoteLoad
();
RemoteLoad
remoteLoad
=
new
RemoteLoad
();
...
@@ -201,6 +202,12 @@ namespace DeviceLibrary
...
@@ -201,6 +202,12 @@ namespace DeviceLibrary
}
}
break
;
break
;
case
MoveStep
.
MI_03
:
if
(
RoboMoveInfo
.
MoveStep
==
MoveStep
.
MI_ReelTacked
)
{
MoveInfo
.
NextMoveStep
(
MoveStep
.
MI_04
);
}
break
;
case
MoveStep
.
MI_04
:
case
MoveStep
.
MI_04
:
if
(
CurrentVStore
.
RTStoreStatus
==
RTStoreStatus
.
Ready
||
CurrentVStore
.
RTStoreStatus
==
RTStoreStatus
.
LockToInStore
)
if
(
CurrentVStore
.
RTStoreStatus
==
RTStoreStatus
.
Ready
||
CurrentVStore
.
RTStoreStatus
==
RTStoreStatus
.
LockToInStore
)
{
{
...
@@ -321,6 +328,7 @@ namespace DeviceLibrary
...
@@ -321,6 +328,7 @@ namespace DeviceLibrary
&&
IOValue
(
IO_Type
.
MI_Robot_Clamp_Check
).
Equals
(
IO_VALUE
.
LOW
))
&&
IOValue
(
IO_Type
.
MI_Robot_Clamp_Check
).
Equals
(
IO_VALUE
.
LOW
))
{
{
MoveInfo
.
log
(
"机器人抓取NG料后发现夹爪上没有料,流程结束处理"
);
MoveInfo
.
log
(
"机器人抓取NG料后发现夹爪上没有料,流程结束处理"
);
TrayStop
.
DeviceList
[
GroupName
].
TrayRelease
();
RoboMoveInfo
.
NextMoveStep
(
MoveStep
.
Wait
);
RoboMoveInfo
.
NextMoveStep
(
MoveStep
.
Wait
);
MoveInfo
.
NextMoveStep
(
MoveStep
.
Wait
);
MoveInfo
.
NextMoveStep
(
MoveStep
.
Wait
);
}
}
...
...
DeviceLibrary/theMachine/sub/TrayStop.cs
查看文件 @
63f15d8
...
@@ -94,7 +94,7 @@ namespace DeviceLibrary
...
@@ -94,7 +94,7 @@ namespace DeviceLibrary
switch
(
MoveInfo
.
MoveStep
)
switch
(
MoveInfo
.
MoveStep
)
{
{
case
MoveStep
.
Wait
:
case
MoveStep
.
Wait
:
if
(
RobotManage
.
mainMachine
.
IOValue
(
IO_Type
.
ML5_DoorSafeCheck
).
Equals
(
IO_VALUE
.
LOW
))
if
(
(
GroupName
==
"AMH-ML5-1"
||
GroupName
==
"AMH-ML5-2"
)
&&
RobotManage
.
mainMachine
.
IOValue
(
IO_Type
.
ML5_DoorSafeCheck
).
Equals
(
IO_VALUE
.
LOW
))
{
{
Msg
.
add
(
crc
.
GetString
(
"Res0041"
,
"ML5料口门光栅被遮挡"
),
MsgLevel
.
warning
);
Msg
.
add
(
crc
.
GetString
(
"Res0041"
,
"ML5料口门光栅被遮挡"
),
MsgLevel
.
warning
);
return
;
return
;
...
@@ -239,11 +239,16 @@ namespace DeviceLibrary
...
@@ -239,11 +239,16 @@ namespace DeviceLibrary
remoteLoad
.
RequestLoadInfo
.
IsEmpty
=
false
;
remoteLoad
.
RequestLoadInfo
.
IsEmpty
=
false
;
MoveInfo
.
remoteLoad
=
remoteLoad
;
MoveInfo
.
remoteLoad
=
remoteLoad
;
var
result
=
RemoteService
.
SendAndWait
(
GroupName
,
remoteLoad
);
var
result
=
RemoteService
.
SendAndWait
(
GroupName
,
remoteLoad
);
if
(
result
!=
RemoteResult
.
Tru
e
)
if
(
result
==
RemoteResult
.
Fals
e
)
{
{
MoveInfo
.
NextMoveStep
(
MoveStep
.
TrayStop_04
);
MoveInfo
.
NextMoveStep
(
MoveStep
.
TrayStop_04
);
MoveInfo
.
log
(
$
"{GroupName} 请求出库失败:{result}"
);
MoveInfo
.
log
(
$
"{GroupName} 请求出库失败:{result}"
);
}
}
else
if
(
result
==
RemoteResult
.
Timeout
)
{
MoveInfo
.
NextMoveStep
(
MoveStep
.
TrayStop_03
);
MoveInfo
.
log
(
$
"{GroupName} 请求出库失败:{result}"
);
}
else
else
{
{
SRec
.
info
(
crc
.
GetString
(
"Res0042"
,
"托盘挡停"
),
GroupName
,
crc
.
GetString
(
"Res0025"
,
"载物托盘"
),
crc
.
GetString
(
"Res0044"
,
"等待物料被接走"
),
CurrrentRFID
,
remoteLoad
.
RequestLoadInfo
.
LoadParam
.
WareCode
);
SRec
.
info
(
crc
.
GetString
(
"Res0042"
,
"托盘挡停"
),
GroupName
,
crc
.
GetString
(
"Res0025"
,
"载物托盘"
),
crc
.
GetString
(
"Res0044"
,
"等待物料被接走"
),
CurrrentRFID
,
remoteLoad
.
RequestLoadInfo
.
LoadParam
.
WareCode
);
...
@@ -251,40 +256,6 @@ namespace DeviceLibrary
...
@@ -251,40 +256,6 @@ namespace DeviceLibrary
}
}
return
;
return
;
}
}
/*
else if ((trayInfo.DestinationAddr == DeviceGroup.addr_1 || trayInfo.DestinationAddr == -1) &&
((GroupName == "AMH-ML5-1" && CurrrentRFID.StartsWith("MTP2")) ||
(GroupName == "AMH-ML5-2" && CurrrentRFID.StartsWith("MTP1")))
&& IOValue(IO_Type.MI_Reel_Check).Equals(IO_VALUE.HIGH))
{
MoveInfo.log($"{GroupName} NG出库流程");
//NG物料
MoveInfo.NextMoveStep(MoveStep.TrayStop_07);
RemoteLoad remoteLoad = new RemoteLoad();
remoteLoad.Seq = DateTime.Now.Ticks;
remoteLoad.Action = "TrayReady";
remoteLoad.RequestLoadInfo = new RequestLoadInfo();
remoteLoad.RequestLoadInfo.TrayType = trayInfo.TrayType.ToString();
remoteLoad.RequestLoadInfo.LoadParam = new ReelParam();
remoteLoad.RequestLoadInfo.LoadParam.PlateW = 794;
remoteLoad.RequestLoadInfo.LoadParam.PlateH = 120;
remoteLoad.RequestLoadInfo.LoadParam.IsNg = true;
remoteLoad.RequestLoadInfo.LoadParam.NgMsg = "[MT]"+ crc.GetString("Res0045","无信息物料");
remoteLoad.RequestLoadInfo.IsEmpty = false;
MoveInfo.remoteLoad = remoteLoad;
var result = RemoteService.SendAndWait(GroupName, remoteLoad);
if (result != RemoteResult.True)
{
MoveInfo.NextMoveStep(MoveStep.TrayStop_04);
MoveInfo.log($"{GroupName} 请求NG出库失败:{result}");
}
else
{
MoveInfo.log($"{GroupName} 请求NG出库成功");
}
return;
}*/
else
else
MoveInfo
.
NextMoveStep
(
MoveStep
.
TrayStop_04
);
MoveInfo
.
NextMoveStep
(
MoveStep
.
TrayStop_04
);
}
}
...
@@ -309,9 +280,9 @@ namespace DeviceLibrary
...
@@ -309,9 +280,9 @@ namespace DeviceLibrary
Location
.
ToLow
(
MoveInfo
);
Location
.
ToLow
(
MoveInfo
);
break
;
break
;
case
MoveStep
.
TrayStop_05
:
case
MoveStep
.
TrayStop_05
:
if
(
RobotManage
.
mainMachine
.
IOValue
(
IO_Type
.
ML5_DoorSafeCheck
).
Equals
(
IO_VALUE
.
LOW
))
if
(
(
GroupName
==
"AMH-ML5-1"
||
GroupName
==
"AMH-ML5-2"
)
&&
RobotManage
.
mainMachine
.
IOValue
(
IO_Type
.
ML5_DoorSafeCheck
).
Equals
(
IO_VALUE
.
LOW
))
{
{
Msg
.
add
(
crc
.
GetString
(
"Res0041"
,
"ML5料口门光栅被遮挡"
),
MsgLevel
.
warning
);
Msg
.
add
(
crc
.
GetString
(
"Res0041"
,
"ML5料口门光栅被遮挡"
),
MsgLevel
.
warning
);
return
;
return
;
}
}
MoveInfo
.
NextMoveStep
(
MoveStep
.
TrayStop_06
);
MoveInfo
.
NextMoveStep
(
MoveStep
.
TrayStop_06
);
...
@@ -334,8 +305,11 @@ namespace DeviceLibrary
...
@@ -334,8 +305,11 @@ namespace DeviceLibrary
break
;
break
;
case
MoveStep
.
TrayStop_07
:
case
MoveStep
.
TrayStop_07
:
MoveInfo
.
NextMoveStep
(
MoveStep
.
TrayStop_WaitLoadProcess
);
MoveInfo
.
NextMoveStep
(
MoveStep
.
TrayStop_WaitLoadProcess
);
if
(
GroupName
!=
"AMH-MI1"
&&
GroupName
!=
"AMH-MI2"
&&
GroupName
!=
"CI"
)
{
Location
.
ToHigh
(
MoveInfo
);
Location
.
ToHigh
(
MoveInfo
);
MoveInfo
.
WaitList
.
Add
(
WaitResultInfo
.
WaitTime
(
2000
));
MoveInfo
.
WaitList
.
Add
(
WaitResultInfo
.
WaitTime
(
1000
));
}
break
;
break
;
case
MoveStep
.
TrayStop_WaitLoadProcess
:
case
MoveStep
.
TrayStop_WaitLoadProcess
:
Msg
.
add
(
crc
.
GetString
(
"Res0046"
,
"等待处理物料"
),
MsgLevel
.
info
);
Msg
.
add
(
crc
.
GetString
(
"Res0046"
,
"等待处理物料"
),
MsgLevel
.
info
);
...
@@ -406,7 +380,7 @@ namespace DeviceLibrary
...
@@ -406,7 +380,7 @@ namespace DeviceLibrary
}
}
else
if
(
RobotManage
.
mainMachine
.
IOValue
(
IO_Type
.
ML5_DoorSafeCheck
).
Equals
(
IO_VALUE
.
LOW
))
else
if
(
RobotManage
.
mainMachine
.
IOValue
(
IO_Type
.
ML5_DoorSafeCheck
).
Equals
(
IO_VALUE
.
LOW
))
{
{
Msg
.
add
(
crc
.
GetString
(
"Res0041"
,
"ML5料口门光栅被遮挡"
),
MsgLevel
.
warning
);
Msg
.
add
(
crc
.
GetString
(
"Res0041"
,
"ML5料口门光栅被遮挡"
),
MsgLevel
.
warning
);
return
false
;
return
false
;
}
}
else
else
...
...
DeviceLibrary/userControl/AxisMoveControl.Designer.cs
查看文件 @
63f15d8
...
@@ -76,10 +76,10 @@
...
@@ -76,10 +76,10 @@
this
.
btnAxisStop
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
btnAxisStop
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
btnAxisReturnHome
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
btnAxisReturnHome
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
cmbAxis
=
new
System
.
Windows
.
Forms
.
ComboBox
();
this
.
cmbAxis
=
new
System
.
Windows
.
Forms
.
ComboBox
();
this
.
btnDelMove
=
new
System
.
Windows
.
Forms
.
Butto
n
();
this
.
btnDelMove
=
new
ToucDownBt
n
();
this
.
btnOpenAxis
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
btnOpenAxis
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
btnCloseAxis
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
btnCloseAxis
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
btnAddMove
=
new
System
.
Windows
.
Forms
.
Butto
n
();
this
.
btnAddMove
=
new
ToucDownBt
n
();
this
.
txtASpeed
=
new
System
.
Windows
.
Forms
.
TextBox
();
this
.
txtASpeed
=
new
System
.
Windows
.
Forms
.
TextBox
();
this
.
label1
=
new
System
.
Windows
.
Forms
.
Label
();
this
.
label1
=
new
System
.
Windows
.
Forms
.
Label
();
this
.
label47
=
new
System
.
Windows
.
Forms
.
Label
();
this
.
label47
=
new
System
.
Windows
.
Forms
.
Label
();
...
@@ -952,8 +952,8 @@
...
@@ -952,8 +952,8 @@
private
System
.
Windows
.
Forms
.
Panel
panel1
;
private
System
.
Windows
.
Forms
.
Panel
panel1
;
private
System
.
Windows
.
Forms
.
Label
label5
;
private
System
.
Windows
.
Forms
.
Label
label5
;
private
System
.
Windows
.
Forms
.
TextBox
txtServoStatue
;
private
System
.
Windows
.
Forms
.
TextBox
txtServoStatue
;
private
System
.
Windows
.
Forms
.
Butto
n
btnDelMove
;
private
ToucDownBt
n
btnDelMove
;
private
System
.
Windows
.
Forms
.
Butto
n
btnAddMove
;
private
ToucDownBt
n
btnAddMove
;
private
System
.
Windows
.
Forms
.
Label
label1
;
private
System
.
Windows
.
Forms
.
Label
label1
;
private
System
.
Windows
.
Forms
.
GroupBox
groupBox1
;
private
System
.
Windows
.
Forms
.
GroupBox
groupBox1
;
private
System
.
Windows
.
Forms
.
ComboBox
comjSpeed
;
private
System
.
Windows
.
Forms
.
ComboBox
comjSpeed
;
...
...
DeviceLibrary/userControl/ToucDownBtn.cs
0 → 100644
查看文件 @
63f15d8
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Security.Permissions
;
using
System.Text
;
using
System.Threading.Tasks
;
using
System.Windows.Forms
;
class
ToucDownBtn
:
System
.
Windows
.
Forms
.
Button
{
public
const
int
WM_POINTERDOWN
=
0x246
;
public
const
int
WM_POINTERUP
=
0x247
;
[
PermissionSet
(
SecurityAction
.
Demand
,
Name
=
"FullTrust"
)]
protected
override
void
WndProc
(
ref
Message
m
)
{
switch
(
m
.
Msg
)
{
case
WM_POINTERDOWN
:
{
MouseEventArgs
args
=
new
MouseEventArgs
(
MouseButtons
.
Left
,
1
,
1
,
1
,
0
);
OnMouseDown
(
args
);
//Console.WriteLine("WM_POINTERDOWN");
break
;
}
case
WM_POINTERUP
:
{
MouseEventArgs
args
=
new
MouseEventArgs
(
MouseButtons
.
Left
,
1
,
1
,
1
,
0
);
OnMouseUp
(
args
);
//Console.WriteLine("WM_POINTERUP");
break
;
}
}
base
.
WndProc
(
ref
m
);
}
}
LoadCVSLibrary/G.cs
0 → 100644
查看文件 @
63f15d8
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
namespace
OnlineStore
{
public
class
G
{
public
static
bool
simulate
=
false
;
}
}
LoadCVSLibrary/LoadCSVLibrary.csproj
查看文件 @
63f15d8
...
@@ -52,6 +52,7 @@
...
@@ -52,6 +52,7 @@
</ItemGroup>
</ItemGroup>
<ItemGroup>
<ItemGroup>
<Compile Include="CSVExection.cs" />
<Compile Include="CSVExection.cs" />
<Compile Include="G.cs" />
<Compile Include="position\RobotPosition.cs" />
<Compile Include="position\RobotPosition.cs" />
<Compile Include="position\DeviceGroup.cs" />
<Compile Include="position\DeviceGroup.cs" />
<Compile Include="position\ACSAStorePosition.cs" />
<Compile Include="position\ACSAStorePosition.cs" />
...
...
RemoteSheardObject/Class1.cs
查看文件 @
63f15d8
...
@@ -5,6 +5,7 @@ using System.Collections.Generic;
...
@@ -5,6 +5,7 @@ using System.Collections.Generic;
using
System.IO
;
using
System.IO
;
using
System.Linq
;
using
System.Linq
;
using
System.Runtime.Serialization.Formatters.Binary
;
using
System.Runtime.Serialization.Formatters.Binary
;
using
System.Security.Cryptography.X509Certificates
;
using
System.Text
;
using
System.Text
;
using
System.Threading.Tasks
;
using
System.Threading.Tasks
;
...
@@ -212,7 +213,8 @@ public class ReelParam
...
@@ -212,7 +213,8 @@ public class ReelParam
/// NG口位置,1=左侧,2=右侧
/// NG口位置,1=左侧,2=右侧
/// </summary>
/// </summary>
/// <param name="NgPos"></param>
/// <param name="NgPos"></param>
public
void
logresult
(
int
NgPos
=
0
)
/// <param name="isInstore"></param>
public
void
logresult
(
int
NgPos
=
0
,
bool
isInstore
=
true
)
{
{
if
(!
islog
)
if
(!
islog
)
{
{
...
@@ -244,11 +246,32 @@ public class ReelParam
...
@@ -244,11 +246,32 @@ public class ReelParam
ngMsgData
.
ngPos
=
NgPos
;
ngMsgData
.
ngPos
=
NgPos
;
ngMsgData
.
ngMsg
=
NgMsg
;
ngMsgData
.
ngMsg
=
NgMsg
;
ngMsgData
.
barcode
=
WareCode
;
ngMsgData
.
barcode
=
WareCode
;
ngMsgData
.
type
=
"1
"
;
ngMsgData
.
type
=
isInstore
?
"1"
:
"0
"
;
ngMsgData
.
mType
=
""
;
ngMsgData
.
posName
=
getposname
(
PosID
)
;
TheLine
.
uploadNgReel
(
ngMsgData
);
TheLine
.
uploadNgReel
(
ngMsgData
);
});
});
}
}
string
getposname
(
string
posid
)
{
switch
(
posid
)
{
case
"NG_7_1"
:
return
"R-SLOT1"
;
case
"NG_13_1"
:
return
"R-SLOT2"
;
case
"NG_13_2"
:
return
"R-SLOT3"
;
case
"DoorL4"
:
return
"L-SLOT1"
;
case
"NG_BOX_1NG"
:
return
"L-SLOT2"
;
case
"NG_BOX_2NG"
:
return
"L-SLOT3"
;
case
"NG_BOX_3NG"
:
return
"L-SLOT4"
;
default
:
return
posid
;
}
}
}
}
}
}
public
enum
DoorStatusE
{
public
enum
DoorStatusE
{
...
...
RemoteSheardObject/RemoteClient.cs
查看文件 @
63f15d8
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
using
Newtonsoft.Json
;
using
Newtonsoft.Json
;
using
System
;
using
System
;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
System.Diagnostics
;
using
System.Linq
;
using
System.Linq
;
using
System.Text
;
using
System.Text
;
using
System.Threading.Tasks
;
using
System.Threading.Tasks
;
...
@@ -18,7 +19,7 @@ public class RemoteClient
...
@@ -18,7 +19,7 @@ public class RemoteClient
{
{
GroupName
=
groupName
;
GroupName
=
groupName
;
Serveraddr
=
serveraddr
;
Serveraddr
=
serveraddr
;
timer
=
new
System
.
Timers
.
Timer
(
200
0
);
timer
=
new
System
.
Timers
.
Timer
(
1000
*
1
0
);
timer
.
Enabled
=
false
;
timer
.
Enabled
=
false
;
timer
.
AutoReset
=
true
;
timer
.
AutoReset
=
true
;
timer
.
Elapsed
+=
Timer_Elapsed
;
timer
.
Elapsed
+=
Timer_Elapsed
;
...
@@ -55,25 +56,38 @@ public class RemoteClient
...
@@ -55,25 +56,38 @@ public class RemoteClient
int
errstatuscounr
=
0
;
int
errstatuscounr
=
0
;
private
void
Timer_Elapsed
(
object
sender
,
ElapsedEventArgs
e
)
private
void
Timer_Elapsed
(
object
sender
,
ElapsedEventArgs
e
)
{
{
Debug
.
WriteLine
(
"WebSocketState:"
+
webSocket
.
State
);
if
(
webSocket
.
State
==
WebSocket4Net
.
WebSocketState
.
Closed
)
if
(
webSocket
.
State
==
WebSocket4Net
.
WebSocketState
.
Closed
)
{
{
try
try
{
{
LOGGER
.
Info
(
$
"Remote:{GroupName} 重新连接"
);
LOGGER
.
Info
(
$
"Remote:{GroupName} 重新连接"
);
webSocket
.
Open
();
webSocket
.
Open
();
timeoutCount
=
0
;
errstatuscounr
=
0
;
errstatuscounr
=
0
;
}
}
catch
{
}
catch
{
}
}
}
else
if
(
webSocket
.
State
==
WebSocket4Net
.
WebSocketState
.
Connecting
)
{
else
if
(
webSocket
.
State
==
WebSocket4Net
.
WebSocketState
.
Connecting
)
{
errstatuscounr
++;
errstatuscounr
++;
if
(
errstatuscounr
>
5
)
{
if
(
errstatuscounr
>
5
)
{
LOGGER
.
Error
(
$
"Remote:{GroupName} Connecting 超时"
);
LOGGER
.
Error
(
$
"Remote:{GroupName} Connecting 超时"
);
try
{
webSocket
.
Close
();
}
catch
{
}
try
{
webSocket
.
Close
();
}
catch
{
}
webSocket
.
Open
();
webSocket
.
Open
();
errstatuscounr
=
0
;
errstatuscounr
=
0
;
}
}
}
}
else
if
(
webSocket
.
State
==
WebSocket4Net
.
WebSocketState
.
Open
)
{
RemoteLoad
remoteLoad
=
new
RemoteLoad
();
remoteLoad
.
Seq
=
DateTime
.
Now
.
Ticks
;
remoteLoad
.
Action
=
"Heartbeats"
;
remoteLoad
.
GroupName
=
GroupName
;
SendAndWait
(
remoteLoad
);
//webSocket.Send(JsonConvert.SerializeObject(remoteLoad));
}
}
}
volatile
RemoteResult
lastresult
=
RemoteResult
.
None
;
volatile
RemoteResult
lastresult
=
RemoteResult
.
None
;
private
void
WebSocket_MessageReceived
(
object
sender
,
WebSocket4Net
.
MessageReceivedEventArgs
e
)
private
void
WebSocket_MessageReceived
(
object
sender
,
WebSocket4Net
.
MessageReceivedEventArgs
e
)
...
@@ -95,7 +109,7 @@ public class RemoteClient
...
@@ -95,7 +109,7 @@ public class RemoteClient
case
"OK"
:
case
"OK"
:
case
"FAIL"
:
case
"FAIL"
:
lastresult
=
remoteLoad
.
Action
==
"OK"
?
RemoteResult
.
True
:
RemoteResult
.
False
;
lastresult
=
remoteLoad
.
Action
==
"OK"
?
RemoteResult
.
True
:
RemoteResult
.
False
;
LOGGER
.
Info
(
"Revice Command Callback:"
+
remoteLoad
.
GroupName
+
" -"
+
remoteLoad
.
Action
+
" ,Seq:"
+
remoteLoad
.
Seq
);
LOGGER
.
Info
(
"Revice Command Callback:"
+
remoteLoad
.
GroupName
+
" -
"
+
remoteLoad
.
Action
+
" ,Seq:"
+
remoteLoad
.
Seq
);
return
;
return
;
default
:
default
:
if
(
actionlist
.
ContainsKey
(
remoteLoad
.
Action
))
{
if
(
actionlist
.
ContainsKey
(
remoteLoad
.
Action
))
{
...
@@ -128,14 +142,25 @@ public class RemoteClient
...
@@ -128,14 +142,25 @@ public class RemoteClient
timeoutCount
++;
timeoutCount
++;
lastresult
=
RemoteResult
.
Timeout
;
lastresult
=
RemoteResult
.
Timeout
;
if
(
timeoutCount
>
3
)
if
(
timeoutCount
>
3
)
{
LOGGER
.
Error
(
"强制断开连接"
);
webSocket
.
Close
();
webSocket
.
Close
();
timeoutCount
=
0
;
}
}
}
else
{
else
{
timeoutCount
=
0
;
timeoutCount
=
0
;
}
}
return
lastresult
;
return
lastresult
;
}
}
/// <summary>
/// 发送并等待结果
/// </summary>
/// <param name="remoteLoad"></param>
/// <param name="waittime"></param>
/// <returns></returns>
public
RemoteResult
SendAndWait
(
RemoteLoad
remoteLoad
,
int
waittime
=
3000
)
{
public
RemoteResult
SendAndWait
(
RemoteLoad
remoteLoad
,
int
waittime
=
3000
)
{
lock
(
webSocket
)
{
remoteLoad
.
Seq
=
DateTime
.
Now
.
Ticks
;
remoteLoad
.
Seq
=
DateTime
.
Now
.
Ticks
;
remoteLoad
.
GroupName
=
GroupName
;
remoteLoad
.
GroupName
=
GroupName
;
if
(
remoteLoad
.
RequestLoadInfo
!=
null
)
if
(
remoteLoad
.
RequestLoadInfo
!=
null
)
...
@@ -144,9 +169,11 @@ public class RemoteClient
...
@@ -144,9 +169,11 @@ public class RemoteClient
remoteLoad
.
RequestLoadInfo
.
DeviceGroupName
=
GroupName
;
remoteLoad
.
RequestLoadInfo
.
DeviceGroupName
=
GroupName
;
}
}
lastresult
=
RemoteResult
.
None
;
lastresult
=
RemoteResult
.
None
;
LOGGER
.
Info
(
$
"Send remote command: {GroupName} - "
+
remoteLoad
.
Action
+
$
", seq:{remoteLoad.Seq}"
);
webSocket
.
Send
(
JsonConvert
.
SerializeObject
(
remoteLoad
));
webSocket
.
Send
(
JsonConvert
.
SerializeObject
(
remoteLoad
));
return
WaitResult
(
waittime
);
return
WaitResult
(
waittime
);
}
}
}
void
SendResult
(
bool
result
,
long
Seq
)
void
SendResult
(
bool
result
,
long
Seq
)
{
{
RemoteLoad
remoteLoad
=
new
RemoteLoad
();
RemoteLoad
remoteLoad
=
new
RemoteLoad
();
...
...
RemoteSheardObject/TheLine.cs
查看文件 @
63f15d8
...
@@ -116,11 +116,54 @@ namespace RemoteSheardObject
...
@@ -116,11 +116,54 @@ namespace RemoteSheardObject
{
{
var
postData
=
new
Dictionary
<
string
,
string
>()
var
postData
=
new
Dictionary
<
string
,
string
>()
{
{
{
"ng
MsgData
"
,
ngPos
.
ToString
()
}
{
"ng
Pos
"
,
ngPos
.
ToString
()
}
};
};
string
url
=
CombineUrl
(
Config
.
Get
(
"Device_Server_Address"
),
"/rest/micron/device/clearNgPos"
)
;
string
url
=
"/rest/micron/device/clearNgPos"
;
var
resultStr
=
SubmitPostData
(
url
,
postData
);
var
resultStr
=
SubmitPostData
(
url
,
postData
);
}
}
/// <summary>
/// 上传自定义数据
/// </summary>
/// <param name="key"></param>
/// <param name="value"></param>
public
static
void
UploadCustData
(
string
key
,
string
value
)
{
var
postData
=
new
Dictionary
<
string
,
string
>()
{
{
"key"
,
key
},
{
"value"
,
value
}
};
string
url
=
"/rest/micron/device/updateData"
;
var
resultStr
=
SubmitPostData
(
url
,
postData
);
}
/// <summary>
/// 上传自定义数据
/// </summary>
/// <param name="key"></param>
/// <param name="value"></param>
public
static
string
GetCustData
(
string
key
)
{
var
postData
=
new
Dictionary
<
string
,
string
>()
{
{
"key"
,
key
}
};
string
url
=
"/rest/micron/device/getData"
;
var
resultStr
=
SubmitPostData
(
url
,
postData
);
var
r
=
JsonConvert
.
DeserializeObject
<
ResultData2
>(
resultStr
);
if
(!
string
.
IsNullOrWhiteSpace
(
r
.
data
))
{
return
r
.
data
;
}
return
null
;
}
public
class
ResultData2
{
//{"code":0,"msg":"ok","data":"7"}
public
int
code
{
get
;
set
;
}
public
string
msg
{
get
;
set
;
}
public
string
data
{
get
;
set
;
}
}
public
class
ResultData
public
class
ResultData
{
{
//{"code":0,"msg":"ok","data":"7"}
//{"code":0,"msg":"ok","data":"7"}
...
...
TheMachine/Program.cs
查看文件 @
63f15d8
...
@@ -21,8 +21,11 @@ namespace TheMachine
...
@@ -21,8 +21,11 @@ namespace TheMachine
/// 应用程序的主入口点。
/// 应用程序的主入口点。
/// </summary>
/// </summary>
[
STAThread
]
[
STAThread
]
static
void
Main
()
static
void
Main
(
string
[]
args
)
{
{
if
(
args
.
ToList
().
FindIndex
(
a
=>
a
.
Contains
(
"simulate"
))>=
0
)
OnlineStore
.
G
.
simulate
=
true
;
_
=
new
Mutex
(
true
,
Application
.
ProductName
,
out
bool
ret
);
_
=
new
Mutex
(
true
,
Application
.
ProductName
,
out
bool
ret
);
if
(!
ret
)
if
(!
ret
)
...
@@ -33,6 +36,13 @@ namespace TheMachine
...
@@ -33,6 +36,13 @@ namespace TheMachine
//MessageBox.Show("该程序已经启动", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
//MessageBox.Show("该程序已经启动", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
return
;
return
;
}
}
var
process
=
Process
.
GetCurrentProcess
();
Process
[]
processes
=
Process
.
GetProcessesByName
(
process
.
ProcessName
);
foreach
(
Process
p
in
processes
)
{
if
(
p
.
Id
!=
process
.
Id
)
p
.
Kill
();
}
var
currnetdrive
=
System
.
IO
.
Path
.
GetPathRoot
(
Application
.
StartupPath
);
var
currnetdrive
=
System
.
IO
.
Path
.
GetPathRoot
(
Application
.
StartupPath
);
var
drives
=
System
.
IO
.
DriveInfo
.
GetDrives
();
var
drives
=
System
.
IO
.
DriveInfo
.
GetDrives
();
foreach
(
var
drive
in
drives
)
{
foreach
(
var
drive
in
drives
)
{
...
...
TheMachine/TheMachine.csproj
查看文件 @
63f15d8
...
@@ -20,7 +20,7 @@
...
@@ -20,7 +20,7 @@
<DebugType>full</DebugType>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>
DEBUG;TRACE
</DefineConstants>
<DefineConstants>
TRACE;DEBUG
</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
<Prefer32Bit>false</Prefer32Bit>
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论