Search in sources :

Example 6 with IpNode

use of org.eclipse.smarthome.binding.dmx.internal.dmxoverethernet.IpNode in project smarthome by eclipse.

the class SacnBridgeHandler method updateConfiguration.

@Override
protected void updateConfiguration() {
    Configuration configuration = getConfig();
    setUniverse(configuration.get(CONFIG_UNIVERSE), MIN_UNIVERSE_ID, MAX_UNIVERSE_ID);
    packetTemplate.setUniverse(universe.getUniverseId());
    receiverNodes.clear();
    if ((configuration.get(CONFIG_SACN_MODE).equals("unicast"))) {
        if (configuration.get(CONFIG_ADDRESS) == null) {
            updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "Could not initialize unicast sender (address not set)");
            return;
        } else {
            try {
                receiverNodes = IpNode.fromString((String) configuration.get(CONFIG_ADDRESS), SacnNode.DEFAULT_PORT);
                logger.debug("using unicast mode to {} for {}", receiverNodes.toString(), this.thing.getUID());
            } catch (IllegalArgumentException e) {
                updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, e.getMessage());
                return;
            }
        }
    } else {
        receiverNodes = new ArrayList<IpNode>();
        receiverNodes.add(SacnNode.getBroadcastNode(universe.getUniverseId()));
        logger.debug("using multicast mode to {} for {}", receiverNodes, this.thing.getUID());
    }
    if (configuration.get(CONFIG_LOCAL_ADDRESS) != null) {
        senderNode = new IpNode((String) configuration.get(CONFIG_LOCAL_ADDRESS));
    }
    logger.debug("originating address is {} for {}", senderNode, this.thing.getUID());
    if (configuration.get(CONFIG_REFRESH_MODE) != null) {
        refreshAlways = (((String) configuration.get(CONFIG_REFRESH_MODE)).equals("always"));
    }
    logger.debug("refresh mode set to always: {}", refreshAlways);
    updateStatus(ThingStatus.UNKNOWN);
    super.updateConfiguration();
    logger.debug("updated configuration for sACN/E1.31 bridge {}", this.thing.getUID());
}
Also used : Configuration(org.eclipse.smarthome.config.core.Configuration) IpNode(org.eclipse.smarthome.binding.dmx.internal.dmxoverethernet.IpNode)

Aggregations

IpNode (org.eclipse.smarthome.binding.dmx.internal.dmxoverethernet.IpNode)6 IOException (java.io.IOException)3 Socket (java.net.Socket)3 Configuration (org.eclipse.smarthome.config.core.Configuration)3 Universe (org.eclipse.smarthome.binding.dmx.internal.multiverse.Universe)1