Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
刘韬
/
1069_MIMO_PlUS
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit 120b4e9c
由
张东亮
编写于
2023-08-30 17:15:22 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
软件无响应优化
1 个父辈
8edbb1a0
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
49 行增加
和
28 行删除
DeviceLibrary/DeviceLibrary/VisionHelper.cs
DeviceLibrary/userControl/AxisMoveControl.cs
TheMachine/Form1.cs
TheMachine/UC/ConfigControl.cs
DeviceLibrary/DeviceLibrary/VisionHelper.cs
查看文件 @
120b4e9
...
...
@@ -9,6 +9,7 @@ using System.Linq;
using
System.Text
;
using
System.Threading
;
using
System.Threading.Tasks
;
using
System.Web.Management
;
using
System.Windows.Forms
;
namespace
DeviceLibrary
...
...
@@ -18,6 +19,10 @@ namespace DeviceLibrary
static
string
visionUrl
=
ConfigHelper
.
Config
.
Get
(
"VisionUrl"
,
"http://localhost:8089/vision/eyem"
);
public
static
bool
ReelStatusCheck
(
string
configName
)
{
if
(
ConfigHelper
.
Config
.
Get
(
"Func_ReelStatusCheck"
,
false
))
{
return
true
;
}
string
cameraName
=
ConfigHelper
.
Config
.
Get
(
"MonitorCamName"
,
"cam1"
);
string
url
=
visionUrl
+
$
"/reelStatusCheck/cam?camName={cameraName}&configName={configName.Replace("
#
", "
%
23
")}"
;
try
...
...
DeviceLibrary/userControl/AxisMoveControl.cs
查看文件 @
120b4e9
...
...
@@ -26,6 +26,7 @@ namespace DeviceLibrary
public
AxisMoveControl
()
{
InitializeComponent
();
CheckForIllegalCrossThreadCalls
=
false
;
crc
.
OpenResourceLog
=
true
;
crc
.
LanguageChangeEvent
+=
Crc_LanguageChangeEvent
;
crc
.
CurrLanguage
=
ConfigHelper
.
Config
.
Get
(
"Device_Default_Language"
,
"zh-CN"
);
...
...
@@ -47,7 +48,7 @@ namespace DeviceLibrary
cmbAxis
.
Items
.
Clear
();
foreach
(
var
a
in
axisList
)
{
cmbAxis
.
Items
.
Add
(
crc
.
GetString
(
a
.
Config
.
ProName
,
a
.
Config
.
Explain
));
cmbAxis
.
Items
.
Add
(
crc
.
GetString
(
a
.
Config
.
ProName
,
a
.
Config
.
Explain
));
}
cmbAxis
.
SelectedIndex
=
0
;
currentAxis
=
axisList
[
0
];
...
...
@@ -78,23 +79,23 @@ namespace DeviceLibrary
{
if
(
axis
==
null
)
{
MessageBox
.
Show
(
crc
.
GetString
(
"Res0011"
,
"请先选择运动轴"
),
crc
.
GetString
(
"Res0012"
,
"警告 "
),
MessageBoxButtons
.
OK
,
MessageBoxIcon
.
Error
);
MessageBox
.
Show
(
crc
.
GetString
(
"Res0011"
,
"请先选择运动轴"
),
crc
.
GetString
(
"Res0012"
,
"警告 "
),
MessageBoxButtons
.
OK
,
MessageBoxIcon
.
Error
);
return
false
;
}
return
true
;
return
true
;
}
private
void
btnOpenAxis_Click
(
object
sender
,
EventArgs
e
)
{
//timer1.Start();
LogUtil
.
info
(
""
+
"点击【打开伺服】,【"
+
PortName
+
"_"
+
SlvAddr
+
"】 "
);
LogUtil
.
info
(
""
+
"点击【打开伺服】,【"
+
PortName
+
"_"
+
SlvAddr
+
"】 "
);
AxisManager
.
ServoOn
(
PortName
,
SlvAddr
);
}
private
void
btnCloseAxis_Click
(
object
sender
,
EventArgs
e
)
{
LogUtil
.
info
(
""
+
"点击【关闭伺服】,【"
+
PortName
+
"_"
+
SlvAddr
+
"】 "
);
AxisManager
.
ServoOff
(
PortName
,
SlvAddr
);
LogUtil
.
info
(
""
+
"点击【关闭伺服】,【"
+
PortName
+
"_"
+
SlvAddr
+
"】 "
);
AxisManager
.
ServoOff
(
PortName
,
SlvAddr
);
}
private
void
btnAxisAMove_Click
(
object
sender
,
EventArgs
e
)
...
...
@@ -105,13 +106,13 @@ namespace DeviceLibrary
}
int
position
=
FormUtil
.
GetIntValue
(
txtAPosition
);
int
speed
=
FormUtil
.
GetIntValue
(
txtASpeed
);
if
(!
currentAxis
.
IsSafe
(
position
,
out
string
msg
))
if
(!
currentAxis
.
IsSafe
(
position
,
out
string
msg
))
{
MessageBox
.
Show
(
msg
);
return
;
}
LogUtil
.
info
(
""
+
"点击【绝对运动】,【"
+
PortName
+
"_"
+
SlvAddr
+
"】位置【"
+
position
+
"】速度【"
+
speed
+
"】"
);
LogUtil
.
info
(
""
+
"点击【绝对运动】,【"
+
PortName
+
"_"
+
SlvAddr
+
"】位置【"
+
position
+
"】速度【"
+
speed
+
"】"
);
var
targetSpeed
=
speed
;
var
AddSpeed
=
currentAxis
.
Config
.
AddSpeed
>
0
?
currentAxis
.
Config
.
AddSpeed
:
targetSpeed
*
4
;
var
DelSpeed
=
currentAxis
.
Config
.
DelSpeed
>
0
?
currentAxis
.
Config
.
DelSpeed
:
targetSpeed
*
4
;
...
...
@@ -127,13 +128,13 @@ namespace DeviceLibrary
int
position
=
FormUtil
.
GetIntValue
(
txtAPosition
);
int
speed
=
FormUtil
.
GetIntValue
(
txtASpeed
);
if
(!
currentAxis
.
IsSafe
(
currentAxis
.
GetAclPosition
()
+
position
,
out
string
msg
))
if
(!
currentAxis
.
IsSafe
(
currentAxis
.
GetAclPosition
()
+
position
,
out
string
msg
))
{
MessageBox
.
Show
(
msg
);
return
;
}
LogUtil
.
info
(
""
+
"点击【相对运动】,【"
+
PortName
+
"_"
+
SlvAddr
+
"】位置【"
+
position
+
"】速度【"
+
speed
+
"】"
);
LogUtil
.
info
(
""
+
"点击【相对运动】,【"
+
PortName
+
"_"
+
SlvAddr
+
"】位置【"
+
position
+
"】速度【"
+
speed
+
"】"
);
var
targetSpeed
=
speed
;
var
AddSpeed
=
currentAxis
.
Config
.
AddSpeed
>
0
?
currentAxis
.
Config
.
AddSpeed
:
targetSpeed
*
4
;
var
DelSpeed
=
currentAxis
.
Config
.
DelSpeed
>
0
?
currentAxis
.
Config
.
DelSpeed
:
targetSpeed
*
4
;
...
...
@@ -149,7 +150,7 @@ namespace DeviceLibrary
int
speed
=
FormUtil
.
GetIntValue
(
txtASpeed
);
//LogUtil.info(""+"点击【匀速运动】,【" + PortName + "_" + SlvAddr + "】 速度【" + speed + "】");
//AxisManager.SpeedMove(PortName, SlvAddr, speed,acc,dec);
var
axis
=
axisList
.
Single
(
a
=>
a
.
Config
.
IsSameAxis
(
PortName
,
SlvAddr
));
var
targetSpeed
=
speed
;
var
AddSpeed
=
axis
.
Config
.
AddSpeed
>
0
?
axis
.
Config
.
AddSpeed
:
targetSpeed
*
4
;
...
...
@@ -160,7 +161,7 @@ namespace DeviceLibrary
}
private
void
btnAxisStop_Click
(
object
sender
,
EventArgs
e
)
{
LogUtil
.
info
(
""
+
"点击【停止运动】,【"
+
PortName
+
"_"
+
SlvAddr
+
"】 "
);
LogUtil
.
info
(
""
+
"点击【停止运动】,【"
+
PortName
+
"_"
+
SlvAddr
+
"】 "
);
AxisManager
.
SuddenStop
(
PortName
,
SlvAddr
);
if
(
btnAddMove
.
BackColor
==
Color
.
Green
)
{
...
...
@@ -170,12 +171,12 @@ namespace DeviceLibrary
{
btnDelMove
.
BackColor
=
System
.
Drawing
.
SystemColors
.
Control
;
}
// btnReadPosition_Click(null, null);
// btnReadPosition_Click(null, null);
}
private
void
btnComAlarmClear_Click
(
object
sender
,
EventArgs
e
)
{
LogUtil
.
info
(
""
+
"点击【清理报警】,【"
+
PortName
+
"_"
+
SlvAddr
+
"】 "
);
LogUtil
.
info
(
""
+
"点击【清理报警】,【"
+
PortName
+
"_"
+
SlvAddr
+
"】 "
);
AxisManager
.
AlarmClear
(
PortName
,
SlvAddr
);
Thread
.
Sleep
(
100
);
AxisManager
.
ServoOn
(
PortName
,
SlvAddr
);
...
...
@@ -187,7 +188,7 @@ namespace DeviceLibrary
{
return
;
}
LogUtil
.
info
(
""
+
"点击【原点返回】,【"
+
PortName
+
"_"
+
SlvAddr
+
"】 速度【"
+
currentAxis
.
Config
.
HomeHighSpeed
+
"】"
);
var
HomeLowSpeed
=
currentAxis
.
Config
.
HomeLowSpeed
>
0
?
currentAxis
.
Config
.
HomeLowSpeed
:
currentAxis
.
Config
.
HomeHighSpeed
/
10
;
...
...
@@ -277,7 +278,7 @@ namespace DeviceLibrary
}
private
void
AxisMove
(
int
speed
)
{
LogUtil
.
info
(
""
+
"【"
+
PortName
+
"_"
+
SlvAddr
+
"】点动: 速度:"
+
speed
);
LogUtil
.
info
(
""
+
"【"
+
PortName
+
"_"
+
SlvAddr
+
"】点动: 速度:"
+
speed
);
AxisManager
.
SpeedMove
(
PortName
,
SlvAddr
,
speed
,
0
,
0
);
}
private
void
btnAddMove_MouseDown
(
object
sender
,
MouseEventArgs
e
)
...
...
@@ -291,7 +292,7 @@ namespace DeviceLibrary
int
speed
=
Convert
.
ToInt32
(
comjSpeed
.
Text
);
if
(
speed
<=
0
)
{
MessageBox
.
Show
(
crc
.
GetString
(
"title"
,
"提示"
),
crc
.
GetString
(
"Res0013"
,
"请先输入正确的速度"
));
MessageBox
.
Show
(
crc
.
GetString
(
"title"
,
"提示"
),
crc
.
GetString
(
"Res0013"
,
"请先输入正确的速度"
));
return
;
}
btnAddMove
.
BackColor
=
Color
.
Green
;
...
...
@@ -320,7 +321,7 @@ namespace DeviceLibrary
int
speed
=
Convert
.
ToInt32
(
comjSpeed
.
Text
);
if
(
speed
<=
0
)
{
MessageBox
.
Show
(
crc
.
GetString
(
"title"
,
"提示"
),
crc
.
GetString
(
"Res0013"
,
"请先输入正确的速度"
));
MessageBox
.
Show
(
crc
.
GetString
(
"title"
,
"提示"
),
crc
.
GetString
(
"Res0013"
,
"请先输入正确的速度"
));
return
;
}
btnDelMove
.
BackColor
=
Color
.
Green
;
...
...
@@ -342,18 +343,32 @@ namespace DeviceLibrary
{
Clipboard
.
SetDataObject
(
lblCountPulse
.
Text
,
true
);
}
object
readObj
=
new
object
();
private
void
timer1_Tick
(
object
sender
,
EventArgs
e
)
{
LogUtil
.
OutputDebugString
(
$
"timer1_Tick:{this.Visible}"
);
if
(!
this
.
IsHandleCreated
)
return
;
if
(
this
.
Visible
)
{
ReadAxisStatus
();
if
(
Monitor
.
TryEnter
(
readObj
,
300
))
{
try
{
this
.
Invoke
(
new
Action
(()
=>
{
ReadAxisStatus
();
}));
}
finally
{
Monitor
.
Exit
(
readObj
);
}
}
}
}
private
void
ReadAxisStatus
()
{
groupBox2
.
Text
=
cmbAxis
.
Text
+
"-"
+
crc
.
GetString
(
L
.
AxisMoveControl_status_monitor
,
"状态监控"
);
groupBox2
.
Text
=
cmbAxis
.
Text
+
"-"
+
crc
.
GetString
(
L
.
AxisMoveControl_status_monitor
,
"状态监控"
);
//【1】更新轴号
short
axisNo
=
SlvAddr
;
if
(
axisNo
<
0
)
...
...
@@ -383,7 +398,7 @@ namespace DeviceLibrary
return
;
}
//【3】更新界面显示
ShowlbSts
(
lblALM
,
sts
.
ALM
,
true
);
//报警信号
ShowlbSts
(
lblALM
,
sts
.
ALM
,
true
);
//报警信号
ShowlbSts
(
lblWARN
,
sts
.
WARN
);
//警告信号
ShowlbSts
(
lblEMG
,
sts
.
EMG
);
//急停信号
ShowlbSts
(
lblSvOn
,
sts
.
ServoOn
);
//使能信号
...
...
@@ -411,20 +426,20 @@ namespace DeviceLibrary
if
(
crc
.
CurrLanguage
==
"zh-CN"
)
lblhomeSts
.
Text
=
homesstr
;
else
lblhomeSts
.
Text
=
value
.
ToString
();
lblhomeSts
.
Text
=
value
.
ToString
();
btnReadPosition_Click
(
null
,
null
);
}
private
void
ShowlbSts
(
Label
lbl
,
int
value
,
bool
isAlarm
=
false
)
private
void
ShowlbSts
(
Label
lbl
,
int
value
,
bool
isAlarm
=
false
)
{
if
(
value
.
Equals
(
1
))
{
if
(
isAlarm
)
{
lbl
.
BackColor
=
Color
.
Red
;
lbl
.
BackColor
=
Color
.
Red
;
lblAlarmcode
.
Visible
=
true
;
lblAlarmcode
.
ForeColor
=
Color
.
Red
;
lblAlarmcode
.
Text
=
crc
.
GetString
(
"Res0014"
,
"错误码:"
)
+
HCBoardManager
.
GetAxErrCode
(
SlvAddr
);
lblAlarmcode
.
Text
=
crc
.
GetString
(
"Res0014"
,
"错误码:"
)
+
HCBoardManager
.
GetAxErrCode
(
SlvAddr
);
}
else
{
...
...
@@ -436,7 +451,7 @@ namespace DeviceLibrary
lbl
.
BackColor
=
Color
.
LightGray
;
if
(
isAlarm
)
{
lblAlarmcode
.
Visible
=
false
;
lblAlarmcode
.
Visible
=
false
;
}
}
else
...
...
TheMachine/Form1.cs
查看文件 @
120b4e9
...
...
@@ -214,7 +214,6 @@ namespace TheMachine
return
;
}
}
TabPage
lineTabPage
=
new
TabPage
(
text
);
lineTabPage
.
Name
=
id
;
Panel
linePan
=
new
Panel
();
...
...
@@ -227,6 +226,7 @@ namespace TheMachine
form
.
Anchor
=
((
AnchorStyles
)((
AnchorStyles
.
Top
|
AnchorStyles
.
Right
|
AnchorStyles
.
Bottom
|
AnchorStyles
.
Left
)));
form
.
Show
();
tabc
.
TabPages
.
Add
(
lineTabPage
);
}
private
void
启用调试模式
ToolStripMenuItem_Click
(
object
sender
,
EventArgs
e
)
...
...
TheMachine/UC/ConfigControl.cs
查看文件 @
120b4e9
...
...
@@ -33,6 +33,7 @@ namespace TheMachine
}
public
ConfigControl
()
{
CheckForIllegalCrossThreadCalls
=
false
;
InitializeComponent
();
this
.
Tag
=
"not"
;
crc
.
LanguageChangeEvent
+=
Crc_LanguageChangeEvent
;
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论