Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
孙克
/
RC1250-AssemblyLine
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit 065d6590
由
LN
编写于
2019-10-23 12:52:54 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
增加位置验证
1 个父辈
5f3160f1
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
147 行增加
和
102 行删除
ABBRobotTest/ABBRobotManager.cs
ABBRobotTest/ABBRobotServer.cs
ABBRobotTest/FrmRobotMain.Designer.cs
ABBRobotTest/FrmRobotMain.cs
doc/ABB机器人程序.txt
source/Common/util/TcpServer.cs
ABBRobotTest/ABBRobotManager.cs
查看文件 @
065d659
...
...
@@ -14,10 +14,11 @@ namespace ABBRobotTest
internal
class
ABBRobotManager
{
internal
static
string
DI_Start
=
"di_start"
;
internal
static
string
DI_Stop
=
"di_stop"
;
internal
static
string
DO_ES
=
"do_ES"
;
internal
static
string
DO_IsRun
=
"do_IsRun"
;
internal
static
string
DI_Start
=
"di_start"
;
//启动程序
internal
static
string
DI_Stop
=
"di_stop"
;
//停止程序
internal
static
string
DO_ES
=
"do_ES"
;
//急停状态
internal
static
string
DO_IsRun
=
"do_IsRun"
;
//机器人程序运行状态
internal
static
string
Do_AutoOn
=
"do_AutoOn"
;
//是否自动状态
private
static
NetworkScanner
scanner
=
null
;
// private Controller controller = null;
...
...
ABBRobotTest/ABBRobotServer.cs
查看文件 @
065d659
...
...
@@ -22,6 +22,7 @@ namespace ABBRobotTest
internal
static
string
Cmd_movep
=
"movep"
;
internal
static
string
Cmd_moveget
=
"moveget"
;
internal
static
string
Cmd_moveput
=
"moveput"
;
internal
static
string
Cmd_validateP
=
"validateP"
;
public
static
Dictionary
<
string
,
Client
>
ClientMap
=
new
Dictionary
<
string
,
Client
>();
...
...
@@ -29,7 +30,7 @@ namespace ABBRobotTest
public
static
string
LastSendPoint
=
""
;
public
delegate
void
OpEnd
(
string
result
);
private
static
event
OpEnd
On
Move
End
;
private
static
event
OpEnd
On
Cmd
End
;
private
static
object
LockObj
=
new
object
();
...
...
@@ -125,43 +126,50 @@ namespace ABBRobotTest
}
else
if
(
msg
.
Contains
(
Cmd_movep
)&&
msg
.
Contains
(
"OK"
))
{
On
Move
End
?.
Invoke
(
msg
);
On
Cmd
End
?.
Invoke
(
msg
);
}
else
if
(
msg
.
Contains
(
Cmd_moveput
)
&&
msg
.
Contains
(
"OK"
))
{
On
Move
End
?.
Invoke
(
msg
);
On
Cmd
End
?.
Invoke
(
msg
);
}
else
if
(
msg
.
Contains
(
Cmd_moveget
)
&&
msg
.
Contains
(
"ok"
))
{
On
Move
End
?.
Invoke
(
msg
);
On
Cmd
End
?.
Invoke
(
msg
);
}
return
false
;
}
public
static
void
MoveToP
(
string
robotIp
,
string
PointName
,
string
moveType
=
"L"
,
double
targetSpeed
=
100
,
OpEnd
After
Move
=
null
)
public
static
void
MoveToP
(
string
robotIp
,
string
PointName
,
string
moveType
=
"L"
,
double
targetSpeed
=
100
,
OpEnd
After
Cmd
=
null
)
{
ABBRobotServer
.
On
MoveEnd
=
AfterMove
;
ABBRobotServer
.
On
CmdEnd
=
AfterCmd
;
SendMovePoint
(
robotIp
,
Cmd_movep
,
PointName
,
moveType
,
targetSpeed
.
ToString
());
}
public
static
void
MoveToPut
(
string
robotIp
,
string
PointName
,
string
moveType
=
"L"
,
double
targetSpeed
=
100
,
OpEnd
After
Move
=
null
)
public
static
void
MoveToPut
(
string
robotIp
,
string
PointName
,
string
moveType
=
"L"
,
double
targetSpeed
=
100
,
OpEnd
After
Cmd
=
null
)
{
ABBRobotServer
.
On
MoveEnd
=
AfterMove
;
ABBRobotServer
.
On
CmdEnd
=
AfterCmd
;
SendMovePoint
(
robotIp
,
Cmd_moveput
,
PointName
,
moveType
,
targetSpeed
.
ToString
());
}
public
static
void
MoveToGet
(
string
robotIp
,
string
PointName
,
string
moveType
=
"L"
,
double
targetSpeed
=
100
,
OpEnd
After
Move
=
null
)
public
static
void
MoveToGet
(
string
robotIp
,
string
PointName
,
string
moveType
=
"L"
,
double
targetSpeed
=
100
,
OpEnd
After
Cmd
=
null
)
{
ABBRobotServer
.
On
MoveEnd
=
AfterMove
;
ABBRobotServer
.
On
CmdEnd
=
AfterCmd
;
SendMovePoint
(
robotIp
,
Cmd_moveget
,
PointName
,
moveType
,
targetSpeed
.
ToString
());
}
public
static
void
Move
(
string
robotIp
,
string
moveCmd
,
string
PointName
,
string
moveType
=
"L"
,
double
targetSpeed
=
100
,
OpEnd
AfterMove
=
null
)
public
static
void
SendCmd
(
string
robotIp
,
string
moveCmd
,
string
PointName
,
string
moveType
=
"L"
,
double
targetSpeed
=
100
,
OpEnd
AfterCmd
=
null
)
{
ABBRobotServer
.
On
MoveEnd
=
AfterMove
;
if
(
moveCmd
.
Equals
(
Cmd_moveget
)
||
moveCmd
.
Equals
(
Cmd_movep
)
||
moveCmd
.
Equals
(
Cmd_moveput
))
ABBRobotServer
.
On
CmdEnd
=
AfterCmd
;
if
(
moveCmd
.
Equals
(
Cmd_moveget
)
||
moveCmd
.
Equals
(
Cmd_movep
)
||
moveCmd
.
Equals
(
Cmd_moveput
)
||
moveCmd
.
Equals
(
Cmd_validateP
)
)
{
SendMovePoint
(
robotIp
,
moveCmd
,
PointName
,
moveType
,
targetSpeed
.
ToString
());
}
}
private
static
void
SendMovePoint
(
string
robotIp
,
string
param1
,
string
param2
,
string
param3
,
string
param4
)
public
static
void
ValidateP
(
string
robotIp
,
string
pointName
,
OpEnd
AfterCmd
=
null
)
{
ABBRobotServer
.
OnCmdEnd
=
AfterCmd
;
SendMovePoint
(
robotIp
,
Cmd_validateP
,
pointName
);
}
private
static
void
SendMovePoint
(
string
robotIp
,
string
param1
,
string
param2
,
string
param3
=
"L"
,
string
param4
=
"10"
)
{
lock
(
LockObj
)
{
...
...
ABBRobotTest/FrmRobotMain.Designer.cs
查看文件 @
065d659
...
...
@@ -209,6 +209,7 @@
//
// comMoveP
//
this
.
comMoveP
.
DropDownStyle
=
System
.
Windows
.
Forms
.
ComboBoxStyle
.
DropDownList
;
this
.
comMoveP
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
12F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
comMoveP
.
FormattingEnabled
=
true
;
this
.
comMoveP
.
Location
=
new
System
.
Drawing
.
Point
(
136
,
130
);
...
...
@@ -227,6 +228,7 @@
//
// comMoveCmd
//
this
.
comMoveCmd
.
DropDownStyle
=
System
.
Windows
.
Forms
.
ComboBoxStyle
.
DropDownList
;
this
.
comMoveCmd
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
12F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
comMoveCmd
.
FormattingEnabled
=
true
;
this
.
comMoveCmd
.
Location
=
new
System
.
Drawing
.
Point
(
136
,
75
);
...
...
ABBRobotTest/FrmRobotMain.cs
查看文件 @
065d659
...
...
@@ -36,14 +36,15 @@ namespace ABBRobotTest
comMoveCmd
.
Items
.
Add
(
ABBRobotServer
.
Cmd_movep
);
comMoveCmd
.
Items
.
Add
(
ABBRobotServer
.
Cmd_moveget
);
comMoveCmd
.
Items
.
Add
(
ABBRobotServer
.
Cmd_moveput
);
comMoveCmd
.
Items
.
Add
(
ABBRobotServer
.
Cmd_validateP
);
comMoveP
.
Items
.
Clear
();
for
(
int
i
=
0
;
i
<
30
;
i
++)
for
(
int
i
=
1
;
i
<=
30
;
i
++)
{
comMoveP
.
Items
.
Add
(
"p"
+
i
);
}
comMoveP
.
SelectedIndex
=
0
;
comMoveCmd
.
SelectedIndex
=
1
;
comMoveCmd
.
SelectedIndex
=
0
;
radioButton1
.
Checked
=
true
;
...
...
@@ -76,13 +77,13 @@ namespace ABBRobotTest
private
void
LoadListView
()
{
this
.
listView1
.
Columns
.
Clear
();
AddHealder
(
"IPAddress"
,
1
0
0
);
AddHealder
(
"ID"
,
80
);
AddHealder
(
"IPAddress"
,
1
5
0
);
AddHealder
(
"ID"
,
1
80
);
// AddHealder("设备状态", 100);
AddHealder
(
"Availability"
,
1
0
0
);
AddHealder
(
"IsVirtual"
,
1
0
0
);
AddHealder
(
"SystemName"
,
1
0
0
);
AddHealder
(
"Version"
,
1
0
0
);
AddHealder
(
"Availability"
,
1
5
0
);
AddHealder
(
"IsVirtual"
,
1
5
0
);
AddHealder
(
"SystemName"
,
1
5
0
);
AddHealder
(
"Version"
,
1
5
0
);
AddHealder
(
"ControllerName"
,
180
);
AddHealder
(
"Statue"
,
180
);
}
...
...
@@ -118,8 +119,7 @@ namespace ABBRobotTest
int
esValue
=
ABBRobotManager
.
GetSingalState
(
SelConIp
);
if
(
esValue
.
Equals
(
1
))
{
lblState
.
Text
=
"机器人["
+
SelConIp
+
"]急停中"
;
lblState
.
ForeColor
=
Color
.
Red
;
SetMsg
(
"机器人["
+
SelConIp
+
"]急停中"
,
Color
.
Red
);
}
else
{
...
...
@@ -128,11 +128,19 @@ namespace ABBRobotTest
int
isRun
=
ABBRobotManager
.
GetSingalState
(
SelConIp
,
ABBRobotManager
.
DO_IsRun
);
if
(
isRun
.
Equals
(
1
))
{
lblState
.
Text
=
"机器人程序正常运行中"
;
lblState
.
ForeColor
=
Color
.
Green
;
SetMsg
(
"机器人程序正常运行中"
,
Color
.
Green
);
}
else
{
SetMsg
(
"机器人["
+
SelConIp
+
"]程序未运行"
,
Color
.
Red
);
}
}
}
private
void
SetMsg
(
string
msg
,
Color
foreColor
)
{
lblState
.
Text
=
msg
;
lblState
.
ForeColor
=
foreColor
;
}
private
void
btnStart_Click
(
object
sender
,
EventArgs
e
)
{
...
...
@@ -199,7 +207,7 @@ namespace ABBRobotTest
{
speed
=
100
;
}
ABBRobotServer
.
Move
(
SelConIp
,
moveCmd
,
PPoint
,
MType
,
speed
,
MoveEnd
);
ABBRobotServer
.
SendCmd
(
SelConIp
,
moveCmd
,
PPoint
,
MType
,
speed
,
MoveEnd
);
}
private
void
MoveEnd
(
string
msg
)
{
...
...
doc/ABB机器人程序.txt
查看文件 @
065d659
MODULE aaa
PERS tooldata MyTool:=[TRUE,[[31.792631019,0,229.638935148],[0.945518576,0,0.325568154,0]],[1,[0,0,1],[1,0,0,0],0,0,0]];
CONST robtarget p1:=[[-
58.97,-251.82,388.62],[0.718543,-0.63799,0.152339,0.23121],[0,0,-1,1
],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]];
CONST robtarget p2:=[[
133.92,-253.65,388.62],[0.718545,-0.637985,0.152332,0.231221],[-1,-1,-1,1
],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]];
CONST robtarget p3:=[[
825.4576,0.000001046,609.3],[0.03072784,-0.000000013,-0.9995278,-0.00000001],[0,0,0
,0],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]];
CONST robtarget p4:=[[
825.4576,-0.000000111,675.4476],[0.03072794,0.000000001,-0.9995278,0.000000001],[0,0
,-1,0],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]];
CONST robtarget p5:=[[
825.4576,0.000000831,745.9818],[0.03072797,-0.000000011,-0.9995278,-0.000000008],[0,0,0
,0],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]];
CONST robtarget p6:=[[
825.4576,0.000000659,815.8895],[0.03072799,-0.000000008,-0.9995278,-0.000000006],[0,0,0
,0],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]];
CONST robtarget p7:=[[
825.4576,-0.000000347,875.2359],[0.03072807,0.000000004,-0.9995278,0.000000003],[0,0
,-1,0],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]];
CONST robtarget p8:=[[8
25.4576,0.000001138,914.6687],[0.03072812,-0.000000014,-0.9995278,-0.000000011],[0,0,0
,0],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]];
CONST robtarget p9:=[[
825.4576,0.000000481,954.2989],[0.03072822,-0.000000006,-0.9995278,-0.000000004],[0,0,0
,0],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]];
CONST robtarget p10:=[[
825.4576,-0.00000035,996.6124],[0.03072831,0.000000004,-0.9995278,0.000000003],[0,0
,-1,0],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]];
CONST robtarget p1:=[[-
16.11,-347.15,474.83],[0.294464,-0.883154,0.297088,0.212292],[0,0,-1,0
],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]];
CONST robtarget p2:=[[
-1.74,-351.15,465.56],[0.300708,-0.919333,0.248148,0.0531494],[0,-1,-1,0
],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]];
CONST robtarget p3:=[[
6.19,-346.97,472.32],[0.376015,-0.914531,0.114921,-0.0950728],[0,-1,-1
,0],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]];
CONST robtarget p4:=[[
-7.80,-337.93,495.03],[0.505132,-0.860161,0.065858,-0.0250314],[0,-1
,-1,0],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]];
CONST robtarget p5:=[[
-8.57,-332.96,417.21],[0.448707,-0.890922,0.0589738,-0.0379704],[0,-1,-1
,0],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]];
CONST robtarget p6:=[[
2.57,-332.92,410.45],[0.443783,-0.892313,0.0696654,-0.0445195],[0,-1,-1
,0],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]];
CONST robtarget p7:=[[
1.82,-327.19,440.61],[0.463316,-0.882346,0.071927,-0.0403786],[0,-1
,-1,0],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]];
CONST robtarget p8:=[[8
.10,-375.52,278.06],[0.352443,-0.931844,0.0590098,-0.0629934],[0,-1,-1
,0],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]];
CONST robtarget p9:=[[
173.02,-380.60,301.74],[0.34939,-0.892928,0.250084,-0.134405],[-1,-1,-1
,0],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]];
CONST robtarget p10:=[[
-107.17,-393.26,299.48],[0.370443,-0.925911,-0.0735457,-0.00716374],[0,-1
,-1,0],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]];
CONST robtarget p11:=[[753.764,243.6931,840.0185],[0.2205171,0.3584949,-0.9055654,0.05296053],[0,0,-1,0],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]];
CONST robtarget p12:=[[753.764,243.6931,775.1548],[0.2205171,0.3584949,-0.9055655,0.05296054],[0,0,-1,0],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]];
...
...
@@ -33,17 +33,19 @@ MODULE aaa
CONST robtarget p29:=[[969.95,296.57,468.46],[0.192573,0.382378,-0.901556,0.0624448],[0,0,-1,0],[9E+9,9E+9,9E+9,9E+9,9E+9,9E+9]];
CONST robtarget p30:=[[969.94,296.56,505.18],[0.17191,0.382088,-0.905649,0.0652315],[0,0,-1,0],[9E+9,9E+9,9E+9,9E+9,9E+9,9E+9]];
PERS speeddata speed1:=[
50,50,4
00,100];
PERS speeddata speed1:=[
10,50,1
00,100];
VAR socketdev socket_server;
VAR socketdev socket_client;
PERS string str_address:="1
27.0.0.1
";
PERS string str_address:="1
92.168.201.88
";
!PERS string str_address:="192.168.201.88";
PERS num n_port:=21;
VAR string strReceive:="p1,L,100";
VAR string strSend:="OK";
VAR string resultStr_OK:=",OK;";
VAR string resultStr_NG:=",NG;";
VAR socketstatus status;
VAR num starBit1:=0;
VAR num endBit1:=0;
...
...
@@ -57,18 +59,18 @@ MODULE aaa
VAR num endBit4:=0;
VAR num LengBit4:=0;
VAR num starBit4:=0;
PERS string
s1_1:="movep
";
PERS string
s1_2
:="p2";
PERS string
s1_3
:="L";
PERS string
s1_4:="5
0";
PERS string
revice_Str1_Cmd:="validateP
";
PERS string
revice_Str2_pName
:="p2";
PERS string
revice_Str3_moveType
:="L";
PERS string
revice_Str4_speed:="1
0";
VAR bool flag1:=false;
PERS num value_1:=700;
PERS num value_2:=50;
PERS num value_3:=50;
!
PERS num value_1:=700;
!
PERS num value_2:=50;
VAR robtarget pTarget:=[[700,50,700],[0.0258621,-0.000364211,-0.999665,0.000003063],[0,-1,0,0],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]];
VAR robtarget pTemp:=[[700,50,700],[0.0258621,-0.000364211,-0.999665,3.06266E-6],[0,-1,0,0],[9E+9,9E+9,9E+9,9E+9,9E+9,9E+9]];
PERS bool b
Linear
:=TRUE;
PERS bool b
ooLineMove
:=TRUE;
PERS bool dataOk:=TRUE;
VAR num len:=0;
...
...
@@ -77,6 +79,9 @@ MODULE aaa
PERS zonedata zone1:=[FALSE,5,8,8,0.8,8,0.8];
PERS loaddata load1:=[4,[0,0,0],[1,0,0,0],0,0,0];
PERS robtarget pCheckTest:=[[-1.73959,-351.15,465.559],[0.300709,-0.919332,0.248149,0.0531482],[0,-1,-1,0],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]];
PERS bool pCheckResult:=TRUE;
PROC modifyPoint()
MoveL p1,speed1,z50,tool1\WObj:=wobj1;
...
...
@@ -121,17 +126,6 @@ MODULE aaa
error
IF ERRNO=ERR_SOCK_TIMEOUT THEN
! socketclose socket_client;
! socketcreate socket_client;
! SocketConnect socket_client,str_address,n_port\Time:=5;
! ResetRetrycount;
! RETRY;
! ELSEIF ERRNO=ERR_SOCK_CLOSED THEN
! socketclose socket_client;
! socketcreate socket_client;
! SocketConnect socket_client,str_address,n_port\Time:=5;
! ResetRetrycount;
! RETRY;
ELSE
SocketPro;
RETURN ;
...
...
@@ -184,42 +178,55 @@ MODULE aaa
strParse strReceive;
IF dataOk THEN
! GOTO label1;
IF
s1_1
="movep" THEN
IF b
Linear
THEN
IF
revice_Str1_Cmd
="movep" THEN
IF b
ooLineMove
THEN
MoveL pTarget,speed1,fine,tool1\WObj:=wobj1;
ELSE
MoveJ pTarget,speed1,fine,tool1\WObj:=wobj1;
ENDIF
SocketSend socket_client\Str:=strReceive+
strSend
;
SocketSend socket_client\Str:=s1_1+","+s1_2+","+strSend
;
ELSEIF
s1_1
="moveget" THEN
IF b
Linear
THEN
SocketSend socket_client\Str:=strReceive+
resultStr_OK
;
!SocketSend socket_client\Str:=revice_Str1_Cmd+","+revice_Str2_pName+","+resultStr_OK+";"
;
ELSEIF
revice_Str1_Cmd
="moveget" THEN
IF b
ooLineMove
THEN
! MoveL Offs(pTarget,0,0,10), speed1, zone1, tool1\WObj:=wobj1;
MoveL pTarget,speed1,fine,tool1\WObj:=wobj1;
GripLoad load0;
!
GripLoad load0;
MoveL Offs(pTarget,0,0,-50),speed1,zone1,tool1\WObj:=wobj1;
MoveL Offs(pTarget,0,-60,0),speed1,zone1,tool1\WObj:=wobj1;
ELSE
MoveJ pTarget,speed1,fine,tool1\WObj:=wobj1;
ENDIF
SocketSend socket_client\Str:=strReceive+
strSend
;
SocketSend socket_client\Str:=s1_1+","+s1_2+","+strSend
;
ELSEIF
s1_1
="moveput" THEN
IF b
Linear
THEN
SocketSend socket_client\Str:=strReceive+
resultStr_OK
;
! SocketSend socket_client\Str:=revice_Str1_Cmd+","+revice_Str2_pName+","+resultStr_OK+";"
;
ELSEIF
revice_Str1_Cmd
="moveput" THEN
IF b
ooLineMove
THEN
MoveL pTarget,speed1,fine,tool1\WObj:=wobj1;
GripLoad load1;
!
GripLoad load1;
MoveL Offs(pTarget,0,0,50),speed1,zone1,tool1\WObj:=wobj1;
MoveL Offs(pTarget,0,-60,0),speed1,zone1,tool1\WObj:=wobj1;
ELSE
MoveJ pTarget,speed1,fine,tool1\WObj:=wobj1;
ENDIF
SocketSend socket_client\Str:=strReceive+strSend;
SocketSend socket_client\Str:=s1_1+","+s1_2+","+strSend;
ENDIF
ELSE
SocketSend socket_client\Str:=strReceive+" DATA ERROR ";
SocketSend socket_client\Str:=strReceive+resultStr_OK ;
! SocketSend socket_client\Str:=revice_Str1_Cmd+","+revice_Str2_pName+","+resultStr_OK+";";
ELSEIF revice_Str1_Cmd="validateP" THEN
!WaitRob\ZeroSpeed;
!wait robot stop;
pCheckTest:=CRobT(\Tool:=tool1\WObj:=wobj1);
!get current position
pCheckResult:=false;
pCheckResult:=validateP(pTarget,pCheckTest,0.1);
IF pCheckResult THEN
SocketSend socket_client\Str:=strReceive+resultStr_OK ;
ELSE
SocketSend socket_client\Str:=strReceive+resultStr_NG ;
ENDIF
ELSE
SocketSend socket_client\Str:=strReceive+" DATA ERROR ;";
ENDIF
ENDIF
ENDWHILE
ERROR
...
...
@@ -233,14 +240,33 @@ MODULE aaa
ENDIF
ENDPROC
FUNC bool validateP(robtarget ptest,robtarget pCompare,num threshold)
VAR jointtarget joinTest:=[[-12.1057,1.3138,-1.32846,-3.7545E-7,90.0147,-12.1057],[9E+9,9E+9,9E+9,9E+9,9E+9,9E+9]];
VAR jointtarget joinCompare:=[[-12.143,1.32099,-1.33096,-0.000317427,90.0147,-12.1215],[9E+9,9E+9,9E+9,9E+9,9E+9,9E+9]];
VAR num counter;
joinTest:=CalcJointT(pTest,tool1\WObj:=wobj1);
joinCompare:=CalcJointT(pCompare,tool1\WObj:=wobj1);
IF abs(joinTest.robax.rax_1-joinCompare.robax.rax_1)<threshold incr counter;
IF abs(joinTest.robax.rax_2-joinCompare.robax.rax_2)<threshold incr counter;
IF abs(joinTest.robax.rax_3-joinCompare.robax.rax_3)<threshold incr counter;
IF abs(joinTest.robax.rax_4-joinCompare.robax.rax_4)<threshold incr counter;
IF abs(joinTest.robax.rax_5-joinCompare.robax.rax_5)<threshold incr counter;
IF abs(joinTest.robax.rax_6-joinCompare.robax.rax_6)<threshold incr counter;
IF counter=6 THEN
RETURN TRUE;
ELSE
RETURN FALSE;
ENDIF
PROC strParse(string string1)
ENDFUNC
PROC strParse(string reviceStr)
VAR num revice_speed:=10;
lable2:
len:=StrLen(
string1
);
len:=StrLen(
reviceStr
);
starBit1:=1;
endBit1:=StrFind(
string1
,starBit1,",");
endBit1:=StrFind(
reviceStr
,starBit1,",");
LengBit1:=endBit1-starBit1;
starBit2:=endBit1+1;
...
...
@@ -248,7 +274,7 @@ MODULE aaa
RETURN ;
ENDIF
endBit2:=StrFind(
string1
,starBit2,",");
endBit2:=StrFind(
reviceStr
,starBit2,",");
LengBit2:=endBit2-starBit2;
starBit3:=endBit2+1;
...
...
@@ -256,7 +282,7 @@ MODULE aaa
IF starBit3>len THEN
RETURN ;
ENDIF
endBit3:=StrFind(
string1
,starBit3,",");
endBit3:=StrFind(
reviceStr
,starBit3,",");
LengBit3:=endBit3-starBit3;
starBit4:=endBit3+1;
...
...
@@ -264,32 +290,32 @@ MODULE aaa
IF starBit4>len THEN
RETURN ;
ENDIF
endBit4:=StrFind(
string1
,starBit4,",");
endBit4:=StrFind(
reviceStr
,starBit4,",");
LengBit4:=endBit4-starBit4;
s1_1:=StrPart(string1
,starBit1,LengBit1);
s1_2:=StrPart(string1
,starBit2,LengBit2);
s1_3:=StrPart(string1
,starBit3,LengBit3);
s1_4:=StrPart(string1
,starBit4,LengBit4);
revice_Str1_Cmd:=StrPart(reviceStr
,starBit1,LengBit1);
revice_Str2_pName:=StrPart(reviceStr
,starBit2,LengBit2);
revice_Str3_moveType:=StrPart(reviceStr
,starBit3,LengBit3);
revice_Str4_speed:=StrPart(reviceStr
,starBit4,LengBit4);
!capture target
GetDataVal
s1_2
,ptemp;
GetDataVal
revice_Str2_pName
,ptemp;
pTarget:=ptemp;
!determine L or J
IF
s1_3
="L" THEN
b
Linear
:=TRUE;
ELSEIF
s1_3
="J" THEN
b
Linear
:=FALSE;
IF
revice_Str3_moveType
="L" THEN
b
ooLineMove
:=TRUE;
ELSEIF
revice_Str3_moveType
="J" THEN
b
ooLineMove
:=FALSE;
ENDIF
! get speed
flag1:=StrToVal(
s1_4,value_3
);
flag1:=StrToVal(
revice_Str4_speed,revice_speed
);
IF
value_3
>100 THEN
value_3
:=100;
IF
revice_speed
>100 THEN
revice_speed
:=100;
ENDIF
speed1.v_tcp:=
value_3
;
speed1.v_tcp:=
revice_speed
;
dataOk:=TRUE;
ERROR
IF errno=ERR_SOCK_CLOSED THEN
...
...
source/Common/util/TcpServer.cs
查看文件 @
065d659
...
...
@@ -121,7 +121,7 @@ namespace OnlineStore.Common
}
private
StringBuilder
sb
=
new
StringBuilder
();
//这个是用来保存:接收到了的,但是还没有结束的消息
private
int
receiveBufferSize
=
1024
;
private
string
terminateString
=
"
\r
"
;
private
string
terminateString
=
"
;
"
;
public
void
ReceiveMessages
(
Client
client
)
//这个函数会被以线程方式运行
{
try
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论