Package it.freedomotic.events

Examples of it.freedomotic.events.ProtocolRead


    }

    //Tries to read the callback of a command with the format INPS01
    private int readHardwareBehaviorValue(String command, String eventPropertyName, int numChars) {
        try {
            ProtocolRead event;
            String serialCommand = STX + "**" + command + 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(command)) {
                String behavior = command;
                String value = output.substring(6 - numChars, 6);
                event = new ProtocolRead(this, "pioneer-kuro", "pioneer-kuro");
                event.addProperty("hardware-behavior", behavior);
                event.addProperty(eventPropertyName, value);
                this.notifyEvent(event);
                return OK;
            } else if (output.contains("ERR") || output.contains("XXX")) {
                return ERR;
            }
View Full Code Here


        }
        //reconstruct freedom object address
        String address = board.getIpAddress() + ":" + board.getPort() + ":" + relayLine;
        Freedomotic.logger.info("Sending Progetti HWSW protocol read event for object address '" + address + "'. It's readed status is " + status);
        //building the event
        ProtocolRead event = new ProtocolRead(this, "SNT084Eth8R8I", 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 // digital inputs - status=up -> off; status=dn -> on
        if (board.getLineToMonitorize().equalsIgnoreCase("btn")) {
            if (status.equalsIgnoreCase("up")) {
                event.addProperty("isOn", "false");
            } else {
                event.addProperty("isOn", "true");
            }
        } else {
            // analog inputs - status=0 -> off; status>0 -> on
            if (board.getLineToMonitorize().equalsIgnoreCase("ptn")) {
                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

        while ((output = br.readLine()) != null) {
            readValue += output;
        }
        System.out.println(Float.parseFloat(readValue));
        //building the event
        ProtocolRead event = new ProtocolRead(this, "zway", board.getAlias() + delimiter + deviceAddress + delimiter + deviceInstance + delimiter + objectType);
        //adding some optional information to the event
        event.addProperty("read.value", String.valueOf(Float.parseFloat(readValue)));
        event.addProperty("object.type", objectType);
        //publishes the event on the messaging bus
        this.notifyEvent(event);

        connection.disconnect();
View Full Code Here

            }

            String address = board.getIpAddress() + ":" + sensorID;
            LOG.info("Sending HWg-STE protocol read event for object address '" + address + "'");
            //building the event
            ProtocolRead event = new ProtocolRead(this, "hwgste", address);
            //adding some optional information to the event
            event.addProperty("object.class", objectClass);
            event.addProperty("object.name", address);
            event.addProperty("sensor.unit", unit);
            event.addProperty("sensor.value", sensorValue.toString());
            event.addProperty("sensor.name", sensorName);
            event.addProperty("sensor.state", state);
            //publish the event on the messaging bus
            this.notifyEvent(event);
        }
    }
View Full Code Here

        String objectClass = null;
        String objectName = null;
        String messageType = null;
        String messageDescription = null;
        String[] frameParts = null;
        ProtocolRead event = null;

        int length = frame.length();
        if (frame.isEmpty() || !frame.endsWith("##")) {
            OpenWebNet.LOG.severe("Malformed frame " + frame + " " + frame.substring(length - 2, length));
            OWNFrame.writeAreaLog(getDateTime() + " Mon: Malformed frame " + frame);
            return null;
        }

        if (frame.equals(OpenWebNet.MSG_OPEN_ACK)) {
            messageType = "ack";
            return null;
        }

        if (frame.equals(OpenWebNet.MSG_OPEN_NACK)) {
            messageType = "nack";
            return null;
        }


        if (frame.substring(0, 2).equalsIgnoreCase("*#")) { // remove *# and ##
            frameParts = frame.split("\\*"); // * is reserved so it must be escaped
            who = frameParts[0];
            where = frameParts[1];
            objectName = who + "*" + where;
            event = new ProtocolRead(pluginReference, "openwebnet", who + "*" + where); // LIGHTING if (who.equalsIgnoreCase("1")) {
            if (who.equalsIgnoreCase("1")) {
                //objectClass = "Light";
                //objectName = who + "*" + where;
                if (frameParts[2].equalsIgnoreCase("1")) {
                    String level = frameParts[3];
                    String speed = frameParts[4];
                    messageDescription = "Luminous intensity change";
                    if (level != null) {
                        event.addProperty("level", level);
                    }
                    if (speed != null) {
                        event.addProperty("speed", speed);
                    }
                }
                if (frameParts[2].equalsIgnoreCase("2")) {
                    String hour = frameParts[3];
                    String min = frameParts[4];
                    String sec = frameParts[5];
                    messageDescription = "Luminous intensity change";
                    if (hour != null) {
                        event.addProperty("hour", hour);
                    }
                    if (min != null) {
                        event.addProperty("min", min);
                    }
                    if (sec != null) {
                        event.addProperty("sec", sec);
                    }
                }
            }
            // POWER MANAGEMENT
            if (who.equalsIgnoreCase("3")) {
                //objectClass = "Powermeter";
                //objectName = who + "*" + where;
                String voltage = null;
                String current = null;
                String power = null;
                String energy = null;
                if (frameParts[3].equalsIgnoreCase("0")) {
                    voltage = frameParts[3];
                    current = frameParts[4];
                    power = frameParts[5];
                    energy = frameParts[6];
                    messageDescription = "Load control status";
                    if (voltage != null) {
                        event.addProperty("voltage", voltage);
                    }
                    if (current != null) {
                        event.addProperty("current", current);
                    }
                    if (power != null) {
                        event.addProperty("power", power);
                    }
                    if (energy != null) {
                        event.addProperty("energy", energy);
                    }
                }
                if (frameParts[3].equalsIgnoreCase("1")) {
                    voltage = frameParts[3];
                    if (voltage != null) {
                        event.addProperty("voltage", voltage);
                    }
                    messageDescription = "Voltage status";
                }
                if (frameParts[3].equalsIgnoreCase("2")) {
                    current = frameParts[3];
                    if (current != null) {
                        event.addProperty("current", current);
                    }
                    messageDescription = "Current status";
                }
                if (frameParts[3].equalsIgnoreCase("3")) {
                    power = frameParts[3];
                    if (power != null) {
                        event.addProperty("power", power);
                    }
                    messageDescription = "Power status";
                }
                if (frameParts[3].equalsIgnoreCase("4")) {
                    energy = frameParts[3];
                    if (energy != null) {
                        event.addProperty("energy", energy);
                    }
                    messageDescription = "Energy status";
                }
            }
            // TERMOREGULATION
            if (who.equalsIgnoreCase("4")) {
                String temperature = null;
                if (frameParts[3].equalsIgnoreCase("0")) {
                    temperature = frameParts[3];
                    temperature = OWNUtilities.convertTemperature(temperature);
                    messageDescription = "Temperature value";
                    if (temperature != null) {
                        event.addProperty("temperature", temperature);
                    }
                }
            }
            // GATEWAY CONTROL
            if (who.equalsIgnoreCase("13")) {
                String hour = null;
                String minute = null;
                String second = null;
                String timeZone = null;
                String dayWeek = null;
                String day = null;
                String month = null;
                String year = null;
                String version = null;
                String release = null;
                String build = null;
                if (frameParts[2].equalsIgnoreCase("0")) {
                    hour = frameParts[3];
                    minute = frameParts[4];
                    second = frameParts[5];
                    timeZone = frameParts[6]; // aggiungere funzione conversione
                    messageType = "gatewayControl";
                    messageDescription = "Time request";
                    if (hour != null) {
                        event.addProperty("hour", hour);
                    }
                    if (minute != null) {
                        event.addProperty("minute", minute);
                    }
                    if (second != null) {
                        event.addProperty("second", second);
                    }
                    if (timeZone != null) {
                        event.addProperty("timeZone", timeZone);
                    }
                }
                if (frameParts[2].equalsIgnoreCase("1")) {
                    dayWeek = OWNUtilities.dayName(frameParts[3]);
                    day = frameParts[4];
                    month = frameParts[5];
                    year = frameParts[6];
                    messageType = "gatewayControl";
                    messageDescription = "Date request";
                    if (dayWeek != null) {
                        event.addProperty("dayWeek", dayWeek);
                    }
                    if (day != null) {
                        event.addProperty("day", day);
                    }
                    if (month != null) {
                        event.addProperty("month", month);
                    }
                    if (year != null) {
                        event.addProperty("year", year);
                    }
                }
                if (frameParts[2].equalsIgnoreCase("10")) {
                    String ip1 = frameParts[3];
                    String ip2 = frameParts[4];
                    String ip3 = frameParts[5];
                    String ip4 = frameParts[6];
                    messageType = "gatewayControl";
                    messageDescription = "IP request";
                    event.addProperty("ip-address", ip1 + "." + ip2 + "." + ip3 + "." + ip4);
                }
                if (frameParts[2].equalsIgnoreCase("11")) {
                    String netmask1 = frameParts[3];
                    String netmask2 = frameParts[4];
                    String netmask3 = frameParts[5];
                    String netmask4 = frameParts[6];
                    messageType = "gatewayControl";
                    messageDescription = "Netmask request";
                    event.addProperty("netmask", netmask1 + "." + netmask2 + "." + netmask3 + "." + netmask4);
                }
                if (frameParts[2].equalsIgnoreCase("12")) {
                    String mac1 = frameParts[3];
                    String mac2 = frameParts[4];
                    String mac3 = frameParts[5];
                    String mac4 = frameParts[6];
                    String mac5 = frameParts[7];
                    String mac6 = frameParts[8];
                    messageType = "gatewayControl";
                    messageDescription = "MAC request";
                    event.addProperty("mac-address", mac1 + ":" + mac2 + ":" + mac3 + ":" + mac4 + ":" + mac5 + ":" + mac6);
                }
                if (frameParts[2].equalsIgnoreCase("15")) {
                    String model = OWNUtilities.gatewayModel(frameParts[3]);
                    messageType = "gatewayControl";
                    messageDescription = "Model request";
                    event.addProperty("model", model);
                }
                if (frameParts[2].equalsIgnoreCase("16")) {
                    version = frameParts[3];
                    release = frameParts[4];
                    build = frameParts[5];
                    messageType = "gatewayControl";
                    messageDescription = "Firmware version request";
                    event.addProperty("firmware - version", version + "." + release + "." + build);
                }
                if (frameParts[2].equalsIgnoreCase("17")) {
                    String days = frameParts[3];
                    String hours = frameParts[4];
                    String minutes = frameParts[5];
                    String seconds = frameParts[6];
                    messageType = "gatewayControl";
                    messageDescription = "Uptime request";
                    event.addProperty("uptime", days + "D:" + hours + "H:" + minutes + "m:" + seconds + "s");
                }
                if (frameParts[2].equalsIgnoreCase("22")) {
                    hour = frameParts[3];
                    minute = frameParts[4];
                    second = frameParts[5];
                    timeZone = frameParts[6];
                    String weekDay = OWNUtilities.dayName(frameParts[7]);
                    day = frameParts[8];
                    month = frameParts[9];
                    year = frameParts[10];
                    messageType = "gatewayControl";
                    messageDescription = "Date&Time request";
                    event.addProperty("date", weekDay + " " + day + "/" + month + "/" + year);
                    event.addProperty("time", hour + ":" + minute + ":" + second);
                }
                if (frameParts[2].equalsIgnoreCase("23")) {
                    version = frameParts[3];
                    release = frameParts[4];
                    build = frameParts[5];
                    messageType = "gatewayControl";
                    messageDescription = "Kernel version request";
                    event.addProperty("kernel - version", version + "." + release + "." + build);
                }
                if (frameParts[2].equalsIgnoreCase("24")) {
                    version = frameParts[3];
                    release = frameParts[4];
                    build = frameParts[5];
                    messageType = "gatewayControl";
                    messageDescription = "Distribution version request";
                    event.addProperty("distribution - version", version + "." + release + "." + build);
                }
            }

            event.addProperty("who", who);
            if (where != null) {
                event.addProperty("where", where);
            }
            if (messageDescription != null) {
                event.addProperty("messageDescription", messageDescription);
            }
            if (messageType != null) {
                event.addProperty("messageType", messageType);
            }
            // notify event
            pluginReference.notifyEvent(event);
            OWNFrame.writeAreaLog(getDateTime() + " Rx: " + frame + " " + "(" + messageDescription + ")");

        }


        if (!(frame.substring(0, 2).equalsIgnoreCase("*#"))) {
            // remove delimiter chars * and ##
            frame = frame.substring(1, length - 2);
            frameParts = frame.split("\\*"); // * is reserved so it must be escaped
            who = frameParts[0];
            what = frameParts[1];
            where = frameParts[2];
            event = new ProtocolRead(pluginReference, "openwebnet", who + "*" + where);
            //objectClass = "Light";
            objectName = who + "*" + where;


            switch (Integer.parseInt(who)) {
                //LIGHTING
                case 1:
                    messageType = "Lighting";
                    objectClass = "Light";
                    switch (Integer.parseInt(what)) {
                        // Light OFF
                        case 0:
                            messageDescription = "Light OFF";
                            break;
                        // Light ON       
                        case 1:
                            messageDescription = "Light ON";
                            break;
                        default:
                            if (Integer.parseInt(what) >= 2 && Integer.parseInt(what) <= 10) {
                                messageDescription = "Light Dimmer";
                            }
                            break;
                    }
                    break; // close LIGHTING switch

                // AUTOMATION
                case 2:
                    messageType = "Automation";
                    switch (Integer.parseInt(what)) {
                        case 0:
                            messageDescription = "Automation STOP";
                            break;
                        case 1:
                            messageDescription = "Automation UP";
                            break;
                        case 2:
                            messageDescription = "Automation DOWN";
                            break;
                    }
                    break; // close AUTOMATION switch

                // POWER MANAGEMENT     
                case 3:
                    objectClass = "Powermeter";
                    messageType = "Power management";
                    switch (Integer.parseInt(what)) {
                        case 0:
                            messageDescription = "Load disable";
                            break;
                        case 1:
                            messageDescription = "Load enable";
                            break;
                        case 2:
                            messageDescription = "Load forced";
                            break;
                        case 3:
                            messageDescription = "Stop load forced";
                            break;
                    }
                    break; // close POWER MANAGEMENT switch


                // TERMOREGULATION
                case 4:
                    messageType = "termoregulation";
                    switch (Integer.parseInt(what)) {
                        case 0:
                            messageDescription = "Conditioning";
                            break;
                        case 1:
                            messageDescription = "Heating";
                            break;
                        case 20:
                            messageDescription = "Remote Control disabled";
                            break;
                        case 21:
                            messageDescription = "Remote Control enabled";
                            break;
                        case 22:
                            messageDescription = "At least one Probe OFF";
                            break;
                        case 23:
                            messageDescription = "At least one Probe in protection";
                            break;
                        case 24:
                            messageDescription = "At least one Probe in manual";
                            break;
                        case 30:
                            messageDescription = "Failure discovered";
                            break;
                        case 31:
                            messageDescription = "Central Unit battery KO";
                            break;
                        case 103:
                            messageDescription = "OFF Heating";
                            break;
                        case 110:
                            messageDescription = "Manual Heating";
                            break;
                        case 111:
                            messageDescription = "Automatic Heating";
                            break;
                        case 202:
                            messageDescription = "AntiFreeze";
                            break;
                        case 203:
                            messageDescription = "OFF Conditioning";
                            break;
                        case 210:
                            messageDescription = "Manual Conditioning";
                            break;
                        case 211:
                            messageDescription = "Automatic Conditioning";
                            break;
                        case 302:
                            messageDescription = "Thermal Protection";
                            break;
                        case 303:
                            messageDescription = "Generic OFF";
                            break;
                        case 311:
                            messageDescription = "Automatic Generic";
                            break;
                    }
                    break; // close TERMOREGULATION switch

                // BURGLAR ALARM   
                case 5:
                    messageType = "alarm";
                    switch (Integer.parseInt(what)) {
                        case 0:
                            messageDescription = "System on maintenance";
                            break;
                        case 4:
                            messageDescription = "Battery fault";
                            break;
                        case 5:
                            messageDescription = "Battery OK";
                            break;
                        case 6:
                            messageDescription = "No Network";
                            break;
                        case 7:
                            messageDescription = "Network OK";
                            break;
                        case 8:
                            messageDescription = "System engaged";
                            break;
                        case 9:
                            messageDescription = "System disengaged";
                            break;
                        case 10:
                            messageDescription = "Battery KO";
                            break;
                        case 11: // prelevare la sottostringa di where #N
                        {
                            messageDescription = "Zone " + where + " engaged";
                        }
                        break;
                        case 12: // prelevare la sottostringa di where #N
                        {
                            messageDescription = "Aux " + where + " in Technical alarm ON";
                        }
                        break;
                        case 13: // prelevare la sottostringa di where #N
                        {
                            messageDescription = "Aux " + where + " in Technical alarm RESET";
                        }
                        break;
                        case 15: // prelevare la sottostringa di where #N
                        {
                            messageDescription = "Zone " + where + " in Intrusion alarm";
                        }
                        break;
                        case 16: // prelevare la sottostringa di where #N
                        {
                            messageDescription = "Zone " + where + " in Tampering alarm";
                        }
                        break;
                        case 17: // prelevare la sottostringa di where #N
                        {
                            messageDescription = "Zone " + where + " in Anti-panic alarm";
                        }
                        break;
                        case 18: // prelevare la sottostringa di where #N
                        {
                            messageDescription = "Zone " + where + " divided";
                        }
                        break;
                        case 31: // prelevare la sottostringa di where #N
                        {
                            messageDescription = "Silent alarm from aux " + where;
                        }
                        break;
                    }
                    break; // close BURGLAR ALARM switch

                // SOUND SYSTEM
                case 16:
                    messageType = "Sound System";
                    switch (Integer.parseInt(what)) {
                        case 0:
                            messageDescription = "ON Baseband";
                            break;
                        case 3:
                            messageDescription = "ON Stereo channel";
                            break;
                        case 10:
                            messageDescription = "OFF Baseband";
                            break;
                        case 13:
                            messageDescription = "OFF Stereo channel";
                            break;
                        case 30:
                            messageDescription = "Sleep on baseband";
                            break;
                        case 33:
                            messageDescription = "Sleep on stereo channel";
                            break;
                    }
                    break; // close SOUND SYSTEM switch


            } // close switch(who)


            if (who != null) {
                event.addProperty("who", who);
            }
            if (what != null) {
                event.addProperty("what", what);
            }
            if (where != null) {
                event.addProperty("where", where);
            }
            if (messageType != null) {
                event.addProperty("messageType", messageType);
            }
            if (messageDescription != null) {
                event.addProperty("messageDescription", messageDescription);
            }
            if (objectClass != null) {
                event.addProperty("object.class", objectClass);
            }
            if (objectName != null) {
                event.addProperty("object.name", objectName);
            }

            //Freedomotic.logger.info("Frame " + frame + " " + "is " + messageType + " message. Notify it as Freedomotic event " + messageDescription); // for debug
            OWNFrame.writeAreaLog(getDateTime() + " Rx: " + frame + " " + "(" + messageDescription + ")");
            pluginReference.notifyEvent(event);
View Full Code Here

        if (control == null || value == null || node == null) {
            return;
        }
        Freedomotic.logger.info("Someone or something changed " + ((control.label == null) ? control.name : control.label) + " to " + value + " at " + node.name);
        Isy99iFrame.writeAreaLog(Isy99iUtilities.getDateTime() + ": Someone or something changed " + ((control.label == null) ? control.name : control.label) + " to " + InsteonOps.convertOnLevelToPercent(value.toString()) + " at " + node.address + " type " + node.typeReadable + " uom " + control.numericUnit);
        ProtocolRead event = new ProtocolRead(this, "Isy99i", node.address); //IP:PORT:RELAYLINE
        int valuePercent = InsteonOps.convertOnLevelToPercent(value.toString());
        event.addProperty("type", node.typeReadable);
        // lighting support
        if (valuePercent > 0) {
            event.addProperty("isOn", "true");
        } else {
            event.addProperty("isOn", "false");
        }
        event.addProperty("value", Integer.toString(valuePercent));
        Isy99i.aux.notifyIsyEvent(event);
    }
View Full Code Here

                    if (portAdapter.checkDeviceListAndEvaluateDiffs() == true) { // temp device is changed
                        if (portAdapter.devicesOneWire != null) {
                            for (DeviceOneWire device : portAdapter.devicesOneWire) {
                                if (device.getChanged()) {
                                    //building the event
                                    ProtocolRead event = new ProtocolRead(this, "onewire", portAdapter.getAdapterName() + ":" + portAdapter.getPortName() + ":" + device.getAddress());
                                    //adding some optional information to the event
                                    event.addProperty("sensor.unit", "C");
                                    event.addProperty("sensor.value", Double.toString(device.getValue()));
                                    event.addProperty("sensor.name", "");
                                    event.addProperty("sensor.state", "Alarm");
                                    Freedomotic.logger.warning("Object " + device.getAddress() + " is change. New Value " + Double.toString(device.getValue()));
                                    this.notifyEvent(event);
                                    device.setChanged(false);
                                }
                            }
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);
        //Freedomotic.logger.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

        txtResult.setText("Command sent, the new object should be on the map");
    }//GEN-LAST:event_btnJoinDeviceActionPerformed

    private void btnBypassTriggerSystemActionPerformed(java.awt.event.ActionEvent evt)    {//GEN-FIRST:event_btnBypassTriggerSystemActionPerformed

        ProtocolRead event = new ProtocolRead(this, "test", "test");
        event.addProperty("behavior.name", "powered");
        event.addProperty("behaviorValue", "true");
        Freedomotic.sendEvent(event);
    }//GEN-LAST:event_btnBypassTriggerSystemActionPerformed
View Full Code Here

            return false;
        }
    }

    public void send() {
        ProtocolRead event = new ProtocolRead(this, "X10", getAddress());
        //A01AOFF
        event.addProperty("X10.event", getAddress() + getFunction());
        //A
        event.addProperty("X10.housecode", getAddress().substring(0, 1));
        //01
        event.addProperty("X10.address", getAddress().substring(1, 3));
        //OFF
        event.addProperty("X10.function", getFunction().substring(1, getFunction().length()));
        Freedomotic.sendEvent(event);
        resetEvent();
    }
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.