SpikeOn:
Code:
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package edu.wpi.first.wpilibj.templates.commands;
import edu.wpi.first.wpilibj.Relay;
import edu.wpi.first.wpilibj.templates.subsystems.Spike;
import edu.wpi.first.wpilibj.templates.commands.CommandBase;
/**
*
* @author Bennett
*/
public class SpikeOn extends CommandBase {
Spike spike = new Spike();
public SpikeOn() {
// Use requires() here to declare subsystem dependencies
// eg. requires(chassis);
}
// Called just before this Command runs the first time
protected void initialize() {
}
// Called repeatedly when this Command is scheduled to run
protected void execute() {
spike.spikeon();
//setTimeout(10.0);
}
// Make this return true when this Command no longer needs to run execute()
protected boolean isFinished() {
return false;
// return isTimedOut();
}
// Called once after isFinished returns true
protected void end() {
}
// Called when another command which requires one or more of the same
// subsystems is scheduled to run
protected void interrupted() {
}
}
SpikeOff:
Code:
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package edu.wpi.first.wpilibj.templates.commands;
import edu.wpi.first.wpilibj.templates.subsystems.Spike;
import edu.wpi.first.wpilibj.templates.commands.SpikeOff;
/**
*
* @author Bennett
*/
public class SpikeOff extends CommandBase {
Spike spike = new Spike();
public SpikeOff() {
// Use requires() here to declare subsystem dependencies
// eg. requires(chassis);
}
// Called just before this Command runs the first time
protected void initialize() {
}
// Called repeatedly when this Command is scheduled to run
protected void execute() {
spike.spikestop();
}
// Make this return true when this Command no longer needs to run execute()
protected boolean isFinished() {
return false;
}
// Called once after isFinished returns true
protected void end() {
}
// Called when another command which requires one or more of the same
// subsystems is scheduled to run
protected void interrupted() {
}
}
Here is my spike class:
Code:
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package edu.wpi.first.wpilibj.templates.subsystems;
import edu.wpi.first.wpilibj.command.Subsystem;
import edu.wpi.first.wpilibj.Relay;
/**
*
* @author Bennett
*/
public class Spike extends Subsystem {
Relay spike = new Relay(8);
public void spikeon(){
spike.set(Relay.Value.kForward);
}
public void spikestop(){
spike.set(Relay.Value.kOff);
}
// Put methods for controlling this subsystem
// here. Call these from Commands.
public void initDefaultCommand() {
// Set the default command for a subsystem here.
//setDefaultCommand(new MySpecialCommand());
}
}