Completed
Push — master ( 0672dd...74c8db )
by John
33s
created

org.usfirst.frc.team3695.robot.commands.CyborgCommandDriveDirect   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 7
c 1
b 0
f 0
dl 0
loc 35
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A isFinished() 0 5 2
A interrupted() 0 2 1
A initialize() 0 4 1
A end() 0 2 1
A CyborgCommandDriveDirect(double) 0 3 1
A execute() 0 2 1
1
2
package org.usfirst.frc.team3695.robot.commands;
3
4
import org.usfirst.frc.team3695.robot.Robot;
5
6
import edu.wpi.first.wpilibj.DriverStation;
7
import edu.wpi.first.wpilibj.command.Command;
8
9
public class CyborgCommandDriveDirect extends Command {
10
11
    public static final long TIME_WAIT = 1000;
12
    public final double percent;
13
    private long time;
14
    private boolean inRange;
15
16
    public CyborgCommandDriveDirect(double percent) {
17
        this.percent = percent;
18
        requires(Robot.SUB_DRIVE);
19
    }
20
21
    protected void initialize() {
22
    	DriverStation.reportWarning("DRIVING BY POWER", false);
23
        Robot.SUB_DRIVE.reset();
24
        time = System.currentTimeMillis() + TIME_WAIT;
25
    }
26
27
    protected void execute() {
28
        inRange = Robot.SUB_DRIVE.driveDistance(percent, percent);
29
    }
30
31
    protected boolean isFinished() {
32
        if(!inRange) {
33
            time = System.currentTimeMillis() + TIME_WAIT;
34
        }
35
        return time < System.currentTimeMillis();
36
    }
37
38
    protected void end() {
39
        Robot.SUB_DRIVE.driveDirect(0, 0);
40
    }
41
42
    protected void interrupted() {
43
        end();
44
    }
45
}