NEW : REBASE THE ENTIRE WORKING PROJECT
This commit is contained in:
		| @@ -1,126 +0,0 @@ | ||||
| import java.util.HashMap; | ||||
| import java.util.Map; | ||||
| import eu.hsrw.ias.ggd.SensorData | ||||
| import javax.swing.JOptionPane | ||||
| import HttpCall.HttpPost | ||||
| import eu.hsrw.ias.ggd.Notification | ||||
| import eu.hsrw.ias.ggd.Severity; | ||||
| import eu.hsrw.ias.ggd.Device; | ||||
|  | ||||
|  | ||||
| rule "CriticalBattery" | ||||
|     when | ||||
|         device: Device(sensorDatas: sensorData) | ||||
|         sensorData: SensorData(tag == "battery", value < 4.0) from sensorDatas | ||||
|  | ||||
|     then | ||||
|  | ||||
|         String greenhouse1="8bdbe6ae-eafb-4e99-bb01-db8784dd9633"; | ||||
|         HttpPost httpPost = new HttpPost(); | ||||
|         final String criticalBatteryOutput = String.format("{\"id\":\"%s\",\"data\":{\"measured\":[{ \"status\": \"Critical Battery %s in the following sensor %s \", \"battery\": %s}]}}",greenhouse1, sensorData.getValue(),sensorData.getTag(),sensorData.getValue()); | ||||
|         httpPost.HttpCallPost("http://connector.dev.whysor.com/default/insert?access_token=3hosOhAeh4k0XmcuAMQGfYldvTuQDvtAj2PJJ4irKPBefD5Ijij6gnUkLtVLd4fW",criticalBatteryOutput); | ||||
|         insert(new Notification("battery", sensorData, Severity.Critical)); | ||||
|  | ||||
| //        modify(sensorData){ | ||||
| //            setState(Severity.Critical) | ||||
| //        } | ||||
|  | ||||
| end | ||||
|  | ||||
| rule "OptimalBattery" | ||||
|     when | ||||
|         device: Device(sensorDatas: sensorData) | ||||
|         sensorData: SensorData(tag == "battery", value > 4.0) from sensorDatas | ||||
|  | ||||
|     then | ||||
|  | ||||
|         String greenhouse1="8bdbe6ae-eafb-4e99-bb01-db8784dd9633"; | ||||
|         HttpPost httpPost = new HttpPost(); | ||||
|         final String optimalBatteryOutput = String.format("{\"id\":\"%s\",\"data\":{\"measured\":[{ \"status\": \"Optimal Battery %s in the following sensor %s \", \"battery\": %s}]}}",greenhouse1, sensorData.getValue(),sensorData.getTag(),sensorData.getValue()); | ||||
|         httpPost.HttpCallPost("http://connector.dev.whysor.com/default/insert?access_token=3hosOhAeh4k0XmcuAMQGfYldvTuQDvtAj2PJJ4irKPBefD5Ijij6gnUkLtVLd4fW",optimalBatteryOutput); | ||||
|         insert(new Notification("battery", sensorData, Severity.Optimal)); | ||||
|  | ||||
| //        modify(sensorData){ | ||||
| //            setState(Severity.Optimal) | ||||
| //        } | ||||
|  | ||||
| end | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
| //        System.out.println(sensorData.getTag()+" "+sensorData.getValue()); | ||||
| //        System.out.println(device); | ||||
|  | ||||
|         /*String fixedIdG1="8bdbe6ae-eafb-4e99-bb01-db8784dd9633"; | ||||
|         HttpPost httpPost = new HttpPost(); | ||||
| //        System.out.println("Tag: '"+tag+"' has low battery with value: '"+level+"'"); | ||||
|         final String battery = String.format("{\"id\":\"%s\",\"data\":{\"measured\":[{ \"status\": \"Critical! Low Battery %s \", \"battery\": %s}]}}", fixedIdG1,level,level); | ||||
|         httpPost.HttpCallPost("http://connector.dev.whysor.com/default/insert?access_token=3hosOhAeh4k0XmcuAMQGfYldvTuQDvtAj2PJJ4irKPBefD5Ijij6gnUkLtVLd4fW",battery); | ||||
|         System.out.println("Low Battery"+level+"in the following sensor"+tag); | ||||
|         */ | ||||
|         /*HttpPost httpPost = new HttpPost(); | ||||
|  | ||||
|         final String finalOutput; | ||||
|         boolean critical = false; | ||||
|         HashMap<String,Double> test = new HashMap<>(); | ||||
|         if (tag.equals("fd694041-581e-4c2c-9810-505e62b762e6")){ // This matches 70B3D570500042D7 | ||||
|                       if (level < 7.2 && k.equals("battery") ) { | ||||
|                                  JOptionPane.showMessageDialog(null,"Low Battery : "+level+"! Please swap the battery soon of the following sensor:"+tag,"Low Battery Level",JOptionPane.INFORMATION_MESSAGE); | ||||
|                                  final String battery = String.format("{\"id\":\"%s\",\"data\":{\"measured\":[{ \"status\": \"Critical! Low Battery %s \", \"battery\": %s}]}}", fixedIdG1,level,level); | ||||
|                                  httpPost.HttpCallPost("http://connector.dev.whysor.com/default/insert?access_token=3hosOhAeh4k0XmcuAMQGfYldvTuQDvtAj2PJJ4irKPBefD5Ijij6gnUkLtVLd4fW",battery); | ||||
|                                  System.out.println("Low Battery"+level+"in the following sensor"+tag); | ||||
|                                  critical = true; | ||||
|                                  test.put("battery",level); | ||||
|                              } | ||||
|                       if (level > 80 && k.equals("temperature") ) { | ||||
|                                  JOptionPane.showMessageDialog(null,"High Temperature : "+level+" in the following sensor: "+tag+"in the following device id: "+id,"Temperature",JOptionPane.INFORMATION_MESSAGE); | ||||
|                                  final String temperature = String.format("{\"id\":\"%s\",\"data\":{\"measured\":[{ \"status\": \"Critical!High Temperature %s \", \"temperature\": %s}]}}", fixedIdG1,level,level); | ||||
|                                  httpPost.HttpCallPost("http://connector.dev.whysor.com/default/insert?access_token=3hosOhAeh4k0XmcuAMQGfYldvTuQDvtAj2PJJ4irKPBefD5Ijij6gnUkLtVLd4fW",temperature); | ||||
|                                  System.out.println("High Temp"); | ||||
|                                  critical = true; | ||||
|                              } | ||||
|                       if (level > 14.5 && k.equals("precipitation") ) { | ||||
|                                  JOptionPane.showMessageDialog(null,"High water level : "+level+" in the following sensor"+tag,"Precipitation",JOptionPane.INFORMATION_MESSAGE); | ||||
|                                  final String precipitation = String.format("{\"id\":\"%s\",\"data\":{\"measured\":[{ \"status\": \"High water level %s\", \"precipitation\": %s}]}}", fixedIdG1, level,level); | ||||
|                                  httpPost.HttpCallPost("http://connector.dev.whysor.com/default/insert?access_token=3hosOhAeh4k0XmcuAMQGfYldvTuQDvtAj2PJJ4irKPBefD5Ijij6gnUkLtVLd4fW",precipitation); | ||||
|                                  System.out.println("High water level"+level +" in the following sensor:"+tag); | ||||
|                                  critical = true; | ||||
|                                              } | ||||
|                       if (level < 22 && k.equals("soilTemperature") ) { | ||||
|                                           JOptionPane.showMessageDialog(null,"Low soil temperature : "+level+" in the following sensor: "+tag+"in the following device id: "+id,"soil Temperature",JOptionPane.INFORMATION_MESSAGE); | ||||
|                                           final String soilTemperature = String.format("{\"id\":\"%s\",\"data\":{\"measured\":[{ \"status\": \"Low soil temperature %s in the following sensor: %s \", \"soilTemperature\": %s}]}}", fixedIdG1,level, tag,level); | ||||
|                                           httpPost.HttpCallPost("http://connector.dev.whysor.com/default/insert?access_token=3hosOhAeh4k0XmcuAMQGfYldvTuQDvtAj2PJJ4irKPBefD5Ijij6gnUkLtVLd4fW",soilTemperature); | ||||
|                                           System.out.println("Low soil Temperature"+level+" in the following sensor "+tag); | ||||
|                                           critical = true; | ||||
|                                           test.put("soilTemperature",level); | ||||
|                                       } | ||||
|                       if (level <= 30 && k.equals("soilMoisture") ) { | ||||
|                                        JOptionPane.showMessageDialog(null,"Be Careful the soil is dry : "+level+" in the following sensor :"+tag +"in the device:"+id,"Soil Moisture",JOptionPane.INFORMATION_MESSAGE); | ||||
|                                        final String soilMoisture = String.format("{\"id\":\"%s\",\"data\":{\"measured\":[{ \"status\": \"Be Careful the soil sensor %s is dry: %s  \", \"soilMoisture\": %s}]}}", fixedIdG1,tag,level,level); | ||||
|                                        httpPost.HttpCallPost("http://connector.dev.whysor.com/default/insert?access_token=3hosOhAeh4k0XmcuAMQGfYldvTuQDvtAj2PJJ4irKPBefD5Ijij6gnUkLtVLd4fW",soilMoisture); | ||||
|                                        System.out.println("Soil is dry"+level+" in the following sensor"+tag); | ||||
|                                        critical = true; | ||||
|                                    } | ||||
|                       if (level <= 0.57 && level >= 0.11 && k.equals("soilConductivity") ) { | ||||
|                                     JOptionPane.showMessageDialog(null,"Optimal EC levels in the soil : "+level+" in the following sensor"+tag,"Soil Conductivity",JOptionPane.INFORMATION_MESSAGE); | ||||
|                                     final String soilConductivity = String.format("{\"id\":\"%s\",\"data\":{\"measured\":[{ \"status\": \"Optimal EC levels in the soil %s\", \"soilConductivity\": %s}]}}", fixedIdG1, level,level); | ||||
|                                     httpPost.HttpCallPost("http://connector.dev.whysor.com/default/insert?access_token=3hosOhAeh4k0XmcuAMQGfYldvTuQDvtAj2PJJ4irKPBefD5Ijij6gnUkLtVLd4fW",soilConductivity); | ||||
|                                     System.out.println("Optimal EC levels in the soil"+level +" in the following sensor:"+tag); | ||||
|                                     critical = true; | ||||
|                                 } | ||||
|                       if (level > 20 && k.equals("dielectricPermittivity") ) { | ||||
|                                        JOptionPane.showMessageDialog(null,"High dielectricPermittivity : "+level+" in the following sensor"+tag,"dielectricPermittivity",JOptionPane.INFORMATION_MESSAGE); | ||||
|                                        final String dielectricPermittivity = String.format("{\"id\":\"%s\",\"data\":{\"measured\":[{ \"status\": \"High dielectricPermittivity %s\", \"dielectricPermittivity\": %s}]}}", fixedIdG1, level,level); | ||||
|                                        httpPost.HttpCallPost("http://connector.dev.whysor.com/default/insert?access_token=3hosOhAeh4k0XmcuAMQGfYldvTuQDvtAj2PJJ4irKPBefD5Ijij6gnUkLtVLd4fW",dielectricPermittivity); | ||||
|                                        System.out.println("High dielectricPermittivity"+level +" in the following sensor:"+tag); | ||||
|                                        critical = true; | ||||
|                                     } | ||||
| //                      if(critical == true){ | ||||
| //                          finalOutput | ||||
| //                      } | ||||
|                         finalOutput = String.format("{\"id\":\"70B3D570500042D7-status\",\"data\":{\"measured\":[{ \"status\": \"The status of the device 1 is critical\",}]}}"); | ||||
|                         System.out.println(finalOutput); | ||||
|         }*/ | ||||
| @@ -1,24 +0,0 @@ | ||||
| import java.util.HashMap; | ||||
| import java.util.Map; | ||||
| import eu.hsrw.ias.ggd.SensorData | ||||
| import javax.swing.JOptionPane | ||||
| import HttpCall.HttpPost | ||||
| import eu.hsrw.ias.ggd.Notification | ||||
| import eu.hsrw.ias.ggd.Severity; | ||||
| import eu.hsrw.ias.ggd.Device; | ||||
|  | ||||
| rule "CriticalPrecipitation" | ||||
|     when | ||||
|             device: Device(sensorDatas: sensorData) | ||||
|             sensorData: SensorData(tag == "precipitation", value > 15.5) from sensorDatas | ||||
|     then | ||||
|             String greenhouse1="8bdbe6ae-eafb-4e99-bb01-db8784dd9633"; | ||||
|             HttpPost httpPost = new HttpPost(); | ||||
|             final String criticalPrecipitationOutput = String.format("{\"id\":\"%s\",\"data\":{\"measured\":[{ \"status\": \"Critical Precipitation %s in the following sensor %s \", \"precipitation\": %s}]}}",greenhouse1, sensorData.getValue(),sensorData.getTag(),sensorData.getValue()); | ||||
|             httpPost.HttpCallPost("http://connector.dev.whysor.com/default/insert?access_token=3hosOhAeh4k0XmcuAMQGfYldvTuQDvtAj2PJJ4irKPBefD5Ijij6gnUkLtVLd4fW",criticalPrecipitationOutput); | ||||
|             insert(new Notification("precipitation", sensorData, Severity.Warning)); | ||||
|  | ||||
| //            modify(sensorData){ | ||||
| //                setState(Severity.Critical) | ||||
| //            } | ||||
| end | ||||
| @@ -1,7 +0,0 @@ | ||||
| package rules; | ||||
| dialect  "mvel" | ||||
|  | ||||
| rule "CriticalSoilConductivity" | ||||
|     when | ||||
|     then | ||||
| end | ||||
| @@ -1,44 +0,0 @@ | ||||
| import java.util.HashMap; | ||||
| import java.util.Map; | ||||
| import eu.hsrw.ias.ggd.SensorData | ||||
| import javax.swing.JOptionPane | ||||
| import HttpCall.HttpPost | ||||
| import eu.hsrw.ias.ggd.Notification | ||||
| import eu.hsrw.ias.ggd.Severity; | ||||
| import eu.hsrw.ias.ggd.Device; | ||||
|  | ||||
| rule "CriticalSoilMoisture" | ||||
|     when | ||||
|         device: Device(sensorDatas: sensorData) | ||||
|         sensorData: SensorData(tag == "soilMoisture", value < 28.0) from sensorDatas | ||||
|     then | ||||
|                 String greenhouse1="8bdbe6ae-eafb-4e99-bb01-db8784dd9633"; | ||||
|                 HttpPost httpPost = new HttpPost(); | ||||
|                 final String criticalSoilMoistureOutput = String.format("{\"id\":\"%s\",\"data\":{\"measured\":[{ \"status\": \"Critical Soil Moisture %s in the following device %s \", \"soilMoisture\": %s}]}}",greenhouse1, sensorData.getValue(),sensorData.getTag(),sensorData.getValue()); | ||||
|                 httpPost.HttpCallPost("http://connector.dev.whysor.com/default/insert?access_token=3hosOhAeh4k0XmcuAMQGfYldvTuQDvtAj2PJJ4irKPBefD5Ijij6gnUkLtVLd4fW",criticalSoilMoistureOutput); | ||||
|                 final String deviceCritical = String.format("{\"id\":\"%s-status\",\"data\":{\"measured\":[{ \"criticalStatus\": \"The status of %s device  is critical\"}]}}",device.IdMapper(device.getId()),device.getId()); | ||||
|                 httpPost.HttpCallPost("http://connector.dev.whysor.com/default/insert?access_token=3hosOhAeh4k0XmcuAMQGfYldvTuQDvtAj2PJJ4irKPBefD5Ijij6gnUkLtVLd4fW",deviceCritical); | ||||
|                 insert(new Notification("soilMoisture", sensorData, Severity.Critical)); | ||||
|  | ||||
| //        modify(device){ | ||||
| //            setState(Severity.Critical) | ||||
| //        } | ||||
|  | ||||
| end | ||||
|  | ||||
| rule "OptimalSoilMoisture" | ||||
|     when | ||||
|     device: Device(sensorDatas: sensorData) | ||||
|     sensorData: SensorData(tag == "soilMoisture", value > 28.0) from sensorDatas | ||||
|     then | ||||
|                 String greenhouse1="8bdbe6ae-eafb-4e99-bb01-db8784dd9633"; | ||||
|                 HttpPost httpPost = new HttpPost(); | ||||
|                 final String optimalSoilMoistureOutput = String.format("{\"id\":\"%s\",\"data\":{\"measured\":[{ \"status\": \"Optimal Soil Moisture %s in the following device %s \", \"soilMoisture\": %s}]}}",greenhouse1, sensorData.getValue(),sensorData.getTag(),sensorData.getValue()); | ||||
|                 httpPost.HttpCallPost("http://connector.dev.whysor.com/default/insert?access_token=3hosOhAeh4k0XmcuAMQGfYldvTuQDvtAj2PJJ4irKPBefD5Ijij6gnUkLtVLd4fW",optimalSoilMoistureOutput); | ||||
|                 insert(new Notification("soilMoisture", sensorData, Severity.Optimal)); | ||||
|                 //device.setState(Severity.Optimal); | ||||
|  | ||||
| //        modify(device){ | ||||
| //            setState(Severity.Optimal) | ||||
| //        } | ||||
| end | ||||
| @@ -1,7 +0,0 @@ | ||||
| package rules; | ||||
| dialect  "mvel" | ||||
|  | ||||
| rule "CriticalSoilTemperature" | ||||
|     when | ||||
|     then | ||||
| end | ||||
| @@ -1,47 +0,0 @@ | ||||
| import java.util.HashMap; | ||||
| import java.util.Map; | ||||
| import eu.hsrw.ias.ggd.SensorData | ||||
| import javax.swing.JOptionPane | ||||
| import HttpCall.HttpPost | ||||
| import eu.hsrw.ias.ggd.Notification | ||||
| import eu.hsrw.ias.ggd.Severity; | ||||
| import eu.hsrw.ias.ggd.Device; | ||||
|  | ||||
| rule "CriticalTemperature" | ||||
|     when | ||||
|         device: Device(sensorDatas: sensorData) | ||||
|         sensorData: SensorData(tag == "temperature", value < 10.0 || value > 30.0) from sensorDatas | ||||
|     then | ||||
|             String greenhouse1="8bdbe6ae-eafb-4e99-bb01-db8784dd9633"; | ||||
|             HttpPost httpPost = new HttpPost(); | ||||
|             final String criticalTemperatureOutput = String.format("{\"id\":\"%s\",\"data\":{\"measured\":[{ \"status\": \"Critical Temperature %s in the following device %s \", \"temperature\": %s}]}}",greenhouse1, sensorData.getValue(),sensorData.getTag(),sensorData.getValue()); | ||||
|             httpPost.HttpCallPost("http://connector.dev.whysor.com/default/insert?access_token=3hosOhAeh4k0XmcuAMQGfYldvTuQDvtAj2PJJ4irKPBefD5Ijij6gnUkLtVLd4fW",criticalTemperatureOutput); | ||||
|             final String deviceCritical = String.format("{\"id\":\"%s-status\",\"data\":{\"measured\":[{ \"criticalStatus\": \"The status of %s device  is critical\"}]}}",device.IdMapper(device.getId()),device.getId()); | ||||
|             httpPost.HttpCallPost("http://connector.dev.whysor.com/default/insert?access_token=3hosOhAeh4k0XmcuAMQGfYldvTuQDvtAj2PJJ4irKPBefD5Ijij6gnUkLtVLd4fW",deviceCritical); | ||||
|             System.out.println(deviceCritical); | ||||
|             insert(new Notification("temperature", sensorData, Severity.Critical)); | ||||
|  | ||||
| //        modify(device){ | ||||
| //            setState(Severity.Critical) | ||||
| //        } | ||||
|  | ||||
|     end | ||||
|  | ||||
| rule "OptimalTemperature" | ||||
|     when | ||||
|         device: Device(sensorDatas: sensorData) | ||||
|         sensorData: SensorData(tag == "temperature", value > 10.0 && value < 30.0) from sensorDatas | ||||
|     then | ||||
|             String greenhouse1="8bdbe6ae-eafb-4e99-bb01-db8784dd9633"; | ||||
|             HttpPost httpPost = new HttpPost(); | ||||
|             final String optimalTemperatureOutput = String.format("{\"id\":\"%s\",\"data\":{\"measured\":[{ \"status\": \"Optimal Temperature %s in the following device %s \", \"temperature\": %s}]}}",greenhouse1, sensorData.getValue(),sensorData.getTag(),sensorData.getValue()); | ||||
|             httpPost.HttpCallPost("http://connector.dev.whysor.com/default/insert?access_token=3hosOhAeh4k0XmcuAMQGfYldvTuQDvtAj2PJJ4irKPBefD5Ijij6gnUkLtVLd4fW",optimalTemperatureOutput); | ||||
|             insert(new Notification("temperature", sensorData, Severity.Optimal)); | ||||
|             System.out.println("Optimal"); | ||||
|  | ||||
| //        modify(sensorData){ | ||||
| //            setState(Severity.Optimal) | ||||
| //        } | ||||
|  | ||||
|     end | ||||
|  | ||||
| @@ -1,20 +0,0 @@ | ||||
| import java.util.HashMap; | ||||
| import java.util.Map; | ||||
| import eu.hsrw.ias.ggd.SensorData | ||||
| import javax.swing.JOptionPane | ||||
| import HttpCall.HttpPost | ||||
| import eu.hsrw.ias.ggd.Notification | ||||
| import eu.hsrw.ias.ggd.Severity; | ||||
| import eu.hsrw.ias.ggd.Device; | ||||
|  | ||||
| rule "DielectricPermittivity" | ||||
|     when | ||||
|     device: Device(sensorDatas: sensorData) | ||||
|     sensorData: SensorData(tag == "dielectricPermittivity", value > 20.0) from sensorDatas | ||||
|     then | ||||
|             String greenhouse1="8bdbe6ae-eafb-4e99-bb01-db8784dd9633"; | ||||
|             HttpPost httpPost = new HttpPost(); | ||||
|             final String dielectricPermittivityOutput = String.format("{\"id\":\"%s\",\"data\":{\"measured\":[{ \"status\": \"Critical dielectricPermittivity %s in the following sensor %s \", \"dielectricPermittivityOutput\": %s}]}}",greenhouse1, sensorData.getValue(),sensorData.getTag(),sensorData.getValue()); | ||||
|             httpPost.HttpCallPost("http://connector.dev.whysor.com/default/insert?access_token=3hosOhAeh4k0XmcuAMQGfYldvTuQDvtAj2PJJ4irKPBefD5Ijij6gnUkLtVLd4fW",dielectricPermittivityOutput); | ||||
|             insert(new Notification("dielectricPermittivity", sensorData, Severity.Warning)); | ||||
| end | ||||
| @@ -1,31 +0,0 @@ | ||||
| import eu.hsrw.ias.ggd.Device; | ||||
| import eu.hsrw.ias.ggd.Severity; | ||||
| import eu.hsrw.ias.ggd.SensorData; | ||||
|  | ||||
| rule "Sensor of device gone critical" | ||||
| when | ||||
|     sensorData: SensorData(state == Severity.Critical) | ||||
|     device: Device(sensorData contains(sensorData)) | ||||
| then | ||||
|     modify(device){ | ||||
|         setState(Severity.Critical) | ||||
|     } | ||||
|     System.out.println("Device: \n" + | ||||
|         "\tID: '" + device.getId() + "'" + | ||||
|         "\tState: '" + device.getState().toString() + "'" | ||||
|      ); | ||||
|     // Do something the info that a device is gone critical | ||||
| end | ||||
|  | ||||
| rule "Sensor of device gone optimal" | ||||
| when | ||||
|     sensorData: SensorData(state == Severity.Optimal) | ||||
|     device: Device(sensorData contains(sensorData)) | ||||
| then | ||||
|     modify(device){ | ||||
|         setState(Severity.Optimal) | ||||
|     } | ||||
|  | ||||
|     // Device is gone optimal | ||||
| end | ||||
|  | ||||
| @@ -1,25 +0,0 @@ | ||||
| import eu.hsrw.ias.ggd.Greenhouse; | ||||
| import eu.hsrw.ias.ggd.Device; | ||||
| import eu.hsrw.ias.ggd.Severity; | ||||
|  | ||||
| rule "Device of greenhouse gone critical" | ||||
| when | ||||
|     device: Device(state == Severity.Critical) | ||||
|     greenhouse: Greenhouse(devices contains(device)) | ||||
|     //greenhouse: Greenhouse(devices contains(Device(state == Severity.Critical))) | ||||
| then | ||||
|     modify(greenhouse){ | ||||
|         setState(Severity.Critical) | ||||
|     } | ||||
|     System.out.println("Greenhouse: '" + greenhouse.getId() + "' is '" + greenhouse.getState().toString() + "'"); | ||||
| end | ||||
|  | ||||
| rule "Device of greenhouse has gone optimal" | ||||
| when | ||||
|     device: Device(state == Severity.Optimal) | ||||
|     greenhouse: Greenhouse(devices contains(device)) | ||||
| then | ||||
|     modify(greenhouse){ | ||||
|         setState(Severity.Optimal) | ||||
|     } | ||||
| end | ||||
| @@ -1,15 +0,0 @@ | ||||
| import eu.hsrw.ias.ggd.Notification; | ||||
| import eu.hsrw.ias.ggd.Severity | ||||
| import HttpCall.HttpPost; | ||||
| import eu.hsrw.ias.ggd.Device; | ||||
|  | ||||
| rule "Green House Optimal" | ||||
| when | ||||
|     warning: Notification(severity == Severity.Optimal) | ||||
|  | ||||
| then | ||||
|     HttpPost httpPost = new HttpPost(); | ||||
|     final String optimalGreenhouse = String.format("{\"id\":\"germes-greenhouse-status\",\"data\":{\"measured\":[{ \"status\": \"The status of the greenhouse is optimal\"}]}}"); | ||||
| //    httpPost.HttpCallPost("http://connector.dev.whysor.com/default/insert?access_token=3hosOhAeh4k0XmcuAMQGfYldvTuQDvtAj2PJJ4irKPBefD5Ijij6gnUkLtVLd4fW",optimalGreenhouse); | ||||
|     System.out.println("Green House optimal, because of: '"+warning.getType()+"'"); | ||||
| end | ||||
| @@ -1,15 +0,0 @@ | ||||
| import eu.hsrw.ias.ggd.Notification; | ||||
| import eu.hsrw.ias.ggd.Severity | ||||
| import HttpCall.HttpPost; | ||||
|  | ||||
| //rule "Green House Critical" | ||||
| //when | ||||
| //    warning: Notification(severity > Severity.Warning) | ||||
| //then | ||||
| //    HttpPost httpPost = new HttpPost(); | ||||
| //    final String criticalGreenhouse = String.format("{\"id\":\"germes-greenhouse-status\",\"data\":{\"measured\":[{ \"status\": \"The status of the greenhouse is critical\"}]}}"); | ||||
| //    httpPost.HttpCallPost("http://connector.dev.whysor.com/default/insert?access_token=3hosOhAeh4k0XmcuAMQGfYldvTuQDvtAj2PJJ4irKPBefD5Ijij6gnUkLtVLd4fW",criticalGreenhouse); | ||||
| //    System.out.println(criticalGreenhouse); | ||||
| //    System.out.println("Green House critical, because of: '"+warning.getType()+"'"); | ||||
| // | ||||
| //end | ||||
		Reference in New Issue
	
	Block a user