//reconstruct freedomotic object address
//String address = board.getIpAddress() + ":" + board.getPort() + ":" + relayLine + ":" + tag;
String address = board.getAlias() + ":" + relayLine + ":" + tag;
//LOG.info("Sending Ipx800 protocol read event for object address '" + address + "'. It's readed status is " + status);
//building the event
ProtocolRead event = new ProtocolRead(this, "ipx800", address); //IP:PORT:RELAYLINE
// relay lines - status=0 -> off; status=1 -> on
if (tag.equalsIgnoreCase("led")) {
event.addProperty("inputValue", "0");
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 (btn tag) status = up -> on; status = down -> off
if (tag.equalsIgnoreCase("btn")) {
if (status.equalsIgnoreCase("up")) {
event.addProperty("isOn", "true");
} else {
event.addProperty("isOn", "false");
}
event.addProperty("inputValue", status);
} else {
// analog inputs (an/analog input) status = 0 -> off; status > 0 -> on
if (tag.equalsIgnoreCase("an") || tag.equalsIgnoreCase("analog")) {
if (status.equalsIgnoreCase("0")) {
event.addProperty("isOn", "false");
} else {
event.addProperty("isOn", "true");
}
event.addProperty("inputValue", status);
}
}
//adding some optional information to the event
event.addProperty("boardIP", board.getIpAddress());
event.addProperty("boardPort", new Integer(board.getPort()).toString());
event.addProperty("relayLine", new Integer(relayLine).toString());
//publish the event on the messaging bus
this.notifyEvent(event);
}