Package it.freedomotic.events

Examples of it.freedomotic.events.ProtocolRead


// this method sends a freedomotic event every time a relay status changes
    private void sendEvent(int objectAddress, String eventProperty, int eventValue) {
        if (relayBitStatus[objectAddress - 1] != eventValue) {
            relayBitStatus[objectAddress - 1] = eventValue;
            ProtocolRead event = new ProtocolRead(this, "kmtronicusbrelay", String.valueOf(objectAddress));
            event.addProperty(eventProperty, String.valueOf(eventValue));
            event.addProperty("object.class", "Light");
            event.addProperty("object.name", String.valueOf(objectAddress));
            //publish the event on the messaging bus
            this.notifyEvent(event);
        }
    }
View Full Code Here


    @Override
    protected void onRun() {
    }

    public void sendEvent(String objectAddress, String eventProperty, String eventValue) {
        ProtocolRead event = new ProtocolRead(this, "openpicus-grove-system", objectAddress);
        event.addProperty("sensor.type", eventProperty);
        event.addProperty("sensor.value", eventValue);
        if (eventProperty.equalsIgnoreCase("temperature")) {
            event.addProperty("object.class", "Thermostat");
        } else if (eventProperty.equalsIgnoreCase("luminosity")) {
            event.addProperty("object.class", "Light Sensor");
        }
        // EXTEND WITH MORE SENSORS
        event.addProperty("object.name", objectAddress);
        //publish the event on the messaging bus
        this.notifyEvent(event);
        //System.out.println("Sending eventProperty " + eventProperty); // FOR DEBUG
    }
View Full Code Here

    }

    @Override
    protected void onRun() {
        //sends a fake sensor read event
        ProtocolRead event = new ProtocolRead(this, "test", "test");
        event.getPayload().addStatement("value",
                powered.toString());
        event.getPayload().addStatement("object.class", "Light");
        event.getPayload().addStatement("object.name", "Created by VariousSensors");
        //invert the value for the next round
        notifyEvent(event);

        if (powered) {
            powered = false;
View Full Code Here

        //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);
    }
View Full Code Here

    }

    @Override
    protected void onRun() {
        //sends a fake sensor read event. Used for testing
        ProtocolRead event = new ProtocolRead(this, "test", "test");
        event.getPayload().addStatement("object.class", "Light");
        event.getPayload().addStatement("object.name", "myLight");
        event.getPayload().addStatement("value",
                powered.toString());
        //invert the value for the next round
        notifyEvent(event);

        if (powered) {
View Full Code Here

            }
        }
    }

    private void notifyRoomStatus(Room z) {
        ProtocolRead event = new ProtocolRead(this, "roomevent", z.getPojo().getName());
        //   Freedomotic.logger.info(event.toString());
        int numLightsOn = 0;
        int totLights = 0;
        String roomName = z.getPojo().getName();
        for (EnvObject obj : z.getPojo().getObjects()) {
            if (obj.getType().equalsIgnoreCase("EnvObject.ElectricDevice.Light")) {
                totLights++;
                if (obj.getCurrentRepresentationIndex() == 1) {
                    numLightsOn++;
                }
            }
        }

        if (totLights != 0) {
            String amount = "";
            if (numLightsOn == 0) {
                amount = "no";
            } else if (numLightsOn == totLights) {
                amount = "all";
            } else {
                amount = "some";
            }


            event.addProperty("hasLightsOn", amount);
            event.addProperty("roomName", roomName);
            this.notifyEvent(event);
            // add and register this
            String triggerName = "Room " + roomName + " has " + amount + " lights On";
            Trigger t = TriggerPersistence.getTrigger(triggerName);
            if (t == null) {
View Full Code Here

        relayLine++;
        //reconstruct freedomotic object address
        String address = board.getAlias() + ":" + relayLine;
        LOG.info("Sending Devantech Eth-Rly protocol read event for object address '" + address + "'. It's readed status is " + status);
        //building the event
        ProtocolRead event = new ProtocolRead(this, "devantech-eth-rly", address); //ALIAS:RELAYLINE
        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);
        }
        //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);
    }
View Full Code Here

    private void sendChanges(int relayLine, Board board, String status) {
        //reconstruct freedomotic object address
        String address = board.getIpAddress() + ":" + board.getPort() + ":" + relayLine;
        LOG.info("Sending Flyport protocol read event for object address '" + address + "'. It's readed status is " + status);
        //building the event
        ProtocolRead event = new ProtocolRead(this, "flyport", address); //IP:PORT:RELAYLINE
        // relay lines - status=0 -> off; status=1 -> on
        if (board.getLineToMonitorize().equalsIgnoreCase("led")) {
            if (status.equals("0")) {
                event.addProperty("isOn", "false");
            } else {
                event.addProperty("isOn", "true");
            }
        } else if (board.getLineToMonitorize().equalsIgnoreCase("btn")) {
            if (status.equalsIgnoreCase("0")) {
                event.addProperty("isOn", "false");
            } else {
                event.addProperty("isOn", "true");
            }
        } else {
            if (board.getLineToMonitorize().equalsIgnoreCase("pot")) {
                if (status.equalsIgnoreCase("0")) {
                    event.addProperty("isOn", "false");
                } else {
                    event.addProperty("isOn", "true");
                }
            }
        }
        //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);
    }
View Full Code Here

                String lowbatt = ev.getAttribute("lowbatt");
                //address = board.getIpAddress() + ":" + board.getPort() + ":" + protocol + id;
                address = board.getAlias() + ":" + protocol + id;
                // print out its manager attribute value
                //System.out.println("Device = " + protocol + id + " v1=" + v1 + " v2=" + v2 + " lowbatt=" + lowbatt);
                ProtocolRead event = new ProtocolRead(this, "zibase", address); //object address ALIAS:PROTOCOL+ID
                event.addProperty("sensor.v1", v1);
                event.addProperty("sensor.v2", v2);
                event.addProperty("sensor.lowbatt", lowbatt);
                //publish the event on the messaging bus
                this.notifyEvent(event);
            }
        }
    }
View Full Code Here

        //reconstruct freedomotic object address
        String address = board.getAlias() + ":" + x10Address + ":" + protocol;
        //String address = board.getIpAddress() + ":" + board.getPort() + ":" + x10Address + ":" + protocol;
        Freedomotic.logger.severe("Sending Zibase protocol read event for object address '" + address + "'. It's readed status is " + status);
        //building the event
        ProtocolRead event = new ProtocolRead(this, "zibase", address); //object address ALIAS:X10ADDRESS:PROTOCOL
        if (status.equals("0")) {
            event.addProperty("isOn", "false");
        } else {
            event.addProperty("isOn", "true");
        }
        //publish the event on the messaging bus
        this.notifyEvent(event);
    }
View Full Code Here

TOP

Related Classes of it.freedomotic.events.ProtocolRead

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.