Пример #1
0
 public void sendStatus(int bus, int address) throws IOException {
   log.debug("send Status called with bus {} and address {}", bus, address);
   java.util.List<SystemConnectionMemo> list =
       jmri.InstanceManager.getList(SystemConnectionMemo.class);
   SystemConnectionMemo memo = null;
   try {
     memo = list.get(bus - 1);
   } catch (java.lang.IndexOutOfBoundsException obe) {
     TimeStampedOutput.writeTimestamp(output, "412 ERROR wrong value\n\r");
     return;
   }
   String turnoutName = memo.getSystemPrefix() + "T" + address;
   try {
     // busy loop, wait for turnout to settle before continuing.
     while (InstanceManager.turnoutManagerInstance().provideTurnout(turnoutName).getKnownState()
         != InstanceManager.turnoutManagerInstance()
             .provideTurnout(turnoutName)
             .getCommandedState()) {}
     int Status =
         InstanceManager.turnoutManagerInstance().provideTurnout(turnoutName).getKnownState();
     if (Status == Turnout.THROWN) {
       TimeStampedOutput.writeTimestamp(output, "100 INFO " + bus + " GA " + address + " 1 0\n\r");
     } else if (Status == Turnout.CLOSED) {
       TimeStampedOutput.writeTimestamp(output, "100 INFO " + bus + " GA " + address + " 0 0\n\r");
     } else {
       //  unknown state
       TimeStampedOutput.writeTimestamp(output, "411 ERROR unknown value\n\r");
     }
   } catch (IllegalArgumentException ex) {
     log.warn("Failed to provide Turnout \"{}\" in sendStatus", turnoutName);
   }
 }
Пример #2
0
  /*
   * for SRCP, we're doing the parsing elsewhere, so we just need to build
   * the correct string from the provided compoents.
   */
  public void parseStatus(int bus, int address, int value)
      throws jmri.JmriException, java.io.IOException {

    log.debug("parse Status called with bus {} address {} and value {}", bus, address, value);
    java.util.List<SystemConnectionMemo> list =
        jmri.InstanceManager.getList(SystemConnectionMemo.class);
    SystemConnectionMemo memo;
    try {
      memo = list.get(bus - 1);
    } catch (java.lang.IndexOutOfBoundsException obe) {
      TimeStampedOutput.writeTimestamp(output, "412 ERROR wrong value\n\r");
      return;
    }
    String turnoutName = memo.getSystemPrefix() + "T" + address;
    // create turnout if it does not exist since closeTurnout() and throwTurnout() no longer do so
    // this.initTurnout(turnoutName);
    if (value == 1) {
      log.debug("Setting Turnout THROWN");
      throwTurnout(turnoutName);
    } else if (value == 0) {
      log.debug("Setting Turnout CLOSED");
      closeTurnout(turnoutName);
    }
    sendStatus(bus, address);
  }
Пример #3
0
 public void dispose() {
   xt = null;
   InstanceManager.deregister(this, DCCppSystemConnectionMemo.class);
   if (cf != null) {
     InstanceManager.deregister(cf, jmri.jmrix.swing.ComponentFactory.class);
   }
   super.dispose();
 }
Пример #4
0
  /*
   * Initialize an SRCP server turnout. Constructs the system name
   * string from the provided parameters.
   */
  public void initTurnout(int bus, int address, String protocol)
      throws jmri.JmriException, java.io.IOException {

    log.debug("init Turnout called with bus {} address {} and protocol {}", bus, address, protocol);
    java.util.List<SystemConnectionMemo> list =
        jmri.InstanceManager.getList(SystemConnectionMemo.class);
    SystemConnectionMemo memo;
    try {
      memo = list.get(bus - 1);
    } catch (java.lang.IndexOutOfBoundsException obe) {
      TimeStampedOutput.writeTimestamp(output, "412 ERROR wrong value\n\r");
      return;
    }
    String turnoutName = memo.getSystemPrefix() + "T" + address;
    // create turnout if it does not exist.
    this.initTurnout(turnoutName);
    TimeStampedOutput.writeTimestamp(
        output, "101 INFO " + bus + " GA " + address + " " + protocol + "\n\r");
  }