feverittm
14-02-2014, 13:03
Here is a question for all you Java types:
Which (if either) way is 'better' (less intensive on the cRIO, easier to understand, etc).
In a command based template we have a compressor subsystem.
We could start the compressor (using the standard compressor.start() method) in the subsystems initialization call. We could also just create a simple command that just does a compressor.start() in its execute function and then call this as the compressor subsystem's default command.
public subcompressor(int compressorSwitchSlot, int compressorSpikeSlot) {
myCompressor = new Compressor(compressorSwitchSlot, compressorSpikeSlot);
LiveWindow.addActuator("compressor", "compressor", myCompressor);
myCompressor.start();
}
or
public subcompressor(int compressorSwitchSlot, int compressorSpikeSlot) {
myCompressor = new Compressor(compressorSwitchSlot, compressorSpikeSlot);
LiveWindow.addActuator("compressor", "compressor", myCompressor);
}
/**
* Default command is to start the compressor. Doing it this way instead
* of in the initializer will put it in a separate thread and not lock the
* main control thread.
*/
public void initDefaultCommand() {
setDefaultCommand(new StartCompressor());
}
Is one way better then the other? Do both ways use separate threads from the main thread?
Just cleaning up code and wondering.
Thanks
Which (if either) way is 'better' (less intensive on the cRIO, easier to understand, etc).
In a command based template we have a compressor subsystem.
We could start the compressor (using the standard compressor.start() method) in the subsystems initialization call. We could also just create a simple command that just does a compressor.start() in its execute function and then call this as the compressor subsystem's default command.
public subcompressor(int compressorSwitchSlot, int compressorSpikeSlot) {
myCompressor = new Compressor(compressorSwitchSlot, compressorSpikeSlot);
LiveWindow.addActuator("compressor", "compressor", myCompressor);
myCompressor.start();
}
or
public subcompressor(int compressorSwitchSlot, int compressorSpikeSlot) {
myCompressor = new Compressor(compressorSwitchSlot, compressorSpikeSlot);
LiveWindow.addActuator("compressor", "compressor", myCompressor);
}
/**
* Default command is to start the compressor. Doing it this way instead
* of in the initializer will put it in a separate thread and not lock the
* main control thread.
*/
public void initDefaultCommand() {
setDefaultCommand(new StartCompressor());
}
Is one way better then the other? Do both ways use separate threads from the main thread?
Just cleaning up code and wondering.
Thanks