Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
刘韬
/
1053_CycleLine
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit cd2c32e9
由
刘韬
编写于
2022-08-23 11:24:52 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
1
1 个父辈
e5f96595
隐藏空白字符变更
内嵌
并排
正在显示
18 个修改的文件
包含
304 行增加
和
110 行删除
DeviceLibrary/theMachine/Common.cs
DeviceLibrary/theMachine/DeviceRunControl.cs
DeviceLibrary/theMachine/MainMachine _BtnProcess.cs
DeviceLibrary/theMachine/MainMachine.cs
DeviceLibrary/theMachine/RobotManage.cs
DeviceLibrary/theMachine/TrayManager.cs
DeviceLibrary/theMachine/sub/SideMove.cs
DeviceLibrary/theMachine/sub/TransplantMove.cs
DeviceLibrary/theMachine/sub/TrayStop.cs
LoadCVSLibrary/CSVAttribute.cs
TheMachine/AxisControl.cs
TheMachine/Form1.Designer.cs
TheMachine/Form1.cs
TheMachine/TheMachine.csproj
TheMachine/TrayManagerControl.Designer.cs
TheMachine/TrayManagerControl.cs
TheMachine/TrayManagerControl.resx
TheMachine/UC/DoubleBufferListView.cs
DeviceLibrary/theMachine/Common.cs
查看文件 @
cd2c32e
...
...
@@ -306,6 +306,7 @@ namespace DeviceLibrary
return
dstobject
;
}
}
[
Serializable
]
public
class
Msg
{
public
string
msgtxt
;
...
...
@@ -316,6 +317,7 @@ namespace DeviceLibrary
public
class
MsgService
{
public
static
Dictionary
<
string
,
MsgService
>
MSList
=
new
Dictionary
<
string
,
MsgService
>();
public
static
Dictionary
<
string
,
List
<
Msg
>>
LastMSGList
=
new
Dictionary
<
string
,
List
<
Msg
>>();
public
static
void
Add
(
string
m
,
MsgLevel
ml
,
ErrInfo
errInfo
=
ErrInfo
.
Empty
)
{
MSList
.
Values
.
ToList
().
ForEach
(
msl
=>
...
...
@@ -332,11 +334,13 @@ namespace DeviceLibrary
}
return
l
;
}
public
static
event
EventHandler
<
Dictionary
<
string
,
List
<
Msg
>>>
ShowMsg
;
public
string
Device
{
get
;
}
public
MsgService
(
string
device
)
{
Device
=
device
;
MSList
.
Add
(
Device
,
this
);
LastMSGList
.
Add
(
Device
,
get
());
}
public
List
<
Msg
>
msg
=
new
List
<
Msg
>();
public
List
<
Msg
>
get
()
...
...
@@ -361,20 +365,40 @@ namespace DeviceLibrary
}
}
bool
_setlogones
=
false
;
internal
void
setlogones
()
{
_setlogones
=
true
;
}
public
void
Show
()
{
Dictionary
<
string
,
List
<
Msg
>>
clonemsglist
;
lock
(
LastMSGList
)
{
LastMSGList
[
Device
]
=
get
();
clonemsglist
=
Clone
(
LastMSGList
);
}
ShowMsg
?.
Invoke
(
Device
,
clonemsglist
);
}
public
void
clear
()
{
msg
.
Clear
();
}
/// <summary>
/// 得到一个对象的克隆(二进制的序列化和反序列化)--需要标记可序列化
/// </summary>
public
static
T
Clone
<
T
>(
T
obj
)
{
MemoryStream
memoryStream
=
new
MemoryStream
();
BinaryFormatter
formatter
=
new
BinaryFormatter
();
formatter
.
Serialize
(
memoryStream
,
obj
);
memoryStream
.
Position
=
0
;
return
(
T
)
formatter
.
Deserialize
(
memoryStream
);
}
}
public
enum
MsgLevel
{
public
enum
MsgLevel
{
warning
,
info
,
...
...
DeviceLibrary/theMachine/DeviceRunControl.cs
查看文件 @
cd2c32e
...
...
@@ -16,8 +16,6 @@ namespace DeviceLibrary
public
static
List
<
ManualResetEvent
>
manualResets
=
new
List
<
ManualResetEvent
>();
List
<
IDevice
>
DevicesList
;
string
DeviceListName
;
public
delegate
void
ProcessMsg
(
List
<
Msg
>
msg
);
public
event
ProcessMsg
ProcessMsgEvent
;
ManualResetEvent
resetEvent
=
new
ManualResetEvent
(
false
);
public
DeviceRunControl
(
string
name
,
List
<
IDevice
>
device
)
{
DevicesList
=
device
;
...
...
@@ -51,9 +49,7 @@ namespace DeviceLibrary
}
finally
{
var
m
=
MsgService
.
MSList
[
x
.
GroupName
].
get
();
ProcessMsgEvent
?.
Invoke
(
m
);
MsgService
.
MSList
[
x
.
GroupName
].
Show
();
}
});
...
...
DeviceLibrary/theMachine/MainMachine _BtnProcess.cs
查看文件 @
cd2c32e
...
...
@@ -29,7 +29,7 @@ namespace DeviceLibrary
}
LogUtil
.
info
(
"按下复位按钮"
);
ProcessMsgEvent
?.
Invoke
(
Msg
.
get
()
);
Msg
.
Show
(
);
//暂停时按下reaet按钮
if
(
RobotManage
.
isRunning
&&
RobotManage
.
mainMachine
.
UserPause
)
...
...
@@ -50,7 +50,7 @@ namespace DeviceLibrary
Msg
.
add
(
crc
.
GetString
(
"Res0165"
,
"急停中,按下启动按钮,无法启动."
),
MsgLevel
.
warning
);
}
LogUtil
.
info
(
"按下启动按钮"
);
ProcessMsgEvent
?.
Invoke
(
Msg
.
get
()
);
Msg
.
Show
(
);
}
}
}
\ No newline at end of file
DeviceLibrary/theMachine/MainMachine.cs
查看文件 @
cd2c32e
...
...
@@ -33,9 +33,6 @@ namespace DeviceLibrary
public
Dictionary
<
string
,
DeviceGroup
>
DeviceGroup
{
get
=>
RobotManage
.
DeviceGroup
;
}
public
bool
UserPause
{
get
;
set
;
}
=
false
;
public
delegate
void
ProcessMsg
(
List
<
Msg
>
msg
);
public
event
ProcessMsg
ProcessMsgEvent
;
ServerCommunication
ServerCM
=
new
ServerCommunication
();
public
ManualResetEvent
ResetEvent
=
new
ManualResetEvent
(
true
);
...
...
@@ -113,9 +110,9 @@ namespace DeviceLibrary
Msg
.
add
(
ex
.
ToString
(),
MsgLevel
.
warning
);
Msg
.
setlogones
();
}
finally
{
finally
{
var
m
=
Msg
.
get
();
ProcessMsgEvent
?.
Invoke
(
m
);
Msg
.
Show
(
);
ServerCM
.
ProcessMsg
(
m
);
StoreStatus
currnetstoreStatus
=
StoreStatus
.
None
;
if
(
m
.
Find
((
aa
)
=>
aa
.
msgLevel
==
MsgLevel
.
alarm
)
==
null
)
...
...
DeviceLibrary/theMachine/RobotManage.cs
查看文件 @
cd2c32e
...
...
@@ -65,6 +65,8 @@ namespace DeviceLibrary
//IsLoadOk = true;
}
catch
(
Exception
ex
)
{
LogUtil
.
error
(
ex
.
ToString
());
MessageBox
.
Show
(
ex
.
ToString
());
LoadFinishEvent
?.
Invoke
(
false
,
ex
.
Message
);
return
;
}
...
...
DeviceLibrary/theMachine/TrayManager.cs
查看文件 @
cd2c32e
using
OnlineStore.Common
;
using
OnlineStore.LoadCSVLibrary
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
...
...
@@ -16,13 +17,14 @@ namespace DeviceLibrary
/// <param name="rfid"></param>
/// <param name="addr"></param>
/// <param name="trayInfo"></param>
/// <returns>是否放行</returns>
/// <returns>是否放行
放行true, 拦截false
</returns>
public
static
bool
Process
(
string
rfid
,
int
addr
,
out
TrayInfo
trayInfo
)
{
if
(!
Traylist
.
ContainsKey
(
rfid
))
{
Traylist
.
Add
(
rfid
,
new
TrayInfo
());
Traylist
[
rfid
].
RFID
=
rfid
;
}
Traylist
[
rfid
].
LastUpdateTime
=
DateTime
.
Now
;
Traylist
[
rfid
].
LastAddr
=
addr
;
trayInfo
=
Traylist
[
rfid
];
return
true
;
...
...
@@ -45,6 +47,7 @@ namespace DeviceLibrary
}
public
string
Destination
;
public
int
DestinationAddr
;
public
int
LastAddr
;
public
bool
HasLoad
;
public
LoadTypeE
LoadType
;
public
TrayTypeE
TrayType
;
...
...
@@ -52,6 +55,7 @@ namespace DeviceLibrary
public
ReelParam
ReelParam
;
}
public
enum
LoadTypeE
{
None
,
MTP2
,
//流水线治具托盘
MTP1
,
//流水线料盘托盘
S007
,
//料串
...
...
@@ -71,7 +75,9 @@ namespace DeviceLibrary
{
public
static
Dictionary
<
LoadTypeE
,
string
>
LoadTypeDesc
=
new
Dictionary
<
LoadTypeE
,
string
>();
public
static
Dictionary
<
TrayTypeE
,
string
>
TrayTypeDesc
=
new
Dictionary
<
TrayTypeE
,
string
>();
public
static
Dictionary
<
int
,
string
>
AddrDesc
=
new
Dictionary
<
int
,
string
>();
static
TrayManager
()
{
LoadTypeDesc
.
Add
(
LoadTypeE
.
None
,
"空"
);
LoadTypeDesc
.
Add
(
LoadTypeE
.
MTP2
,
"流水线治具托盘"
);
LoadTypeDesc
.
Add
(
LoadTypeE
.
MTP1
,
"流水线料盘托盘"
);
LoadTypeDesc
.
Add
(
LoadTypeE
.
S007
,
"料串"
);
...
...
@@ -83,6 +89,19 @@ namespace DeviceLibrary
TrayTypeDesc
.
Add
(
TrayTypeE
.
C02
,
"Pizza治具"
);
TrayTypeDesc
.
Add
(
TrayTypeE
.
C03
,
"Tray治具"
);
TrayTypeDesc
.
Add
(
TrayTypeE
.
C04
,
"ShoeBOX治具"
);
}
public
static
void
Init
(
Dictionary
<
string
,
DeviceGroup
>
deviceGroup
)
{
foreach
(
var
dg
in
deviceGroup
)
{
if
(
dg
.
Value
.
addr_2
>=
0
)
{
AddrDesc
.
Add
(
dg
.
Value
.
addr_1
,
dg
.
Value
.
GroupName
+
"-1"
);
AddrDesc
.
Add
(
dg
.
Value
.
addr_2
,
dg
.
Value
.
GroupName
+
"-2"
);
}
else
{
AddrDesc
.
Add
(
dg
.
Value
.
addr_1
,
dg
.
Value
.
GroupName
);
}
}
}
}
}
DeviceLibrary/theMachine/sub/SideMove.cs
查看文件 @
cd2c32e
...
...
@@ -196,6 +196,7 @@ namespace DeviceLibrary
var
Ls_B_Tray_Check
=
$
"Ls_{sideb}_Tray_Check"
;
var
RFID
=
Minfo
==
LSAMoveInfo
?
RFID_1
:
RFID_2
;
var
lsb
=
(
Minfo
==
LSAMoveInfo
?
LSBMoveInfo
:
LSAMoveInfo
);
var
addr
=
(
Minfo
==
LSAMoveInfo
?
DeviceGroup
.
addr_1
:
DeviceGroup
.
addr_2
);
switch
(
Minfo
.
MoveStep
)
{
case
MoveStep
.
Wait
:
...
...
@@ -233,8 +234,8 @@ namespace DeviceLibrary
if
(
RFID
.
TryRead
(
out
string
rfid
,
out
_
)
==
1
)
{
TrayManager
.
Process
(
rfid
,
DeviceGroup
.
addr_1
,
out
TrayInfo
trayInfo
);
if
(
rfid
==
"通过"
)
var
through
=
TrayManager
.
Process
(
rfid
,
addr
,
out
TrayInfo
trayInfo
);
if
(
through
)
Minfo
.
NextMoveStep
(
MoveStep
.
SideMove_04
);
else
Minfo
.
NextMoveStep
(
MoveStep
.
SideMove_10
);
...
...
@@ -244,6 +245,7 @@ namespace DeviceLibrary
{
Minfo
.
CanWhileCount
--;
Minfo
.
log
(
$
"RFid读取失败,重试第{3- Minfo.CanWhileCount}次"
);
Minfo
.
WaitList
.
Add
(
WaitResultInfo
.
WaitMsg
(
"RFid读取失败"
,
MsgLevel
.
warning
));
}
else
{
Minfo
.
log
(
"RFid读取失败,直接通过"
);
...
...
DeviceLibrary/theMachine/sub/TransplantMove.cs
查看文件 @
cd2c32e
...
...
@@ -105,7 +105,8 @@ namespace DeviceLibrary
case
MoveStep
.
TransplantMove_02
:
if
(
RFID_1
.
TryRead
(
out
string
rfid
,
out
_
)
==
1
)
{
if
(
rfid
==
"通过"
)
var
through
=
TrayManager
.
Process
(
rfid
,
DeviceGroup
.
addr_1
,
out
TrayInfo
trayInfo
);
if
(
through
)
MoveInfo
.
NextMoveStep
(
MoveStep
.
TransplantMove_03
);
else
if
(
IOValue
(
IO_Type
.
AMH_Reel_Check
).
Equals
(
IO_VALUE
.
HIGH
))
MoveInfo
.
NextMoveStep
(
MoveStep
.
TransplantMove_10
);
...
...
@@ -117,11 +118,12 @@ namespace DeviceLibrary
{
MoveInfo
.
CanWhileCount
--;
MoveInfo
.
log
(
$
"RFid读取失败,重试第{3 - MoveInfo.CanWhileCount}次"
);
MoveInfo
.
WaitList
.
Add
(
WaitResultInfo
.
WaitMsg
(
"RFid读取失败"
,
MsgLevel
.
warning
));
}
else
{
MoveInfo
.
log
(
"RFid读取失败,直接通过"
);
MoveInfo
.
NextMoveStep
(
MoveStep
.
TransplantMove_0
4
);
MoveInfo
.
NextMoveStep
(
MoveStep
.
TransplantMove_0
3
);
}
break
;
case
MoveStep
.
TransplantMove_03
:
...
...
DeviceLibrary/theMachine/sub/TrayStop.cs
查看文件 @
cd2c32e
...
...
@@ -104,7 +104,8 @@ namespace DeviceLibrary
case
MoveStep
.
TrayStop_02
:
if
(
RFID_1
.
TryRead
(
out
string
rfid
,
out
_
)
==
1
)
{
if
(
rfid
==
"通过"
)
var
through
=
TrayManager
.
Process
(
rfid
,
DeviceGroup
.
addr_1
,
out
TrayInfo
trayInfo
);
if
(
through
)
MoveInfo
.
NextMoveStep
(
MoveStep
.
TrayStop_03
);
else
MoveInfo
.
NextMoveStep
(
MoveStep
.
TrayStop_WaitLoadLeave
);
...
...
@@ -114,6 +115,7 @@ namespace DeviceLibrary
{
MoveInfo
.
CanWhileCount
--;
MoveInfo
.
log
(
$
"RFid读取失败,重试第{3 - MoveInfo.CanWhileCount}次"
);
MoveInfo
.
WaitList
.
Add
(
WaitResultInfo
.
WaitMsg
(
"RFid读取失败"
,
MsgLevel
.
warning
));
}
else
{
...
...
LoadCVSLibrary/CSVAttribute.cs
查看文件 @
cd2c32e
...
...
@@ -8,7 +8,7 @@ namespace OnlineStore.LoadCSVLibrary
{
//这里利用AttributeUsage 来设置我们的自定义属性的应用范围,这里定义的可以用于类,结构和方法的声明
[
AttributeUsage
(
AttributeTargets
.
Property
|
AttributeTargets
.
Class
|
AttributeTargets
.
Method
,
AllowMultiple
=
true
)]
public
class
CSVAttribute
:
Attribute
public
class
CSVAttribute
:
Attribute
{
public
CSVAttribute
(
string
fieldName
)
{
...
...
TheMachine/AxisControl.cs
查看文件 @
cd2c32e
...
...
@@ -48,6 +48,7 @@ namespace TheMachine
configControl1
.
Config
=
RobotManage
.
Config
;
LogUtil
.
info
(
"伺服面板加载完成."
);
}
...
...
TheMachine/Form1.Designer.cs
查看文件 @
cd2c32e
...
...
@@ -42,10 +42,10 @@ namespace TheMachine
this
.
tabP1
=
new
System
.
Windows
.
Forms
.
TabPage
();
this
.
pnl
=
new
System
.
Windows
.
Forms
.
Panel
();
this
.
groupBox1
=
new
System
.
Windows
.
Forms
.
GroupBox
();
this
.
stateView
=
new
System
.
Windows
.
Forms
.
ListView
();
this
.
stateView
=
new
TheMachine
.
DoubleBufferListView
();
this
.
listView1
=
new
TheMachine
.
DoubleBufferListView
();
this
.
cb_EnableBuzzer
=
new
System
.
Windows
.
Forms
.
CheckBox
();
this
.
btn_PauseBuzzer
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
listView1
=
new
System
.
Windows
.
Forms
.
ListView
();
this
.
btn_stop
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
btn_run
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
menuStrip1
.
SuspendLayout
();
...
...
@@ -161,8 +161,7 @@ namespace TheMachine
// pnl
//
this
.
pnl
.
Controls
.
Add
(
this
.
groupBox1
);
this
.
pnl
.
Controls
.
Add
(
this
.
cb_EnableBuzzer
);
this
.
pnl
.
Controls
.
Add
(
this
.
btn_PauseBuzzer
);
this
.
pnl
.
Controls
.
Add
(
this
.
listView1
);
this
.
pnl
.
Dock
=
System
.
Windows
.
Forms
.
DockStyle
.
Fill
;
this
.
pnl
.
Location
=
new
System
.
Drawing
.
Point
(
0
,
0
);
this
.
pnl
.
Name
=
"pnl"
;
...
...
@@ -172,7 +171,7 @@ namespace TheMachine
// groupBox1
//
this
.
groupBox1
.
Controls
.
Add
(
this
.
stateView
);
this
.
groupBox1
.
Location
=
new
System
.
Drawing
.
Point
(
3
,
4
);
this
.
groupBox1
.
Location
=
new
System
.
Drawing
.
Point
(
776
,
336
);
this
.
groupBox1
.
Name
=
"groupBox1"
;
this
.
groupBox1
.
Size
=
new
System
.
Drawing
.
Size
(
598
,
244
);
this
.
groupBox1
.
TabIndex
=
1
;
...
...
@@ -192,12 +191,27 @@ namespace TheMachine
this
.
stateView
.
TabIndex
=
0
;
this
.
stateView
.
UseCompatibleStateImageBehavior
=
false
;
//
// listView1
//
this
.
listView1
.
Anchor
=
((
System
.
Windows
.
Forms
.
AnchorStyles
)(((
System
.
Windows
.
Forms
.
AnchorStyles
.
Top
|
System
.
Windows
.
Forms
.
AnchorStyles
.
Left
)
|
System
.
Windows
.
Forms
.
AnchorStyles
.
Right
)));
this
.
listView1
.
BorderStyle
=
System
.
Windows
.
Forms
.
BorderStyle
.
None
;
this
.
listView1
.
HeaderStyle
=
System
.
Windows
.
Forms
.
ColumnHeaderStyle
.
Nonclickable
;
this
.
listView1
.
HideSelection
=
false
;
this
.
listView1
.
Location
=
new
System
.
Drawing
.
Point
(
8
,
52
);
this
.
listView1
.
MultiSelect
=
false
;
this
.
listView1
.
Name
=
"listView1"
;
this
.
listView1
.
ShowGroups
=
false
;
this
.
listView1
.
Size
=
new
System
.
Drawing
.
Size
(
825
,
364
);
this
.
listView1
.
TabIndex
=
2
;
this
.
listView1
.
UseCompatibleStateImageBehavior
=
false
;
//
// cb_EnableBuzzer
//
this
.
cb_EnableBuzzer
.
AutoSize
=
true
;
this
.
cb_EnableBuzzer
.
Location
=
new
System
.
Drawing
.
Point
(
607
,
16
);
this
.
cb_EnableBuzzer
.
Location
=
new
System
.
Drawing
.
Point
(
344
,
63
);
this
.
cb_EnableBuzzer
.
Name
=
"cb_EnableBuzzer"
;
this
.
cb_EnableBuzzer
.
Size
=
new
System
.
Drawing
.
Size
(
109
,
25
);
this
.
cb_EnableBuzzer
.
Size
=
new
System
.
Drawing
.
Size
(
96
,
18
);
this
.
cb_EnableBuzzer
.
TabIndex
=
5
;
this
.
cb_EnableBuzzer
.
Text
=
"使用蜂鸣器"
;
this
.
cb_EnableBuzzer
.
UseVisualStyleBackColor
=
true
;
...
...
@@ -206,7 +220,7 @@ namespace TheMachine
// btn_PauseBuzzer
//
this
.
btn_PauseBuzzer
.
BackColor
=
System
.
Drawing
.
Color
.
OrangeRed
;
this
.
btn_PauseBuzzer
.
Location
=
new
System
.
Drawing
.
Point
(
607
,
109
);
this
.
btn_PauseBuzzer
.
Location
=
new
System
.
Drawing
.
Point
(
547
,
51
);
this
.
btn_PauseBuzzer
.
Name
=
"btn_PauseBuzzer"
;
this
.
btn_PauseBuzzer
.
Size
=
new
System
.
Drawing
.
Size
(
301
,
40
);
this
.
btn_PauseBuzzer
.
TabIndex
=
6
;
...
...
@@ -215,21 +229,6 @@ namespace TheMachine
this
.
btn_PauseBuzzer
.
Visible
=
false
;
this
.
btn_PauseBuzzer
.
Click
+=
new
System
.
EventHandler
(
this
.
btn_PauseBuzzer_Click
);
//
// listView1
//
this
.
listView1
.
Anchor
=
((
System
.
Windows
.
Forms
.
AnchorStyles
)(((
System
.
Windows
.
Forms
.
AnchorStyles
.
Top
|
System
.
Windows
.
Forms
.
AnchorStyles
.
Left
)
|
System
.
Windows
.
Forms
.
AnchorStyles
.
Right
)));
this
.
listView1
.
BorderStyle
=
System
.
Windows
.
Forms
.
BorderStyle
.
None
;
this
.
listView1
.
HeaderStyle
=
System
.
Windows
.
Forms
.
ColumnHeaderStyle
.
Nonclickable
;
this
.
listView1
.
HideSelection
=
false
;
this
.
listView1
.
Location
=
new
System
.
Drawing
.
Point
(
328
,
0
);
this
.
listView1
.
MultiSelect
=
false
;
this
.
listView1
.
Name
=
"listView1"
;
this
.
listView1
.
ShowGroups
=
false
;
this
.
listView1
.
Size
=
new
System
.
Drawing
.
Size
(
680
,
118
);
this
.
listView1
.
TabIndex
=
2
;
this
.
listView1
.
UseCompatibleStateImageBehavior
=
false
;
//
// btn_stop
//
this
.
btn_stop
.
Enabled
=
false
;
...
...
@@ -260,8 +259,9 @@ namespace TheMachine
this
.
BackColor
=
System
.
Drawing
.
Color
.
White
;
this
.
ClientSize
=
new
System
.
Drawing
.
Size
(
1008
,
729
);
this
.
Controls
.
Add
(
this
.
tabc
);
this
.
Controls
.
Add
(
this
.
listView1
);
this
.
Controls
.
Add
(
this
.
btn_stop
);
this
.
Controls
.
Add
(
this
.
btn_PauseBuzzer
);
this
.
Controls
.
Add
(
this
.
cb_EnableBuzzer
);
this
.
Controls
.
Add
(
this
.
btn_run
);
this
.
Controls
.
Add
(
this
.
menuStrip1
);
this
.
Font
=
new
System
.
Drawing
.
Font
(
"宋体"
,
10.5F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
...
...
@@ -276,7 +276,6 @@ namespace TheMachine
this
.
tabc
.
ResumeLayout
(
false
);
this
.
tabP1
.
ResumeLayout
(
false
);
this
.
pnl
.
ResumeLayout
(
false
);
this
.
pnl
.
PerformLayout
();
this
.
groupBox1
.
ResumeLayout
(
false
);
this
.
ResumeLayout
(
false
);
this
.
PerformLayout
();
...
...
@@ -291,11 +290,11 @@ namespace TheMachine
private
System
.
Windows
.
Forms
.
TabControl
tabc
;
private
System
.
Windows
.
Forms
.
ToolStripMenuItem
启用调试模式
ToolStripMenuItem
;
private
System
.
Windows
.
Forms
.
ToolStripSeparator
toolStripSeparator4
;
private
System
.
Windows
.
Forms
.
ListView
listView1
;
private
DoubleBuffer
ListView
listView1
;
private
System
.
Windows
.
Forms
.
Button
btn_stop
;
private
System
.
Windows
.
Forms
.
Button
btn_run
;
private
System
.
Windows
.
Forms
.
TabPage
tabP1
;
private
System
.
Windows
.
Forms
.
ListView
stateView
;
private
DoubleBuffer
ListView
stateView
;
private
System
.
Windows
.
Forms
.
GroupBox
groupBox1
;
private
System
.
Windows
.
Forms
.
ToolStripMenuItem
关于
ToolStripMenuItem
;
private
System
.
Windows
.
Forms
.
CheckBox
cb_EnableBuzzer
;
...
...
TheMachine/Form1.cs
查看文件 @
cd2c32e
...
...
@@ -62,6 +62,7 @@ namespace TheMachine
//LogControl lc = new LogControl();
IOControls
ioc
=
new
IOControls
();
TrayManagerControl
tmc
=
new
TrayManagerControl
();
CycleHYControl
<
HYControl
>
hy
=
new
CycleHYControl
<
HYControl
>();
CycleHYControl
<
TransplantControl
>
yz
=
new
CycleHYControl
<
TransplantControl
>();
CycleHYControl
<
TrayStopControl
>
ts
=
new
CycleHYControl
<
TrayStopControl
>();
...
...
@@ -93,12 +94,16 @@ namespace TheMachine
emptycol
.
Width
=
0
;
ColumnHeader
msgcol
=
new
ColumnHeader
();
msgcol
.
Text
=
crc
.
GetString
(
"Form1_tabc_tabP1_Text"
,
"信息"
);
msgcol
.
Width
=
53
0
;
msgcol
.
Width
=
70
0
;
ColumnHeader
timecol
=
new
ColumnHeader
();
timecol
.
Text
=
crc
.
GetString
(
"Res0197"
,
"时间"
);
timecol
.
Width
=
150
;
timecol
.
Width
=
100
;
ColumnHeader
devicecol
=
new
ColumnHeader
();
devicecol
.
Text
=
"模块"
;
devicecol
.
Width
=
100
;
listView1
.
Columns
.
Add
(
emptycol
);
listView1
.
Columns
.
Add
(
timecol
);
listView1
.
Columns
.
Add
(
devicecol
);
listView1
.
Columns
.
Add
(
msgcol
);
listView1
.
ColumnWidthChanging
+=
listView_ColumnWidthChanging
;
#
endregion
...
...
@@ -139,7 +144,7 @@ namespace TheMachine
RobotManage
.
Init
();
});
ListViewItem
lvi
=
new
ListViewItem
(
new
string
[]
{
""
,
DateTime
.
Now
.
ToString
(),
crc
.
GetString
(
"Res0200"
,
"设备加载中,请稍后..."
)
});
ListViewItem
lvi
=
new
ListViewItem
(
new
string
[]
{
""
,
DateTime
.
Now
.
ToString
(),
"Main"
,
crc
.
GetString
(
"Res0200"
,
"设备加载中,请稍后..."
)
});
lvi
.
ForeColor
=
Color
.
DarkGreen
;
listView1
.
Items
.
Add
(
lvi
);
//while (!loadtask.IsCompleted) {
...
...
@@ -164,6 +169,7 @@ namespace TheMachine
const
int
tabpagecount
=
5
;
void
addTablePage
()
{
AddForm
(
"tab_io"
,
"I/O"
,
ioc
);
AddForm
(
"tab_tmc"
,
"托盘"
,
tmc
);
AddForm
(
"tab_sidemove"
,
hy
.
DeviceName
,
hy
);
AddForm
(
"tab_transmove"
,
yz
.
DeviceName
,
yz
);
AddForm
(
"tab_traystop"
,
ts
.
DeviceName
,
ts
);
...
...
@@ -173,7 +179,7 @@ namespace TheMachine
private
void
T1_Tick
(
object
sender
,
EventArgs
e
)
{
SetState
(
MoveInfo
.
List
);
//
SetState(MoveInfo.List);
}
void
SetState
(
List
<
MoveInfo
>
moveInfoList
)
{
...
...
@@ -239,17 +245,22 @@ namespace TheMachine
}
public
delegate
void
setmsgdelegate
(
List
<
Msg
>
msgs
);
private
void
M
ainMachine_ProcessMsgEvent
(
List
<
Msg
>
msgs
)
private
void
M
sgService_ShowMsg
(
object
sender
,
Dictionary
<
string
,
List
<
Msg
>>
e
)
{
if
(
msgs
==
null
)
if
(
this
.
InvokeRequired
)
{
this
.
Invoke
((
EventHandler
)
delegate
{
MsgService_ShowMsg
(
sender
,
e
);
});
return
;
}
try
{
var
d
=
new
setmsgdelegate
(
SetMsg
);
this
.
Invoke
(
d
,
msgs
);
SetMsg
(
e
);
}
catch
(
Exception
e
)
{
LogUtil
.
info
(
"MainMachine_ProcessMsgEvent:"
+
e
.
ToString
());
catch
(
Exception
e
x
)
{
LogUtil
.
info
(
"MainMachine_ProcessMsgEvent:"
+
e
x
.
ToString
());
}
}
...
...
@@ -270,7 +281,7 @@ namespace TheMachine
{
btn_run
.
Enabled
=
true
;
//btn_stop.Enabled = true;
RobotManage
.
mainMachine
.
ProcessMsgEvent
+=
MainMachine_ProcessMsgEvent
;
MsgService
.
ShowMsg
+=
MsgService_ShowMsg
;
}
...
...
@@ -278,6 +289,7 @@ namespace TheMachine
yz
.
Init
(
"SISO"
);
ts
.
Init
(
"RT"
);
ioc
.
Config
=
RobotManage
.
Config
;
tmc
.
Config
=
RobotManage
.
Config
;
addTablePage
();
var
lm
=
new
List
<
Msg
>();
...
...
@@ -289,7 +301,7 @@ namespace TheMachine
m
.
msgLevel
=
state
?
MsgLevel
.
info
:
MsgLevel
.
warning
;
lm
.
Add
(
m
);
}
SetMsg
(
lm
);
SetMsg
(
new
Dictionary
<
string
,
List
<
Msg
>>()
{
{
"root"
,
lm
}
}
);
//启用调试模式ToolStripMenuItem.Enabled = true;
//启用调试模式ToolStripMenuItem_Click(启用调试模式ToolStripMenuItem, EventArgs.Empty);
...
...
@@ -303,54 +315,65 @@ namespace TheMachine
});
}
void
SetMsg
(
List
<
Msg
>
msgs
)
void
SetMsg
(
Dictionary
<
string
,
List
<
Msg
>>
e
)
{
this
.
SuspendLayout
();
listView1
.
Items
.
Clear
();
msgs
.
Sort
((
a
,
b
)
=>
{
if
(
a
==
null
)
return
4
;
if
(
b
==
null
)
return
4
;
if
(
a
.
msgLevel
==
MsgLevel
.
alarm
)
return
1
;
if
(
a
.
msgLevel
==
MsgLevel
.
warning
)
return
2
;
return
3
;
});
foreach
(
Msg
msg
in
msgs
)
foreach
(
var
k
in
e
.
Keys
)
{
if
(
string
.
IsNullOrEmpty
(
msg
.
msgtxt
)
||
msg
.
datetime
==
null
)
continue
;
ListViewItem
lvi
=
new
ListViewItem
(
new
string
[]
{
""
,
msg
.
datetime
.
ToString
(),
msg
.
msgtxt
});
if
(
msg
.
msgLevel
==
MsgLevel
.
info
)
lvi
.
ForeColor
=
Color
.
DarkGreen
;
else
lvi
.
ForeColor
=
Color
.
Red
;
listView1
.
Items
.
Add
(
lvi
);
if
(
msg
.
errInfo
==
ErrInfo
.
X09_BoxNotDetect
)
{
}
else
if
(
msg
.
errInfo
==
ErrInfo
.
X09_Clear
)
{
}
else
if
(
msg
.
errInfo
==
ErrInfo
.
RunBtn
)
var
msgs
=
e
[
k
];
msgs
.
Sort
((
a
,
b
)
=>
{
Task
.
Run
(()=>
{
if
(!
RobotManage
.
isRunning
)
btn_run_Click
(
this
,
EventArgs
.
Empty
);
});
}
else
if
(
msg
.
errInfo
==
ErrInfo
.
SuddenStop
)
if
(
a
==
null
)
return
4
;
if
(
b
==
null
)
return
4
;
if
(
a
.
msgLevel
==
MsgLevel
.
alarm
)
return
1
;
if
(
a
.
msgLevel
==
MsgLevel
.
warning
)
return
2
;
return
3
;
});
foreach
(
Msg
msg
in
msgs
)
{
Task
.
Run
(()=>
{
if
(
RobotManage
.
isRunning
)
//btn_run_Click(this, EventArgs.Empty);
btn_stop_Click
(
this
,
EventArgs
.
Empty
);
});
if
(
string
.
IsNullOrEmpty
(
msg
.
msgtxt
)
||
msg
.
datetime
==
null
)
continue
;
ListViewItem
lvi
=
new
ListViewItem
(
new
string
[]
{
""
,
msg
.
datetime
.
ToString
(
"HH:mm:ss"
),
k
,
msg
.
msgtxt
});
if
(
msg
.
msgLevel
==
MsgLevel
.
info
)
lvi
.
ForeColor
=
Color
.
DarkGreen
;
else
lvi
.
ForeColor
=
Color
.
Red
;
listView1
.
Items
.
Add
(
lvi
);
if
(
msg
.
errInfo
==
ErrInfo
.
X09_BoxNotDetect
)
{
}
else
if
(
msg
.
errInfo
==
ErrInfo
.
X09_Clear
)
{
}
else
if
(
msg
.
errInfo
==
ErrInfo
.
RunBtn
)
{
Task
.
Run
(()
=>
{
if
(!
RobotManage
.
isRunning
)
btn_run_Click
(
this
,
EventArgs
.
Empty
);
});
}
else
if
(
msg
.
errInfo
==
ErrInfo
.
SuddenStop
)
{
Task
.
Run
(()
=>
{
if
(
RobotManage
.
isRunning
)
//btn_run_Click(this, EventArgs.Empty);
btn_stop_Click
(
this
,
EventArgs
.
Empty
);
});
}
}
}
this
.
ResumeLayout
(
true
);
...
...
@@ -365,13 +388,13 @@ namespace TheMachine
if
(
RobotManage
.
mainMachine
.
IOValue
(
IO_Type
.
SuddenStop_BTN
).
Equals
(
IO_VALUE
.
LOW
))
{
RobotManage
.
mainMachine
.
Msg
.
add
(
"急停中,无法启动"
,
MsgLevel
.
warning
);
MainMachine_ProcessMsgEvent
(
RobotManage
.
mainMachine
.
Msg
.
get
()
);
RobotManage
.
mainMachine
.
Msg
.
Show
(
);
return
;
}
if
(
RobotManage
.
mainMachine
.
IOValue
(
IO_Type
.
AutoRun_Single
).
Equals
(
IO_VALUE
.
LOW
))
{
RobotManage
.
mainMachine
.
Msg
.
add
(
"运行开关没有打开,无法启动"
,
MsgLevel
.
warning
);
MainMachine_ProcessMsgEvent
(
RobotManage
.
mainMachine
.
Msg
.
get
()
);
RobotManage
.
mainMachine
.
Msg
.
Show
(
);
return
;
}
RobotManage
.
Start
();
...
...
@@ -521,7 +544,8 @@ namespace TheMachine
crc
.
ProcessListItem
(
menuStrip1
.
Items
,
"menuStrip1"
);
listView1
.
Columns
[
1
].
Text
=
crc
.
GetString
(
"Res0197"
,
"时间"
);
listView1
.
Columns
[
2
].
Text
=
crc
.
GetString
(
"Form1_tabc_tabP1_Text"
,
"信息"
);
listView1
.
Columns
[
2
].
Text
=
"模块"
;
listView1
.
Columns
[
3
].
Text
=
crc
.
GetString
(
"Form1_tabc_tabP1_Text"
,
"信息"
);
stateView
.
Columns
[
1
].
Text
=
crc
.
GetString
(
"Res0198"
,
"模块"
);
stateView
.
Columns
[
2
].
Text
=
crc
.
GetString
(
"Res0199"
,
"步骤"
);
...
...
TheMachine/TheMachine.csproj
查看文件 @
cd2c32e
...
...
@@ -147,6 +147,9 @@
<Compile Include="UC\CylinderButton.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="UC\DoubleBufferListView.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="UC\StorePosControl.cs">
<SubType>UserControl</SubType>
</Compile>
...
...
TheMachine/TrayManagerControl.Designer.cs
查看文件 @
cd2c32e
...
...
@@ -29,18 +29,44 @@ namespace TheMachine
/// </summary>
private
void
InitializeComponent
()
{
this
.
components
=
new
System
.
ComponentModel
.
Container
();
this
.
timer1
=
new
System
.
Windows
.
Forms
.
Timer
(
this
.
components
);
this
.
listView1
=
new
TheMachine
.
DoubleBufferListView
();
this
.
SuspendLayout
();
//
// timer1
//
this
.
timer1
.
Interval
=
1000
;
this
.
timer1
.
Tick
+=
new
System
.
EventHandler
(
this
.
timer1_Tick
);
//
// listView1
//
this
.
listView1
.
Anchor
=
((
System
.
Windows
.
Forms
.
AnchorStyles
)((((
System
.
Windows
.
Forms
.
AnchorStyles
.
Top
|
System
.
Windows
.
Forms
.
AnchorStyles
.
Bottom
)
|
System
.
Windows
.
Forms
.
AnchorStyles
.
Left
)
|
System
.
Windows
.
Forms
.
AnchorStyles
.
Right
)));
this
.
listView1
.
HideSelection
=
false
;
this
.
listView1
.
Location
=
new
System
.
Drawing
.
Point
(
3
,
34
);
this
.
listView1
.
Name
=
"listView1"
;
this
.
listView1
.
Size
=
new
System
.
Drawing
.
Size
(
706
,
412
);
this
.
listView1
.
TabIndex
=
0
;
this
.
listView1
.
UseCompatibleStateImageBehavior
=
false
;
//
// TrayManagerControl
//
this
.
AutoScaleDimensions
=
new
System
.
Drawing
.
SizeF
(
6F
,
12
F
);
this
.
AutoScaleDimensions
=
new
System
.
Drawing
.
SizeF
(
7F
,
14
F
);
this
.
AutoScaleMode
=
System
.
Windows
.
Forms
.
AutoScaleMode
.
Font
;
this
.
Controls
.
Add
(
this
.
listView1
);
this
.
Font
=
new
System
.
Drawing
.
Font
(
"宋体"
,
10.5F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
Name
=
"TrayManagerControl"
;
this
.
Size
=
new
System
.
Drawing
.
Size
(
725
,
462
);
this
.
Size
=
new
System
.
Drawing
.
Size
(
846
,
449
);
this
.
Load
+=
new
System
.
EventHandler
(
this
.
TrayManagerControl_Load
);
this
.
ResumeLayout
(
false
);
}
#
endregion
private
DoubleBufferListView
listView1
;
private
System
.
Windows
.
Forms
.
Timer
timer1
;
}
}
TheMachine/TrayManagerControl.cs
查看文件 @
cd2c32e
using
System
;
using
DeviceLibrary
;
using
OnlineStore.LoadCSVLibrary
;
using
System
;
using
System.Collections.Generic
;
using
System.ComponentModel
;
using
System.Data
;
...
...
@@ -12,9 +14,70 @@ namespace TheMachine
{
public
partial
class
TrayManagerControl
:
UserControl
{
Robot_Config
_Config
;
public
Robot_Config
Config
{
get
{
return
_Config
;
}
set
{
_Config
=
value
;
Init
();
}
}
public
TrayManagerControl
()
{
InitializeComponent
();
}
private
void
TrayManagerControl_Load
(
object
sender
,
EventArgs
e
)
{
}
void
Init
()
{
#
region
listview
初始化
var
ColList
=
new
string
[]
{
"RFID"
,
"上次地址"
,
"更新时间"
,
"托盘类型"
,
"载荷"
,
"目的地"
};
listView1
.
View
=
View
.
Details
;
foreach
(
var
coltxt
in
ColList
)
{
ColumnHeader
col1
=
new
ColumnHeader
();
col1
.
Text
=
coltxt
;
col1
.
AutoResize
(
ColumnHeaderAutoResizeStyle
.
ColumnContent
);
listView1
.
Columns
.
Add
(
col1
);
}
#
endregion
timer1
.
Start
();
}
private
void
timer1_Tick
(
object
sender
,
EventArgs
e
)
{
if
(!
Visible
)
return
;
var
traylist
=
TrayManager
.
Traylist
.
Values
.
ToList
();
foreach
(
var
ti
in
traylist
)
{
var
timego
=
(
DateTime
.
Now
-
ti
.
LastUpdateTime
);
var
lasttime
=
timego
.
Seconds
+
"秒前"
;
if
(
timego
.
Minutes
>
0
)
lasttime
=
timego
.
Minutes
+
"分 "
+
lasttime
;
if
(
timego
.
Hours
>
0
)
lasttime
=
timego
.
Hours
+
"时 "
+
lasttime
;
var
traydesc
=
TrayManager
.
TrayTypeDesc
[
ti
.
TrayType
];
var
loaddesc
=
TrayManager
.
LoadTypeDesc
[
ti
.
LoadType
];
var
lastaddrdesc
=
TrayManager
.
AddrDesc
[
ti
.
LastAddr
];
var
toaddrdesc
=
TrayManager
.
AddrDesc
[
ti
.
DestinationAddr
];
var
items
=
new
string
[]
{
ti
.
RFID
,
lastaddrdesc
.
ToString
(),
lasttime
,
traydesc
,
loaddesc
,
toaddrdesc
};
var
listviewitem
=
new
ListViewItem
();
if
(
timego
.
TotalSeconds
<
10
)
listviewitem
.
BackColor
=
Color
.
DarkGreen
;
else
if
(
timego
.
TotalSeconds
>
30
)
listviewitem
.
BackColor
=
Color
.
DarkGray
;
else
listviewitem
.
BackColor
=
Color
.
Black
;
listviewitem
.
UseItemStyleForSubItems
=
true
;
listviewitem
.
SubItems
.
AddRange
(
items
);
}
}
}
}
TheMachine/TrayManagerControl.resx
查看文件 @
cd2c32e
...
...
@@ -117,4 +117,7 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="timer1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>
\ No newline at end of file
TheMachine/UC/DoubleBufferListView.cs
0 → 100644
查看文件 @
cd2c32e
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
using
System.Windows.Forms
;
namespace
TheMachine
{
public
class
DoubleBufferListView
:
System
.
Windows
.
Forms
.
ListView
{
public
DoubleBufferListView
()
{
// 开启双缓冲
this
.
SetStyle
(
ControlStyles
.
OptimizedDoubleBuffer
|
ControlStyles
.
AllPaintingInWmPaint
,
true
);
// Enable the OnNotifyMessage event so we get a chance to filter out
// Windows messages before they get to the form's WndProc
this
.
SetStyle
(
ControlStyles
.
EnableNotifyMessage
,
true
);
}
protected
override
void
OnNotifyMessage
(
Message
m
)
{
//Filter out the WM_ERASEBKGND message
if
(
m
.
Msg
!=
0x14
)
{
base
.
OnNotifyMessage
(
m
);
}
}
}
}
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论