ADD : New feature modify the knowledgebase
This commit is contained in:
		| @@ -8,7 +8,7 @@ import eu.hsrw.ias.ggd.Severity; | ||||
| import eu.hsrw.ias.ggd.Device; | ||||
|  | ||||
|  | ||||
| rule "Critical Battery" | ||||
| rule "CriticalBattery" | ||||
|     when | ||||
|         device: Device(sensorDatas: sensorData) | ||||
|         sensorData: SensorData(tag == "battery", value < 4.0) from sensorDatas | ||||
| @@ -19,7 +19,38 @@ rule "Critical Battery" | ||||
|         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.Info)); | ||||
|         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); | ||||
|  | ||||
| @@ -92,7 +123,4 @@ rule "Critical Battery" | ||||
| //                      } | ||||
|                         finalOutput = String.format("{\"id\":\"70B3D570500042D7-status\",\"data\":{\"measured\":[{ \"status\": \"The status of the device 1 is critical\",}]}}"); | ||||
|                         System.out.println(finalOutput); | ||||
|         }*/ | ||||
|  | ||||
| end | ||||
|  | ||||
|         }*/ | ||||
| @@ -9,12 +9,36 @@ import eu.hsrw.ias.ggd.Device; | ||||
|  | ||||
| rule "CriticalSoilMoisture" | ||||
|     when | ||||
|     device: Device(sensorDatas: sensorData) | ||||
|     sensorData: SensorData(tag == "soilMoisture", value < 28.0) from sensorDatas | ||||
|         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 | ||||
| @@ -10,14 +10,38 @@ 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 | ||||
|         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()); | ||||
|             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 | ||||
|  | ||||
|   | ||||
| @@ -16,5 +16,5 @@ rule "DielectricPermittivity" | ||||
|             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.Info)); | ||||
|             insert(new Notification("dielectricPermittivity", sensorData, Severity.Warning)); | ||||
| end | ||||
|   | ||||
| @@ -2,14 +2,14 @@ import eu.hsrw.ias.ggd.Notification; | ||||
| import eu.hsrw.ias.ggd.Severity | ||||
| import HttpCall.HttpPost; | ||||
|  | ||||
| rule "Green House Critical" | ||||
| when | ||||
|     warning: Notification(severity > Severity.Info) | ||||
| 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 | ||||
| //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