Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void main(final String[] args) {
- String[] MenuOpts = {"Left", "Left 2", "Right", "Right 2", "Up", "Down"};
- Map <String, String> macrosMap = new HashMap<String, String>();
- // final String commmunication_port = args[0];
- // final SerialPort serial_port = new SerialPort(commmunication_port);
- try {
- // serial_port.openPort();
- // serial_port.setParams(9600, 8, 1, 0);
- // printFromMenu("Sending address:");
- // sendAddress(serial_port);
- // try {
- // final byte[] response = ViscaResponseReader.readResponse(serial_port);
- // printFromVisca(response);
- // }
- // catch (ViscaResponseReader.TimeoutException ex) {
- // printTimeoutExeception();
- // printFromMenu(ex.toString());
- // }
- try {
- Thread.sleep(3000);
- }
- catch (InterruptedException e) {
- e.printStackTrace();
- }
- System.out.println("-> If you want to define MACRO type (y) otherwise (n)");
- sc = new Scanner(System.in);
- String defOrNo = sc.nextLine();
- while("y".equals(defOrNo)){
- System.out.println("-> Enter MACRO name or cancel (n)");
- String name = sc.nextLine();
- if ("n".equals(name))break;
- printFromMenu("Possible moves:");
- for(int i=0;i<MenuOpts.length;i++){
- System.out.println("-> " + (i+1) + " -- " + MenuOpts[i]);
- }
- System.out.println("-> Enter options sequence for defined MACRO");
- String values = sc.nextLine();
- macrosMap.put(name, values);
- }
- while (true) {
- System.out.println("-- Main Menu --");
- printFromMenu("Choose option:");
- for(int i=0;i<MenuOpts.length;i++){
- System.out.println("-> " + (i+1) + " -- " + MenuOpts[i]);
- }
- printFromMenu("Or choose your MACRO:");
- printFromMenu(macrosMap.keySet().toString());
- sc = new Scanner(System.in);
- String line = sc.nextLine();
- if(macrosMap.containsKey(line)){
- String value = macrosMap.get(line);
- for(int i =0; i < value.length() ; i++){
- System.out.println(value.charAt(i));
- // makeMove(String.valueOf(value.charAt(i)),serial_port);
- }
- }else{
- System.out.println(line);
- // makeMove(line,serial_port);
- }
- }
- }
- catch (Exception ex) {
- System.out.println(ex);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement