ClampJawBean.cs
3.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
using Neotel;
using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OnlineStore.DeviceLibrary
{
public class ClampJawBean
{
public string Name = "";
public ConfigClampJaw config = null;
public Rmaxis rmaxis = null;
public ClampJawBean (ConfigClampJaw config)
{
this.config = config;
Name = config.DisplayStr + "(" + config.PortName + "_" + config.AxisNo + ")";
OpenPort();
}
public bool OpenPort()
{
if (config == null)
{
return false;
}
if (rmaxis == null)
{
rmaxis = new Rmaxis("Rmaxis");
}
if (!rmaxis.IsPortOpen)
{
bool result = rmaxis.OpenPort(config.PortName, config.AxisNo);
if (!result)
{
LogUtil.error(Name + " OpenPort 失败");
}
}
return rmaxis.IsPortOpen;
}
public void ClosePort()
{
if (rmaxis != null)
{
rmaxis.ClosePort();
}
}
public void Push(LineMoveInfo moveInfo = null, bool checkHasReel = true)
{
if (rmaxis != null && rmaxis.IsPortOpen)
{
rmaxis.Push(config.Force, config.Distance, config.Velocity);
}
if (moveInfo != null)
{
moveInfo.WaitList.Add(WaitResultInfo.WaitClampReached((int)config.Distance));
if (checkHasReel)
{
moveInfo.WaitList.Add(WaitResultInfo.WaitClampHasReel());
}
//有一个到位就算到位
moveInfo.OneWaitCanEndStep = true;
}
}
public bool IsReached()
{
if (rmaxis != null && rmaxis.IsPortOpen)
{
return rmaxis.IsReached;
}
return false;
}
public bool HasReel()
{
if (rmaxis != null && rmaxis.IsPortOpen)
{
return !rmaxis.IsPushEmpty;
}
return false;
}
public void Relax(LineMoveInfo moveInfo = null)
{
if (rmaxis != null && rmaxis.IsPortOpen)
{
rmaxis.MoveAbsolute(1);
}
if (moveInfo != null)
{
moveInfo.WaitList.Add(WaitResultInfo.WaitClampReached(1));
}
}
public void GoHome(LineMoveInfo moveInfo = null)
{
if (rmaxis != null && rmaxis.IsPortOpen)
{
rmaxis.GoHome();
}
if (moveInfo != null)
{
moveInfo.WaitList.Add(WaitResultInfo.WaitClampReached(0));
}
}
public float GetPosition()
{
return rmaxis.GetPosition();
}
public float GetTorque()
{
return rmaxis.GetTorque();
}
public void PushTest(float force, float distance)
{
if (rmaxis != null && rmaxis.IsPortOpen)
{
rmaxis.Push(force, distance, config.Velocity);
}
}
}
}