Exemple #1
0
 /** Start devices threads */
 private void startThreads() {
   for (Ipx800DeviceConfig config : Ipx800Config.INSTANCE.getDevices().values()) {
     Ipx800DeviceConnector thread = new Ipx800DeviceConnector(config);
     thread.start();
     devices.put(config.name, thread);
   }
 }
Exemple #2
0
 /** Exit all the device threads */
 private void quitThreads() {
   logger.info("Exiting IPX800 threads");
   for (Ipx800DeviceConnector device : devices.values()) {
     device.interrupt();
   }
   devices.clear();
 }
Exemple #3
0
 @Override
 public void deactivate() {
   for (Ipx800DeviceConnector device : devices.values()) {
     device.destroyAndExit();
   }
   logger.debug("DeActivate called");
 }
Exemple #4
0
 /** @{inheritDoc */
 @Override
 protected void internalReceiveCommand(String itemName, Command command) {
   logger.debug("Received command item='{}', command='{}'", itemName, command.toString());
   for (Ipx800DeviceConnector device : devices.values()) {
     for (Ipx800Port slot : device.getAllPorts()) {
       Ipx800Item itemSlot = slot.getItemSlot(itemName);
       if (itemSlot != null) {
         itemSlot.setState((State) command);
         if (itemSlot instanceof Ipx800OutputItem) {
           device.setOutput((Ipx800OutputItem) itemSlot);
         }
       }
     }
   }
 }
Exemple #5
0
  private Ipx800DeviceAndPort getDeviceAndPort(String name, String portString)
      throws Ipx800UnknownDeviceException {
    if (name.isEmpty() || portString.isEmpty()) {
      return new Ipx800DeviceAndPort(null, null);
    }
    int extDelta = 0;
    Ipx800DeviceConnector device = devices.get(name);

    if (device == null) {
      // Try to find extensions
      for (Ipx800DeviceConnector dev : devices.values()) {
        extDelta = dev.getExtensionDelta(name);
        if (extDelta != 0) {
          device = dev;
          break;
        }
      }
      if (extDelta == 0) {
        throw new Ipx800UnknownDeviceException(
            "Device '" + name + "' doesn't exist, please check your config/items");
      }
    }
    return new Ipx800DeviceAndPort(device, device.getPort(portString, extDelta));
  }