-
Notifications
You must be signed in to change notification settings - Fork 0
/
PneumaticManip.java
48 lines (41 loc) · 1.14 KB
/
PneumaticManip.java
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
//pneumatic manipulator class
import edu.wpi.first.wpilibj.DoubleSolenoid;
import edu.wpi.first.wpilibj.Solenoid;
import edu.wpi.first.wpilibj.Timer;
public class PneumaticManip {
//single valve solenoid
protected Solenoid sol;
//double valve solenoid
protected DoubleSolenoid dSol;
protected String status;
public PneumaticManip(Solenoid sol) {
this.sol = sol;
status = "reverse";
}
public PneumaticManip(DoubleSolenoid dSol) {
this.dSol = dSol;
status = "reverse";
}
//fires a single valve solenoid
protected void fire() {
sol.set(true);
Timer.delay(1);
sol.set(false);
}
//extends the cylinder(double valve)
protected void extend() {
//sets the solenoid to a predefined final value that corresponds to the extended position
dSol.set(DoubleSolenoid.Value.kReverse);
status = "forward";
}
//retracts the cylinder(double valve)
protected void retract() {
//sets the solenoid to a predefined final value that corresponds to the retracted position
dSol.set(DoubleSolenoid.Value.kForward);
status = "reverse";
}
//returns the current position of the cylinder
public String getStatus() {
return status;
}
}