Example #1
0
 /**
  * Apparently the binary "exitProgrammingMode" command can crash the command station if the EPROM
  * was built before 2006. This method uses a state flag ({@link
  * NceTrafficController#getNceProgMode}) to detect whether a command to enter program mode has
  * been generated, and presumably sent, when using the later EPROMS. *
  */
 public static NceMessage getExitProgMode(NceTrafficController tc) {
   NceMessage m = new NceMessage(1);
   if (tc.getCommandOptions() >= NceTrafficController.OPTION_2006) {
     // Sending exit programming mode binary can crash pre 2006 EPROMs
     // assumption is that program mode hasn't been entered, so exit without
     // sending command
     if (tc.getNceProgMode() == false) {
       return null;
     }
     // not supported by USB connected to SB3 or PH
     if (tc.getUsbSystem() == NceTrafficController.USB_SYSTEM_SB3
         || tc.getUsbSystem() == NceTrafficController.USB_SYSTEM_SB5
         || tc.getUsbSystem() == NceTrafficController.USB_SYSTEM_TWIN
         || tc.getUsbSystem() == NceTrafficController.USB_SYSTEM_POWERHOUSE) {
       log.error("attempt to send unsupported binary command EXIT_PROG_CMD to NCE USB");
       //    			return null;
     }
     tc.setNceProgMode(false);
     m.setBinary(true);
     m.setReplyLen(1);
     m.setOpCode(EXIT_PROG_CMD);
     m.setTimeout(SHORT_TIMEOUT);
   } else {
     m.setBinary(false);
     m.setOpCode('X');
     m.setTimeout(SHORT_TIMEOUT);
   }
   return m;
 }
Example #2
0
 /**
  * enter programming track mode
  *
  * @param tc
  */
 public static NceMessage getProgMode(NceTrafficController tc) {
   // test if supported on current connection
   if (tc.getUsbSystem() != NceTrafficController.USB_SYSTEM_NONE
       && (tc.getCmdGroups() & NceTrafficController.CMDS_PROGTRACK)
           != NceTrafficController.CMDS_PROGTRACK) {
     log.error("attempt to send unsupported binary command ENTER_PROG_CMD to NCE USB");
     //			return null;
   }
   NceMessage m = new NceMessage(1);
   if (tc.getCommandOptions() >= NceTrafficController.OPTION_2006) {
     tc.setNceProgMode(true);
     m.setBinary(true);
     m.setReplyLen(1);
     m.setOpCode(ENTER_PROG_CMD);
     m.setTimeout(SHORT_TIMEOUT);
   } else {
     m.setBinary(false);
     m.setOpCode('M');
     m.setTimeout(SHORT_TIMEOUT);
   }
   return m;
 }