Advertisement
Guest User

Untitled

a guest
Dec 7th, 2016
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.88 KB | None | 0 0
  1. public static void main(final String[] args) {
  2. String[] MenuOpts = {"Left", "Left 2", "Right", "Right 2", "Up", "Down"};
  3. Map <String, String> macrosMap = new HashMap<String, String>();
  4. // final String commmunication_port = args[0];
  5. // final SerialPort serial_port = new SerialPort(commmunication_port);
  6. try {
  7. // serial_port.openPort();
  8. // serial_port.setParams(9600, 8, 1, 0);
  9. // printFromMenu("Sending address:");
  10. // sendAddress(serial_port);
  11. // try {
  12. // final byte[] response = ViscaResponseReader.readResponse(serial_port);
  13. // printFromVisca(response);
  14. // }
  15. // catch (ViscaResponseReader.TimeoutException ex) {
  16. // printTimeoutExeception();
  17. // printFromMenu(ex.toString());
  18. // }
  19.  
  20. try {
  21. Thread.sleep(3000);
  22. }
  23. catch (InterruptedException e) {
  24. e.printStackTrace();
  25. }
  26.  
  27.  
  28. System.out.println("-> If you want to define MACRO type (y) otherwise (n)");
  29.  
  30. sc = new Scanner(System.in);
  31. String defOrNo = sc.nextLine();
  32.  
  33. while("y".equals(defOrNo)){
  34. System.out.println("-> Enter MACRO name or cancel (n)");
  35. String name = sc.nextLine();
  36. if ("n".equals(name))break;
  37.  
  38. printFromMenu("Possible moves:");
  39. for(int i=0;i<MenuOpts.length;i++){
  40. System.out.println("-> " + (i+1) + " -- " + MenuOpts[i]);
  41. }
  42. System.out.println("-> Enter options sequence for defined MACRO");
  43. String values = sc.nextLine();
  44. macrosMap.put(name, values);
  45. }
  46.  
  47.  
  48.  
  49.  
  50. while (true) {
  51. System.out.println("-- Main Menu --");
  52. printFromMenu("Choose option:");
  53. for(int i=0;i<MenuOpts.length;i++){
  54. System.out.println("-> " + (i+1) + " -- " + MenuOpts[i]);
  55. }
  56. printFromMenu("Or choose your MACRO:");
  57. printFromMenu(macrosMap.keySet().toString());
  58.  
  59. sc = new Scanner(System.in);
  60. String line = sc.nextLine();
  61.  
  62.  
  63.  
  64.  
  65. if(macrosMap.containsKey(line)){
  66. String value = macrosMap.get(line);
  67. for(int i =0; i < value.length() ; i++){
  68. System.out.println(value.charAt(i));
  69. // makeMove(String.valueOf(value.charAt(i)),serial_port);
  70. }
  71. }else{
  72. System.out.println(line);
  73. // makeMove(line,serial_port);
  74. }
  75. }
  76. }
  77. catch (Exception ex) {
  78. System.out.println(ex);
  79. }
  80.  
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement