Package it.freedomotic.events

Examples of it.freedomotic.events.ProtocolRead


    private void sendChanges(Board board, int id, int slot, String val, String typical) { //
        //reconstruct freedomotic object address
        String address = board.getIpAddress() + ":" + board.getPort() + ":" + id + ":" + slot;
        LOG.info("Sending Souliss protocol read event for object address '" + address + "'");
        //building the event ProtocolRead
        ProtocolRead event = new ProtocolRead(this, "souliss", address);
        event.addProperty("souliss.typical", typical);
        event.addProperty("souliss.val", val);
        switch (Integer.parseInt(typical)) {
            case 11:
                if (val.equals("0")) {
                    event.addProperty("isOn", "false");
                } else {
                    event.addProperty("isOn", "true");
                }
                break;
        }
        //publish the event on the messaging bus
        this.notifyEvent(event);
View Full Code Here


    private void sendChanges(Board board, String parametersValue) {
        String address = board.getIpAddress() + ":" + board.getPort();
        //Freedomotic.logger.severe("Sending Arduino WeatherShield protocol read event for board '" + address + "'");
        String values[] = parametersValue.split(board.getDelimiter());
        //building the event
        ProtocolRead event = new ProtocolRead(this, "ArduinoWeatherShield", address); //IP:PORT
        //adding some optional information to the event
        event.addProperty("boardIP", board.getIpAddress());
        event.addProperty("boardPort", new Integer(board.getPort()).toString());
        event.addProperty("sensor.temperature", values[0]);
        event.addProperty("sensor.pressure", values[1]);
        event.addProperty("sensor.humidity", values[2]);
        //publish the event on the messaging bus
        this.notifyEvent(event);
    }
View Full Code Here

    private void sendChanges(int relayLine, int device, String typeLine, String status) {
        //first parameter in the constructor is the reference for the source of the event (typically the sensor plugin class)
        //second parameter is the protocol of the object we want to change
        //third parameter must be the exact address of the object we want to change
        String address = Integer.toString(device) + ":" + typeLine + ":" + relayLine;
        ProtocolRead event = new ProtocolRead(this, "k8055", address);
        //LOG.severe("k8055 address " + address);
        //add a property that defines the status readed from hardware
        //event.addProperty("relay.number", new Integer(relayLine).toString());
        if (typeLine.equals("ID")) {
            if (status.equals("0")) {
                event.addProperty("isOn", "false");
            } else {
                event.addProperty("isOn", "true");
            }
        } else if (typeLine.equals("IA")) {
            if (status.equals("0")) {
                event.addProperty("isOn", "false");
                event.addProperty("valueLine", status);
            } else {
                event.addProperty("isOn", "true");
                event.addProperty("valueLine", status);
            }
        }

        //others additional optional info
        //event.addProperty("status", status);
View Full Code Here

    private void notifyChangeEvent(String device_address, int val) {

        Freedomotic.logger.log(Level.INFO, "Sending I2C protocol read event for object address ''{0}''. It''s readed status is {1}", new Object[]{device_address, val});
        //building the event
        ProtocolRead event = new ProtocolRead(this, "i2c", device_address); //IP:PORT:RELAYLINE

        if (val == 1) {
            event.addProperty("isOn", "true");
        } else {
            event.addProperty("isOn", "false");
        }

        //adding some optional information to the event
        //event.addProperty("boardIP", board.getIpAddress());
        //event.addProperty("boardPort", new Integer(board.getPort()).toString());
View Full Code Here

            //loops waittime is specified using setPollingWait()
            URL url = null;
            InputStream is = null;
            BufferedReader br;
            String line, html = null;
            ProtocolRead event;
            Authenticator.setDefault(new MyAuthenticator());
            //URL url = new URL(configuration.getStringProperty("url", ""));
            //InputStream ins = url.openConnection().getInputStream();
            //BufferedReader reader = new BufferedReader(new InputStreamReader(ins));
            //String str;
            //while((str = reader.readLine()) != null)
            //System.out.println(str);
            try {
                url = new URL(configuration.getStringProperty("url", ""));
                is = url.openStream()// throws an IOException
                br = new BufferedReader(new InputStreamReader(is));
                while ((line = br.readLine()) != null) {
                    html = html + line;
                }
            } catch (IOException ioe) {
                setDescription(ioe.getMessage());
            }
            //Freedomotic.logger.config(html);
            html = html.toLowerCase();
            System.out.println("HTML: " + html);
            for (EnvObjectLogic object : EnvObjectPersistence.getObjectByProtocol("wifi_id")) {
                String mac_address = object.getPojo().getPhisicalAddress();
                String name = object.getPojo().getName();
                //Freedomotic.logger.info(mac_address);
                //Freedomotic.logger.info(name);
                if (html.contains(mac_address.toLowerCase())) {
                    // user exist
                    event = new ProtocolRead(this, "wifi_id", mac_address);
                    event.addProperty("wifi_id.present", "true");
                    Freedomotic.sendEvent(event);
                } else {
                    // user not exist
                    event = new ProtocolRead(this, "wifi_id", mac_address);
                    event.addProperty("wifi_id.present", "false");
                    Freedomotic.sendEvent(event);
                }
            }
            is.close();
View Full Code Here

            }
        }
    }

    private void sendEvent(String objectAddress, String eventProperty, String eventValue) {
        ProtocolRead event = new ProtocolRead(this, PROTOCOL_NAME, objectAddress);
        event.addProperty(eventProperty, eventValue);
        //publish the event on the messaging bus
        this.notifyEvent(event);
    }
View Full Code Here

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

        }
    }
    // }

    private void sendEvent(String objectAddress, String eventProperty, String eventValue, String objectTemplate) {
        ProtocolRead event = new ProtocolRead(this, "tcw122bcm", objectAddress);
        event.addProperty(eventProperty, eventValue);
        //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, "arduino-remote-controller", objectAddress);
        event.addProperty("button.pressed", eventValue);
        //publish the event on the messaging bus
        this.notifyEvent(event);
        System.out.println("Sending event : " + event.toString())// FOR DEBUG USE
    }
View Full Code Here

        return STX + "**" + hardwareString + ETX;
    }

    //special Case
    private int readHardwareInputValue() {
        ProtocolRead event;
        try {
            String serialCommand = STX + "**" + "INP" + ETX;
            System.out.println("Command to send to serial: " + serialCommand);
            String output = usb.send(serialCommand);
            System.out.println("Output from serial: " + output);
            if (output.contains("XXX")) //TV is off
            {
                event = new ProtocolRead(this, "pioneer-kuro", "pioneer-kuro");
                event.addProperty("hardware-behavior", "POWER");
                event.addProperty("power-value", "false");
                this.notifyEvent(event);
            } else if (!output.contains("ERR")) {
                event = new ProtocolRead(this, "pioneer-kuro", "pioneer-kuro");
                event.addProperty("hardware-behavior", "POWER");
                event.addProperty("power-value", "true");
                this.notifyEvent(event);
                String value = output.substring(4, 6);
                if (value.equals("81")) {
                    //analog
                } else if (value.equals("83")) {//terrestrial
                } else if (value.equals("84")) {//Digital
                } else {
                    event = new ProtocolRead(this, "pioneer-kuro", "pioneer-kuro");
                    event.addProperty("hardware-behavior", "INP");
                    event.addProperty("input-value", value);
                    this.notifyEvent(event);
                }
            }
            return OK;

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.