Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
刘韬
/
1053_CycleLine
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit 61f4e58c
由
刘韬
编写于
2023-09-26 09:39:35 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
1
1 个父辈
8ea5ab94
隐藏空白字符变更
内嵌
并排
正在显示
17 个修改的文件
包含
715 行增加
和
624 行删除
Common/Setting_Init.cs
DeviceLibrary/DeviceLibrary.csproj
DeviceLibrary/DeviceLibrary/ShareFolderWatcher.cs
DeviceLibrary/DeviceLibrary/VJCounter.cs
DeviceLibrary/VirtuallyStore/VStore.cs
DeviceLibrary/theMachine/MainMachine.cs
DeviceLibrary/theMachine/RobotManage.cs
DeviceLibrary/theMachine/TrayManager.cs
DeviceLibrary/theMachine/sub/CI.cs
DeviceLibrary/theMachine/sub/TrayStop.cs
DeviceLibrary/userControl/AxisMoveControl.Designer.cs
DeviceLibrary/userControl/AxisMoveControl.cs
RemoteSheardObject/TheLine.cs
TheMachine/TheMachine.csproj
TheMachine/TrayManagerControl.cs
TheMachine/device/CIDebugControl.Designer.cs
TheMachine/device/CIDebugControl.cs
Common/Setting_Init.cs
查看文件 @
61f4e58
...
...
@@ -64,10 +64,13 @@ namespace OnlineStore.Common
public
static
MyConfig
<
int
>
URRobot_CI_ListenPort
=
31
;
[
MyConfigComment
(
"VJ点料机串口端口号"
)]
public
static
MyConfig
<
string
>
VJCounter_COMPORT
=
"COM5"
;
[
MyConfigComment
(
"VJ点料机串口比特率"
)]
public
static
MyConfig
<
int
>
VJCounter_BaudRate
=
115200
;
[
MyConfigComment
(
"VJ点料机数据共享路径"
)]
public
static
MyConfig
<
string
>
Device_VJCounterFolder
=
"\\\\XQUIKII-3679\\Sample Log Directory"
;
/// <summary>
/// 摄像机名称
...
...
DeviceLibrary/DeviceLibrary.csproj
查看文件 @
61f4e58
...
...
@@ -110,6 +110,7 @@
<Compile Include="DeviceLibrary\RobotMoveHelper.cs" />
<Compile Include="DeviceLibrary\ServerCommunication.cs" />
<Compile Include="DeviceLibrary\AxisBean.cs" />
<Compile Include="DeviceLibrary\ShareFolderWatcher.cs" />
<Compile Include="DeviceLibrary\VJCounter.cs" />
<Compile Include="theMachine\Common.cs" />
<Compile Include="theMachine\JobList.cs" />
...
...
DeviceLibrary/DeviceLibrary/ShareFolderWatcher.cs
0 → 100644
查看文件 @
61f4e58
using
HalconDotNet
;
using
OnlineStore.Common
;
using
System
;
using
System.Collections.Generic
;
using
System.IO
;
using
System.Linq
;
using
System.Text
;
using
System.Threading
;
using
System.Threading.Tasks
;
public
class
ShareFolderWatcher
:
IDisposable
{
Thread
thread
;
bool
run
=
false
;
string
backupfolder
=
"\\image\\VJBackup"
;
public
string
FolderName
;
public
ShareFolderWatcher
(
string
foldername
)
{
FolderName
=
foldername
;
Directory
.
CreateDirectory
(
backupfolder
);
LogUtil
.
info
(
"[ShareFolderWatcher] "
+
"set:"
+
foldername
);
}
public
bool
Start
(
out
string
errmsg
)
{
errmsg
=
""
;
try
{
if
(!
Directory
.
Exists
(
FolderName
))
{
errmsg
=
$
"Directory not exists:{FolderName}"
;
LogUtil
.
error
(
"[ShareFolderWatcher] "
+
errmsg
);
return
false
;
}
}
catch
(
Exception
ex
)
{
errmsg
=
ex
.
ToString
();
LogUtil
.
error
(
"[ShareFolderWatcher] "
+
errmsg
);
return
false
;
}
thread
=
new
Thread
(
new
ThreadStart
(
Watcher
));
thread
.
Start
();
LogUtil
.
error
(
"[ShareFolderWatcher] 文件监听启动成功"
);
return
true
;
}
DateTime
lastUpdateTime
=
DateTime
.
MinValue
;
Dictionary
<
string
,
int
>
CountList
=
new
Dictionary
<
string
,
int
>();
public
DateTime
LastUpdateTime
{
get
=>
lastUpdateTime
;
}
public
int
LastQty
=
0
;
public
string
LastSN
=
""
;
void
Watcher
()
{
run
=
true
;
while
(
run
)
{
Thread
.
Sleep
(
1000
);
try
{
DirectoryInfo
directoryInfo
=
new
DirectoryInfo
(
FolderName
);
var
fis
=
directoryInfo
.
GetFiles
(
"*.csv"
).
Where
(
x
=>
x
.
LastWriteTime
>
lastUpdateTime
).
ToList
();
fis
.
Sort
((
a
,
b
)
=>
b
.
LastWriteTime
.
CompareTo
(
a
.
LastWriteTime
));
if
(
fis
.
Count
>
0
)
lastUpdateTime
=
fis
[
0
].
LastWriteTime
;
else
continue
;
lock
(
CountList
)
{
foreach
(
var
fi
in
fis
)
{
var
file
=
fi
.
FullName
;
var
localfile
=
Path
.
Combine
(
backupfolder
,
Path
.
GetFileName
(
file
));
File
.
Copy
(
file
,
localfile
,
true
);
try
{
File
.
Delete
(
file
);
}
catch
(
Exception
ex
)
{
LogUtil
.
error
(
"[ShareFolderWatcher] "
+
ex
.
ToString
());
}
var
ft
=
File
.
ReadAllLines
(
localfile
);
if
(
ft
.
Length
>=
2
&&
!
string
.
IsNullOrWhiteSpace
(
ft
[
1
]))
{
var
datas
=
ft
[
1
].
Split
(
','
);
if
(
datas
.
Length
==
3
&&
int
.
TryParse
(
datas
[
2
],
out
int
qty
))
{
LogUtil
.
info
(
$
"读取到VJ点料结果:{datas[1]},{qty}"
);
if
(!
CountList
.
ContainsKey
(
datas
[
1
]))
CountList
.
Add
(
datas
[
1
],
qty
);
else
CountList
[
datas
[
1
]]
=
qty
;
LastQty
=
qty
;
LastSN
=
datas
[
1
];
}
}
}
}
}
catch
(
Exception
ex
)
{
LogUtil
.
error
(
"[ShareFolderWatcher] "
+
ex
.
ToString
());
}
}
}
public
bool
GetQty
(
string
barcode
,
out
int
qty
)
{
if
(
barcode
.
Count
(
c
=>
c
==
'#'
)
==
3
)
{
barcode
=
barcode
.
Split
(
'#'
)[
1
].
Substring
(
1
);
}
lock
(
CountList
)
{
if
(
CountList
.
TryGetValue
(
barcode
,
out
qty
))
{
CountList
.
Remove
(
barcode
);
return
true
;
}
}
qty
=
0
;
return
false
;
}
public
void
Dispose
()
{
run
=
false
;
}
}
DeviceLibrary/DeviceLibrary/VJCounter.cs
查看文件 @
61f4e58
...
...
@@ -16,17 +16,32 @@ namespace DeviceLibrary
private
static
StopBits
stopBits
=
StopBits
.
One
;
//停止位
private
static
SerialPort
_serialPort
=
null
;
public
static
string
newline
=
"\n"
;
static
string
comPortName
;
public
static
bool
Connect
(
string
_comport
,
out
string
msg
)
{
public
static
bool
Connect
(
string
_comport
,
int
_baudRate
,
out
string
msg
)
{
msg
=
""
;
try
{
try
{
if
(
_serialPort
!=
null
&&
_serialPort
.
IsOpen
)
{
_serialPort
.
Close
();
_serialPort
.
Dispose
();
_serialPort
=
null
;
}
}
catch
(
Exception
ex
)
{
LogUtil
.
error
(
$
"VJCounter: "
+
ex
);
}
comPortName
=
_comport
;
baudRate
=
_baudRate
;
_serialPort
=
new
SerialPort
(
comPortName
,
baudRate
,
parity
,
dataBits
,
stopBits
);
//_serialPort.RtsEnable = true; //自动请求
//_serialPort.ReadTimeout = 100;//超时
_serialPort
.
Open
();
LogUtil
.
info
(
"VJCounter: 串口连接成功
"
);
LogUtil
.
info
(
$
"VJCounter: 串口连接成功 comPortName:{comPortName},baudRate:{baudRate}
"
);
return
true
;
}
catch
(
Exception
ex
)
{
...
...
@@ -40,19 +55,20 @@ namespace DeviceLibrary
{
if
(
_serialPort
==
null
)
{
return
Connect
(
comPortName
,
out
_
);
return
Connect
(
comPortName
,
baudRate
,
out
_
);
}
else
if
(!
_serialPort
.
IsOpen
)
{
_serialPort
=
null
;
return
Connect
(
comPortName
,
out
_
);
return
Connect
(
comPortName
,
baudRate
,
out
_
);
}
else
return
true
;
}
public
static
void
SendBarcode
(
string
barcode
)
{
var
b
=
Encoding
.
ASCII
.
GetBytes
(
barcode
+
"\n"
);
var
b
=
Encoding
.
ASCII
.
GetBytes
(
barcode
);
_serialPort
.
Write
(
b
,
0
,
b
.
Length
);
_serialPort
.
BaseStream
.
Flush
();
LogUtil
.
info
(
"VJCounter: 串口发送:"
+
barcode
);
}
}
...
...
DeviceLibrary/VirtuallyStore/VStore.cs
查看文件 @
61f4e58
...
...
@@ -252,9 +252,9 @@ namespace DeviceLibrary
//}
//LastProcessErrorTimes++;
Msg
.
add
(
$
"StatusCode:{ti.StatusCode},StatusText:{ti.StatusText},OnlineStatus:{ti.OnlineStatus}"
,
MsgLevel
.
warning
);
//RTStoreStatus = RTStoreStatus.InStoreError
;
//ServerCM.storeStatus = StoreStatus.InStoreFaild
;
RTStoreStatus
=
RTStoreStatus
.
Offline
;
TerminalError
=
false
;
//ServerCM.storeStatus = StoreStatus.None;
}
else
if
(
ti
.
StatusCode
<
10000
)
...
...
@@ -296,32 +296,35 @@ namespace DeviceLibrary
310234,Error clamping on opening (234)
*/
//统计剩余容量
string
capacity
=
""
;
for
(
int
i
=
0
;
i
<
ti
.
Slots
.
Count
;
i
++)
if
(
ti
!=
null
)
{
var
sn
=
ti
.
Slots
[
i
].
Slotname
;
int
w
=
0
;
int
h
=
0
;
if
(
sn
.
StartsWith
(
"s15"
))
{
w
=
15
;
int
.
TryParse
(
sn
.
Substring
(
3
),
out
h
);
}
else
if
(
sn
.
StartsWith
(
"s13"
))
{
w
=
13
;
int
.
TryParse
(
sn
.
Substring
(
3
),
out
h
);
}
else
if
(
sn
.
StartsWith
(
"s7"
))
string
capacity
=
""
;
for
(
int
i
=
0
;
i
<
ti
.
Slots
.
Count
;
i
++)
{
w
=
7
;
int
.
TryParse
(
sn
.
Substring
(
2
),
out
h
);
var
sn
=
ti
.
Slots
[
i
].
Slotname
;
int
w
=
0
;
int
h
=
0
;
if
(
sn
.
StartsWith
(
"s15"
))
{
w
=
15
;
int
.
TryParse
(
sn
.
Substring
(
3
),
out
h
);
}
else
if
(
sn
.
StartsWith
(
"s13"
))
{
w
=
13
;
int
.
TryParse
(
sn
.
Substring
(
3
),
out
h
);
}
else
if
(
sn
.
StartsWith
(
"s7"
))
{
w
=
7
;
int
.
TryParse
(
sn
.
Substring
(
2
),
out
h
);
}
//boxStatus.data.Add("capacity", "7X8=1000;7X12=345;13X32=100;");
capacity
+=
$
"{w}X{h}={ti.Slots[i].Slots_free - ti.Slots[i].Slots_used};"
;
SlotsInfo
[
$
"{w}X{h}"
]
=
$
"{ti.Slots[i].Slots_used}/{ti.Slots[i].Slots_free}"
;
}
//boxStatus.data.Add("capacity", "7X8=1000;7X12=345;13X32=100;");
capacity
+=
$
"{w}X{h}={ti.Slots[i].Slots_free- ti.Slots[i].Slots_used};"
;
SlotsInfo
[
$
"{w}X{h}"
]
=
$
"{ti.Slots[i].Slots_used}/{ti.Slots[i].Slots_free}"
;
ServerCM
.
capacity
=
capacity
;
}
ServerCM
.
capacity
=
capacity
;
}
catch
(
Exception
ex
)
{
...
...
DeviceLibrary/theMachine/MainMachine.cs
查看文件 @
61f4e58
...
...
@@ -60,6 +60,7 @@ namespace DeviceLibrary
TrayManager
.
Init
(
DeviceGroup
);
MI
.
Init
(
Config
,
DeviceGroup
,
out
m
);
CI
.
Init
(
Config
,
DeviceGroup
,
out
m
);
msg
+=
m
;
#
region
初始化
led
灯
RunningLed
=
new
Led
(
Config
.
DOList
[
"root"
][
IO_Type
.
Run_Led
].
GetIOAddr
(),
LedColor
.
green
);
...
...
@@ -163,6 +164,7 @@ namespace DeviceLibrary
TransplantMove
.
DeviceList
.
Values
.
ToList
().
ForEach
(
s
=>
s
.
Stop
());
TrayStop
.
DeviceList
.
Values
.
ToList
().
ForEach
(
s
=>
s
.
Stop
());
MI
.
DeviceList
.
Values
.
ToList
().
ForEach
(
s
=>
s
.
Stop
());
CI
.
DeviceList
.
Values
.
ToList
().
ForEach
(
s
=>
s
.
Stop
());
IOMove
(
IO_Type
.
Line_Run
,
IO_VALUE
.
LOW
);
ResetEvent
.
Set
();
Alarm
(
AlarmType
.
None
);
...
...
@@ -183,6 +185,7 @@ namespace DeviceLibrary
TransplantMove
.
DeviceList
.
Values
.
ToList
().
ForEach
(
s
=>
s
.
Start
());
TrayStop
.
DeviceList
.
Values
.
ToList
().
ForEach
(
s
=>
s
.
Start
());
MI
.
DeviceList
.
Values
.
ToList
().
ForEach
(
s
=>
s
.
Start
());
CI
.
DeviceList
.
Values
.
ToList
().
ForEach
(
s
=>
s
.
Start
());
}
...
...
DeviceLibrary/theMachine/RobotManage.cs
查看文件 @
61f4e58
...
...
@@ -40,6 +40,7 @@ namespace DeviceLibrary
public
static
URRobotControl
Robot_CI
;
public
static
VStoreCollection
VStoreCollection
;
public
static
ShareFolderWatcher
folderWatcher
;
public
static
void
Init
()
{
string
msg
=
""
;
try
...
...
@@ -60,6 +61,14 @@ namespace DeviceLibrary
msg
+=
crc
.
GetString
(
"Res0180"
,
"找不到库位配置文件"
)
+
"\n"
;
}
folderWatcher
=
new
ShareFolderWatcher
(
Setting_Init
.
Device_VJCounterFolder
);
if
(!
folderWatcher
.
Start
(
out
string
errmsg
))
{
IsLoadOk
=
false
;
msg
+=
errmsg
+
"\n"
;
LogUtil
.
error
(
"ShareFolderWatcher:"
+
errmsg
);
}
string
MI1PostionFile
=
"config\\MI1Postion.csv"
;
string
MI2PostionFile
=
"config\\MI2Postion.csv"
;
string
CIPostionFile
=
"config\\CIPostion.csv"
;
...
...
@@ -93,7 +102,7 @@ namespace DeviceLibrary
msg
+=
crc
.
GetString
(
"Res0181"
,
"IO板卡初始化失败"
)
+
"\n"
;
}
if
(!
VJCounter
.
Connect
(
Setting_Init
.
VJCounter_COMPORT
,
out
string
msgs
))
{
if
(!
VJCounter
.
Connect
(
Setting_Init
.
VJCounter_COMPORT
,
Setting_Init
.
VJCounter_BaudRate
,
out
string
msgs
))
{
IsLoadOk
=
false
;
msg
+=
crc
.
GetString
(
"Res0111.43f91cee"
,
"VJ点料机连接失败"
)
+
"\n"
;
LogUtil
.
error
(
msg
+
","
+
msgs
);
...
...
@@ -103,6 +112,7 @@ namespace DeviceLibrary
DeviceRunControl
.
AddDevice
(
"TransplantMove"
,
TransplantMove
.
DeviceList
.
Values
.
ToList
<
IDevice
>());
//DeviceRunControl.AddDevice("TrayStop", TrayStop.DeviceList.Values.ToList<IDevice>());
DeviceRunControl
.
AddDevice
(
"MI"
,
MI
.
DeviceList
.
Values
.
ToList
<
IDevice
>());
DeviceRunControl
.
AddDevice
(
"CI"
,
CI
.
DeviceList
.
Values
.
ToList
<
IDevice
>());
TrayStop
.
DeviceList
.
Values
.
ToList
<
IDevice
>().
ForEach
(
device
=>
{
DeviceRunControl
.
AddDevice
(
device
.
GroupName
,
new
List
<
IDevice
>()
{
device
});
});
if
(
G
.
simulate
)
...
...
DeviceLibrary/theMachine/TrayManager.cs
查看文件 @
61f4e58
...
...
@@ -95,7 +95,7 @@ namespace DeviceLibrary
static
void
SaveTrayInfo
()
{
try
{
var
TL
=
Traylist
.
Where
(
t
=>
t
.
Value
.
DestinationAddr
>=
0
).
ToDictionary
(
a
=>
a
.
Key
,
a
=>
a
.
Value
);
var
TL
=
Traylist
.
Where
(
t
=>
t
.
Value
.
RFID
!=
null
&&
t
.
Value
.
DestinationAddr
>=
0
).
ToDictionary
(
a
=>
a
.
Key
,
a
=>
a
.
Value
);
ConfigHelper
.
Config
.
FileSave
(
JsonConvert
.
SerializeObject
(
TL
),
"Config\\TrayList.temp~"
);
ConfigHelper
.
Config
.
FileSave
(
JsonConvert
.
SerializeObject
(
TL
),
"Config\\TrayList.temp"
);
}
...
...
@@ -235,7 +235,7 @@ namespace DeviceLibrary
else
{
SetTrayLoadInfo
(
device
.
CurrrentRFID
,
requestLoadInfo
);
}
LogUtil
.
info
(
"释放设备:"
+
device
.
GroupName
);
LogUtil
.
info
(
"释放设备:"
+
device
.
GroupName
+
","
+
device
.
CurrrentRFID
);
device
.
TrayRelease
();
}
}
...
...
@@ -287,7 +287,7 @@ namespace DeviceLibrary
public
static
bool
IsNeedProcessNG
(
RemoteLoad
remoteLoad
)
{
var
requestLoadInfo
=
remoteLoad
.
RequestLoadInfo
;
var
xx
=
TrayManager
.
Traylist
.
Values
.
ToList
().
Where
(
t
=>
t
.
HasLoad
&&
t
.
LoadType
==
requestLoadInfo
.
GetTrayType
&&
t
.
DestinationAddr
==
3
&&
(
t
.
LastAddr
>=
20
||
t
.
LastAddr
<=
3
));
var
xx
=
TrayManager
.
Traylist
.
Values
.
ToList
().
Where
(
t
=>
t
.
RFID
!=
null
&&
t
.
HasLoad
&&
t
.
LoadType
==
requestLoadInfo
.
GetTrayType
&&
t
.
DestinationAddr
==
3
&&
(
t
.
LastAddr
>=
20
||
t
.
LastAddr
<=
3
));
return
xx
.
Count
()
>
0
;
}
...
...
@@ -347,9 +347,12 @@ namespace DeviceLibrary
public
string
RFID
{
get
=>
_rfid
;
set
{
try
{
var
ss
=
Enum
.
GetNames
(
typeof
(
TrayTypeE
));
TrayType
=
(
TrayTypeE
)
Enum
.
Parse
(
typeof
(
TrayTypeE
),
ss
.
ToList
().
Find
(
s
=>
value
.
StartsWith
(
s
)));
_rfid
=
value
;
if
(
value
!=
null
)
{
var
ss
=
Enum
.
GetNames
(
typeof
(
TrayTypeE
));
TrayType
=
(
TrayTypeE
)
Enum
.
Parse
(
typeof
(
TrayTypeE
),
ss
.
ToList
().
Find
(
s
=>
value
.
StartsWith
(
s
)));
_rfid
=
value
;
}
}
catch
(
Exception
ex
)
{
LogUtil
.
error
(
$
"获取RFID的类型时出错:{value}"
);
...
...
DeviceLibrary/theMachine/sub/CI.cs
查看文件 @
61f4e58
using
ConfigHelper
;
using
HalconDotNet
;
using
Newtonsoft.Json
;
using
OnlineStore
;
using
OnlineStore.Common
;
...
...
@@ -19,8 +20,6 @@ namespace DeviceLibrary
public
class
CI
:
DeviceBase
,
IDevice
{
public
static
Dictionary
<
string
,
CI
>
DeviceList
=
new
Dictionary
<
string
,
CI
>();
public
static
void
Init
(
Robot_Config
config
,
Dictionary
<
string
,
DeviceGroup
>
devices
,
out
string
msg
)
{
msg
=
""
;
CI
sideMove
=
new
CI
(
devices
[
"CI"
],
out
string
m
);
...
...
@@ -39,6 +38,8 @@ namespace DeviceLibrary
string
POS_Start
=
"CI"
;
string
robotname
=
""
;
public
bool
ManualCount
=
false
;
public
event
EventHandler
<
string
>
ReelReady
;
public
event
EventHandler
<
XRayStepE
>
XRayStep
;
public
CI
(
DeviceGroup
device
,
out
string
msg
)
:
base
()
{
msg
=
""
;
...
...
@@ -55,14 +56,11 @@ namespace DeviceLibrary
robotname
=
"R3"
;
}
Robot
.
Name
=
robotname
;
robotHelper
=
new
RobotHelper
(
Robot
,
robotname
);
Comp
=
AxisBean
.
List
[
DeviceGroup
.
GroupName
][
0
];
//
robotHelper = new RobotHelper(Robot, robotname);
//
Comp = AxisBean.List[DeviceGroup.GroupName][0];
//Rotate = AxisBean.List[DeviceGroup.GroupName][1];
BufferSlotsManger
=
new
BufferSlotsManger
(
POS_Start
);
}
}
public
DeviceStateE
DeviceState
{
get
;
set
;
}
public
void
Start
()
...
...
@@ -71,7 +69,7 @@ namespace DeviceLibrary
//robotHelper.Start();
DeviceState
=
DeviceStateE
.
HomeReset
;
MoveInfo
.
NewMove
(
MoveStep
.
H01_HomeReset
);
MoveInfo
.
log
(
"开始回原"
);
MoveInfo
.
log
(
"开始回原
1
"
);
}
public
void
Stop
()
...
...
@@ -79,7 +77,7 @@ namespace DeviceLibrary
//robotHelper.Stop();
//Robot.StopRobot();
DeviceState
=
DeviceStateE
.
Stop
;
MoveInfo
.
log
(
"停止运行"
);
MoveInfo
.
log
(
"停止运行
1
"
);
}
public
void
Process
()
{
...
...
@@ -122,22 +120,14 @@ namespace DeviceLibrary
return
true
;
}
int
isalivetrytimes
=
0
;
int
StopBufDelayMS
=
500
;
int
StopDelayMS
=
1500
;
RobotPosition
FromPos
;
RobotPosition
ToPos
;
VStore
CurrentVStore
;
JobInfo
CurrentJobInfo
;
VStore
CurrntOutReadyStore
;
public
void
OneWayProcess
()
{
//Config.Set("RuntimeRobot_MoveStep", MoveInfo.MoveStep.ToString());
if
(
CheckWait
(
MoveInfo
))
return
;
switch
(
MoveInfo
.
MoveStep
)
{
case
MoveStep
.
Wait
:
...
...
@@ -160,257 +150,158 @@ namespace DeviceLibrary
MoveInfo
.
MoveParam
.
PlateH
=
CurrentJobInfo
.
plateH
;
MoveInfo
.
MoveParam
.
cid
=
CurrentJobInfo
.
CID
;
MoveInfo
.
NextMoveStep
(
MoveStep
.
MI_01
);
//FromPos = GetMIPosition(GroupName, POS_Start + "_MT");
//var cid = MoveInfo.MoveParam.PosID;//.Split('_')[0];
//ToPos = GetMIPosition(GroupName, TowerList.List[cid].PosID);
Config
.
Set
(
"Runtime_Robot_"
+
robotname
+
"_ReelInfo"
,
JsonConvert
.
SerializeObject
(
MoveInfo
.
MoveParam
));
//Config.Set("Runtime_Robot_" + robotname + "_FromPos" , FromPos.PositionNum);
//Config.Set("Runtime_Robot_" + robotname + "_ToPos" , ToPos.PositionNum);
//MoveInfo.log($"开始转移物料:{FromPos.PositionNum}=>{ToPos.PositionNum}");
Config
.
Set
(
"Runtime_Robot_"
+
robotname
+
"_ReelInfo"
,
JsonConvert
.
SerializeObject
(
MoveInfo
.
MoveParam
));
var
cc
=
MoveInfo
.
MoveParam
.
WareCode
.
Split
(
'#'
);
if
(
cc
.
Count
()>
2
)
ReelReady
?.
Invoke
(
this
,
cc
[
0
].
Substring
(
1
)
+
"|"
+
cc
[
1
].
Substring
(
1
));
else
ReelReady
?.
Invoke
(
this
,
MoveInfo
.
MoveParam
.
WareCode
);
XRayStep
?.
Invoke
(
this
,
XRayStepE
.
WaitMTtoVJ
);
MoveInfo
.
log
(
$
"开始点料"
);
VJCounter
.
SendBarcode
(
ProcessCodeGetVJType
(
MoveInfo
.
MoveParam
.
WareCode
)
+
VJCounter
.
newline
);
}
break
;
case
MoveStep
.
MI_01
:
MoveInfo
.
NextMoveStep
(
MoveStep
.
MI_02
);
RoboMoveInfo
.
MoveParam
=
MoveInfo
.
MoveParam
.
clone
();
RoboMoveInfo
.
NextMoveStep
(
MoveStep
.
MI_01
);
MoveInfo
.
log
(
"机器人开始取料"
);
Msg
.
add
(
"等待人员料盘放置到点料机"
,
MsgLevel
.
warning
);
MoveInfo
.
log
(
"等待人员取走料盘"
);
break
;
case
MoveStep
.
MI_02
:
if
(
RoboMoveInfo
.
MoveStep
>=
MoveStep
.
MI_08
)
MoveInfo
.
NextMoveStep
(
MoveStep
.
MI_10
);
RemoteLoad
remoteLoad
=
new
RemoteLoad
();
remoteLoad
.
Action
=
""
;
remoteLoad
.
GroupName
=
GroupName
;
remoteLoad
.
RequestLoadInfo
=
new
RequestLoadInfo
();
remoteLoad
.
RequestLoadInfo
.
DeviceGroupName
=
GroupName
;
remoteLoad
.
RequestLoadInfo
.
IsEmpty
=
true
;
remoteLoad
.
RequestLoadInfo
.
LoadParam
=
MoveInfo
.
MoveParam
.
clone
();
TrayManager
.
TrayRelease
(
remoteLoad
);
TrayStop
.
DeviceList
[
GroupName
].
TrayRelease
();
MoveInfo
.
log
(
"取料完成托盘放行"
);
TheLine
.
UpdateLocInfo
(
""
,
remoteLoad
.
RequestLoadInfo
.
LoadParam
.
WareCode
,
TheLine
.
LineStatusE
.
INROBOT
,
GroupName
);
//VJCounter.SendBarcode(ProcessCodeGetVJType(MoveInfo.MoveParam.WareCode));
MoveInfo
.
WaitList
.
Add
(
WaitResultInfo
.
WaitTime
(
1000
));
break
;
case
MoveStep
.
MI_10
:
MoveInfo
.
NextMoveStep
(
MoveStep
.
MI_11
);
///VJCounter.SendBarcode(ProcessCodeGetVJType(MoveInfo.MoveParam.WareCode));
//Thread.Sleep(1000);
TrayStop
.
DeviceList
[
"CI"
].
IOMove
(
IO_Type
.
CI_Start
,
IO_VALUE
.
HIGH
,
500
);
MoveInfo
.
log
(
"步骤1: 按下启动开始点料"
);
XRayStep
?.
Invoke
(
this
,
XRayStepE
.
Counting
);
break
;
case
MoveStep
.
MI_11
:
if
(
IOValue
(
IO_Type
.
CI_Count_Finished
).
Equals
(
IO_VALUE
.
LOW
))
{
MoveInfo
.
NextMoveStep
(
MoveStep
.
MI_03
);
if
(
FromPos
.
PositionNum
.
EndsWith
(
"MT"
))
{
RemoteLoad
remoteLoad
=
new
RemoteLoad
();
remoteLoad
.
Action
=
""
;
remoteLoad
.
GroupName
=
GroupName
;
remoteLoad
.
RequestLoadInfo
=
new
RequestLoadInfo
();
remoteLoad
.
RequestLoadInfo
.
DeviceGroupName
=
GroupName
;
remoteLoad
.
RequestLoadInfo
.
IsEmpty
=
true
;
remoteLoad
.
RequestLoadInfo
.
LoadParam
=
RoboMoveInfo
.
MoveParam
.
clone
();
TrayManager
.
TrayRelease
(
remoteLoad
);
TrayStop
.
DeviceList
[
GroupName
].
TrayRelease
();
RoboMoveInfo
.
log
(
"取料完成托盘放行"
);
TheLine
.
UpdateLocInfo
(
""
,
remoteLoad
.
RequestLoadInfo
.
LoadParam
.
WareCode
,
TheLine
.
LineStatusE
.
INROBOT
,
GroupName
);
}
else
RoboMoveInfo
.
log
(
"取料完成"
);
MoveInfo
.
NextMoveStep
(
MoveStep
.
MI_12
);
MoveInfo
.
log
(
"步骤2: 满抽屉正在进入"
);
}
break
;
case
MoveStep
.
MI_03
:
if
(
RoboMoveInfo
.
MoveStep
==
MoveStep
.
MI_ReelTacked
)
else
if
(
MoveInfo
.
IsTimeOut
(
2000
))
{
MoveInfo
.
NextMoveStep
(
MoveStep
.
MI_04
);
MoveInfo
.
log
(
"等待抽屉进入点料机超时"
);
Msg
.
add
(
"等待抽屉进入点料机超时"
,
MsgLevel
.
warning
);
}
break
;
case
MoveStep
.
MI_
04
:
if
(
CurrentVStore
.
RTStoreStatus
==
RTStoreStatus
.
Ready
||
CurrentVStore
.
RTStoreStatus
==
RTStoreStatus
.
LockToInStore
)
case
MoveStep
.
MI_
12
:
if
(
IOValue
(
IO_Type
.
CI_Count_Finished
).
Equals
(
IO_VALUE
.
HIGH
)
)
{
MoveInfo
.
NextMoveStep
(
MoveStep
.
MI_05
);
RoboMoveInfo
.
NextMoveStep
(
MoveStep
.
MI_40
);
MoveInfo
.
log
(
"机器人开始放料"
);
CurrentVStore
.
RequestInStore
(
new
JobInfo
(
RoboMoveInfo
.
MoveParam
.
WareCode
,
""
,
RoboMoveInfo
.
MoveParam
.
PlateW
,
RoboMoveInfo
.
MoveParam
.
PlateH
));
MoveInfo
.
NextMoveStep
(
MoveStep
.
MI_13
);
MoveInfo
.
log
(
"步骤3: 空抽屉已退出, 等待一会"
);
MoveInfo
.
WaitList
.
Add
(
WaitResultInfo
.
WaitTime
(
1000
*
40
));
}
else
else
if
(
MoveInfo
.
IsTimeOut
(
5000
))
{
MoveInfo
.
log
(
"机器人放料时发现舱门口有料"
);
MoveInfo
.
log
(
"等待内部抽屉退出超时"
);
Msg
.
add
(
"等待内部抽屉退出超时"
,
MsgLevel
.
warning
);
}
break
;
case
MoveStep
.
MI_05
:
if
(
RoboMoveInfo
.
MoveStep
==
MoveStep
.
Wait
)
case
MoveStep
.
MI_13
:
MoveInfo
.
NextMoveStep
(
MoveStep
.
MI_14
);
MoveInfo
.
log
(
"步骤4: 按启动按钮准备退出满抽屉"
);
TrayStop
.
DeviceList
[
"CI"
].
IOMove
(
IO_Type
.
CI_Start
,
IO_VALUE
.
HIGH
,
500
);
break
;
case
MoveStep
.
MI_14
:
if
(
IOValue
(
IO_Type
.
CI_Count_Finished
).
Equals
(
IO_VALUE
.
LOW
))
{
MoveInfo
.
NextMoveStep
(
MoveStep
.
MI_15
);
MoveInfo
.
log
(
"步骤5: 空抽屉正在进入"
);
}
else
if
(
MoveInfo
.
IsTimeOut
(
2000
))
{
MoveInfo
.
log
(
"
放入料仓口完成:"
+
RoboMoveInfo
.
MoveParam
.
ToStr
()
);
M
oveInfo
.
NewMove
(
MoveStep
.
Wait
);
MoveInfo
.
log
(
"
等待抽屉进入点料机超时"
);
M
sg
.
add
(
"等待抽屉进入点料机超时"
,
MsgLevel
.
warning
);
}
break
;
case
MoveStep
.
MI_50
:
//var InStoreError = VStoreCollection.VStoreList.Values.Where(vs => vs.TowerInfo.DeviceGroupName == GroupName).ToList().Find(vs => DateTime.Now > vs.LastProcessErrorTime && vs.LastProcessErrorTimes < 4 && (vs.RTStoreStatus == RTStoreStatus.InStoreError || vs.RTStoreStatus == RTStoreStatus.InStoreDataTimeOut || vs.TerminalError));
var
InStoreError
=
VStoreCollection
.
VStoreList
.
Values
.
Where
(
vs
=>
vs
.
TowerInfo
.
DeviceGroupName
==
GroupName
).
ToList
().
Find
(
vs
=>
(
vs
.
RTStoreStatus
==
RTStoreStatus
.
InStoreError
||
vs
.
RTStoreStatus
==
RTStoreStatus
.
InStoreDataTimeOut
||
vs
.
TerminalError
));
if
(
InStoreError
!=
null
)
case
MoveStep
.
MI_15
:
if
(
IOValue
(
IO_Type
.
CI_Count_Finished
).
Equals
(
IO_VALUE
.
HIGH
))
{
var
result
=
TheLine
.
GetReelSize
<
ResultData
>(
InStoreError
.
CurrentTerminalReelID
);
if
(
result
!=
null
&&
result
.
code
==
0
)
{
CurrntOutReadyStore
=
InStoreError
;
//InStoreError.ServerCM.cancelPutInTask(CurrntOutReadyStore.CurrentTerminalReelID);
CurrentJobInfo
=
new
JobInfo
(
InStoreError
.
CurrentTerminalReelID
,
""
,
int
.
Parse
(
result
.
data
[
"plateW"
]),
int
.
Parse
(
result
.
data
[
"plateH"
]));
InStoreError
.
InStoreJobInfo
=
null
;
MoveInfo
.
log
(
"从服务器检索到物料数据:"
+
CurrentJobInfo
.
ToStr
());
CurrentJobInfo
.
isNG
=
true
;
CurrentJobInfo
.
NgMsg
=
InStoreError
.
CID
+
"-"
+
InStoreError
.
CurrentTowerStatusText
;
MoveInfo
.
log
(
"检测到有料仓入库NG:"
+
MoveInfo
.
MoveParam
.
NgMsg
);
}
else
{
if
(
result
!=
null
)
MoveInfo
.
log
(
JsonConvert
.
SerializeObject
(
result
));
MoveInfo
.
log
(
$
"没有找到,在等待出库的料仓 CID:{InStoreError.CID} SN:"
+
InStoreError
.
CurrentTerminalReelID
);
MoveInfo
.
NextMoveStep
(
MoveStep
.
Wait
);
TrayStop
.
DeviceList
[
GroupName
].
TrayRelease
();
return
;
}
MoveInfo
.
NextMoveStep
(
MoveStep
.
MI_16
);
MoveInfo
.
log
(
"步骤6: 满抽屉已退出, 点料完成"
);
//IOMove(IO_Type.CI_Start, IO_VALUE.HIGH, 1000);
XRayStep
?.
Invoke
(
this
,
XRayStepE
.
WaitCountResult
);
}
else
{
var
random
=
new
Random
(
DateTime
.
Now
.
Millisecond
);
CurrntOutReadyStore
=
VStoreCollection
.
VStoreList
.
Values
.
Where
(
vs
=>
vs
.
TowerInfo
.
DeviceGroupName
==
GroupName
).
ToList
().
FindAll
(
vs
=>
vs
.
RTStoreStatus
==
RTStoreStatus
.
OutStoreReady
).
OrderBy
(
x
=>
random
.
Next
()).
FirstOrDefault
();
if
(
CurrntOutReadyStore
!=
null
)
{
if
(
string
.
IsNullOrEmpty
(
CurrntOutReadyStore
.
CurrentTerminalReelID
))
{
MoveInfo
.
log
(
"当前出库料仓:"
+
CurrntOutReadyStore
.
CID
+
"已是出库完成状态,但是还没有读到物料完成通知"
);
return
;
}
if
(!
VStoreCollection
.
OutStoreReelInfo
.
ContainsKey
(
CurrntOutReadyStore
.
CurrentTerminalReelID
))
{
MoveInfo
.
log
(
"当前出库料仓:"
+
CurrntOutReadyStore
.
CID
+
",没有找到料盘信息:"
+
CurrntOutReadyStore
.
CurrentTerminalReelID
);
var
result
=
TheLine
.
GetReelSize
<
ResultData
>(
CurrntOutReadyStore
.
CurrentTerminalReelID
);
if
(
result
!=
null
&&
result
.
code
==
0
)
{
CurrentJobInfo
=
new
JobInfo
(
CurrntOutReadyStore
.
CurrentTerminalReelID
,
""
,
int
.
Parse
(
result
.
data
[
"plateW"
]),
int
.
Parse
(
result
.
data
[
"plateH"
]));
MoveInfo
.
log
(
"从服务器检索到物料数据:"
+
CurrentJobInfo
.
ToStr
());
}
else
return
;
}
else
{
var
job
=
VStoreCollection
.
OutStoreReelInfo
[
CurrntOutReadyStore
.
CurrentTerminalReelID
];
CurrentJobInfo
=
job
.
Clone
();
}
}
else
{
MoveInfo
.
log
(
"没有找到,在等待出库的料仓"
);
MoveInfo
.
NextMoveStep
(
MoveStep
.
Wait
);
TrayStop
.
DeviceList
[
GroupName
].
TrayRelease
();
return
;
}
else
if
(
MoveInfo
.
IsTimeOut
(
60
))
{
MoveInfo
.
log
(
"等待内部抽屉退出超时"
);
Msg
.
add
(
"等待内部抽屉退出超时"
,
MsgLevel
.
warning
);
}
CurrntOutReadyStore
.
LastProcessErrorTime
=
DateTime
.
Now
.
AddSeconds
(
15
);
MoveInfo
.
log
(
"收到物料出库任务:"
+
CurrentJobInfo
.
ToStr
());
MoveInfo
.
MoveParam
.
WareCode
=
CurrentJobInfo
.
WareNum
;
MoveInfo
.
MoveParam
.
PosID
=
CurrentJobInfo
.
PosId
;
MoveInfo
.
MoveParam
.
PlateW
=
CurrentJobInfo
.
plateW
;
MoveInfo
.
MoveParam
.
PlateH
=
CurrentJobInfo
.
plateH
;
MoveInfo
.
MoveParam
.
IsNg
=
CurrentJobInfo
.
isNG
;
MoveInfo
.
MoveParam
.
NgMsg
=
CurrentJobInfo
.
NgMsg
;
MoveInfo
.
MoveParam
.
cid
=
CurrntOutReadyStore
.
CID
;
FromPos
=
GetMIPosition
(
GroupName
,
TowerList
.
List
[
MoveInfo
.
MoveParam
.
cid
].
PosID
);
ToPos
=
GetMIPosition
(
GroupName
,
POS_Start
+
"_MT"
);
Config
.
Set
(
"Runtime_Robot_"
+
robotname
+
"_ReelInfo"
,
JsonConvert
.
SerializeObject
(
MoveInfo
.
MoveParam
));
Config
.
Set
(
"Runtime_Robot_"
+
robotname
+
"_FromPos"
,
FromPos
.
PositionNum
);
Config
.
Set
(
"Runtime_Robot_"
+
robotname
+
"_ToPos"
,
ToPos
.
PositionNum
);
MoveInfo
.
NextMoveStep
(
MoveStep
.
MI_51
);
MoveInfo
.
log
(
$
"开始转移物料:{FromPos.PositionNum}=>{ToPos.PositionNum}"
);
break
;
case
MoveStep
.
MI_51
:
MoveInfo
.
NextMoveStep
(
MoveStep
.
MI_52
);
RoboMoveInfo
.
MoveParam
=
MoveInfo
.
MoveParam
.
clone
();
RoboMoveInfo
.
NextMoveStep
(
MoveStep
.
MI_01
);
MoveInfo
.
log
(
"机器人开始取料"
);
break
;
case
MoveStep
.
MI_52
:
if
(
RoboMoveInfo
.
MoveStep
==
MoveStep
.
MI_ReelTacked
)
case
MoveStep
.
MI_16
:
if
(
RobotManage
.
folderWatcher
.
GetQty
(
MoveInfo
.
MoveParam
.
WareCode
,
out
int
qty
))
{
MoveInfo
.
NextMoveStep
(
MoveStep
.
MI_17
);
TheLine
.
UpdateReelQty
(
MoveInfo
.
MoveParam
.
WareCode
,
qty
);
MoveInfo
.
MoveParam
.
WareCode
=
ProcessCodeInsertQty
(
MoveInfo
.
MoveParam
.
WareCode
,
qty
);
MoveInfo
.
MoveParam
.
QTY
=
qty
;
MoveInfo
.
log
(
"步骤7: 获得点料结果:"
+
qty
+
", "
+
MoveInfo
.
MoveParam
.
WareCode
);
}
else
if
(
MoveInfo
.
IsTimeOut
(
120
))
{
lock
(
VStoreCollection
.
OutStoreReelInfo
)
{
VStoreCollection
.
OutStoreReelInfo
.
Remove
(
MoveInfo
.
MoveParam
.
WareCode
);
}
TheLine
.
UpdateLocInfo
(
""
,
MoveInfo
.
MoveParam
.
WareCode
,
TheLine
.
LineStatusE
.
INROBOT
,
GroupName
);
MoveInfo
.
log
(
"机器人已取到料"
);
if
(
CurrntOutReadyStore
.
TerminalError
)
{
MoveInfo
.
log
(
$
"当前出库料仓[{CurrntOutReadyStore.CID}]存在状态错误:"
+
CurrntOutReadyStore
.
RTStoreStatus
);
CurrntOutReadyStore
.
RTStoreStatus
=
RTStoreStatus
.
Busy
;
}
MoveInfo
.
log
(
$
"机器人抓取状态:MI_Robot_Reel_Check:{IOValue(IO_Type.MI_Robot_Reel_Check)}, MI_Robot_Clamp_Check:{IOValue(IO_Type.MI_Robot_Clamp_Check)}"
);
if
(
IOValue
(
IO_Type
.
MI_Robot_Reel_Check
).
Equals
(
IO_VALUE
.
LOW
)
&&
IOValue
(
IO_Type
.
MI_Robot_Clamp_Check
).
Equals
(
IO_VALUE
.
LOW
))
{
if
(
MoveInfo
.
MoveParam
.
IsNg
||
CurrntOutReadyStore
.
TerminalError
)
{
MoveInfo
.
log
(
"机器人抓取NG料后发现夹爪上没有料,流程结束处理"
);
}
else
MoveInfo
.
log
(
"机器人抓取正常出库物料后发现夹爪上没有料,流程结束处理"
);
CurrntOutReadyStore
.
TerminalError
=
false
;
RoboMoveInfo
.
NextMoveStep
(
MoveStep
.
Wait
);
MoveInfo
.
NextMoveStep
(
MoveStep
.
Wait
);
if
(!
TrayStop
.
DeviceList
[
GroupName
].
IsFree
())
{
RemoteLoad
remoteLoad
=
new
RemoteLoad
();
remoteLoad
.
Action
=
"SetTrayRequest"
;
remoteLoad
.
GroupName
=
GroupName
;
remoteLoad
.
RequestLoadInfo
=
new
RequestLoadInfo
();
remoteLoad
.
RequestLoadInfo
.
TrayType
=
TrayTypeE
.
MTP1
.
ToString
();
remoteLoad
.
RequestLoadInfo
.
IsEmpty
=
true
;
remoteLoad
.
RequestLoadInfo
.
DeviceGroupName
=
GroupName
;
TrayManager
.
SetTrayRequest
(
remoteLoad
);
}
TheLine
.
emptyOut
(
CurrentJobInfo
.
WareNum
);
TheLine
.
UpdateLocInfo
(
""
,
CurrentJobInfo
.
WareNum
,
TheLine
.
LineStatusE
.
BOXDOOR_NOREEL
,
CurrntOutReadyStore
.
CID
);
MoveInfo
.
log
(
"检测到夹爪空抓 reelid:"
+
CurrentJobInfo
.
WareNum
);
return
;
}
if
(!
MoveInfo
.
MoveParam
.
IsNg
&&
IOValue
(
IO_Type
.
MI_Robot_Reel_Check
).
Equals
(
IO_VALUE
.
LOW
)
&&
IOValue
(
IO_Type
.
MI_Robot_Clamp_Check
).
Equals
(
IO_VALUE
.
LOW
))
{
return
;
}
else
if
(
MoveInfo
.
MoveParam
.
IsNg
)
{
CurrntOutReadyStore
.
ServerCM
.
cancelPutInTask
(
CurrntOutReadyStore
.
CurrentTerminalReelID
);
MoveInfo
.
log
(
"物料NG取消入库:"
+
CurrntOutReadyStore
.
CurrentTerminalReelID
);
}
MoveInfo
.
NextMoveStep
(
MoveStep
.
MI_53
);
MoveInfo
.
NextMoveStep
(
MoveStep
.
MI_16
);
MoveInfo
.
log
(
"等待点料结果超时"
);
Msg
.
add
(
"等待点料结果超时"
,
MsgLevel
.
warning
);
}
break
;
case
MoveStep
.
MI_17
:
MoveInfo
.
NextMoveStep
(
MoveStep
.
MI_50
);
MoveInfo
.
MoveParam
=
TheLine
.
Regetposid
(
MoveInfo
.
MoveParam
,
TrayTypeE
.
MTP1
.
ToString
(),
out
string
msg
);
MoveInfo
.
log
(
$
"步骤7: 重新获取库位 msg:{msg},\t {MoveInfo.MoveParam.ToStr()}"
);
break
;
case
MoveStep
.
MI_50
:
MoveInfo
.
NextMoveStep
(
MoveStep
.
MI_53
);
break
;
case
MoveStep
.
MI_53
:
if
(!
TrayStop
.
DeviceList
[
GroupName
].
IsFree
())
{
MoveInfo
.
NextMoveStep
(
MoveStep
.
MI_54
);
RoboMoveInfo
.
NextMoveStep
(
MoveStep
.
MI_40
);
MoveInfo
.
log
(
"机器人开始放料"
);
XRayStep
?.
Invoke
(
this
,
XRayStepE
.
WaitVJtoMT
);
RequestLoadInfo
RequestLoadInfo
=
new
RequestLoadInfo
();
RequestLoadInfo
.
LoadParam
=
MoveInfo
.
MoveParam
.
clone
();
RequestLoadInfo
.
DeviceGroupName
=
MoveInfo
.
MoveParam
.
cid
;
RequestLoadInfo
.
TrayType
=
TrayTypeE
.
MTP1
.
ToString
();
RequestLoadInfo
.
IsEmpty
=
false
;
TrayManager
.
SetTrayLoadInfo
(
TrayStop
.
DeviceList
[
"CI"
].
CurrrentRFID
,
RequestLoadInfo
);
}
else
{
RemoteLoad
remoteLoad
=
new
RemoteLoad
();
remoteLoad
.
Action
=
"SetTrayRequest"
;
remoteLoad
.
GroupName
=
GroupName
;
remoteLoad
.
RequestLoadInfo
=
new
RequestLoadInfo
();
remoteLoad
.
RequestLoadInfo
.
TrayType
=
TrayTypeE
.
MTP1
.
ToString
();
remoteLoad
.
RequestLoadInfo
.
IsEmpty
=
true
;
remoteLoad
.
RequestLoadInfo
.
DeviceGroupName
=
GroupName
;
TrayManager
.
SetTrayRequest
(
remoteLoad
);
Msg
.
add
(
crc
.
GetString
(
"Res0097.b5a12101"
,
"等待空托盘"
),
MsgLevel
.
info
);
else
{
RemoteLoad
remoteLoad1
=
new
RemoteLoad
();
remoteLoad1
.
Action
=
"SetTrayRequest"
;
remoteLoad1
.
GroupName
=
GroupName
;
remoteLoad1
.
RequestLoadInfo
=
new
RequestLoadInfo
();
remoteLoad1
.
RequestLoadInfo
.
TrayType
=
TrayTypeE
.
MTP1
.
ToString
();
remoteLoad1
.
RequestLoadInfo
.
IsEmpty
=
true
;
remoteLoad1
.
RequestLoadInfo
.
DeviceGroupName
=
GroupName
;
TrayManager
.
SetTrayRequest
(
remoteLoad1
);
Msg
.
add
(
crc
.
GetString
(
"Res0097.b5a12101"
,
"等待空托盘"
),
MsgLevel
.
info
);
}
break
;
case
MoveStep
.
MI_54
:
if
(
RoboMoveInfo
.
MoveStep
>=
MoveStep
.
MI_44
)
{
MoveInfo
.
log
(
"机器人完成放料"
);
RemoteLoad
remoteLoad
=
new
RemoteLoad
();
remoteLoad
.
GroupName
=
GroupName
;
remoteLoad
.
RequestLoadInfo
=
new
RequestLoadInfo
();
remoteLoad
.
RequestLoadInfo
.
DeviceGroupName
=
"AMH-ML5-2"
;
remoteLoad
.
RequestLoadInfo
.
IsEmpty
=
false
;
remoteLoad
.
RequestLoadInfo
.
TrayType
=
TrayTypeE
.
MTP1
.
ToString
();
remoteLoad
.
RequestLoadInfo
.
LoadParam
=
MoveInfo
.
MoveParam
.
clone
();
// 填充料盘信息
TrayManager
.
TrayRelease
(
remoteLoad
);
//这条会自动放行托盘并且写入托盘目的地
TheLine
.
UpdateLocInfo
(
""
,
MoveInfo
.
MoveParam
.
WareCode
,
TheLine
.
LineStatusE
.
INLINE
,
CurrrentRFID
);
TrayManager
.
ClearTrayRequest
(
GroupName
);
MoveInfo
.
NextMoveStep
(
MoveStep
.
MI_55
);
}
case
MoveStep
.
MI_54
:
Msg
.
add
(
"等待人工放上料盘"
,
MsgLevel
.
warning
);
break
;
case
MoveStep
.
MI_55
:
if
(
RoboMoveInfo
.
MoveStep
==
MoveStep
.
Wait
)
{
MoveInfo
.
log
(
"机器人任务结束"
);
MoveInfo
.
NewMove
(
MoveStep
.
Wait
);
}
MoveInfo
.
log
(
"点料任务结束"
);
XRayStep
?.
Invoke
(
this
,
XRayStepE
.
Finish
);
MoveInfo
.
NewMove
(
MoveStep
.
Wait
);
break
;
}
...
...
@@ -427,85 +318,7 @@ namespace DeviceLibrary
{
case
MoveStep
.
Wait
:
break
;
//机器人取料
case
MoveStep
.
MI_01
:
RoboMoveInfo
.
NextMoveStep
(
MoveStep
.
MI_02
);
CompTOP1
(
RoboMoveInfo
);
RoboMoveInfo
.
log
(
"压紧轴到待机点"
);
robotHelper
.
lastWeight
=
GetWeight
(
RoboMoveInfo
.
MoveParam
);
break
;
case
MoveStep
.
MI_02
:
RoboMoveInfo
.
NextMoveStep
(
MoveStep
.
MI_03
);
robotHelper
.
Move
(
RoboMoveInfo
,
FromPos
.
Take_P5
,
1
);
RoboMoveInfo
.
log
(
"机器人到Take_P5"
);
break
;
case
MoveStep
.
MI_03
:
RoboMoveInfo
.
NextMoveStep
(
MoveStep
.
MI_04
);
TrayStop
.
DeviceList
[
GroupName
].
Location
.
ToLow
(
MoveInfo
);
CompTOCompression
(
RoboMoveInfo
);
RoboMoveInfo
.
log
(
"压紧轴都下压"
);
break
;
case
MoveStep
.
MI_04
:
if
(!
Comp
.
IsBusy
)
{
RoboMoveInfo
.
NextMoveStep
(
MoveStep
.
MI_05
);
robotHelper
.
Move
(
RoboMoveInfo
,
FromPos
.
Take_P6
,
1
);
RoboMoveInfo
.
log
(
"压紧轴到位"
);
RoboMoveInfo
.
log
(
"机器人到Take_P6"
);
}
break
;
case
MoveStep
.
MI_05
:
RoboMoveInfo
.
NextMoveStep
(
MoveStep
.
MI_06
);
CompTOCompression
(
RoboMoveInfo
);
RoboMoveInfo
.
log
(
"压紧轴都下压"
);
break
;
case
MoveStep
.
MI_06
:
if
(!
Comp
.
IsBusy
)
{
RoboMoveInfo
.
log
(
"压紧轴到位脉冲值:"
+
Comp
.
GetAclPosition
());
RoboMoveInfo
.
NextMoveStep
(
MoveStep
.
MI_07
);
robotHelper
.
Move
(
RoboMoveInfo
,
FromPos
.
Take_P7
,
robotHelper
.
lastWeight
);
RoboMoveInfo
.
log
(
"机器人到Take_P7"
);
}
break
;
case
MoveStep
.
MI_07
:
RoboMoveInfo
.
NextMoveStep
(
MoveStep
.
MI_08
);
robotHelper
.
Move
(
RoboMoveInfo
,
FromPos
.
P1
,
robotHelper
.
lastWeight
);
RoboMoveInfo
.
log
(
"机器人到P1"
);
break
;
case
MoveStep
.
MI_08
:
RoboMoveInfo
.
NextMoveStep
(
MoveStep
.
MI_ReelTacked
);
RoboMoveInfo
.
log
(
"机器人取料完成"
);
break
;
//机器人放料
case
MoveStep
.
MI_40
:
RoboMoveInfo
.
NextMoveStep
(
MoveStep
.
MI_41
);
robotHelper
.
Move
(
RoboMoveInfo
,
ToPos
.
Put_P2
,
robotHelper
.
lastWeight
);
RoboMoveInfo
.
log
(
"机器人到Put_P2"
);
break
;
case
MoveStep
.
MI_41
:
RoboMoveInfo
.
NextMoveStep
(
MoveStep
.
MI_42
);
//Comp.AbsMove(RoboMoveInfo, RobotManage.Config.AMH_RoboMI1_Comp_P1, RobotManage.Config.AMH_RoboMI1_Comp_P1_speed);
CompTOP1
(
RoboMoveInfo
);
robotHelper
.
Move
(
RoboMoveInfo
,
ToPos
.
Put_P3
,
robotHelper
.
lastWeight
);
RoboMoveInfo
.
log
(
"压紧轴释放"
);
RoboMoveInfo
.
log
(
"机器人到Put_P3"
);
break
;
case
MoveStep
.
MI_42
:
RoboMoveInfo
.
NextMoveStep
(
MoveStep
.
MI_43
);
robotHelper
.
Move
(
RoboMoveInfo
,
ToPos
.
Put_P4
,
1
);
RoboMoveInfo
.
log
(
"机器人到Put_P4"
);
break
;
case
MoveStep
.
MI_43
:
RoboMoveInfo
.
NextMoveStep
(
MoveStep
.
MI_44
);
robotHelper
.
Move
(
RoboMoveInfo
,
ToPos
.
P1
,
1
);
RoboMoveInfo
.
log
(
"机器人到P1"
);
break
;
case
MoveStep
.
MI_44
:
RoboMoveInfo
.
NextMoveStep
(
MoveStep
.
Wait
);
RoboMoveInfo
.
log
(
"放料完成"
);
break
;
}
}
...
...
@@ -528,17 +341,56 @@ namespace DeviceLibrary
OutStoreJobList
.
Enqueue
(
trayParam
.
Clone
());
MoveInfo
.
log
(
"写入出库队列:"
+
trayParam
.
ToStr
());
}
internal
void
StartOutStore
()
public
void
StartOutStore
()
{
if
(
MoveInfo
.
MoveStep
>=
MoveStep
.
MI_50
)
if
(
MoveInfo
.
MoveStep
!=
MoveStep
.
MI_54
)
{
MoveInfo
.
log
(
"
机器人正在等待托盘
"
);
MoveInfo
.
log
(
"
没有在等待托盘状态
"
);
}
else
{
MoveInfo
.
NewMove
(
MoveStep
.
MI_50
);
MoveInfo
.
log
(
"开始出库"
);
MoveInfo
.
log
(
"人工完成放料"
);
RemoteLoad
remoteLoad
=
new
RemoteLoad
();
remoteLoad
.
GroupName
=
GroupName
;
remoteLoad
.
RequestLoadInfo
=
new
RequestLoadInfo
();
remoteLoad
.
RequestLoadInfo
.
DeviceGroupName
=
MoveInfo
.
MoveParam
.
cid
;
remoteLoad
.
RequestLoadInfo
.
IsEmpty
=
false
;
remoteLoad
.
RequestLoadInfo
.
TrayType
=
TrayTypeE
.
MTP1
.
ToString
();
remoteLoad
.
RequestLoadInfo
.
LoadParam
=
MoveInfo
.
MoveParam
.
clone
();
// 填充料盘信息
TrayManager
.
TrayRelease
(
remoteLoad
);
//这条会自动放行托盘并且写入托盘目的地
TheLine
.
UpdateLocInfo
(
""
,
MoveInfo
.
MoveParam
.
WareCode
,
TheLine
.
LineStatusE
.
INLINE
,
CurrrentRFID
);
TrayManager
.
ClearTrayRequest
(
GroupName
);
MoveInfo
.
NextMoveStep
(
MoveStep
.
MI_55
);
MoveInfo
.
log
(
"完成点料放料"
);
}
}
string
ProcessCodeInsertQty
(
string
barcode
,
int
qty
)
{
if
(
barcode
.
Count
(
c
=>
c
==
'#'
)
==
3
)
{
MoveInfo
.
log
(
"CI: 原条码:"
+
barcode
+
", qty:"
+
qty
);
var
barcodes
=
barcode
.
Split
(
'#'
);
barcodes
[
2
]
=
qty
.
ToString
();
var
af
=
string
.
Join
(
"#"
,
barcodes
);
MoveInfo
.
log
(
"CI: 转换后:"
+
af
);
return
af
;
}
MoveInfo
.
log
(
"CI: Barcode转换失败:"
+
barcode
);
return
""
;
}
string
ProcessCodeGetVJType
(
string
barcode
)
{
if
(
barcode
.
Count
(
c
=>
c
==
'#'
)
==
3
)
{
var
barcodes
=
barcode
.
Split
(
'#'
);
var
vjcode
=
barcodes
[
0
].
Substring
(
1
)
+
"|"
+
barcodes
[
1
].
Substring
(
1
);
MoveInfo
.
log
(
$
"CI: VJ转换:{barcode} => {vjcode}"
);
return
vjcode
;
}
MoveInfo
.
log
(
"CI: VJ转换失败:"
+
barcode
);
return
""
;
}
/// <summary>
/// 释放托盘
...
...
@@ -547,25 +399,6 @@ namespace DeviceLibrary
//MoveInfo.log("释放托盘");
// MoveInfo.NextMoveStep(MoveStep.TrayStop_LoadProcessed);
}
void
CompTOP1
(
MoveInfo
MoveInfo
)
{
if
(
Comp
.
HasHome
())
Comp
.
AbsMove
(
MoveInfo
,
RobotManage
.
Config
.
AMH_RoboMI1_Comp_P1
,
RobotManage
.
Config
.
AMH_RoboMI1_Comp_P1_speed
);
else
Comp
.
HomeMove
(
MoveInfo
);
}
void
CompTOCompression
(
MoveInfo
MoveInfo
)
{
if
(!
Comp
.
HasHome
())
return
;
Comp
.
AbsMove
(
null
,
DeviceGroup
.
p3
,
RobotManage
.
Config
.
AMH_RoboMI1_Comp_P2_speed
);
Comp
.
BatchAxisStartCheck
(
IO_Type
.
MI_Robot_Clamp_Check
,
IO_VALUE
.
HIGH
);
}
bool
compdetereel
=
false
;
int
lastCmd
=
0
;
int
lastStep
=
0
;
int
lastPrefix
=
0
;
public
void
ResetProcess
()
{
if
(
CheckWait
(
MoveInfo
))
...
...
@@ -574,169 +407,20 @@ namespace DeviceLibrary
switch
(
MoveInfo
.
MoveStep
)
{
case
MoveStep
.
Wait
:
//MoveInfo.NextMoveStep(MoveStep.H01_HomeReset);
break
;
case
MoveStep
.
H01_HomeReset
:
MoveInfo
.
EndMove
();
DeviceState
=
DeviceStateE
.
Run
;
return
;
if
(!
Enum
.
TryParse
<
MoveStep
>(
Config
.
Get
(
"RuntimeRobot_"
+
robotname
+
"_MoveStep"
,
MoveStep
.
Wait
.
ToString
()),
out
MoveStep
m1step
))
m1step
=
MoveStep
.
Wait
;
if
(!
Enum
.
TryParse
<
MoveStep
>(
Config
.
Get
(
"RuntimeRobot_"
+
robotname
+
"_Arm_MoveStep"
,
MoveStep
.
Wait
.
ToString
()),
out
MoveStep
m2step
))
m2step
=
MoveStep
.
Wait
;
//var m1step = (MoveStep)Enum.Parse(typeof(MoveStep), Config.Get("RuntimeRobot_" + robotname + "_MoveStep", MoveStep.Wait.ToString()));
//var m2step = (MoveStep)Enum.Parse(typeof(MoveStep), Config.Get("RuntimeRobot_" + robotname + "_Arm_MoveStep", MoveStep.Wait.ToString()));
if
(
IOValue
(
IO_Type
.
MI_Robot_Clamp_Check
).
Equals
(
IO_VALUE
.
LOW
)
&&
IOValue
(
IO_Type
.
MI_Robot_Reel_Check
).
Equals
(
IO_VALUE
.
LOW
)
&&
m1step
==
MoveStep
.
Wait
)
{
MoveInfo
.
NextMoveStep
(
MoveStep
.
H09_HomeReset
);
Robot
.
SendMoveCmd
(
1
,
Setting_Init
.
URRobot_MI1_Speed_Rate
,
false
,
RobotHelper
.
LoadRateParam
[
robotHelper
.
lastWeight
]);
MoveInfo
.
log
(
"没有最后的动作, 机器人回待机点"
);
}
else
{
MoveInfo
.
MoveParam
=
JsonConvert
.
DeserializeObject
<
ReelParam
>(
Config
.
Get
(
"Runtime_Robot_"
+
robotname
+
"_ReelInfo"
));
RoboMoveInfo
.
MoveParam
=
MoveInfo
.
MoveParam
.
clone
();
FromPos
=
GetMIPosition
(
GroupName
,
Config
.
Get
(
"Runtime_Robot_"
+
robotname
+
"_FromPos"
));
ToPos
=
GetMIPosition
(
GroupName
,
Config
.
Get
(
"Runtime_Robot_"
+
robotname
+
"_ToPos"
));
CurrentVStore
=
VStoreCollection
.
VStoreList
[
MoveInfo
.
MoveParam
.
cid
];
MoveInfo
.
NextMoveStep
(
m1step
);
RoboMoveInfo
.
NextMoveStep
(
m2step
);
DeviceState
=
DeviceStateE
.
Run
;
}
break
;
case
MoveStep
.
H02_HomeReset
:
if
(!
Robot
.
StartRobot
())
{
MoveInfo
.
CanWhileCount
--;
MoveInfo
.
WaitList
.
Add
(
WaitResultInfo
.
WaitTime
(
5000
));
MoveInfo
.
WaitList
.
Add
(
WaitResultInfo
.
WaitMsg
(
POS_Start
+
crc
.
GetString
(
"Res0016"
,
"机器人连接失败"
),
MoveInfo
.
CanWhileCount
<=
0
?
MsgLevel
.
alarm
:
MsgLevel
.
warning
));
}
else
MoveInfo
.
NextMoveStep
(
MoveStep
.
H03_HomeReset
);
break
;
case
MoveStep
.
H03_HomeReset
:
if
(
Robot
.
IsRun
)
{
MoveInfo
.
NextMoveStep
(
MoveStep
.
H04_HomeReset
);
Robot
.
PlayProgram
();
MoveInfo
.
log
(
"Robot.ProgramState:"
+
Robot
.
ProgramState
);
MoveInfo
.
log
(
"Robot.ClientIsConnected:"
+
Robot
.
ClientIsConnected
);
MoveInfo
.
log
(
"Robot.IsRun:"
+
Robot
.
IsRun
);
MoveInfo
.
log
(
"Robot.IsStartConnect:"
+
Robot
.
IsStartConnect
);
MoveInfo
.
log
(
"Robot.CurCmdReponse:"
+
Robot
.
CurCmdReponse
);
MoveInfo
.
WaitList
.
Add
(
WaitResultInfo
.
WaitTime
(
2000
));
}
else
if
(
MoveInfo
.
IsTimeOut
(
30
))
{
MoveInfo
.
NextMoveStep
(
MoveStep
.
H02_HomeReset
);
}
MoveInfo
.
WaitList
.
Add
(
WaitResultInfo
.
WaitMsg
(
POS_Start
+
crc
.
GetString
(
"Res0017"
,
"机器人启动失败"
),
MoveInfo
.
CanWhileCount
<=
0
?
MsgLevel
.
alarm
:
MsgLevel
.
warning
));
break
;
case
MoveStep
.
H04_HomeReset
:
if
(
Robot
.
ClientIsConnected
&&
Robot
.
CurCmdReponse
.
Contains
(
"Start Program"
))
{
MoveInfo
.
NextMoveStep
(
MoveStep
.
H05_HomeReset
);
}
else
if
(
MoveInfo
.
IsTimeOut
(
10
))
{
MoveInfo
.
NextMoveStep
(
MoveStep
.
H10_HomeReset
);
}
MoveInfo
.
WaitList
.
Add
(
WaitResultInfo
.
WaitMsg
(
POS_Start
+
crc
.
GetString
(
"Res0018"
,
"机器人未连接MT"
),
MoveInfo
.
CanWhileCount
<=
0
?
MsgLevel
.
alarm
:
MsgLevel
.
warning
));
break
;
case
MoveStep
.
H05_HomeReset
:
MoveInfo
.
NextMoveStep
(
MoveStep
.
H09_HomeReset
);
return
;
case
MoveStep
.
H06_HomeReset
:
if
(
Robot
.
MoveCmdOk
())
{
//如果上一步是回到待机点,并且料叉上无物料
if
(
lastStep
==
1
&&
!
compdetereel
&&
!
IOValue
(
IO_Type
.
MI_Robot_Reel_Check
).
Equals
(
IO_VALUE
.
HIGH
))
{
//回原结束
return
;
}
RoboMoveInfo
.
MoveParam
=
MoveInfo
.
MoveParam
.
clone
();
robotHelper
.
lastWeight
=
GetWeight
(
RoboMoveInfo
.
MoveParam
);
//如果上一步是回待机点,但料叉上有物料
if
(
lastStep
==
1
)
{
MoveInfo
.
NextMoveStep
(
MoveStep
.
MI_02
);
RoboMoveInfo
.
NextMoveStep
(
MoveStep
.
MI_07
);
}
else
if
(
lastStep
==
0
)
//P5 取料低点
{
MoveInfo
.
NextMoveStep
(
MoveStep
.
MI_02
);
RoboMoveInfo
.
NextMoveStep
(
MoveStep
.
MI_02
);
}
else
if
(
lastStep
==
2
)
//P6 取料高点
{
MoveInfo
.
NextMoveStep
(
MoveStep
.
MI_02
);
RoboMoveInfo
.
NextMoveStep
(
MoveStep
.
MI_04
);
}
else
if
(
lastStep
==
5
)
//P7 取料退出过度点
{
MoveInfo
.
NextMoveStep
(
MoveStep
.
MI_02
);
RoboMoveInfo
.
NextMoveStep
(
MoveStep
.
MI_06
);
}
else
if
(
lastStep
==
1
)
//P2 放料高点P2
{
MoveInfo
.
NextMoveStep
(
MoveStep
.
MI_02
);
RoboMoveInfo
.
NextMoveStep
(
MoveStep
.
MI_40
);
}
}
break
;
case
MoveStep
.
H09_HomeReset
:
if
(
Robot
.
MoveCmdOk
())
{
MoveInfo
.
EndMove
();
DeviceState
=
DeviceStateE
.
Run
;
}
break
;
//尝试解除安全保护
case
MoveStep
.
H10_HomeReset
:
MoveInfo
.
NextMoveStep
(
MoveStep
.
H11_HomeReset
);
Robot
.
SendCMD
(
"safetymode"
,
0
);
MoveInfo
.
WaitList
.
Add
(
WaitResultInfo
.
WaitTime
(
500
));
break
;
case
MoveStep
.
H11_HomeReset
:
MoveInfo
.
log
(
"机器人反馈安全模式为:"
+
Robot
.
CurDashboardReponse
);
if
(
Robot
.
CurDashboardReponse
.
Contains
(
"PROTECTIVE_STOP"
))
{
MoveInfo
.
NextMoveStep
(
MoveStep
.
H12_HomeReset
);
MoveInfo
.
WaitList
.
Add
(
WaitResultInfo
.
WaitTime
(
5000
));
}
else
if
(
Robot
.
CurDashboardReponse
.
Contains
(
"NORMAL"
))
{
MoveInfo
.
NextMoveStep
(
MoveStep
.
H02_HomeReset
);
}
else
if
(
Robot
.
CurDashboardReponse
.
Contains
(
"Starting program"
))
if
(
IOValue
(
IO_Type
.
CI_Count_Finished
).
Equals
(
IO_VALUE
.
HIGH
))
{
MoveInfo
.
NextMoveStep
(
MoveStep
.
H02_HomeReset
);
MoveInfo
.
log
(
"VJ点料机状态正常"
);
}
else
{
Msg
.
add
(
crc
.
GetString
(
"Res0059"
,
"机器人状态异常:"
)
+
Robot
.
CurDashboardReponse
,
MsgLevel
.
alarm
);
Msg
.
add
(
"VJ点料机状态异常"
,
MsgLevel
.
warning
);
}
break
;
case
MoveStep
.
H12_HomeReset
:
MoveInfo
.
NextMoveStep
(
MoveStep
.
H13_HomeReset
);
MoveInfo
.
log
(
"机器人反馈安全模式为:"
+
Robot
.
CurCmdReponse
);
Robot
.
SendCMD
(
"unlock protective stop"
,
0
);
MoveInfo
.
log
(
"尝试解除机器人保护"
);
MoveInfo
.
WaitList
.
Add
(
WaitResultInfo
.
WaitTime
(
500
));
break
;
case
MoveStep
.
H13_HomeReset
:
if
(
Robot
.
CurCmdReponse
.
Contains
(
"Protective stop releasing"
))
{
MoveInfo
.
log
(
"机器人成功解除保护"
);
Robot
.
StopProgram
();
MoveInfo
.
NextMoveStep
(
MoveStep
.
H02_HomeReset
);
MoveInfo
.
WaitList
.
Add
(
WaitResultInfo
.
WaitTime
(
500
));
}
else
if
(
MoveInfo
.
IsTimeOut
(
5
))
{
MoveInfo
.
NextMoveStep
(
MoveStep
.
H10_HomeReset
);
}
case
MoveStep
.
H02_HomeReset
:
MoveInfo
.
EndMove
();
DeviceState
=
DeviceStateE
.
Run
;
break
;
}
}
...
...
@@ -748,94 +432,38 @@ namespace DeviceLibrary
/// <returns></returns>
public
bool
HasJob
(
ReelParam
reelParam
)
{
MoveInfo
.
log
(
$
"DeviceState:{DeviceState},{MoveInfo.MoveStep},{reelParam}"
);
if
(
DeviceState
!=
DeviceStateE
.
Run
)
return
false
;
if
(
reelParam
==
null
&&
MoveInfo
.
MoveStep
>=
MoveStep
.
MI_53
)
//正在出库中
if
(
reelParam
==
null
&&
MoveInfo
.
MoveStep
>=
MoveStep
.
MI_53
)
//正在出库中
return
true
;
if
(
MoveInfo
.
MoveStep
!=
MoveStep
.
Wait
)
return
false
;
if
(
reelParam
==
null
)
{
//空托盘,判断有没有出库任务
var
sc
=
VStoreCollection
.
VStoreList
.
Values
.
Where
(
vs
=>
vs
.
TowerInfo
.
DeviceGroupName
==
GroupName
).
ToList
().
Find
(
vs
=>
vs
.
RTStoreStatus
==
RTStoreStatus
.
OutStoreReady
||
vs
.
RTStoreStatus
==
RTStoreStatus
.
InStoreError
||
vs
.
RTStoreStatus
==
RTStoreStatus
.
InStoreDataTimeOut
||
vs
.
TerminalError
);
return
(
sc
!=
null
);
}
if
(
string
.
IsNullOrEmpty
(
reelParam
.
SubCID
))
{
MoveInfo
.
log
(
"SubCID为空"
);
return
false
;
}
if
(!
VStoreCollection
.
VStoreList
.
ContainsKey
(
reelParam
.
SubCID
))
{
MoveInfo
.
log
(
"RT料仓CID不存在:"
+
reelParam
.
SubCID
);
return
false
;
}
//有料托盘,判断目的地料仓是否空闲
if
(
VStoreCollection
.
VStoreList
[
reelParam
.
SubCID
].
RTStoreStatus
==
RTStoreStatus
.
Ready
)
{
//料仓空闲, 锁定料仓准备入库
VStoreCollection
.
VStoreList
[
reelParam
.
SubCID
].
RTStoreStatus
=
RTStoreStatus
.
LockToInStore
;
if
(
reelParam
!=
null
&&
MoveInfo
.
MoveStep
==
MoveStep
.
Wait
)
return
true
;
}
MoveInfo
.
log
(
"RT料仓当前状态:"
+
VStoreCollection
.
VStoreList
[
reelParam
.
SubCID
].
RTStoreStatus
);
return
false
;
}
int
bufferstoresindex
=
0
;
string
[]
bufferstores
=
new
string
[]
{
"B01"
,
"B02"
,
"B03"
,
"B04"
,
"B05"
,
"B06"
,
"B07"
,
"B08"
};
string
GetNextBufferStore
()
{
if
(
bufferstoresindex
>=
bufferstores
.
Length
)
bufferstoresindex
=
0
;
var
c
=
POS_Start
+
"_"
+
bufferstores
[
bufferstoresindex
];
bufferstoresindex
++;
return
c
;
}
public
bool
FrontCheck
(
int
curaddr
)
{
throw
new
NotImplementedException
();
}
public
bool
IsFree
()
{
throw
new
NotImplementedException
();
}
public
RobotPosition
GetMIPosition
(
string
device
,
string
pos
)
{
if
(
device
==
"AMH-MI1"
)
return
RobotManage
.
MI1Postion
[
pos
];
else
if
(
device
==
"AMH-MI2"
)
return
RobotManage
.
MI2Postion
[
pos
];
else
return
RobotManage
.
CIPostion
[
pos
];
}
int
GetWeight
(
ReelParam
reelParam
)
{
int
w
=
0
;
if
(
reelParam
==
null
)
w
=
1
;
else
if
(
reelParam
.
PlateW
==
7
)
w
=
2
;
else
if
(
reelParam
.
PlateW
==
13
&&
reelParam
.
PlateH
==
8
)
w
=
2
;
else
if
(
reelParam
.
PlateW
==
13
)
w
=
3
;
else
if
(
reelParam
.
PlateW
==
15
)
w
=
3
;
else
w
=
2
;
RoboMoveInfo
.
log
(
$
"机器人负载设定: {reelParam?.PlateW}x{reelParam?.PlateH}={w}"
);
return
w
;
}
public
void
FrontStopProcess
()
{
//throw new NotImplementedException();
}
}
public
enum
XRayStepE
{
WaitMTtoVJ
,
Counting
,
WaitCountResult
,
WaitVJtoMT
,
Finish
}
}
\ No newline at end of file
DeviceLibrary/theMachine/sub/TrayStop.cs
查看文件 @
61f4e58
...
...
@@ -149,7 +149,7 @@ namespace DeviceLibrary
CurrrentRFID
=
Common
.
RfidFilter
(
data
);
TrayManager
.
Process
(
MoveInfo
,
CurrrentRFID
,
DeviceGroup
.
addr_1
,
IOValue
(
IO_Type
.
MI_Reel_Check
).
Equals
(
IO_VALUE
.
HIGH
)?
1
:
0
,
out
TrayInfo
trayInfo
);
var
stop
=
TrayManager
.
TryGetTrayRequest
(
GroupName
,
CurrrentRFID
,
out
_
);
MoveInfo
.
log
(
$
"CurrrentRFID:{CurrrentRFID},HasLoad:{trayInfo.HasLoad},MI_Reel_Check:{IOValue(IO_Type.MI_Reel_Check)},NeedStop:{stop}"
);
MoveInfo
.
log
(
$
"CurrrentRFID:{CurrrentRFID},HasLoad:{trayInfo.HasLoad},MI_Reel_Check:{IOValue(IO_Type.MI_Reel_Check)},NeedStop:{stop}
,GroupName:{GroupName},TrayType:{trayInfo.TrayType}
"
);
#
region
MI1
,
Mi2
的情况判断
if
((
GroupName
==
"AMH-MI1"
||
GroupName
==
"AMH-MI2"
)
&&
trayInfo
.
TrayType
==
TrayTypeE
.
MTP1
)
{
...
...
@@ -245,15 +245,17 @@ namespace DeviceLibrary
MoveInfo
.
NextMoveStep
(
MoveStep
.
TrayStop_04
);
return
;
}
else
if
(
GroupName
==
"CI"
&&
trayInfo
.
TrayType
==
TrayTypeE
.
MTP1
)
{
else
if
(
GroupName
==
"CI"
&&
trayInfo
.
TrayType
==
TrayTypeE
.
MTP1
)
{
MoveInfo
.
log
(
$
"在CI设备:{trayInfo.DestinationAddr}=={DeviceGroup.addr_1}"
);
var
device
=
CI
.
DeviceList
[
GroupName
];
if
(!
device
.
ManualCount
)
{
MoveInfo
.
log
(
$
"点料机当前不可用,NG处理"
);
RequestLoadInfo
RequestLoadInfo
=
new
RequestLoadInfo
();
RequestLoadInfo
.
LoadParam
=
trayInfo
.
TrayParam
.
clone
();
RequestLoadInfo
.
LoadParam
.
IsNg
=
true
;
RequestLoadInfo
.
LoadParam
.
NgMsg
=
"XRay not enable"
;
RequestLoadInfo
.
LoadParam
.
IsNg
=
true
;
RequestLoadInfo
.
LoadParam
.
NgMsg
=
"XRay not enable"
;
RequestLoadInfo
.
DeviceGroupName
=
"AMH-MI2"
;
RequestLoadInfo
.
TrayType
=
trayInfo
.
TrayType
.
ToString
();
RequestLoadInfo
.
IsEmpty
=
false
;
...
...
@@ -262,11 +264,24 @@ namespace DeviceLibrary
MoveInfo
.
NextMoveStep
(
MoveStep
.
TrayStop_03
);
return
;
}
else
if
(!
trayInfo
.
HasLoad
&&
IOValue
(
IO_Type
.
MI_Reel_Check
).
Equals
(
IO_VALUE
.
LOW
))
{
MoveInfo
.
log
(
"开始处理出料"
);
MoveInfo
.
NextMoveStep
(
MoveStep
.
TrayStop_07
);
//
抵达了一个有物料的托盘等待处理
//
请求的空托盘到达时
if
(!
device
.
HasJob
(
null
))
MoveInfo
.
NextMoveStep
(
MoveStep
.
TrayStop_04
);
else
{
MoveInfo
.
NextMoveStep
(
MoveStep
.
TrayStop_07
);
//device.StartOutStore();
}
}
else
if
(
trayInfo
.
DestinationAddr
==
DeviceGroup
.
addr_1
&&
trayInfo
.
HasLoad
)
{
MoveInfo
.
log
(
"开始处理入料"
);
//抵达了一个有物料的托盘等待处理
if
(!
device
.
HasJob
(
trayInfo
.
TrayParam
))
MoveInfo
.
NextMoveStep
(
MoveStep
.
TrayStop_04
);
else
...
...
@@ -275,6 +290,10 @@ namespace DeviceLibrary
device
.
StartInStore
(
trayInfo
.
TrayParam
);
}
}
else
MoveInfo
.
NextMoveStep
(
MoveStep
.
TrayStop_04
);
return
;
}
#
endregion
if
(
stop
&&
!
trayInfo
.
HasLoad
&&
IOValue
(
IO_Type
.
MI_Reel_Check
).
Equals
(
IO_VALUE
.
LOW
))
...
...
DeviceLibrary/userControl/AxisMoveControl.Designer.cs
查看文件 @
61f4e58
...
...
@@ -163,6 +163,7 @@
this
.
lblAlarmcode
.
Tag
=
"not"
;
this
.
lblAlarmcode
.
Text
=
"ErrCode:160"
;
this
.
lblAlarmcode
.
Visible
=
false
;
this
.
lblAlarmcode
.
Click
+=
new
System
.
EventHandler
(
this
.
lblAlarmcode_Click
);
//
// label4
//
...
...
DeviceLibrary/userControl/AxisMoveControl.cs
查看文件 @
61f4e58
...
...
@@ -445,5 +445,11 @@ namespace DeviceLibrary
lbl
.
BackColor
=
this
.
BackColor
;
}
}
private
void
lblAlarmcode_Click
(
object
sender
,
EventArgs
e
)
{
MessageBox
.
Show
(
string
.
Join
(
","
,
HuichuanLibrary
.
HCBoardManager
.
GetAxisErrorDetail
(
currentAxis
.
Config
.
GetAxisValue
())));
}
}
}
\ No newline at end of file
RemoteSheardObject/TheLine.cs
查看文件 @
61f4e58
using
ConfigHelper
;
using
Newtonsoft.Json
;
using
OnlineStore
;
using
OnlineStore.Common
;
using
System
;
using
System.Collections.Generic
;
using
System.Collections.Specialized
;
using
System.Diagnostics
;
using
System.Linq
;
using
System.Net
;
using
System.Text
;
...
...
@@ -34,9 +36,26 @@ namespace RemoteSheardObject
{
"locInfo"
,
locInfo
}
};
return
!
string
.
IsNullOrEmpty
(
SubmitPostData
(
"/service/store/robotBox/updateLocInfo"
,
postData
));
return
!
string
.
IsNullOrEmpty
(
SubmitPostData
(
"/service/store/robotBox/updateLocInfo"
,
postData
,
out
_
));
}
public
static
bool
UpdateReelQty
(
string
barcode
,
int
qty
)
{
if
(
barcode
.
Count
(
c
=>
c
==
'#'
)
==
3
)
{
barcode
=
barcode
.
Split
(
'#'
)[
1
].
Substring
(
1
);
}
var
postData
=
new
Dictionary
<
string
,
string
>()
{
{
"barcode"
,
barcode
},
{
"qty"
,
qty
.
ToString
()}
};
var
data
=
SubmitPostData
(
"/rest/micron/device/updateReelQty"
,
postData
,
out
string
msg
);
LogUtil
.
info
(
"UpdateReelQty:"
+
data
);
if
(
string
.
IsNullOrEmpty
(
data
))
LogUtil
.
info
(
"UpdateReelQty:"
+
msg
);
return
!
string
.
IsNullOrEmpty
(
data
);
}
public
static
bool
emptyOut
(
string
barcode
)
{
//料盘空出后直接结束任务
...
...
@@ -49,7 +68,7 @@ namespace RemoteSheardObject
{
{
"barcode"
,
barcode
}
};
return
!
string
.
IsNullOrEmpty
(
SubmitPostData
(
"/service/store/robotBox/emptyOut"
,
postData
));
return
!
string
.
IsNullOrEmpty
(
SubmitPostData
(
"/service/store/robotBox/emptyOut"
,
postData
,
out
_
));
}
/// <summary>
/// 获取正在进行的任务数量
...
...
@@ -67,7 +86,7 @@ namespace RemoteSheardObject
taskdata
[
"tray"
]
=
0
;
taskdata
[
"reel"
]
=
0
;
var
result
=
JsonConvert
.
DeserializeObject
<
ResultData
>(
SubmitPostData
(
"/rest/micron/device/getTaskCount"
,
postData
));
var
result
=
JsonConvert
.
DeserializeObject
<
ResultData
>(
SubmitPostData
(
"/rest/micron/device/getTaskCount"
,
postData
,
out
_
));
if
(
result
==
null
||
result
.
code
!=
0
)
return
taskdata
;
...
...
@@ -107,7 +126,7 @@ namespace RemoteSheardObject
{
{
"barcode"
,
barcode
},
};
var
result
=
SubmitPostData
(
"/service/store/robotBox/getSize"
,
postData
);
var
result
=
SubmitPostData
(
"/service/store/robotBox/getSize"
,
postData
,
out
_
);
if
(
result
!=
null
)
return
JsonConvert
.
DeserializeObject
<
T
>(
result
);
else
...
...
@@ -147,7 +166,7 @@ namespace RemoteSheardObject
{
"ngPos"
,
ngPos
.
ToString
()
}
};
string
url
=
"/rest/micron/device/clearNgPos"
;
var
resultStr
=
SubmitPostData
(
url
,
postData
);
var
resultStr
=
SubmitPostData
(
url
,
postData
,
out
_
);
}
/// <summary>
/// 上传自定义数据
...
...
@@ -162,7 +181,7 @@ namespace RemoteSheardObject
{
"value"
,
value
}
};
string
url
=
"/rest/micron/device/updateData"
;
var
resultStr
=
SubmitPostData
(
url
,
postData
);
var
resultStr
=
SubmitPostData
(
url
,
postData
,
out
_
);
}
/// <summary>
/// 上传自定义数据
...
...
@@ -176,7 +195,7 @@ namespace RemoteSheardObject
{
"key"
,
key
}
};
string
url
=
"/rest/micron/device/getData"
;
var
resultStr
=
SubmitPostData
(
url
,
postData
);
var
resultStr
=
SubmitPostData
(
url
,
postData
,
out
_
);
var
r
=
JsonConvert
.
DeserializeObject
<
ResultData2
>(
resultStr
);
if
(!
string
.
IsNullOrWhiteSpace
(
r
.
data
))
{
return
r
.
data
;
...
...
@@ -201,8 +220,9 @@ namespace RemoteSheardObject
public
Dictionary
<
string
,
object
>
data
{
get
;
set
;
}
}
public
static
string
SubmitPostData
(
string
url
,
Dictionary
<
string
,
string
>
postData
)
public
static
string
SubmitPostData
(
string
url
,
Dictionary
<
string
,
string
>
postData
,
out
string
msg
)
{
msg
=
""
;
url
=
CombineUrl
(
Config
.
Get
(
"Device_Server_Address"
),
url
);
//创建WebClient对象
using
(
var
client
=
new
WebClient
())
...
...
@@ -226,6 +246,7 @@ namespace RemoteSheardObject
if
(
postDataString
.
Length
>
0
)
postDataString
.
Length
--;
msg
+=
postDataString
;
//将POST请求参数转换为字节数组
byte
[]
bytes
=
Encoding
.
UTF8
.
GetBytes
(
postDataString
.
ToString
());
...
...
@@ -240,8 +261,10 @@ namespace RemoteSheardObject
{
// 捕获任何网络异常,并输出错误信息
//Console.WriteLine(crc.GetString("Res0071","提交POST请求时发生错误:") + ex.Message);
msg
+=
"\r\n提交POST请求时发生错误:"
+
ex
.
Message
;
// 请求失败,返回false
Debug
.
WriteLine
(
url
);
Debug
.
WriteLine
(
ex
);
return
""
;
}
}
...
...
@@ -259,7 +282,11 @@ namespace RemoteSheardObject
var
barcode
=
reelParam
.
WareCode
;
if
(
barcode
.
Count
(
c
=>
c
==
'#'
)
==
3
)
{
barcode
=
barcode
.
Split
(
'#'
)[
1
].
Substring
(
1
);
var
bs
=
barcode
.
Split
(
'#'
);
reelParam
.
RI
=
bs
[
1
].
Substring
(
1
);
reelParam
.
PN
=
bs
[
0
].
Substring
(
1
);
reelParam
.
DC
=
bs
[
2
];
barcode
=
bs
[
1
].
Substring
(
1
);
}
try
{
...
...
@@ -271,7 +298,7 @@ namespace RemoteSheardObject
else
//不包含 AMH-SBDH3-1
nameValue
.
Add
(
"cids"
,
"AMH-SBDH3-1,AMH-SBDH3-2,AMH-SBSH1,AMH-SBSH2,AMH-SBDH2-1,AMH-SBDH2-2,AMH-SBDH1-1,AMH-SBDH1-2,003040,003048,003039,003043,003035,003036,003041,003042"
);
var
data
=
SubmitPostData
(
"/service/store/robotBox/renewPosForPutin"
,
nameValue
);
var
data
=
SubmitPostData
(
"/service/store/robotBox/renewPosForPutin"
,
nameValue
,
out
_
);
msg
+=
"Regetposid code: "
+
reelParam
.
WareCode
+
",preCid: "
+
reelParam
.
cid
+
",cids:"
+
nameValue
[
"cids"
]
+
",Result: "
+
data
+
"\r\n"
;
emptyPosForPutin
result
=
JsonConvert
.
DeserializeObject
<
emptyPosForPutin
>(
data
);
...
...
TheMachine/TheMachine.csproj
查看文件 @
61f4e58
...
...
@@ -260,6 +260,7 @@
</EmbeddedResource>
<EmbeddedResource Include="Form1.resx">
<DependentUpon>Form1.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="IOControls.resx">
<DependentUpon>IOControls.cs</DependentUpon>
...
...
TheMachine/TrayManagerControl.cs
查看文件 @
61f4e58
...
...
@@ -123,6 +123,9 @@ namespace TheMachine
reelid
=
ti
.
TrayParam
?.
WareCode
;
var
items
=
new
string
[]
{
lastaddrdesc
.
ToString
(),
lasttime
,
traydesc
,
loaddesc
,
toaddrdesc
,
reelid
};
if
(
string
.
IsNullOrEmpty
(
ti
.
RFID
))
continue
;
if
(
listView1
.
Items
.
ContainsKey
(
ti
.
RFID
))
{
while
(
listView1
.
Items
[
ti
.
RFID
].
SubItems
.
Count
>
1
)
...
...
@@ -189,7 +192,8 @@ namespace TheMachine
txt
+=
"\r\n"
+
crc
.
GetString
(
"Res0021"
,
"托盘类型"
)
+
": "
+
listView1
.
SelectedItems
[
0
].
SubItems
[
2
].
Text
;
txt
+=
"\r\n"
+
crc
.
GetString
(
"Res0055"
,
"物料"
)
+
": "
+
listView1
.
SelectedItems
[
0
].
SubItems
[
3
].
Text
;
txt
+=
"\r\n"
+
crc
.
GetString
(
"Res0023"
,
"目的地"
)
+
": "
+
listView1
.
SelectedItems
[
0
].
SubItems
[
4
].
Text
;
txt
+=
"\r\n"
+
"Code"
+
": "
+
listView1
.
SelectedItems
[
0
].
SubItems
[
6
].
Text
;
if
(
listView1
.
SelectedItems
[
0
].
SubItems
.
Count
>
6
)
txt
+=
"\r\n"
+
"Code"
+
": "
+
listView1
.
SelectedItems
[
0
].
SubItems
[
6
].
Text
;
if
(
ti
.
HasLoad
&&
ti
.
TrayParam
.
IsNg
)
{
txt
+=
"\r\n"
+
"NgMsg"
+
": "
+
ti
.
TrayParam
.
NgMsg
;
}
...
...
TheMachine/device/CIDebugControl.Designer.cs
查看文件 @
61f4e58
...
...
@@ -35,12 +35,21 @@
this
.
label_barcode
=
new
System
.
Windows
.
Forms
.
Label
();
this
.
timer1
=
new
System
.
Windows
.
Forms
.
Timer
(
this
.
components
);
this
.
cb_manualcount
=
new
System
.
Windows
.
Forms
.
CheckBox
();
this
.
btn_finishcount
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
label_watchstatus
=
new
System
.
Windows
.
Forms
.
Label
();
this
.
btn_manualsend
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
cb_com
=
new
System
.
Windows
.
Forms
.
ComboBox
();
this
.
cb_bitrate
=
new
System
.
Windows
.
Forms
.
ComboBox
();
this
.
btn_reopen
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
button_start
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
cb_enter
=
new
System
.
Windows
.
Forms
.
CheckBox
();
this
.
cb_newline
=
new
System
.
Windows
.
Forms
.
CheckBox
();
this
.
SuspendLayout
();
//
// label_status
//
this
.
label_status
.
AutoSize
=
true
;
this
.
label_status
.
Location
=
new
System
.
Drawing
.
Point
(
60
,
1
28
);
this
.
label_status
.
Location
=
new
System
.
Drawing
.
Point
(
60
,
1
43
);
this
.
label_status
.
Name
=
"label_status"
;
this
.
label_status
.
Size
=
new
System
.
Drawing
.
Size
(
41
,
12
);
this
.
label_status
.
TabIndex
=
0
;
...
...
@@ -48,11 +57,12 @@
//
// btn_start
//
this
.
btn_start
.
Location
=
new
System
.
Drawing
.
Point
(
325
,
128
);
this
.
btn_start
.
Enabled
=
false
;
this
.
btn_start
.
Location
=
new
System
.
Drawing
.
Point
(
305
,
143
);
this
.
btn_start
.
Name
=
"btn_start"
;
this
.
btn_start
.
Size
=
new
System
.
Drawing
.
Size
(
135
,
23
);
this
.
btn_start
.
TabIndex
=
1
;
this
.
btn_start
.
Text
=
"
开始点料
"
;
this
.
btn_start
.
Text
=
"
Start count
"
;
this
.
btn_start
.
UseVisualStyleBackColor
=
true
;
this
.
btn_start
.
Click
+=
new
System
.
EventHandler
(
this
.
btn_start_Click
);
//
...
...
@@ -62,7 +72,7 @@
this
.
txt_barcode
.
Name
=
"txt_barcode"
;
this
.
txt_barcode
.
Size
=
new
System
.
Drawing
.
Size
(
337
,
21
);
this
.
txt_barcode
.
TabIndex
=
2
;
this
.
txt_barcode
.
Text
=
"
P123456#S123456789#0#182+EA
"
;
this
.
txt_barcode
.
Text
=
"
12345|123456789
"
;
//
// label_barcode
//
...
...
@@ -82,25 +92,143 @@
// cb_manualcount
//
this
.
cb_manualcount
.
AutoSize
=
true
;
this
.
cb_manualcount
.
Checked
=
true
;
this
.
cb_manualcount
.
CheckState
=
System
.
Windows
.
Forms
.
CheckState
.
Checked
;
this
.
cb_manualcount
.
Location
=
new
System
.
Drawing
.
Point
(
32
,
27
);
this
.
cb_manualcount
.
Name
=
"cb_manualcount"
;
this
.
cb_manualcount
.
Size
=
new
System
.
Drawing
.
Size
(
96
,
16
);
this
.
cb_manualcount
.
Size
=
new
System
.
Drawing
.
Size
(
120
,
16
);
this
.
cb_manualcount
.
TabIndex
=
3
;
this
.
cb_manualcount
.
Text
=
"
手动拦截点料
"
;
this
.
cb_manualcount
.
Text
=
"
Manual operation
"
;
this
.
cb_manualcount
.
UseVisualStyleBackColor
=
true
;
this
.
cb_manualcount
.
CheckedChanged
+=
new
System
.
EventHandler
(
this
.
cb_manualcount_CheckedChanged
);
//
// btn_finishcount
//
this
.
btn_finishcount
.
Enabled
=
false
;
this
.
btn_finishcount
.
Location
=
new
System
.
Drawing
.
Point
(
305
,
221
);
this
.
btn_finishcount
.
Name
=
"btn_finishcount"
;
this
.
btn_finishcount
.
Size
=
new
System
.
Drawing
.
Size
(
135
,
23
);
this
.
btn_finishcount
.
TabIndex
=
4
;
this
.
btn_finishcount
.
Text
=
"Finish count"
;
this
.
btn_finishcount
.
UseVisualStyleBackColor
=
true
;
this
.
btn_finishcount
.
Click
+=
new
System
.
EventHandler
(
this
.
btn_finishcount_Click
);
//
// label_watchstatus
//
this
.
label_watchstatus
.
AutoSize
=
true
;
this
.
label_watchstatus
.
Location
=
new
System
.
Drawing
.
Point
(
60
,
284
);
this
.
label_watchstatus
.
Name
=
"label_watchstatus"
;
this
.
label_watchstatus
.
Size
=
new
System
.
Drawing
.
Size
(
41
,
12
);
this
.
label_watchstatus
.
TabIndex
=
0
;
this
.
label_watchstatus
.
Text
=
"label1"
;
//
// btn_manualsend
//
this
.
btn_manualsend
.
Location
=
new
System
.
Drawing
.
Point
(
486
,
74
);
this
.
btn_manualsend
.
Name
=
"btn_manualsend"
;
this
.
btn_manualsend
.
Size
=
new
System
.
Drawing
.
Size
(
132
,
23
);
this
.
btn_manualsend
.
TabIndex
=
5
;
this
.
btn_manualsend
.
Text
=
"Send manually"
;
this
.
btn_manualsend
.
UseVisualStyleBackColor
=
true
;
this
.
btn_manualsend
.
Click
+=
new
System
.
EventHandler
(
this
.
btn_manualsend_Click
);
//
// cb_com
//
this
.
cb_com
.
FormattingEnabled
=
true
;
this
.
cb_com
.
Items
.
AddRange
(
new
object
[]
{
"COM1"
,
"COM2"
,
"COM3"
,
"COM4"
,
"COM5"
,
"COM6"
,
"COM7"
,
"COM8"
,
"COM9"
,
"COM10"
});
this
.
cb_com
.
Location
=
new
System
.
Drawing
.
Point
(
224
,
25
);
this
.
cb_com
.
Name
=
"cb_com"
;
this
.
cb_com
.
Size
=
new
System
.
Drawing
.
Size
(
101
,
20
);
this
.
cb_com
.
TabIndex
=
6
;
//
// cb_bitrate
//
this
.
cb_bitrate
.
FormattingEnabled
=
true
;
this
.
cb_bitrate
.
Items
.
AddRange
(
new
object
[]
{
"115200"
,
"9600"
,
"4800"
});
this
.
cb_bitrate
.
Location
=
new
System
.
Drawing
.
Point
(
331
,
25
);
this
.
cb_bitrate
.
Name
=
"cb_bitrate"
;
this
.
cb_bitrate
.
Size
=
new
System
.
Drawing
.
Size
(
121
,
20
);
this
.
cb_bitrate
.
TabIndex
=
6
;
//
// btn_reopen
//
this
.
btn_reopen
.
Location
=
new
System
.
Drawing
.
Point
(
469
,
23
);
this
.
btn_reopen
.
Name
=
"btn_reopen"
;
this
.
btn_reopen
.
Size
=
new
System
.
Drawing
.
Size
(
75
,
23
);
this
.
btn_reopen
.
TabIndex
=
7
;
this
.
btn_reopen
.
Text
=
"Apply"
;
this
.
btn_reopen
.
UseVisualStyleBackColor
=
true
;
this
.
btn_reopen
.
Click
+=
new
System
.
EventHandler
(
this
.
btn_reopen_Click
);
//
// button_start
//
this
.
button_start
.
Location
=
new
System
.
Drawing
.
Point
(
486
,
104
);
this
.
button_start
.
Name
=
"button_start"
;
this
.
button_start
.
Size
=
new
System
.
Drawing
.
Size
(
132
,
23
);
this
.
button_start
.
TabIndex
=
8
;
this
.
button_start
.
Text
=
"Start button"
;
this
.
button_start
.
UseVisualStyleBackColor
=
true
;
this
.
button_start
.
Click
+=
new
System
.
EventHandler
(
this
.
button_start_Click
);
//
// cb_enter
//
this
.
cb_enter
.
AutoSize
=
true
;
this
.
cb_enter
.
Location
=
new
System
.
Drawing
.
Point
(
360
,
54
);
this
.
cb_enter
.
Name
=
"cb_enter"
;
this
.
cb_enter
.
Size
=
new
System
.
Drawing
.
Size
(
36
,
16
);
this
.
cb_enter
.
TabIndex
=
9
;
this
.
cb_enter
.
Tag
=
"not"
;
this
.
cb_enter
.
Text
=
"\\r"
;
this
.
cb_enter
.
UseVisualStyleBackColor
=
true
;
this
.
cb_enter
.
CheckedChanged
+=
new
System
.
EventHandler
(
this
.
cb_enter_CheckedChanged
);
//
// cb_newline
//
this
.
cb_newline
.
AutoSize
=
true
;
this
.
cb_newline
.
Checked
=
true
;
this
.
cb_newline
.
CheckState
=
System
.
Windows
.
Forms
.
CheckState
.
Checked
;
this
.
cb_newline
.
Location
=
new
System
.
Drawing
.
Point
(
424
,
54
);
this
.
cb_newline
.
Name
=
"cb_newline"
;
this
.
cb_newline
.
Size
=
new
System
.
Drawing
.
Size
(
36
,
16
);
this
.
cb_newline
.
TabIndex
=
9
;
this
.
cb_newline
.
Tag
=
"not"
;
this
.
cb_newline
.
Text
=
"\\n"
;
this
.
cb_newline
.
UseVisualStyleBackColor
=
true
;
this
.
cb_newline
.
CheckedChanged
+=
new
System
.
EventHandler
(
this
.
cb_enter_CheckedChanged
);
//
// CIDebugControl
//
this
.
AutoScaleDimensions
=
new
System
.
Drawing
.
SizeF
(
6F
,
12F
);
this
.
AutoScaleMode
=
System
.
Windows
.
Forms
.
AutoScaleMode
.
Font
;
this
.
Controls
.
Add
(
this
.
cb_newline
);
this
.
Controls
.
Add
(
this
.
cb_enter
);
this
.
Controls
.
Add
(
this
.
button_start
);
this
.
Controls
.
Add
(
this
.
btn_reopen
);
this
.
Controls
.
Add
(
this
.
cb_bitrate
);
this
.
Controls
.
Add
(
this
.
cb_com
);
this
.
Controls
.
Add
(
this
.
btn_manualsend
);
this
.
Controls
.
Add
(
this
.
btn_finishcount
);
this
.
Controls
.
Add
(
this
.
cb_manualcount
);
this
.
Controls
.
Add
(
this
.
txt_barcode
);
this
.
Controls
.
Add
(
this
.
btn_start
);
this
.
Controls
.
Add
(
this
.
label_barcode
);
this
.
Controls
.
Add
(
this
.
label_watchstatus
);
this
.
Controls
.
Add
(
this
.
label_status
);
this
.
Name
=
"CIDebugControl"
;
this
.
Size
=
new
System
.
Drawing
.
Size
(
517
,
310
);
this
.
Size
=
new
System
.
Drawing
.
Size
(
693
,
359
);
this
.
ResumeLayout
(
false
);
this
.
PerformLayout
();
...
...
@@ -114,5 +242,14 @@
private
System
.
Windows
.
Forms
.
Label
label_barcode
;
private
System
.
Windows
.
Forms
.
Timer
timer1
;
private
System
.
Windows
.
Forms
.
CheckBox
cb_manualcount
;
private
System
.
Windows
.
Forms
.
Button
btn_finishcount
;
private
System
.
Windows
.
Forms
.
Label
label_watchstatus
;
private
System
.
Windows
.
Forms
.
Button
btn_manualsend
;
private
System
.
Windows
.
Forms
.
ComboBox
cb_com
;
private
System
.
Windows
.
Forms
.
ComboBox
cb_bitrate
;
private
System
.
Windows
.
Forms
.
Button
btn_reopen
;
private
System
.
Windows
.
Forms
.
Button
button_start
;
private
System
.
Windows
.
Forms
.
CheckBox
cb_enter
;
private
System
.
Windows
.
Forms
.
CheckBox
cb_newline
;
}
}
TheMachine/device/CIDebugControl.cs
查看文件 @
61f4e58
...
...
@@ -12,6 +12,7 @@ using System.Text;
using
System.Threading
;
using
System.Threading.Tasks
;
using
System.Windows.Forms
;
using
ConfigHelper
;
namespace
TheMachine.device
{
...
...
@@ -20,6 +21,51 @@ namespace TheMachine.device
public
CIDebugControl
()
{
InitializeComponent
();
RobotManage
.
LoadFinishEvent
+=
RobotManage_LoadFinishEvent
;
Config
.
PropertyBind
(
Setting_Init
.
VJCounter_COMPORT
.
Key
,
cb_com
,
"SelectedItem"
,
"SelectedIndexChanged"
);
Config
.
PropertyBind
(
Setting_Init
.
VJCounter_BaudRate
.
Key
,
cb_bitrate
,
"SelectedItem"
,
"SelectedIndexChanged"
);
}
private
void
RobotManage_LoadFinishEvent
(
bool
state
,
string
msg
)
{
if
(!
TrayStop
.
DeviceList
.
ContainsKey
(
"CI"
))
return
;
CI
.
DeviceList
[
"CI"
].
ReelReady
+=
CIDebugControl_ReelReady
;
CI
.
DeviceList
[
"CI"
].
XRayStep
+=
CIDebugControl_XRayStep
;
CI
.
DeviceList
[
"CI"
].
ManualCount
=
cb_manualcount
.
Checked
;
}
XRayStepE
currentstep
=
XRayStepE
.
Finish
;
private
void
CIDebugControl_XRayStep
(
object
sender
,
XRayStepE
e
)
{
currentstep
=
e
;
LogUtil
.
info
(
"CID:CI测试界面接受到步骤:"
+
e
);
this
.
Invoke
((
EventHandler
)
delegate
{
switch
(
e
)
{
case
XRayStepE
.
WaitMTtoVJ
:
btn_start
.
Enabled
=
true
;
break
;
case
XRayStepE
.
Counting
:
btn_start
.
Enabled
=
false
;
break
;
case
XRayStepE
.
WaitVJtoMT
:
btn_finishcount
.
Enabled
=
true
;
break
;
case
XRayStepE
.
Finish
:
btn_finishcount
.
Enabled
=
false
;
btn_start
.
Enabled
=
false
;
break
;
}
});
}
private
void
CIDebugControl_ReelReady
(
object
sender
,
string
e
)
{
this
.
Invoke
((
EventHandler
)
delegate
{
LogUtil
.
info
(
"CID:CI测试界面接受到条码:"
+
e
);
txt_barcode
.
Text
=
e
;
});
}
private
void
timer1_Tick
(
object
sender
,
EventArgs
e
)
...
...
@@ -36,19 +82,27 @@ namespace TheMachine.device
status
=
"Counting"
;
}
label_status
.
Text
=
status
;
label_status
.
Text
=
status
+
", "
+
currentstep
;
label_watchstatus
.
Text
=
$
"Last SN:{RobotManage.folderWatcher.LastSN}, QTY:{RobotManage.folderWatcher.LastQty}, "
+
RobotManage
.
folderWatcher
.
LastUpdateTime
.
ToString
();
}
private
void
btn_start_Click
(
object
sender
,
EventArgs
e
)
{
if
(
CI
.
DeviceList
[
"CI"
].
MoveInfo
.
MoveStep
==
MoveStep
.
MI_01
)
CI
.
DeviceList
[
"CI"
].
MoveInfo
.
NextMoveStep
(
MoveStep
.
MI_02
);
else
MessageBox
.
Show
(
"没有准备点料的托盘"
);
return
;
if
(
TrayStop
.
DeviceList
[
"CI"
].
IOValue
(
IO_Type
.
CI_Count_Finished
).
Equals
(
IO_VALUE
.
HIGH
))
{
if
(
VJCounter
.
CheckConnect
())
{
VJCounter
.
SendBarcode
(
txt_barcode
.
Text
.
Trim
());
Thread
.
Sleep
(
500
);
TrayStop
.
DeviceList
[
"CI"
].
IOMove
(
IO_Type
.
CI_Start
,
IO_VALUE
.
HIGH
,
10
00
);
LogUtil
.
info
(
"手动点击开始点料"
);
TrayStop
.
DeviceList
[
"CI"
].
IOMove
(
IO_Type
.
CI_Start
,
IO_VALUE
.
HIGH
,
5
00
);
LogUtil
.
info
(
"
CID:
手动点击开始点料"
);
}
else
{
MessageBox
.
Show
(
crc
.
GetString
(
"Res0117.c9f109fe"
,
"未成功连接VJ点料机"
));
...
...
@@ -64,5 +118,45 @@ namespace TheMachine.device
{
CI
.
DeviceList
[
"CI"
].
ManualCount
=
cb_manualcount
.
Checked
;
}
private
void
btn_finishcount_Click
(
object
sender
,
EventArgs
e
)
{
LogUtil
.
info
(
"CID:用户确认放料完成"
);
CI
.
DeviceList
[
"CI"
].
StartOutStore
();
}
private
void
btn_manualsend_Click
(
object
sender
,
EventArgs
e
)
{
LogUtil
.
info
(
"CID:手动点击SendBarcode"
);
var
bc
=
txt_barcode
.
Text
.
Trim
()
+
VJCounter
.
newline
;
VJCounter
.
SendBarcode
(
bc
);
MessageBox
.
Show
(
"send: \""
+
bc
.
Replace
(
"\r"
,
"\\r"
).
Replace
(
"\n"
,
"\\n"
)+
"\""
);
}
private
void
btn_reopen_Click
(
object
sender
,
EventArgs
e
)
{
if
(!
VJCounter
.
Connect
(
Setting_Init
.
VJCounter_COMPORT
,
Setting_Init
.
VJCounter_BaudRate
,
out
string
msgs
))
{
MessageBox
.
Show
(
msgs
);
}
}
private
void
button_start_Click
(
object
sender
,
EventArgs
e
)
{
LogUtil
.
info
(
"CID:手动点击startbtn"
);
TrayStop
.
DeviceList
[
"CI"
].
IOMove
(
IO_Type
.
CI_Start
,
IO_VALUE
.
HIGH
,
500
);
}
private
void
cb_enter_CheckedChanged
(
object
sender
,
EventArgs
e
)
{
string
newline
=
""
;
if
(
cb_enter
.
Checked
)
newline
+=
"\r"
;
if
(
cb_newline
.
Checked
)
newline
+=
"\n"
;
VJCounter
.
newline
=
newline
;
}
}
}
\ No newline at end of file
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论