}
//reconstruct freedomotic object address
String address = board.getAlias() + ":" + relayLine + ":" + tag;
LOG.info("Sending ProgettiHwSw protocol read event for object address '" + address + "'. It's readed status is " + status);
//building the event
ProtocolRead event = new ProtocolRead(this, "phwswethv2", address); //IP:PORT:RELAYLINE
// relay lines - status=0 -> off; status=1 -> on
if (tag.equalsIgnoreCase(board.getLedTag())) {
if (status.equals("0")) {
event.addProperty("isOn", "false");
} else {
event.addProperty("isOn", "true");
//if autoconfiguration is true create an object if not already exists
if (board.getAutoConfiguration().equalsIgnoreCase("true")) {
event.addProperty("object.class", board.getObjectClass());
event.addProperty("object.name", address);
}
}
} else // digital inputs status = up -> off/open; status = dn -> on/closed
if (tag.equalsIgnoreCase(board.getDigitalInputTag())) {
if (status.equalsIgnoreCase("up")) {
event.addProperty("isOn", "false");
event.addProperty("isOpen", "true");
} else {
event.addProperty("isOn", "true");
event.addProperty("isOpen", "false");
}
} else {
// analog inputs status = 0 -> off; status > 0 -> on
if (tag.equalsIgnoreCase(board.getAnalogInputTag())) {
if (status.equalsIgnoreCase("0")) {
event.addProperty("isOn", "false");
} else {
event.addProperty("isOn", "true");
}
event.addProperty("analog.input.value", status);
}
}
//publish the event on the messaging bus
this.notifyEvent(event);