14
14
* the valve to move to the open position. Power is then turned off and the valve
15
15
* stays where it is (open). Calling close applies power to the close side momentarily causing the
16
16
* valve to move to the closed position. Power is then turned off and the valve
17
- * stays where it is (closed).
17
+ * stays where it is (closed). Note that the actual movement of the valve which lasts for whatever
18
+ * the slide time is set to is done in a separate thread so as not to delay the calling thread.
18
19
*
19
20
* Open and Close are arbitrary definitions, they are actually defined by the physical robot
20
21
* valve piping/wiring and what you want the cylinder to do. Typically you would pipe the "open" side
21
22
* of the valve to extend a cylinder and close to retract. For DA valves, our convention is to wire
22
23
* the A side to the first port and pipe to open or extend the cylinder and B side to close or retract.
23
- * Again, these are conventions and the reality is what you design your valve to cylinder piping to be
24
- * and the wiring to the corresponding sides of the valve to the control module ports.
24
+ * This means we pipe B side to the "at rest" or not "active" position of the cylinder. A side is piped
25
+ * to the "active" or "doing the desired action" position of the cylinder. This based on the SMC manifold
26
+ * and valves which have A and B sides. So for a valve you would wire the A side of the valve to the port
27
+ * number on the constructor and the B side to that port + 1. Hoses go into A and B air ports to the ends
28
+ * of the target cylinder corredsponding to at rest and active.
25
29
*/
26
30
27
31
public class ValveDA implements Sendable
@@ -35,7 +39,7 @@ public class ValveDA implements Sendable
35
39
* Sets the time to apply power to make sure valve slide moves correctly.
36
40
* The movement takes time so power has to be applied until slide has
37
41
* moved from one side to the other. In seconds, defaults to .02 sec.
38
- * This default determined using Test mode.
42
+ * This default determined using Test mode.ve
39
43
*/
40
44
public double solenoidSlideTime = .02 ;
41
45
@@ -93,7 +97,6 @@ public void setName(String name)
93
97
this .name = String .format ("%s[%d-%d]" , name , canId , port );
94
98
95
99
SendableRegistry .setName (this , this .name );
96
-
97
100
}
98
101
99
102
/**
@@ -118,17 +121,22 @@ public void Open()
118
121
119
122
valveCloseSide .set (false );
120
123
121
- valveOpenSide .set (true );
122
- Timer .delay (solenoidSlideTime );
123
- valveOpenSide .set (false );
124
+ // valveOpenSide.set(true);
125
+ // Timer.delay(solenoidSlideTime);
126
+ // valveOpenSide.set(false);
124
127
125
- valveOpen = true ;
128
+ new Thread (() -> {
129
+ try {
130
+ valveOpenSide .set (true );
131
+ Timer .delay (solenoidSlideTime );
132
+ valveOpenSide .set (false );
133
+ valveOpen = true ;
134
+ } catch (Exception e ) { }
135
+ }).start ();
126
136
}
127
137
128
138
/**
129
139
* Pressurize the A side of the valve.
130
- * This function delays calling thread for the valve
131
- * slide time (default 20ms).
132
140
*/
133
141
public void SetA ()
134
142
{
@@ -139,26 +147,29 @@ public void SetA()
139
147
140
148
/**
141
149
* Close the valve (pressurize port+1. This is B side).
142
- * This function delays calling thread for the valve
143
- * slide time (default 20ms).
144
150
*/
145
151
public void Close ()
146
152
{
147
153
Util .consoleLog ("canid=%d, port=%d" , canId , port );
148
154
149
155
valveOpenSide .set (false );
150
156
151
- valveCloseSide .set (true );
152
- Timer .delay (solenoidSlideTime );
153
- valveCloseSide .set (false );
157
+ // valveCloseSide.set(true);
158
+ // Timer.delay(solenoidSlideTime);
159
+ // valveCloseSide.set(false);
154
160
155
- valveOpen = false ;
161
+ new Thread (() -> {
162
+ try {
163
+ valveCloseSide .set (true );
164
+ Timer .delay (solenoidSlideTime );
165
+ valveCloseSide .set (false );
166
+ valveOpen = false ;
167
+ } catch (Exception e ) { }
168
+ }).start ();
156
169
}
157
170
158
171
/**
159
172
* Pressurize the B side of the valve.
160
- * This function delays calling thread for the valve
161
- * slide time (default 20ms).
162
173
*/
163
174
public void SetB ()
164
175
{
@@ -172,7 +183,7 @@ public void SetB()
172
183
* valve, which is open based on our convention. Note, this value
173
184
* is not reliable until your first call to open/SetA or close/SetB to set
174
185
* the initial physical state of the valve.
175
- * @return True if valve open (pressure on A side), false if closed.
186
+ * @return True if valve open (pressure on A side), false if closed (pressure on B side) .
176
187
*/
177
188
public boolean isOpen ()
178
189
{
0 commit comments