Changes: Inference engine works fine with the JavaNator benchmark. Found some problem...
[IRC.git] / Robust / src / Benchmarks / SSJava / JavaNatorInfer / HWSimulator.java
1 public class HWSimulator {
2
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;
7
8   // public byte currentSonars;
9
10   @TRUST
11   public static Command getCommand() {
12
13     byte currentCommand = TestSensorInput.getCommand();
14
15     int data = (int) (currentCommand & RobotMain.ALL_DATA);
16     int opCode = (int) (currentCommand & 0xe0); // ALL_COMMANDS);
17
18     switch ((int) opCode) {
19     case RobotMain.ON_OFF:
20       if ((data & 0x1) == 0x1) {
21         HWSimulator.onOffMode = RobotMain.ON_MODE;
22       } else {
23         HWSimulator.onOffMode = RobotMain.OFF_MODE;
24       }
25       break;
26     case RobotMain.MANUAL_AUTONOMUS:
27       if ((data & 0x1) == 0x1) {
28         HWSimulator.manualAutonomusMode = RobotMain.MANUAL_MODE;
29       } else {
30         HWSimulator.manualAutonomusMode = RobotMain.AUTONOMUS_MODE;
31       }
32       break;
33     case RobotMain.LINE_SENSORS:
34       HWSimulator.lineSensorsMask = (byte) (data & RobotMain.LS_ALL);
35       break;
36     case RobotMain.SONAR_SENSORS:
37       HWSimulator.sonarSensors = (byte) (data & RobotMain.ALL_SONARS);
38       break;
39     }
40
41     Command com = new Command();
42
43     com.command = currentCommand;
44
45     com.onOffMode = HWSimulator.onOffMode;
46     com.manualAutonomusMode = HWSimulator.manualAutonomusMode;
47     com.lineSensorsMask = HWSimulator.lineSensorsMask;
48     com.sonarSensors = HWSimulator.sonarSensors;
49
50     return com;
51
52   }
53
54 }