You want this command to always run on the compressor so that it will always have full pressure and so that it will automatically shut off at the right time. To do this you need to set your UpdatePressure command as the default command for the compressor.
Here is an example from my team's code:
Compressor Subsystem
Code:
public class Compressor1 extends Subsystem {
Compressor compressor = RobotMap.compressor1compressor;
public void initDefaultCommand() {
setDefaultCommand(new CompressorCommand());
}
}
CompressorCommand
Code:
public class CompressorCommand extends Command {
Compressor compressor;
public CompressorCommand() {
requires(Robot.compressor1);
compressor = RobotMap.compressor1compressor;
}
protected void execute() {
if(!compressor.getPressureSwitchValue()){
//Compressor NOT Full
if(!compressor.enabled()){
compressor.start();
}
}else{
//Compressor Full
compressor.stop();
}
}
protected boolean isFinished() {
return false;
}
}