1 public class HWSimulator {
3 public static int onOffMode = RobotMain.ON_MODE;
4 public static int manualAutonomusMode = RobotMain.AUTONOMUS_MODE;
5 public static byte lineSensorsMask;
6 public static byte sonarSensors;
8 // public byte currentSonars;
11 public static Command getCommand() {
13 byte currentCommand = TestSensorInput.getCommand();
15 int data = (int) (currentCommand & RobotMain.ALL_DATA);
16 int opCode = (int) (currentCommand & 0xe0); // ALL_COMMANDS);
18 switch ((int) opCode) {
19 case RobotMain.ON_OFF:
20 if ((data & 0x1) == 0x1) {
21 HWSimulator.onOffMode = RobotMain.ON_MODE;
23 HWSimulator.onOffMode = RobotMain.OFF_MODE;
26 case RobotMain.MANUAL_AUTONOMUS:
27 if ((data & 0x1) == 0x1) {
28 HWSimulator.manualAutonomusMode = RobotMain.MANUAL_MODE;
30 HWSimulator.manualAutonomusMode = RobotMain.AUTONOMUS_MODE;
33 case RobotMain.LINE_SENSORS:
34 HWSimulator.lineSensorsMask = (byte) (data & RobotMain.LS_ALL);
36 case RobotMain.SONAR_SENSORS:
37 HWSimulator.sonarSensors = (byte) (data & RobotMain.ALL_SONARS);
41 Command com = new Command();
43 com.command = currentCommand;
45 com.onOffMode = HWSimulator.onOffMode;
46 com.manualAutonomusMode = HWSimulator.manualAutonomusMode;
47 com.lineSensorsMask = HWSimulator.lineSensorsMask;
48 com.sonarSensors = HWSimulator.sonarSensors;