Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
刘韬
/
1069_MIMO_PlUS
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit f28ac78b
由
LN
编写于
2024-06-18 16:33:22 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
颜色调整
1 个父辈
e004515f
隐藏空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
373 行增加
和
78 行删除
DeviceLibrary/DeviceLibrary/flyelectronicControl/Flyelectronic_485_RGB_Controller.cs
DeviceLibrary/theMachine/MainMachine _LedRGBProcess.cs
DeviceLibrary/theMachine/MainMachine.cs
TheMachine/AxisControl.Designer.cs
TheMachine/AxisControl.cs
TheMachine/AxisControl.resx
TheMachine/Form1.cs
DeviceLibrary/DeviceLibrary/flyelectronicControl/Flyelectronic_485_RGB_Controller.cs
查看文件 @
f28ac78
...
@@ -27,12 +27,15 @@ namespace DeviceLibrary
...
@@ -27,12 +27,15 @@ namespace DeviceLibrary
string
comPortName
;
string
comPortName
;
string
Name
;
string
Name
;
private
Dictionary
<
string
,
byte
[][
]>
effactValue
=
new
Dictionary
<
string
,
byte
[][
]>
();
public
Flyelectronic_485_RGB_Controller
(
string
name
,
string
logname
=
"RollingLogFileAppender"
)
public
Flyelectronic_485_RGB_Controller
(
string
name
,
string
logname
=
"RollingLogFileAppender"
)
{
{
Name
=
name
;
Name
=
name
;
loge
=
LogManager
.
GetLogger
(
logname
);
loge
=
LogManager
.
GetLogger
(
logname
);
}
}
bool
ok
=
false
;
/// <summary>
/// <summary>
/// 打开串口资源
/// 打开串口资源
/// <returns>返回bool类型</returns>
/// <returns>返回bool类型</returns>
...
@@ -56,8 +59,7 @@ namespace DeviceLibrary
...
@@ -56,8 +59,7 @@ namespace DeviceLibrary
OpenPort
(
comPortName
,
out
errmsg
);
OpenPort
(
comPortName
,
out
errmsg
);
}
}
bool
ok
=
false
;
ok
=
false
;
try
try
{
{
//打开串口
//打开串口
...
@@ -74,6 +76,7 @@ namespace DeviceLibrary
...
@@ -74,6 +76,7 @@ namespace DeviceLibrary
if
(
rev
.
Count
()
>
0
)
if
(
rev
.
Count
()
>
0
)
{
{
ok
=
true
;
ok
=
true
;
Run
();
break
;
break
;
}
}
}
}
...
@@ -85,6 +88,45 @@ namespace DeviceLibrary
...
@@ -85,6 +88,45 @@ namespace DeviceLibrary
}
}
return
ok
;
return
ok
;
}
}
private
void
Run
()
{
Task
.
Run
(()
=>
{
try
{
var
p1
=
RobotManage
.
mainMachine
.
Config
.
Middle_P1
;
var
p1_speed
=
RobotManage
.
mainMachine
.
Config
.
Middle_P1_speed
;
var
axis
=
RobotManage
.
mainMachine
.
Middle_Axis
;
while
(
ok
)
{
Task
.
Delay
(
200
).
Wait
();
if
(
RobotManage
.
mainMachine
.
lastColor
.
Equals
(
"yellowL"
))
{
ShowYellowLight
();
}
else
if
(
RobotManage
.
mainMachine
.
lastColor
.
Equals
(
"greenL"
))
{
ShowGreenLight
();
}
else
if
(
RobotManage
.
mainMachine
.
lastColor
.
Equals
(
Color
.
Black
.
Name
.
ToString
())){
}
//else if (RobotManage.mainMachine.lastColor != "")
//{
// Color color = Color.FromName(RobotManage.mainMachine.lastColor);
// if (color != null)
// {
// ShowColor(color);
// }
//}
}
}
catch
(
Exception
Ex
)
{
LogUtil
.
error
(
"出错:"
+
Ex
.
ToString
());
}
});
}
public
bool
ShowColor
(
Color
color
,
ColorFormat
colorFormat
=
ColorFormat
.
GRB
)
public
bool
ShowColor
(
Color
color
,
ColorFormat
colorFormat
=
ColorFormat
.
GRB
)
{
{
var
newbyte
=
CommandByte
.
SetOneColor
;
var
newbyte
=
CommandByte
.
SetOneColor
;
...
@@ -103,38 +145,55 @@ namespace DeviceLibrary
...
@@ -103,38 +145,55 @@ namespace DeviceLibrary
}
}
return
false
;
return
false
;
}
}
p
ublic
bool
ShowEffact
(
string
fileName
)
p
rivate
byte
[][]
getEffactValue
(
string
fileName
)
{
{
if
(
fileName
!=
""
&&
File
.
Exists
(
fileName
))
if
(
effactValue
==
null
)
{
effactValue
=
new
Dictionary
<
string
,
byte
[][
]>
();
}
if
(
effactValue
.
ContainsKey
(
fileName
))
{
return
effactValue
[
fileName
];
}
return
null
;
}
public
bool
ShowEffact
(
string
fileName
,
Color
defColor
)
{
var
newbyte
=
getEffactValue
(
fileName
);
if
(
newbyte
!=
null
)
{
{
string
Text
=
File
.
ReadAllText
(
fileName
);
var
newbyte
=
CommandByte
.
GetEffBytes
(
Text
);
foreach
(
var
b
in
newbyte
)
foreach
(
var
b
in
newbyte
)
{
{
var
rev
=
SendAndReceive
(
b
);
var
rev
=
SendAndReceive
(
b
);
}
}
return
true
;
}
}
else
else
if
(
fileName
!=
""
&&
File
.
Exists
(
fileName
))
{
{
var
newbyte
=
CommandByte
.
GetEffBytes
(
CommandByte
.
eff1
);
string
Text
=
File
.
ReadAllText
(
fileName
);
newbyte
=
CommandByte
.
GetEffBytes
(
Text
);
foreach
(
var
b
in
newbyte
)
foreach
(
var
b
in
newbyte
)
{
{
var
rev
=
SendAndReceive
(
b
);
var
rev
=
SendAndReceive
(
b
);
}
}
return
true
;
}
else
{
//newbyte = CommandByte.GetEffBytes(CommandByte.eff1);
ShowColor
(
defColor
);
}
}
return
true
;
}
}
public
bool
ShowYellowLight
()
public
bool
ShowYellowLight
()
{
{
string
fileName
=
Application
.
StartupPath
+
"/ledColor/green.txt"
;
string
fileName
=
Application
.
StartupPath
+
"/ledColor/yellow.txt"
;
return
ShowEffact
(
fileName
);
return
ShowEffact
(
fileName
,
Color
.
Yellow
);
}
}
public
bool
ShowGreenLight
()
public
bool
ShowGreenLight
()
{
{
string
fileName
=
Application
.
StartupPath
+
"/ledColor/
yellow
.txt"
;
string
fileName
=
Application
.
StartupPath
+
"/ledColor/
green
.txt"
;
return
ShowEffact
(
fileName
);
return
ShowEffact
(
fileName
,
Color
.
Green
);
}
}
public
bool
CloseLed
()
public
bool
CloseLed
()
...
@@ -199,8 +258,13 @@ namespace DeviceLibrary
...
@@ -199,8 +258,13 @@ namespace DeviceLibrary
}
}
static
class
CommandByte
static
class
CommandByte
{
{
public
static
byte
[]
GetDeviceID
=
ConvertStringToByteArray
(
"DD 55 EE 00 00 00 00 00 8F 01 00 00 00 03 00 01 00 00 00 AA BB"
);
public
static
byte
[]
GetDeviceID
=
ConvertStringToByteArray
(
"DD 55 EE 00 00 00 00 00 8F 01 00 00 00 03 00 01 00 00 00 AA BB"
);
public
static
byte
[]
SetOneColor
=
ConvertStringToByteArray
(
"DD 55 EE 00 00 00 01 00 99 01 00 00 00 03 04 00 FF 00 00 AA BB"
);
public
static
byte
[]
SetOneColor
=
ConvertStringToByteArray
(
"DD 55 EE 00 00 00 01 00 99 01 00 00 00 03 00 C9 FF 00 00 AA BB"
);
// DD 55 EE 00 00 00 01 00 99 01 00 00 00 03 00 C9 F0 F0 F0 AA BB
//DD 55 EE 00 00 00 01 00 99 01 00 00 00 03 00 C9 F0 F0 F0 AA BB
public
static
string
eff1
=
@
"
public
static
string
eff1
=
@
"
DD
55
EE
00
00
00
01
00
99
01
00
00
00
5
A
00
01
6D
67
44
4D
43
53
2
C
1D
63
1D
0
B
6
B
1
B
09
6
C
1
B
09
6
C
1
B
09
6
C
1
B
09
6
C
1
B
09
6
C
1
B
09
6
C
1
B
09
6
C
1
B
09
6
C
1
B
09
6
C
1
B
09
6
C
1
B
09
6
C
1
B
09
6
C
1
B
09
6
C
1
B
09
6
C
1
B
09
6
C
1
B
09
6
C
1
B
09
6
C
1
B
09
6
C
1
B
09
6
C
1
B
09
6
C
1
B
09
6
C
1
B
09
6
C
1
B
09
6
C
1
B
09
6
C
1
B
09
6
C
1
B
09
6
C
AA
BB
DD
55
EE
00
00
00
01
00
99
01
00
00
00
5
A
00
01
6D
67
44
4D
43
53
2
C
1D
63
1D
0
B
6
B
1
B
09
6
C
1
B
09
6
C
1
B
09
6
C
1
B
09
6
C
1
B
09
6
C
1
B
09
6
C
1
B
09
6
C
1
B
09
6
C
1
B
09
6
C
1
B
09
6
C
1
B
09
6
C
1
B
09
6
C
1
B
09
6
C
1
B
09
6
C
1
B
09
6
C
1
B
09
6
C
1
B
09
6
C
1
B
09
6
C
1
B
09
6
C
1
B
09
6
C
1
B
09
6
C
1
B
09
6
C
1
B
09
6
C
1
B
09
6
C
1
B
09
6
C
1
B
09
6
C
AA
BB
...
@@ -355,6 +419,7 @@ DD 55 EE 00 00 00 01 00 99 01 00 00 00 5A 00 01 1B 09 6C 1B 09 6C 1B 09 6C 1B 09
...
@@ -355,6 +419,7 @@ DD 55 EE 00 00 00 01 00 99 01 00 00 00 5A 00 01 1B 09 6C 1B 09 6C 1B 09 6C 1B 09
public
void
Dispose
()
public
void
Dispose
()
{
{
ok
=
false
;
_serialPort
?.
Close
();
_serialPort
?.
Close
();
}
}
}
}
...
...
DeviceLibrary/theMachine/MainMachine _LedRGBProcess.cs
查看文件 @
f28ac78
...
@@ -56,17 +56,33 @@ namespace DeviceLibrary
...
@@ -56,17 +56,33 @@ namespace DeviceLibrary
}
}
return
false
;
return
false
;
}
}
public
void
CloseColor
()
private
void
ShowColor
(
Color
color
)
{
{
if
(
lastColor
.
Equals
(
color
.
ToArgb
().
ToString
()))
rGB_Controller
.
CloseLed
();
lastColor
=
""
;
}
public
void
ShowColor
(
Color
color
)
{
if
(
lastColor
!=
""
&&
lastColor
.
Equals
(
color
.
Name
.
ToString
()))
{
{
return
;
return
;
}
}
rGB_Controller
.
CloseLed
();
//
rGB_Controller.CloseLed();
rGB_Controller
.
ShowColor
(
color
);
rGB_Controller
.
ShowColor
(
color
);
lastColor
=
color
.
Name
.
ToString
();
}
public
void
ShowYellowLight
()
{
lastColor
=
"yellowL"
;
//rGB_Controller.CloseLed();
rGB_Controller
.
ShowYellowLight
();
}
public
void
ShowGreenLight
()
{
lastColor
=
"greenL"
;
//rGB_Controller.CloseLed();
rGB_Controller
.
ShowGreenLight
();
}
}
private
void
RgbLedProcess
(
object
o
)
private
void
RgbLedProcess
(
object
o
)
{
{
if
(
rGB_Controller
==
null
||
(!
rgbLedInitOk
))
if
(
rGB_Controller
==
null
||
(!
rgbLedInitOk
))
...
@@ -84,7 +100,7 @@ namespace DeviceLibrary
...
@@ -84,7 +100,7 @@ namespace DeviceLibrary
if
(
runStatus
==
RunStatus
.
Stop
)
if
(
runStatus
==
RunStatus
.
Stop
)
{
{
//未启动 黑色
//未启动 黑色
ShowColor
(
Color
.
Black
);
//
ShowColor(Color.Black);
}
}
else
if
(
isInSuddenDown
)
else
if
(
isInSuddenDown
)
...
@@ -128,25 +144,23 @@ namespace DeviceLibrary
...
@@ -128,25 +144,23 @@ namespace DeviceLibrary
//出入库 绿闪 黄闪
//出入库 绿闪 黄闪
else
if
(
StoreMoveInfo
.
MoveStep
>=
MoveStep
.
StoreOut10
)
else
if
(
StoreMoveInfo
.
MoveStep
>=
MoveStep
.
StoreOut10
)
{
{
//流动黄: 出库,
////流动黄: 出库,
if
(
lastColor
.
Equals
(
"yellowRun"
))
//if (lastColor.Equals("yellowRun"))
{
//{
return
;
// return;
}
//}
rGB_Controller
.
CloseLed
();
ShowYellowLight
();
rGB_Controller
.
ShowYellowLight
();
}
}
else
if
(
StoreMoveInfo
.
MoveStep
>=
MoveStep
.
StoreIn01
)
else
if
(
StoreMoveInfo
.
MoveStep
>=
MoveStep
.
StoreIn01
)
{
{
//流动绿: 入库
////流动绿: 入库
if
(
lastColor
.
Equals
(
"yellowRun"
))
//if (lastColor.Equals("yellowRun"))
{
//{
return
;
// return;
}
//}
rGB_Controller
.
CloseLed
();
ShowGreenLight
();
rGB_Controller
.
ShowYellowLight
();
}
}
}
}
else
else
...
...
DeviceLibrary/theMachine/MainMachine.cs
查看文件 @
f28ac78
...
@@ -324,7 +324,7 @@ namespace DeviceLibrary
...
@@ -324,7 +324,7 @@ namespace DeviceLibrary
currnetstoreStatus
=
isInSuddenDown
?
StoreStatus
.
SuddenStop
:
StoreStatus
.
Warning
;
currnetstoreStatus
=
isInSuddenDown
?
StoreStatus
.
SuddenStop
:
StoreStatus
.
Warning
;
}
}
//ProcessMoveinfoEvent?.Invoke(MoveInfo.List);
//ProcessMoveinfoEvent?.Invoke(MoveInfo.List);
if
(!
UserPause
)
if
(!
UserPause
&&(!
mstart
)
)
Msg
.
clear
();
Msg
.
clear
();
//else
//else
// currnetstoreStatus = StoreStatus.Debugging;
// currnetstoreStatus = StoreStatus.Debugging;
...
@@ -931,7 +931,7 @@ namespace DeviceLibrary
...
@@ -931,7 +931,7 @@ namespace DeviceLibrary
}
}
else
if
(
isInSuddenDown
)
else
if
(
isInSuddenDown
)
{
{
Alarm
(
AlarmType
.
SuddenStop
);
//
Alarm(AlarmType.SuddenStop);
Msg
.
add
(
crc
.
GetString
(
L
.
in_suddenstop
,
"急停中"
),
MsgLevel
.
alarm
);
Msg
.
add
(
crc
.
GetString
(
L
.
in_suddenstop
,
"急停中"
),
MsgLevel
.
alarm
);
DeviceSuddenStop
();
DeviceSuddenStop
();
lastSafeCheckStatus
=
false
;
lastSafeCheckStatus
=
false
;
...
...
TheMachine/AxisControl.Designer.cs
查看文件 @
f28ac78
...
@@ -31,27 +31,35 @@ namespace TheMachine
...
@@ -31,27 +31,35 @@ namespace TheMachine
{
{
this
.
components
=
new
System
.
ComponentModel
.
Container
();
this
.
components
=
new
System
.
ComponentModel
.
Container
();
this
.
panel1
=
new
System
.
Windows
.
Forms
.
Panel
();
this
.
panel1
=
new
System
.
Windows
.
Forms
.
Panel
();
this
.
btnChangeColor
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
btnGree
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
btnYellow
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
lblLed
=
new
System
.
Windows
.
Forms
.
Label
();
this
.
lblLed
=
new
System
.
Windows
.
Forms
.
Label
();
this
.
lblOkValue
=
new
System
.
Windows
.
Forms
.
Label
();
this
.
lblOkValue
=
new
System
.
Windows
.
Forms
.
Label
();
this
.
lblSensor
=
new
System
.
Windows
.
Forms
.
Label
();
this
.
lblSensor
=
new
System
.
Windows
.
Forms
.
Label
();
this
.
btnAxisRStop
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
btnAxisRStop
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
btnAxisRTest
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
btnAxisRTest
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
axisMoveControl1
=
new
DeviceLibrary
.
AxisMoveControl
();
this
.
axisMoveControl1
=
new
DeviceLibrary
.
AxisMoveControl
();
this
.
configControl1
=
new
TheMachine
.
ConfigControl
();
this
.
timer1
=
new
System
.
Windows
.
Forms
.
Timer
(
this
.
components
);
this
.
timer1
=
new
System
.
Windows
.
Forms
.
Timer
(
this
.
components
);
this
.
configControl1
=
new
TheMachine
.
ConfigControl
();
this
.
colorDialog1
=
new
System
.
Windows
.
Forms
.
ColorDialog
();
this
.
button1
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
panel1
.
SuspendLayout
();
this
.
panel1
.
SuspendLayout
();
this
.
SuspendLayout
();
this
.
SuspendLayout
();
//
//
// panel1
// panel1
//
//
this
.
panel1
.
AutoScroll
=
true
;
this
.
panel1
.
AutoScroll
=
true
;
this
.
panel1
.
Controls
.
Add
(
this
.
button1
);
this
.
panel1
.
Controls
.
Add
(
this
.
btnChangeColor
);
this
.
panel1
.
Controls
.
Add
(
this
.
btnGree
);
this
.
panel1
.
Controls
.
Add
(
this
.
btnYellow
);
this
.
panel1
.
Controls
.
Add
(
this
.
lblLed
);
this
.
panel1
.
Controls
.
Add
(
this
.
lblLed
);
this
.
panel1
.
Controls
.
Add
(
this
.
lblOkValue
);
this
.
panel1
.
Controls
.
Add
(
this
.
lblOkValue
);
this
.
panel1
.
Controls
.
Add
(
this
.
lblSensor
);
this
.
panel1
.
Controls
.
Add
(
this
.
lblSensor
);
this
.
panel1
.
Controls
.
Add
(
this
.
btnAxisRStop
);
this
.
panel1
.
Controls
.
Add
(
this
.
btnAxisRStop
);
this
.
panel1
.
Controls
.
Add
(
this
.
btnAxisRTest
);
this
.
panel1
.
Controls
.
Add
(
this
.
btnAxisRTest
);
this
.
panel1
.
Controls
.
Add
(
this
.
axisMoveControl1
);
this
.
panel1
.
Controls
.
Add
(
this
.
axisMoveControl1
);
this
.
panel1
.
Controls
.
Add
(
this
.
configControl1
);
this
.
panel1
.
Controls
.
Add
(
this
.
configControl1
);
this
.
panel1
.
Dock
=
System
.
Windows
.
Forms
.
DockStyle
.
Fill
;
this
.
panel1
.
Dock
=
System
.
Windows
.
Forms
.
DockStyle
.
Fill
;
this
.
panel1
.
Location
=
new
System
.
Drawing
.
Point
(
0
,
0
);
this
.
panel1
.
Location
=
new
System
.
Drawing
.
Point
(
0
,
0
);
...
@@ -59,10 +67,40 @@ namespace TheMachine
...
@@ -59,10 +67,40 @@ namespace TheMachine
this
.
panel1
.
Size
=
new
System
.
Drawing
.
Size
(
1234
,
924
);
this
.
panel1
.
Size
=
new
System
.
Drawing
.
Size
(
1234
,
924
);
this
.
panel1
.
TabIndex
=
2
;
this
.
panel1
.
TabIndex
=
2
;
//
//
// btnChangeColor
//
this
.
btnChangeColor
.
Location
=
new
System
.
Drawing
.
Point
(
25
,
567
);
this
.
btnChangeColor
.
Name
=
"btnChangeColor"
;
this
.
btnChangeColor
.
Size
=
new
System
.
Drawing
.
Size
(
155
,
31
);
this
.
btnChangeColor
.
TabIndex
=
19
;
this
.
btnChangeColor
.
Text
=
"切换颜色"
;
this
.
btnChangeColor
.
UseVisualStyleBackColor
=
true
;
this
.
btnChangeColor
.
Click
+=
new
System
.
EventHandler
(
this
.
btnChangeColor_Click
);
//
// btnGree
//
this
.
btnGree
.
Location
=
new
System
.
Drawing
.
Point
(
25
,
530
);
this
.
btnGree
.
Name
=
"btnGree"
;
this
.
btnGree
.
Size
=
new
System
.
Drawing
.
Size
(
155
,
31
);
this
.
btnGree
.
TabIndex
=
18
;
this
.
btnGree
.
Text
=
"流动绿"
;
this
.
btnGree
.
UseVisualStyleBackColor
=
true
;
this
.
btnGree
.
Click
+=
new
System
.
EventHandler
(
this
.
btnGree_Click
);
//
// btnYellow
//
this
.
btnYellow
.
Location
=
new
System
.
Drawing
.
Point
(
25
,
493
);
this
.
btnYellow
.
Name
=
"btnYellow"
;
this
.
btnYellow
.
Size
=
new
System
.
Drawing
.
Size
(
155
,
31
);
this
.
btnYellow
.
TabIndex
=
17
;
this
.
btnYellow
.
Text
=
"流动黄"
;
this
.
btnYellow
.
UseVisualStyleBackColor
=
true
;
this
.
btnYellow
.
Click
+=
new
System
.
EventHandler
(
this
.
btnYellow_Click
);
//
// lblLed
// lblLed
//
//
this
.
lblLed
.
AutoSize
=
true
;
this
.
lblLed
.
AutoSize
=
true
;
this
.
lblLed
.
Location
=
new
System
.
Drawing
.
Point
(
2
56
,
487
);
this
.
lblLed
.
Location
=
new
System
.
Drawing
.
Point
(
2
3
,
460
);
this
.
lblLed
.
Name
=
"lblLed"
;
this
.
lblLed
.
Name
=
"lblLed"
;
this
.
lblLed
.
Size
=
new
System
.
Drawing
.
Size
(
41
,
12
);
this
.
lblLed
.
Size
=
new
System
.
Drawing
.
Size
(
41
,
12
);
this
.
lblLed
.
TabIndex
=
16
;
this
.
lblLed
.
TabIndex
=
16
;
...
@@ -71,7 +109,7 @@ namespace TheMachine
...
@@ -71,7 +109,7 @@ namespace TheMachine
// lblOkValue
// lblOkValue
//
//
this
.
lblOkValue
.
AutoSize
=
true
;
this
.
lblOkValue
.
AutoSize
=
true
;
this
.
lblOkValue
.
Location
=
new
System
.
Drawing
.
Point
(
2
56
,
45
4
);
this
.
lblOkValue
.
Location
=
new
System
.
Drawing
.
Point
(
2
3
,
43
4
);
this
.
lblOkValue
.
Name
=
"lblOkValue"
;
this
.
lblOkValue
.
Name
=
"lblOkValue"
;
this
.
lblOkValue
.
Size
=
new
System
.
Drawing
.
Size
(
65
,
12
);
this
.
lblOkValue
.
Size
=
new
System
.
Drawing
.
Size
(
65
,
12
);
this
.
lblOkValue
.
TabIndex
=
15
;
this
.
lblOkValue
.
TabIndex
=
15
;
...
@@ -80,7 +118,7 @@ namespace TheMachine
...
@@ -80,7 +118,7 @@ namespace TheMachine
// lblSensor
// lblSensor
//
//
this
.
lblSensor
.
AutoSize
=
true
;
this
.
lblSensor
.
AutoSize
=
true
;
this
.
lblSensor
.
Location
=
new
System
.
Drawing
.
Point
(
2
56
,
421
);
this
.
lblSensor
.
Location
=
new
System
.
Drawing
.
Point
(
2
3
,
408
);
this
.
lblSensor
.
Name
=
"lblSensor"
;
this
.
lblSensor
.
Name
=
"lblSensor"
;
this
.
lblSensor
.
Size
=
new
System
.
Drawing
.
Size
(
65
,
12
);
this
.
lblSensor
.
Size
=
new
System
.
Drawing
.
Size
(
65
,
12
);
this
.
lblSensor
.
TabIndex
=
14
;
this
.
lblSensor
.
TabIndex
=
14
;
...
@@ -88,7 +126,7 @@ namespace TheMachine
...
@@ -88,7 +126,7 @@ namespace TheMachine
//
//
// btnAxisRStop
// btnAxisRStop
//
//
this
.
btnAxisRStop
.
Location
=
new
System
.
Drawing
.
Point
(
3
8
,
481
);
this
.
btnAxisRStop
.
Location
=
new
System
.
Drawing
.
Point
(
3
97
,
447
);
this
.
btnAxisRStop
.
Name
=
"btnAxisRStop"
;
this
.
btnAxisRStop
.
Name
=
"btnAxisRStop"
;
this
.
btnAxisRStop
.
Size
=
new
System
.
Drawing
.
Size
(
155
,
31
);
this
.
btnAxisRStop
.
Size
=
new
System
.
Drawing
.
Size
(
155
,
31
);
this
.
btnAxisRStop
.
TabIndex
=
13
;
this
.
btnAxisRStop
.
TabIndex
=
13
;
...
@@ -98,7 +136,7 @@ namespace TheMachine
...
@@ -98,7 +136,7 @@ namespace TheMachine
//
//
// btnAxisRTest
// btnAxisRTest
//
//
this
.
btnAxisRTest
.
Location
=
new
System
.
Drawing
.
Point
(
3
8
,
432
);
this
.
btnAxisRTest
.
Location
=
new
System
.
Drawing
.
Point
(
3
97
,
405
);
this
.
btnAxisRTest
.
Name
=
"btnAxisRTest"
;
this
.
btnAxisRTest
.
Name
=
"btnAxisRTest"
;
this
.
btnAxisRTest
.
Size
=
new
System
.
Drawing
.
Size
(
155
,
31
);
this
.
btnAxisRTest
.
Size
=
new
System
.
Drawing
.
Size
(
155
,
31
);
this
.
btnAxisRTest
.
TabIndex
=
12
;
this
.
btnAxisRTest
.
TabIndex
=
12
;
...
@@ -114,11 +152,6 @@ namespace TheMachine
...
@@ -114,11 +152,6 @@ namespace TheMachine
this
.
axisMoveControl1
.
TabIndex
=
0
;
this
.
axisMoveControl1
.
TabIndex
=
0
;
this
.
axisMoveControl1
.
Tag
=
"not"
;
this
.
axisMoveControl1
.
Tag
=
"not"
;
//
//
// timer1
//
this
.
timer1
.
Interval
=
1000
;
this
.
timer1
.
Tick
+=
new
System
.
EventHandler
(
this
.
timer1_Tick
);
//
// configControl1
// configControl1
//
//
this
.
configControl1
.
Config
=
null
;
this
.
configControl1
.
Config
=
null
;
...
@@ -128,6 +161,21 @@ namespace TheMachine
...
@@ -128,6 +161,21 @@ namespace TheMachine
this
.
configControl1
.
TabIndex
=
1
;
this
.
configControl1
.
TabIndex
=
1
;
this
.
configControl1
.
Tag
=
"not"
;
this
.
configControl1
.
Tag
=
"not"
;
//
//
// timer1
//
this
.
timer1
.
Interval
=
1000
;
this
.
timer1
.
Tick
+=
new
System
.
EventHandler
(
this
.
timer1_Tick
);
//
// button1
//
this
.
button1
.
Location
=
new
System
.
Drawing
.
Point
(
25
,
604
);
this
.
button1
.
Name
=
"button1"
;
this
.
button1
.
Size
=
new
System
.
Drawing
.
Size
(
155
,
31
);
this
.
button1
.
TabIndex
=
20
;
this
.
button1
.
Text
=
"停止"
;
this
.
button1
.
UseVisualStyleBackColor
=
true
;
this
.
button1
.
Click
+=
new
System
.
EventHandler
(
this
.
button1_Click
);
//
// AxisControl
// AxisControl
//
//
this
.
AutoScaleMode
=
System
.
Windows
.
Forms
.
AutoScaleMode
.
None
;
this
.
AutoScaleMode
=
System
.
Windows
.
Forms
.
AutoScaleMode
.
None
;
...
@@ -154,5 +202,10 @@ namespace TheMachine
...
@@ -154,5 +202,10 @@ namespace TheMachine
private
System
.
Windows
.
Forms
.
Label
lblLed
;
private
System
.
Windows
.
Forms
.
Label
lblLed
;
private
System
.
Windows
.
Forms
.
Label
lblOkValue
;
private
System
.
Windows
.
Forms
.
Label
lblOkValue
;
private
System
.
Windows
.
Forms
.
Timer
timer1
;
private
System
.
Windows
.
Forms
.
Timer
timer1
;
private
System
.
Windows
.
Forms
.
Button
btnChangeColor
;
private
System
.
Windows
.
Forms
.
Button
btnGree
;
private
System
.
Windows
.
Forms
.
Button
btnYellow
;
private
System
.
Windows
.
Forms
.
ColorDialog
colorDialog1
;
private
System
.
Windows
.
Forms
.
Button
button1
;
}
}
}
}
TheMachine/AxisControl.cs
查看文件 @
f28ac78
...
@@ -27,8 +27,21 @@ namespace TheMachine
...
@@ -27,8 +27,21 @@ namespace TheMachine
lblLed
.
Text
=
""
;
lblLed
.
Text
=
""
;
lblOkValue
.
Text
=
""
;
lblOkValue
.
Text
=
""
;
lblSensor
.
Text
=
""
;
lblSensor
.
Text
=
""
;
if
(
Setting_Init
.
Device_LedLight_PortName
!=
""
)
{
btnYellow
.
Visible
=
true
;
btnGree
.
Visible
=
true
;
btnChangeColor
.
Visible
=
true
;
}
else
{
btnYellow
.
Visible
=
true
;
btnGree
.
Visible
=
true
;
btnChangeColor
.
Visible
=
true
;
}
if
(
Setting_Init
.
Enable_HideAxisTestBtn
)
if
(
Setting_Init
.
Enable_HideAxisTestBtn
)
{
{
btnAxisRTest
.
Visible
=
false
;
btnAxisRTest
.
Visible
=
false
;
btnAxisRStop
.
Visible
=
false
;
btnAxisRStop
.
Visible
=
false
;
...
@@ -76,32 +89,32 @@ namespace TheMachine
...
@@ -76,32 +89,32 @@ namespace TheMachine
volatile
bool
roateloop
=
false
;
volatile
bool
roateloop
=
false
;
private
void
button2_Click
(
object
sender
,
EventArgs
e
)
private
void
button2_Click
(
object
sender
,
EventArgs
e
)
{
{
Task
.
Run
(()
=>
{
//
Task.Run(() => {
var
p1
=
RobotManage
.
mainMachine
.
Config
.
UpDown_P1
;
//
var p1 = RobotManage.mainMachine.Config.UpDown_P1;
var
p1_speed
=
RobotManage
.
mainMachine
.
Config
.
UpDown_P1_speed
;
//
var p1_speed = RobotManage.mainMachine.Config.UpDown_P1_speed;
var
axis
=
RobotManage
.
mainMachine
.
UpDown_Axis
;
//
var axis = RobotManage.mainMachine.UpDown_Axis;
roateloop
=
true
;
//
roateloop = true;
while
(
roateloop
)
//
while (roateloop)
{
//
{
axis
.
AbsMove
(
null
,
p1
,
p1_speed
);
//
axis.AbsMove(null, p1, p1_speed);
Task
.
Delay
(
200
).
Wait
();
//
Task.Delay(200).Wait();
while
(
axis
.
IsBusy
)
//
while (axis.IsBusy)
{
//
{
Task
.
Delay
(
100
).
Wait
();
//
Task.Delay(100).Wait();
}
//
}
if
(!
roateloop
)
//
if (!roateloop)
break
;
//
break;
Task
.
Delay
(
500
).
Wait
();
//
Task.Delay(500).Wait();
axis
.
AbsMove
(
null
,
1
,
p1_speed
);
//
axis.AbsMove(null, 1, p1_speed);
Task
.
Delay
(
200
).
Wait
();
//
Task.Delay(200).Wait();
while
(
axis
.
IsBusy
)
//
while (axis.IsBusy)
{
//
{
Task
.
Delay
(
100
).
Wait
();
//
Task.Delay(100).Wait();
}
//
}
Task
.
Delay
(
500
).
Wait
();
//
Task.Delay(500).Wait();
}
//
}
});
//
});
Task
.
Run
(()
=>
{
Task
.
Run
(()
=>
{
var
p1
=
RobotManage
.
mainMachine
.
Config
.
Middle_P1
;
var
p1
=
RobotManage
.
mainMachine
.
Config
.
Middle_P1
;
...
@@ -138,7 +151,7 @@ namespace TheMachine
...
@@ -138,7 +151,7 @@ namespace TheMachine
private
bool
isPro
=
false
;
private
bool
isPro
=
false
;
private
void
timer1_Tick
(
object
sender
,
EventArgs
e
)
private
void
timer1_Tick
(
object
sender
,
EventArgs
e
)
{
{
if
(!
this
.
Visible
)
if
(!
this
.
Visible
||
RobotManage
.
mainMachine
==
null
)
{
{
return
;
return
;
}
}
...
@@ -189,5 +202,32 @@ namespace TheMachine
...
@@ -189,5 +202,32 @@ namespace TheMachine
}
}
});
});
}
}
private
void
btnYellow_Click
(
object
sender
,
EventArgs
e
)
{
RobotManage
.
mainMachine
.
ShowYellowLight
();
}
private
void
btnGree_Click
(
object
sender
,
EventArgs
e
)
{
RobotManage
.
mainMachine
.
ShowGreenLight
();
}
private
void
btnChangeColor_Click
(
object
sender
,
EventArgs
e
)
{
DialogResult
result
=
colorDialog1
.
ShowDialog
();
if
(
result
.
Equals
(
DialogResult
.
OK
))
{
Color
color
=
colorDialog1
.
Color
;
btnChangeColor
.
BackColor
=
color
;
RobotManage
.
mainMachine
.
ShowColor
(
color
);
}
}
private
void
button1_Click
(
object
sender
,
EventArgs
e
)
{
RobotManage
.
mainMachine
.
CloseColor
();
}
}
}
}
}
TheMachine/AxisControl.resx
查看文件 @
f28ac78
...
@@ -120,4 +120,7 @@
...
@@ -120,4 +120,7 @@
<metadata name="timer1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<metadata name="timer1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
<value>17, 17</value>
</metadata>
</metadata>
<metadata name="colorDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>109, 17</value>
</metadata>
</root>
</root>
\ No newline at end of file
\ No newline at end of file
TheMachine/Form1.cs
查看文件 @
f28ac78
...
@@ -9,6 +9,7 @@ using System;
...
@@ -9,6 +9,7 @@ using System;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
System.Drawing
;
using
System.Drawing
;
using
System.IO
;
using
System.IO
;
using
System.Linq
;
using
System.Runtime.ExceptionServices
;
using
System.Runtime.ExceptionServices
;
using
System.Runtime.Serialization.Formatters.Binary
;
using
System.Runtime.Serialization.Formatters.Binary
;
using
System.Threading
;
using
System.Threading
;
...
@@ -382,6 +383,126 @@ namespace TheMachine
...
@@ -382,6 +383,126 @@ namespace TheMachine
RobotManage
.
mainMachine
.
UploadVideoProcessInit
();
RobotManage
.
mainMachine
.
UploadVideoProcessInit
();
}
}
object
showMsgLoc
=
new
object
();
object
showMsgLoc
=
new
object
();
private
List
<
Msg
>
allMsgList
=
new
List
<
Msg
>();
//void SetMsg(List<Msg> msgs)
//{
// if (Monitor.TryEnter(showMsgLoc))
// {
// try
// {
// if (msgs == null || msgs.Count <= 0)
// {
// if (allMsgList.Count <= 0)
// {
// return;
// }
// msgs = new List<Msg>();
// }
// this.SuspendLayout();
// listView1.Items.Clear();
// msgs.Sort((a, b) =>
// {
// if (a.msgLevel == b.msgLevel)
// return 0;
// if (a.msgLevel == MsgLevel.alarm)
// return -1;
// if (b.msgLevel == MsgLevel.alarm)
// return 1;
// if (a.msgLevel == MsgLevel.warning)
// return b.msgLevel == MsgLevel.info ? -1 : -1;
// if (a.msgLevel == MsgLevel.info)
// return 1;
// return 0;
// });
// try
// {
// allMsgList.AddRange(msgs);
// int maxCount = 5;
// if (msgs.Count > maxCount)
// {
// maxCount = msgs.Count;
// }
// if (allMsgList.Count > maxCount)
// {
// allMsgList.RemoveRange(0, allMsgList.Count - maxCount);
// }
// }
// catch (Exception ex)
// {
// LogUtil.error(" SetMsg 出错:" + ex.ToString());
// allMsgList = new List<Msg>(msgs);
// }
// foreach (Msg msg in allMsgList)
// {
// if (string.IsNullOrEmpty(msg.msgtxt) || msg.datetime == null)
// continue;
// List<Msg> lists = (from m in msgs where m.msgtxt.Equals(msg.msgtxt) select m).ToList();
// if (lists.Count <= 0 && msg.msgLevel != MsgLevel.info)
// {
// //如果已经超时2分钟,不显示
// TimeSpan span = DateTime.Now - msg.datetime;
// if (span.TotalMinutes > 2)
// {
// 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 (lists.Count > 0)
// {
// if (msg.errInfo == ErrInfo.X09_BoxNotDetect)
// {
// if (btn_IgnoreX09.Visible) continue;
// btn_IgnoreX09.Invoke(new Action(() =>
// {
// btn_IgnoreX09.Visible = true;
// }));
// }
// else if (msg.errInfo == ErrInfo.X09_Clear)
// {
// if (!btn_IgnoreX09.Visible) continue;
// btn_IgnoreX09.Invoke(new Action(() =>
// {
// btn_IgnoreX09.Visible = false;
// }));
// }
// else if (msg.errInfo == ErrInfo.RunBtn)// || msg.errInfo == ErrInfo.ResetBtn)
// {
// Task.Run(() =>
// {
// Task.Delay(1000).Wait();
// if (!RobotManage.isRunning || RobotManage.IsUserPause)
// btn_run_Click(this, EventArgs.Empty);
// });
// }
// else if (msg.errInfo == ErrInfo.SuddenStop)
// {
// Task.Run(() =>
// {
// if (RobotManage.isRunning)
// btn_stop_Click(this, EventArgs.Empty);
// });
// }
// }
// }
// this.ResumeLayout(true);
// }
// finally
// { Monitor.Exit(showMsgLoc); }
// }
//}
void
SetMsg
(
List
<
Msg
>
msgs
)
void
SetMsg
(
List
<
Msg
>
msgs
)
{
{
if
(
Monitor
.
TryEnter
(
showMsgLoc
))
if
(
Monitor
.
TryEnter
(
showMsgLoc
))
...
@@ -444,7 +565,6 @@ namespace TheMachine
...
@@ -444,7 +565,6 @@ namespace TheMachine
}
}
}
}
private
void
btn_run_Click
(
object
sender
,
EventArgs
e
)
private
void
btn_run_Click
(
object
sender
,
EventArgs
e
)
{
{
if
(!
RobotManage
.
isRunning
)
if
(!
RobotManage
.
isRunning
)
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论