use of org.eclipse.smarthome.binding.dmx.internal.dmxoverethernet.IpNode in project smarthome by eclipse.
the class ArtnetBridgeHandler 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_ADDRESS) == null) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "Could not initialize sender (address not set)");
uninstallScheduler();
logger.debug("remote address not set for {}", this.thing.getUID());
return;
} else {
try {
receiverNodes = IpNode.fromString((String) configuration.get(CONFIG_ADDRESS), ArtnetNode.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;
}
}
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 ArtNet bridge {}", this.thing.getUID());
}
use of org.eclipse.smarthome.binding.dmx.internal.dmxoverethernet.IpNode in project smarthome by eclipse.
the class Lib485BridgeHandler method openConnection.
@Override
protected void openConnection() {
if (getThing().getStatus() != ThingStatus.ONLINE) {
for (IpNode receiverNode : receiverNodes.keySet()) {
Socket socket = receiverNodes.get(receiverNode);
if (socket == null) {
try {
socket = new Socket(receiverNode.getAddressString(), receiverNode.getPort());
} catch (IOException e) {
logger.debug("Could not connect to {} in {}: {}", receiverNode, this.thing.getUID(), e.getMessage());
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, "could not connect to " + receiverNode.toString());
return;
}
}
if (socket.isConnected()) {
receiverNodes.put(receiverNode, socket);
} else {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR);
receiverNodes.put(receiverNode, null);
return;
}
}
updateStatus(ThingStatus.ONLINE);
}
}
use of org.eclipse.smarthome.binding.dmx.internal.dmxoverethernet.IpNode in project smarthome by eclipse.
the class Lib485BridgeHandler method sendDmxData.
@Override
protected void sendDmxData() {
if (getThing().getStatus() == ThingStatus.ONLINE) {
long now = System.currentTimeMillis();
universe.calculateBuffer(now);
for (IpNode receiverNode : receiverNodes.keySet()) {
Socket socket = receiverNodes.get(receiverNode);
if (socket.isConnected()) {
try {
socket.getOutputStream().write(universe.getBuffer());
} catch (IOException e) {
logger.debug("Could not send to {} in {}: {}", receiverNode, this.thing.getUID(), e.getMessage());
closeConnection(ThingStatusDetail.COMMUNICATION_ERROR, "could not send DMX data");
return;
}
} else {
closeConnection(ThingStatusDetail.NONE, "reconnect");
return;
}
}
} else {
openConnection();
}
}
use of org.eclipse.smarthome.binding.dmx.internal.dmxoverethernet.IpNode in project smarthome by eclipse.
the class Lib485BridgeHandler method closeConnection.
@Override
protected void closeConnection() {
for (IpNode receiverNode : receiverNodes.keySet()) {
Socket socket = receiverNodes.get(receiverNode);
if ((socket != null) && (!socket.isClosed())) {
try {
socket.close();
} catch (IOException e) {
logger.warn("Could not close socket {} in {}: {}", receiverNode, this.thing.getUID(), e.getMessage());
}
}
receiverNodes.put(receiverNode, null);
}
}
use of org.eclipse.smarthome.binding.dmx.internal.dmxoverethernet.IpNode in project smarthome by eclipse.
the class Lib485BridgeHandler method updateConfiguration.
@Override
protected void updateConfiguration() {
Configuration configuration = getConfig();
universe = new Universe(MIN_UNIVERSE_ID);
receiverNodes.clear();
if (configuration.get(CONFIG_ADDRESS) == null) {
receiverNodes.put(new IpNode("localhost:9020"), null);
logger.debug("sending to {} for {}", receiverNodes, this.thing.getUID());
} else {
try {
for (IpNode receiverNode : IpNode.fromString((String) configuration.get(CONFIG_ADDRESS), DEFAULT_PORT)) {
receiverNodes.put(receiverNode, null);
logger.debug("sending to {} for {}", receiverNode, this.thing.getUID());
}
} catch (IllegalArgumentException e) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, e.getMessage());
return;
}
}
super.updateConfiguration();
updateStatus(ThingStatus.UNKNOWN, ThingStatusDetail.NONE);
logger.debug("updated configuration for Lib485 bridge {}", this.thing.getUID());
}
Aggregations