forked from kevin.shehu/GGD
NEW : First working version of GGD
parent
5a14e0eab8
commit
673f0c09f5
|
@ -1 +1 @@
|
|||
[{"sensorId":"09a91c61-6572-4476-8bf1-310a2fb2eb02","datetimeMeasure":"2021-12-10T15:31:31.804Z","value":3.68,"groupId":null,"metadata":null}]externalTemperature,f9bb4a5c-f783-4bcf-8c34-0a7c3dd5a632
|
||||
[{"sensorId":"09a91c61-6572-4476-8bf1-310a2fb2eb02","datetimeMeasure":"2021-12-14T13:49:51.261Z","value":8.87,"groupId":null,"metadata":null}]externalTemperature,f9bb4a5c-f783-4bcf-8c34-0a7c3dd5a632
|
|
@ -1 +1 @@
|
|||
[{"sensorId":"1f49de66-0921-4583-ae68-ff0fcc070bd1","datetimeMeasure":"2021-12-10T15:34:04.506Z","value":20.92,"groupId":null,"metadata":null}]dielectricPermittivity,fd694041-581e-4c2c-9810-505e62b762e6
|
||||
[{"sensorId":"1f49de66-0921-4583-ae68-ff0fcc070bd1","datetimeMeasure":"2021-12-14T13:47:17.012Z","value":21.87,"groupId":null,"metadata":null}]dielectricPermittivity,fd694041-581e-4c2c-9810-505e62b762e6
|
|
@ -1 +1 @@
|
|||
[{"sensorId":"22e5b1b0-b28c-4aa1-97c7-94ff12c51384","datetimeMeasure":"2021-12-10T15:34:04.506Z","value":4.1,"groupId":null,"metadata":null}]soilTemperature,fd694041-581e-4c2c-9810-505e62b762e6
|
||||
[{"sensorId":"22e5b1b0-b28c-4aa1-97c7-94ff12c51384","datetimeMeasure":"2021-12-14T13:47:17.012Z","value":9,"groupId":null,"metadata":null}]soilTemperature,fd694041-581e-4c2c-9810-505e62b762e6
|
|
@ -1 +1 @@
|
|||
[{"sensorId":"3b6a8c15-5cea-4994-954d-5b25c22e2c32","datetimeMeasure":"2021-12-10T15:34:04.506Z","value":35.7,"groupId":null,"metadata":null}]soilMoisture,fd694041-581e-4c2c-9810-505e62b762e6
|
||||
[{"sensorId":"3b6a8c15-5cea-4994-954d-5b25c22e2c32","datetimeMeasure":"2021-12-14T13:47:17.012Z","value":36.8,"groupId":null,"metadata":null}]soilMoisture,fd694041-581e-4c2c-9810-505e62b762e6
|
|
@ -1 +1 @@
|
|||
[{"sensorId":"5209815d-974f-4729-ae1a-06bd1000db67","datetimeMeasure":"2021-12-10T15:34:04.506Z","value":0.07,"groupId":null,"metadata":null}]soilConductivity,fd694041-581e-4c2c-9810-505e62b762e6
|
||||
[{"sensorId":"5209815d-974f-4729-ae1a-06bd1000db67","datetimeMeasure":"2021-12-14T13:47:17.012Z","value":0.07,"groupId":null,"metadata":null}]soilConductivity,fd694041-581e-4c2c-9810-505e62b762e6
|
|
@ -1 +1 @@
|
|||
[{"sensorId":"65e95c11-ec15-4039-840a-e9be3d77ca63","datetimeMeasure":"2021-12-10T15:29:08.613Z","value":748.8,"groupId":null,"metadata":null}]precipitation,e8c3fca3-c5cd-48e7-9224-0f8c294fa3c0
|
||||
[{"sensorId":"65e95c11-ec15-4039-840a-e9be3d77ca63","datetimeMeasure":"2021-12-14T13:48:01.273Z","value":753.4,"groupId":null,"metadata":null}]precipitation,e8c3fca3-c5cd-48e7-9224-0f8c294fa3c0
|
|
@ -1 +1 @@
|
|||
[{"sensorId":"69bcaae0-9ccd-4342-8a71-c72dca37cfe9","datetimeMeasure":"2021-12-10T15:34:09.418Z","value":4.721,"groupId":null,"metadata":null}]battery,6c9efd4a-db04-453d-8ab8-d480ec97dd26
|
||||
[{"sensorId":"69bcaae0-9ccd-4342-8a71-c72dca37cfe9","datetimeMeasure":"2021-12-14T13:47:24.324Z","value":4.796,"groupId":null,"metadata":null}]battery,6c9efd4a-db04-453d-8ab8-d480ec97dd26
|
|
@ -1 +1 @@
|
|||
[{"sensorId":"812c6e62-e855-424b-8ec1-78fb424a94b5","datetimeMeasure":"2021-12-10T15:29:08.613Z","value":35.5,"groupId":null,"metadata":null}]soilMoisture,e8c3fca3-c5cd-48e7-9224-0f8c294fa3c0
|
||||
[{"sensorId":"812c6e62-e855-424b-8ec1-78fb424a94b5","datetimeMeasure":"2021-12-14T13:48:01.273Z","value":36.4,"groupId":null,"metadata":null}]soilMoisture,e8c3fca3-c5cd-48e7-9224-0f8c294fa3c0
|
|
@ -1 +1 @@
|
|||
[{"sensorId":"88c8442f-62b9-4952-b28c-73790a555060","datetimeMeasure":"2021-12-10T15:31:31.804Z","value":5.132,"groupId":null,"metadata":null}]battery,f9bb4a5c-f783-4bcf-8c34-0a7c3dd5a632
|
||||
[{"sensorId":"88c8442f-62b9-4952-b28c-73790a555060","datetimeMeasure":"2021-12-14T13:49:51.261Z","value":5.17,"groupId":null,"metadata":null}]battery,f9bb4a5c-f783-4bcf-8c34-0a7c3dd5a632
|
|
@ -1 +1 @@
|
|||
[{"sensorId":"adba09f9-ab84-4252-bf1a-ac49b1b6bdd3","datetimeMeasure":"2021-12-10T15:34:04.506Z","value":5.796,"groupId":null,"metadata":null}]battery,fd694041-581e-4c2c-9810-505e62b762e6
|
||||
[{"sensorId":"adba09f9-ab84-4252-bf1a-ac49b1b6bdd3","datetimeMeasure":"2021-12-14T13:47:17.012Z","value":5.79,"groupId":null,"metadata":null}]battery,fd694041-581e-4c2c-9810-505e62b762e6
|
|
@ -1 +1 @@
|
|||
[{"sensorId":"bc08edce-d214-40db-ba51-a0802243c235","datetimeMeasure":"2021-12-10T15:31:31.804Z","value":38.3,"groupId":null,"metadata":null}]soilMoisture,f9bb4a5c-f783-4bcf-8c34-0a7c3dd5a632
|
||||
[{"sensorId":"bc08edce-d214-40db-ba51-a0802243c235","datetimeMeasure":"2021-12-14T13:49:51.261Z","value":39.5,"groupId":null,"metadata":null}]soilMoisture,f9bb4a5c-f783-4bcf-8c34-0a7c3dd5a632
|
File diff suppressed because one or more lines are too long
|
@ -1 +1 @@
|
|||
[{"sensorId":"f75934dc-af98-4206-a5bd-22d23dd5f268","datetimeMeasure":"2021-12-10T15:34:09.418Z","value":3.68,"groupId":null,"metadata":null}]temperature,6c9efd4a-db04-453d-8ab8-d480ec97dd26
|
||||
[{"sensorId":"f75934dc-af98-4206-a5bd-22d23dd5f268","datetimeMeasure":"2021-12-14T13:47:24.324Z","value":9.12,"groupId":null,"metadata":null}]temperature,6c9efd4a-db04-453d-8ab8-d480ec97dd26
|
|
@ -1 +1 @@
|
|||
[{"sensorId":"ff6f11e0-c969-4cbb-829c-f44a13683918","datetimeMeasure":"2021-12-10T15:34:09.418Z","value":72.5,"groupId":null,"metadata":null}]precipitation,6c9efd4a-db04-453d-8ab8-d480ec97dd26
|
||||
[{"sensorId":"ff6f11e0-c969-4cbb-829c-f44a13683918","datetimeMeasure":"2021-12-14T13:47:24.324Z","value":75.75,"groupId":null,"metadata":null}]precipitation,6c9efd4a-db04-453d-8ab8-d480ec97dd26
|
|
@ -1 +1 @@
|
|||
[{"sensorId":"ffca826c-d1b5-4ac8-869a-ec0da15d9076","datetimeMeasure":"2021-12-10T15:29:08.613Z","value":5.106,"groupId":null,"metadata":null}]battery,e8c3fca3-c5cd-48e7-9224-0f8c294fa3c0
|
||||
[{"sensorId":"ffca826c-d1b5-4ac8-869a-ec0da15d9076","datetimeMeasure":"2021-12-14T13:48:01.273Z","value":5.146,"groupId":null,"metadata":null}]battery,e8c3fca3-c5cd-48e7-9224-0f8c294fa3c0
|
|
@ -1 +1 @@
|
|||
VSiZpQv9EEyXdVzTcudeG2GRo5hM5YGaDaMcdS3qY8hXKb34q0KypT9qLfr0BkOg
|
||||
b2MHpGkJdYo5Y7ZITUql9wVi8S6dN7see7Ki4QgkBiTJF5SBtr8MG5DJSsj0Z18x
|
|
@ -24,6 +24,26 @@ public class Device {
|
|||
return id;
|
||||
}
|
||||
|
||||
public String setId(String id) {
|
||||
this.id = id;
|
||||
return id;
|
||||
}
|
||||
public String IdMapper(String id){
|
||||
switch (id) {
|
||||
case "fd694041-581e-4c2c-9810-505e62b762e6":
|
||||
return setId("70B3D570500042D7");
|
||||
case "e8c3fca3-c5cd-48e7-9224-0f8c294fa3c0":
|
||||
return setId("70B3D57050004EF4");
|
||||
|
||||
case "f9bb4a5c-f783-4bcf-8c34-0a7c3dd5a632":
|
||||
return setId("70B3D57050006223");
|
||||
case "6c9efd4a-db04-453d-8ab8-d480ec97dd26":
|
||||
return setId("70B3D5705000623C");
|
||||
default:
|
||||
return "NO Working id was found";
|
||||
}
|
||||
}
|
||||
|
||||
public Boolean hasTag(String tag) {
|
||||
for (SensorData sensorData : data) {
|
||||
if (sensorData.getTag() == tag) return true;
|
||||
|
@ -56,4 +76,9 @@ public class Device {
|
|||
|
||||
return str + "]";
|
||||
}
|
||||
|
||||
public Device(String id, List<SensorData> data) {
|
||||
this.id = id;
|
||||
this.data = data;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,18 +10,18 @@ import eu.hsrw.ias.ggd.Device;
|
|||
|
||||
rule "Critical Battery"
|
||||
when
|
||||
//$t: HashMap( contains(Device(sensorData.contains(SensorData(tag == "battery")) )))
|
||||
//device: Device()
|
||||
device: Device(sensorDatas: sensorData)
|
||||
sensorData: SensorData(tag == "battery", value < 4.0) from sensorDatas
|
||||
|
||||
sensorData: SensorData(tag == "battery", value < 5.0) from sensorDatas
|
||||
//device: Device(hasTag("battery") == true) from $tMap
|
||||
// e: Map.Entry(k:key == "battery", v:value) from $tMap.entrySet()
|
||||
//s: SensorData(tag == "battery") from device.getSensorData()
|
||||
then
|
||||
//insertLogical(new Notification("battery", s, Severity.Warning));
|
||||
System.out.println(sensorData.getTag()+" "+sensorData.getValue());
|
||||
|
||||
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.Info));
|
||||
// System.out.println(sensorData.getTag()+" "+sensorData.getValue());
|
||||
// System.out.println(device);
|
||||
|
||||
/*String fixedIdG1="8bdbe6ae-eafb-4e99-bb01-db8784dd9633";
|
||||
HttpPost httpPost = new HttpPost();
|
||||
|
@ -95,3 +95,4 @@ rule "Critical Battery"
|
|||
}*/
|
||||
|
||||
end
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
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);
|
||||
insert(new Notification("soilMoisture", sensorData, Severity.Critical));
|
||||
end
|
|
@ -0,0 +1,23 @@
|
|||
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));
|
||||
end
|
|
@ -0,0 +1,20 @@
|
|||
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.Info));
|
||||
end
|
|
@ -1,9 +1,15 @@
|
|||
import eu.hsrw.ias.ggd.Notification;
|
||||
import eu.hsrw.ias.ggd.Severity;
|
||||
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
|
|
@ -1,41 +0,0 @@
|
|||
import java.util.List;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Iterator;
|
||||
import eu.hsrw.ias.ggd.ScheduledTask
|
||||
import eu.hsrw.ias.ggd.SensorData
|
||||
import javax.swing.JOptionPane
|
||||
import HttpCall.HttpPost
|
||||
import Files.ReadFile
|
||||
import Credentials.UserCredentials;
|
||||
|
||||
rule "Low Battery Level"
|
||||
|
||||
when
|
||||
// This is like declaring a variable tMap where is Map and contains a key with name battery
|
||||
$tMap: HashMap( containsKey("battery") == true )
|
||||
//In this part we are iterating through the entire map
|
||||
e: Map.Entry(k:key, v:value) from $tMap.entrySet()
|
||||
// for(e <- $tMap) {
|
||||
SensorData(level: value ) from v
|
||||
SensorData(tag: sensorTag) from v
|
||||
SensorData(id: deviceId) from v
|
||||
then
|
||||
HttpPost httpPost = new HttpPost();
|
||||
String fixedIdG1="8bdbe6ae-eafb-4e99-bb01-db8784dd9633";
|
||||
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 data = String.format("{\"id\":\"%s\",\"data\":{\"measured\":[{ \"status\": \"Low Battery %s in the following sensor: %s \", \"battery\": %s}]}}", fixedIdG1,level, tag,level);
|
||||
httpPost.HttpCallPost("http://connector.dev.whysor.com/default/insert?access_token=3hosOhAeh4k0XmcuAMQGfYldvTuQDvtAj2PJJ4irKPBefD5Ijij6gnUkLtVLd4fW",data);
|
||||
System.out.println("Low Battery"+level+"in the following sensor"+tag);
|
||||
}
|
||||
// else {
|
||||
// JOptionPane.showMessageDialog(null,"Battery OK : "+level+"! in the following sensor :"+tag,"Battery OK",JOptionPane.INFORMATION_MESSAGE);
|
||||
// final String data1 = String.format("{\"id\":\"%s\",\"data\":{\"measured\":[{ \"status\": \"Battery OK %s in the following sensor: %s \", \"battery\": %s}]}}", fixedIdG1,level, tag,level);
|
||||
//// httpPost.HttpCallPost("http://connector.dev.whysor.com/default/insert?access_token=3hosOhAeh4k0XmcuAMQGfYldvTuQDvtAj2PJJ4irKPBefD5Ijij6gnUkLtVLd4fW",data1);
|
||||
// System.out.println(data1);
|
||||
// }
|
||||
// System.out.println($tMap);
|
||||
// System.out.println(e.getKey() + " " + String.valueOf(level)+" " + tag+" "+id);
|
||||
|
||||
end
|
|
@ -11,11 +11,17 @@ import eu.hsrw.ias.ggd.Device;
|
|||
rule "Critical Battery"
|
||||
when
|
||||
device: Device(sensorDatas: sensorData)
|
||||
sensorData: SensorData(tag == "battery", value < 5.0) from sensorDatas
|
||||
then
|
||||
insert(new Notification("batte2ry", sensorData, Severity.Warning));
|
||||
System.out.println(sensorData.getTag()+" "+sensorData.getValue());
|
||||
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.Info));
|
||||
// System.out.println(sensorData.getTag()+" "+sensorData.getValue());
|
||||
// System.out.println(device);
|
||||
|
||||
/*String fixedIdG1="8bdbe6ae-eafb-4e99-bb01-db8784dd9633";
|
||||
HttpPost httpPost = new HttpPost();
|
||||
|
@ -89,3 +95,4 @@ rule "Critical Battery"
|
|||
}*/
|
||||
|
||||
end
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
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);
|
||||
insert(new Notification("soilMoisture", sensorData, Severity.Critical));
|
||||
end
|
|
@ -0,0 +1,23 @@
|
|||
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));
|
||||
end
|
|
@ -1,33 +1,20 @@
|
|||
import java.util.List;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Iterator;
|
||||
import eu.hsrw.ias.ggd.ScheduledTask;
|
||||
import javax.swing.JOptionPane
|
||||
import HttpCall.HttpPost;
|
||||
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
|
||||
$tMap: HashMap( containsKey("dielectricPermittivity") == true )
|
||||
//In this part we are iterating through the entire map
|
||||
e: Map.Entry(k:key, v:value) from $tMap.entrySet()
|
||||
// for(e <- $tMap) {
|
||||
SensorData(level: value ) from v
|
||||
SensorData(tag: sensorTag) from v
|
||||
SensorData(id: deviceId) from v
|
||||
device: Device(sensorDatas: sensorData)
|
||||
sensorData: SensorData(tag == "dielectricPermittivity", value > 20.0) from sensorDatas
|
||||
then
|
||||
String fixedIdG1="8bdbe6ae-eafb-4e99-bb01-db8784dd9633";
|
||||
String greenhouse1="8bdbe6ae-eafb-4e99-bb01-db8784dd9633";
|
||||
HttpPost httpPost = new HttpPost();
|
||||
if (level > 14.5 && k.equals("dielectricPermittivity") ) {
|
||||
JOptionPane.showMessageDialog(null,"High dielectricPermittivity : "+level+" in the following sensor"+tag,"dielectricPermittivity",JOptionPane.INFORMATION_MESSAGE);
|
||||
final String data = 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",data);
|
||||
System.out.println("High dielectricPermittivity"+level +" in the following sensor:"+tag);
|
||||
|
||||
}
|
||||
System.out.println(k);
|
||||
System.out.println(level);
|
||||
System.out.println(tag);
|
||||
System.out.println(id);
|
||||
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));
|
||||
end
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
package rules;
|
||||
|
||||
|
||||
rule "ExternalTemperature"
|
||||
when
|
||||
then
|
||||
end
|
|
@ -1,33 +0,0 @@
|
|||
import java.util.List;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Iterator;
|
||||
import eu.hsrw.ias.ggd.ScheduledTask;
|
||||
import javax.swing.JOptionPane
|
||||
import HttpCall.HttpPost;
|
||||
import eu.hsrw.ias.ggd.SensorData
|
||||
|
||||
rule "Precipitation"
|
||||
when
|
||||
$tMap: HashMap( containsKey("precipitation") == true )
|
||||
//In this part we are iterating through the entire map
|
||||
e: Map.Entry(k:key, v:value) from $tMap.entrySet()
|
||||
// for(e <- $tMap) {
|
||||
SensorData(level: value ) from v
|
||||
SensorData(tag: sensorTag) from v
|
||||
SensorData(id: deviceId) from v
|
||||
then
|
||||
String fixedIdG1="8bdbe6ae-eafb-4e99-bb01-db8784dd9633";
|
||||
HttpPost httpPost = new HttpPost();
|
||||
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 data = 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",data);
|
||||
System.out.println("High water level"+level +" in the following sensor:"+tag);
|
||||
|
||||
}
|
||||
// System.out.println(k);
|
||||
// System.out.println(level);
|
||||
// System.out.println(tag);
|
||||
// System.out.println(id);
|
||||
end
|
|
@ -1,39 +0,0 @@
|
|||
import java.util.List;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Iterator;
|
||||
import eu.hsrw.ias.ggd.ScheduledTask;
|
||||
import javax.swing.JOptionPane
|
||||
import HttpCall.HttpPost;
|
||||
import eu.hsrw.ias.ggd.SensorData
|
||||
|
||||
rule "Optimal EC levels in the soil"
|
||||
|
||||
when
|
||||
$tMap: HashMap( containsKey("soilConductivity") == true )
|
||||
//In this part we are iterating through the entire map
|
||||
e: Map.Entry(k:key, v:value) from $tMap.entrySet()
|
||||
// for(e <- $tMap) {
|
||||
SensorData(level: value ) from v
|
||||
SensorData(tag: sensorTag) from v
|
||||
SensorData(id: deviceId) from v
|
||||
then
|
||||
String fixedIdG1="8bdbe6ae-eafb-4e99-bb01-db8784dd9633";
|
||||
HttpPost httpPost = new HttpPost();
|
||||
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 data = 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",data);
|
||||
System.out.println("Optimal EC levels in the soil"+level +" in the following sensor:"+tag);
|
||||
}
|
||||
// else {
|
||||
// JOptionPane.showMessageDialog(null,"Non Optimal EC levels in the soil : "+level+" in the following sensor:"+tag,"Soil Conductivity",JOptionPane.INFORMATION_MESSAGE);
|
||||
// final String data1 = String.format("{\"id\":\"%s\",\"data\":{\"measured\":[{ \"status\": \"Non Optimal EC levels in the soil %s\", \"soil Conductivity\": %s}]}}", fixedIdG1, level,level);
|
||||
//// httpPost.HttpCallPost("http://connector.dev.whysor.com/default/insert?access_token=3hosOhAeh4k0XmcuAMQGfYldvTuQDvtAj2PJJ4irKPBefD5Ijij6gnUkLtVLd4fW",data1);
|
||||
// System.out.println(data1);
|
||||
// }
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,40 +0,0 @@
|
|||
import java.util.List;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Iterator;
|
||||
import eu.hsrw.ias.ggd.ScheduledTask;
|
||||
import javax.swing.JOptionPane;
|
||||
import HttpCall.HttpPost;
|
||||
import eu.hsrw.ias.ggd.SensorData
|
||||
|
||||
|
||||
rule "Soil Moisture"
|
||||
|
||||
when
|
||||
$tMap: HashMap( containsKey("soilMoisture") == true )
|
||||
//In this part we are iterating through the entire map
|
||||
e: Map.Entry(k:key, v:value) from $tMap.entrySet()
|
||||
// for(e <- $tMap) {
|
||||
SensorData(level: value ) from v
|
||||
SensorData(tag: sensorTag) from v
|
||||
SensorData(id : deviceId) from v
|
||||
|
||||
then
|
||||
HttpPost httpPost = new HttpPost();
|
||||
String fixedIdG1="8bdbe6ae-eafb-4e99-bb01-db8784dd9633";
|
||||
|
||||
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 dataInfo = 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",dataInfo);
|
||||
System.out.println("Soil is dry"+level+" in the following sensor"+tag);
|
||||
}
|
||||
else if (level <= 80 && k.equals("soilMoisture") ) {
|
||||
JOptionPane.showMessageDialog(null,"Optimal moisture in the soil : "+level+" in the following sensor"+tag,"Soil Moisture",JOptionPane.INFORMATION_MESSAGE);
|
||||
final String data = String.format("{\"id\":\"%s\",\"data\":{\"measured\":[{ \"status\": \"Be Careful the soil sensor %s is wet: %s\", \"soilMoisture\": %s}]}}", fixedIdG1,tag,level,level);
|
||||
httpPost.HttpCallPost("http://connector.dev.whysor.com/default/insert?access_token=3hosOhAeh4k0XmcuAMQGfYldvTuQDvtAj2PJJ4irKPBefD5Ijij6gnUkLtVLd4fW",data);
|
||||
System.out.println("Optimal moisture in the soil"+level+" in the following sensor"+tag);
|
||||
}
|
||||
end
|
||||
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
import java.util.List;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Iterator;
|
||||
import eu.hsrw.ias.ggd.ScheduledTask;
|
||||
import javax.swing.JOptionPane;
|
||||
import HttpCall.HttpPost;
|
||||
import eu.hsrw.ias.ggd.SensorData
|
||||
|
||||
|
||||
rule "SoilTemperature"
|
||||
|
||||
when
|
||||
$tMap: HashMap( containsKey("soilTemperature") == true )
|
||||
e: Map.Entry(k:key, v:value) from $tMap.entrySet()
|
||||
SensorData(level: value ) from v
|
||||
SensorData(tag: sensorTag) from v
|
||||
SensorData(id : deviceId) from v
|
||||
then
|
||||
|
||||
String fixedIdG1="8bdbe6ae-eafb-4e99-bb01-db8784dd9633";
|
||||
HttpPost httpPost = new HttpPost();
|
||||
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 data = 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",data);
|
||||
System.out.println("Low soil Temperature"+level+" in the following sensor "+tag);
|
||||
}
|
||||
end
|
|
@ -1,40 +0,0 @@
|
|||
import java.util.List;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Iterator;
|
||||
import eu.hsrw.ias.ggd.ScheduledTask
|
||||
import eu.hsrw.ias.ggd.SensorData
|
||||
import javax.swing.JOptionPane
|
||||
import HttpCall.HttpPost
|
||||
import Files.ReadFile
|
||||
import Credentials.UserCredentials;
|
||||
|
||||
rule "Temperature Check"
|
||||
|
||||
when
|
||||
// This is like declaring a variable tMap where is Map and contains a key with name battery
|
||||
$tMap: HashMap( containsKey("temperature") == true )
|
||||
//In this part we are iterating through the entire map
|
||||
e: Map.Entry(k:key, v:value) from $tMap.entrySet()
|
||||
// for(e <- $tMap) {
|
||||
SensorData(level: value ) from v
|
||||
SensorData(tag: sensorTag) from v
|
||||
SensorData(id: deviceId) from v
|
||||
then
|
||||
String fixedIdG1="8bdbe6ae-eafb-4e99-bb01-db8784dd9633";
|
||||
HttpPost httpPost = new HttpPost();
|
||||
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 data = String.format("{\"id\":\"%s\",\"data\":{\"measured\":[{ \"status\": \"High Temperature %s in the following sensor: %s \", \"temperature\": %s}]}}", fixedIdG1,level, tag,level);
|
||||
httpPost.HttpCallPost("http://connector.dev.whysor.com/default/insert?access_token=3hosOhAeh4k0XmcuAMQGfYldvTuQDvtAj2PJJ4irKPBefD5Ijij6gnUkLtVLd4fW",data);
|
||||
System.out.println("High Temp");
|
||||
}
|
||||
else if(level < 20 && k.equals("temperature")){
|
||||
JOptionPane.showMessageDialog(null,"Low Temperature : "+level+" in the following sensor: "+tag+"in the following device id: "+id,"Temperature",JOptionPane.INFORMATION_MESSAGE);
|
||||
final String data1 = String.format("{\"id\":\"%s\",\"data\":{\"measured\":[{ \"status\": \"Low Temperature %s in the following sensor: %s \", \"temperature\": %s}]}}",fixedIdG1,level, tag,level);
|
||||
httpPost.HttpCallPost("http://connector.dev.whysor.com/default/insert?access_token=3hosOhAeh4k0XmcuAMQGfYldvTuQDvtAj2PJJ4irKPBefD5Ijij6gnUkLtVLd4fW",data1);
|
||||
System.out.println("Low Temp "+tag);
|
||||
}
|
||||
|
||||
|
||||
end
|
|
@ -1,9 +1,15 @@
|
|||
import eu.hsrw.ias.ggd.Notification;
|
||||
import eu.hsrw.ias.ggd.Severity;
|
||||
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
|
Loading…
Reference in New Issue