package apitester;

import core.ArgumentException;
import core.BluetoothCommunication;
import core.Brick;
import core.Command;
import core.EV3Types.*;
import java.util.Scanner;

/**
 * Test the api
 * @author Jordan
 */
public class Ev3ApiTester {

    public static void main(String[] args) throws ArgumentException, InterruptedException {
              
        Brick ev3 = new Brick(new BluetoothCommunication("COM5"));
        ev3.connect();
        
        Scanner s = new Scanner(System.in);

        boolean next = true;        
        
        while(next)
        {          
            
            switch(s.nextLine().toLowerCase())
            {
                case "c":
                    ev3.directCommand.resetMotorCount(OutputPort.All);
                    ev3.directCommand.resetGyroscope(InputPort.Two);
                    break;
                    
                case "m":
                    ev3.directCommand.stepMotorSync(OutputPort.A, OutputPort.D, 50, 720, true);
                    break;
                    
                case "s":
                    ev3.directCommand.stopMotor(OutputPort.All, false);
                    break;
                    
                case "q": next = false; break;
                    
                default:
//                    System.out.println(ev3.directCommand.readTachoCount(InputPort.A));
//                    System.out.println(ev3.directCommand.readTachoCount(InputPort.D));
//                    System.out.println(ev3.directCommand.readUltrasonic(InputPort.Four));
//                    System.out.println(ev3.directCommand.readGyroscope(InputPort.Two));
                    ev3.batchCommand = new Command(CommandType.DirectReply, 13, 0);
                    ev3.batchCommand.readRaw(InputPort.A, MotorMode.Degrees.ordinal(), 0);
                    ev3.batchCommand.readRaw(InputPort.D, MotorMode.Degrees.ordinal(), 4);
                    ev3.batchCommand.readRaw(InputPort.Four, 0, 8);
                    ev3.batchCommand.readRaw(InputPort.Two, 0, 12);
                    ev3.sendBatchCommand();
                    
                    for(byte b : ev3.batchCommand.response.getData())
                        System.out.print((b & 0xff) + " ");
                    
                    System.out.println();
            }
        }

        ev3.directCommand.stopMotor(OutputPort.All, false);
        ev3.disconnect();
    }    
}

@@ -191,23 +191,10 @@
 %0D%0A *
- Test the api
 %0D%0A
+
  * @
@@ -1238,444 +1238,11 @@
 se %22
-q
+b
 %22:
- next = false; break;%0D%0A                    %0D%0A                default:%0D%0A//                    System.out.println(ev3.directCommand.readTachoCount(InputPort.A));%0D%0A//                    System.out.println(ev3.directCommand.readTachoCount(InputPort.D));%0D%0A//                    System.out.println(ev3.directCommand.readUltrasonic(InputPort.Four));%0D%0A//                    System.out.println(ev3.directCommand.readGyroscope(InputPort.Two));
 %0D%0A  
@@ -1701,36 +1701,34 @@
                 
-  
 %0D%0A
+
                 
@@ -1839,24 +1839,1385 @@
 f) + %22 %22);%0D%0A
+                    %0D%0A                    break;%0D%0A                    %0D%0A                case %22q%22: next = false; break;%0D%0A                    %0D%0A                case %22t%22:%0D%0A                    ev3.directCommand.playTone(20, 200, 200);%0D%0A                    Thread.sleep(200);%0D%0A                    ev3.directCommand.playTone(20, 500, 200);%0D%0A                    Thread.sleep(200);%0D%0A                    ev3.directCommand.playTone(20, 100, 200);%0D%0A                    Thread.sleep(200);%0D%0A                    ev3.directCommand.playTone(20, 900, 200);%0D%0A                    Thread.sleep(200);%0D%0A                    ev3.directCommand.playTone(20, 1000, 200);%0D%0A                    Thread.sleep(200);%0D%0A                    ev3.directCommand.playTone(20, 300, 200);%0D%0A                    Thread.sleep(200);%0D%0A                    ev3.directCommand.playTone(20, 700, 200);%0D%0A                    break;%0D%0A                    %0D%0A                default:%0D%0A                    System.out.println(%22Tacho left  : %22 + ev3.directCommand.readTachoCount(InputPort.A));%0D%0A                    System.out.println(%22Tacho right : %22 + ev3.directCommand.readTachoCount(InputPort.D));%0D%0A                    System.out.println(%22Ultrasonic  : %22 + ev3.directCommand.readUltrasonic(InputPort.Four));%0D%0A                    System.out.println(%22      Gyro  : %22 + ev3.directCommand.readGyroscope(InputPort.Two));%0D%0A%0D%0A
             
@@ -3385,21 +3385,23 @@
 ect();%0D%0A
-
     %7D
+%0D%0A
     %0D%0A%7D%0D

Update API tester