forked from kevin.shehu/GGD
ADD : New feature modify the knowledgebase
parent
673f0c09f5
commit
64e7af7f13
|
@ -43,17 +43,18 @@ public class BoxCall4Partner {
|
||||||
cName = readFile.ReadFromFile(homeRoot + cName + ".txt");
|
cName = readFile.ReadFromFile(homeRoot + cName + ".txt");
|
||||||
ArrayList<String> listOfCompanyOutputs = new ArrayList<String>();
|
ArrayList<String> listOfCompanyOutputs = new ArrayList<String>();
|
||||||
|
|
||||||
String[] arrayOfCompany = cName.split(",");
|
String[] listOfCompanyDevices = cName.split(",");
|
||||||
for (String iterator : arrayOfCompany) {
|
for (String companyExternalID : listOfCompanyDevices) {
|
||||||
for (int i = 0; i < jsonarray.length(); i++) {
|
for (int i = 0; i < jsonarray.length(); i++) {
|
||||||
JSONObject jsonobject = jsonarray.getJSONObject(i);
|
JSONObject deviceFromCall = jsonarray.getJSONObject(i);
|
||||||
String jsonExternalID = jsonobject.getString("externalId");
|
String deviceExternalID = deviceFromCall.getString("externalId");
|
||||||
if (iterator.equals(jsonExternalID)) {
|
|
||||||
String jsonID = jsonobject.getString("id");
|
if (companyExternalID.equals(deviceExternalID)) {
|
||||||
|
String backendID = deviceFromCall.getString("id");
|
||||||
// String deviceID = jsonobject.getString("deviceId");
|
// String deviceID = jsonobject.getString("deviceId");
|
||||||
String companyOutput = httpCall.HttpGetCall(devUrl + "devices/" + jsonID + "/sensors" + "?access_token=" + token, token);
|
String companyOutput = httpCall.HttpGetCall(devUrl + "devices/" + jsonID + "/sensors" + "?access_token=" + token, token);
|
||||||
listOfCompanyOutputs.add(companyOutput);
|
listOfCompanyOutputs.add(companyOutput);
|
||||||
writingIntoFile.WriteFile(homeRoot + iterator + ".json", companyOutput);
|
writingIntoFile.WriteFile(homeRoot + companyExternalID + ".json", companyOutput);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,6 @@ public class Device {
|
||||||
return setId("70B3D570500042D7");
|
return setId("70B3D570500042D7");
|
||||||
case "e8c3fca3-c5cd-48e7-9224-0f8c294fa3c0":
|
case "e8c3fca3-c5cd-48e7-9224-0f8c294fa3c0":
|
||||||
return setId("70B3D57050004EF4");
|
return setId("70B3D57050004EF4");
|
||||||
|
|
||||||
case "f9bb4a5c-f783-4bcf-8c34-0a7c3dd5a632":
|
case "f9bb4a5c-f783-4bcf-8c34-0a7c3dd5a632":
|
||||||
return setId("70B3D57050006223");
|
return setId("70B3D57050006223");
|
||||||
case "6c9efd4a-db04-453d-8ab8-d480ec97dd26":
|
case "6c9efd4a-db04-453d-8ab8-d480ec97dd26":
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package eu.hsrw.ias.ggd;
|
package eu.hsrw.ias.ggd;
|
||||||
|
|
||||||
public class Notification {
|
public class Notification {
|
||||||
private Severity severity = Severity.None;
|
private Severity severity = Severity.Optimal;
|
||||||
private String type;
|
private String type;
|
||||||
private SensorData cause;
|
private SensorData cause;
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package eu.hsrw.ias.ggd;
|
package eu.hsrw.ias.ggd;
|
||||||
|
|
||||||
public enum Severity {
|
public enum Severity {
|
||||||
None,
|
Optimal,
|
||||||
Info,
|
Info,
|
||||||
Warning,
|
Warning,
|
||||||
Error,
|
Error,
|
||||||
|
|
|
@ -19,7 +19,38 @@ rule "Critical Battery"
|
||||||
HttpPost httpPost = new HttpPost();
|
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());
|
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);
|
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(sensorData.getTag()+" "+sensorData.getValue());
|
||||||
// System.out.println(device);
|
// System.out.println(device);
|
||||||
|
|
||||||
|
@ -93,6 +124,3 @@ rule "Critical Battery"
|
||||||
finalOutput = String.format("{\"id\":\"70B3D570500042D7-status\",\"data\":{\"measured\":[{ \"status\": \"The status of the device 1 is critical\",}]}}");
|
finalOutput = String.format("{\"id\":\"70B3D570500042D7-status\",\"data\":{\"measured\":[{ \"status\": \"The status of the device 1 is critical\",}]}}");
|
||||||
System.out.println(finalOutput);
|
System.out.println(finalOutput);
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
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
|
|
@ -0,0 +1,7 @@
|
||||||
|
package rules;
|
||||||
|
dialect "mvel"
|
||||||
|
|
||||||
|
rule "CriticalSoilConductivity"
|
||||||
|
when
|
||||||
|
then
|
||||||
|
end
|
|
@ -16,5 +16,24 @@ rule "CriticalSoilMoisture"
|
||||||
HttpPost httpPost = new HttpPost();
|
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());
|
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);
|
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));
|
insert(new Notification("soilMoisture", sensorData, Severity.Critical));
|
||||||
end
|
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
|
|
@ -0,0 +1,7 @@
|
||||||
|
package rules;
|
||||||
|
dialect "mvel"
|
||||||
|
|
||||||
|
rule "CriticalSoilTemperature"
|
||||||
|
when
|
||||||
|
then
|
||||||
|
end
|
|
@ -21,3 +21,22 @@ rule "CriticalTemperature"
|
||||||
System.out.println(deviceCritical);
|
System.out.println(deviceCritical);
|
||||||
insert(new Notification("temperature", sensorData, Severity.Critical));
|
insert(new Notification("temperature", sensorData, Severity.Critical));
|
||||||
end
|
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();
|
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());
|
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);
|
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
|
end
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
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
|
|
@ -2,14 +2,14 @@ import eu.hsrw.ias.ggd.Notification;
|
||||||
import eu.hsrw.ias.ggd.Severity
|
import eu.hsrw.ias.ggd.Severity
|
||||||
import HttpCall.HttpPost;
|
import HttpCall.HttpPost;
|
||||||
|
|
||||||
rule "Green House Critical"
|
//rule "Green House Critical"
|
||||||
when
|
//when
|
||||||
warning: Notification(severity > Severity.Info)
|
// warning: Notification(severity > Severity.Warning)
|
||||||
then
|
//then
|
||||||
HttpPost httpPost = new HttpPost();
|
// HttpPost httpPost = new HttpPost();
|
||||||
final String criticalGreenhouse = String.format("{\"id\":\"germes-greenhouse-status\",\"data\":{\"measured\":[{ \"status\": \"The status of the greenhouse is critical\"}]}}");
|
// 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);
|
// httpPost.HttpCallPost("http://connector.dev.whysor.com/default/insert?access_token=3hosOhAeh4k0XmcuAMQGfYldvTuQDvtAj2PJJ4irKPBefD5Ijij6gnUkLtVLd4fW",criticalGreenhouse);
|
||||||
System.out.println(criticalGreenhouse);
|
// System.out.println(criticalGreenhouse);
|
||||||
System.out.println("Green House critical, because of: '"+warning.getType()+"'");
|
// System.out.println("Green House critical, because of: '"+warning.getType()+"'");
|
||||||
|
//
|
||||||
end
|
//end
|
|
@ -19,7 +19,38 @@ rule "Critical Battery"
|
||||||
HttpPost httpPost = new HttpPost();
|
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());
|
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);
|
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(sensorData.getTag()+" "+sensorData.getValue());
|
||||||
// System.out.println(device);
|
// System.out.println(device);
|
||||||
|
|
||||||
|
@ -93,6 +124,3 @@ rule "Critical Battery"
|
||||||
finalOutput = String.format("{\"id\":\"70B3D570500042D7-status\",\"data\":{\"measured\":[{ \"status\": \"The status of the device 1 is critical\",}]}}");
|
finalOutput = String.format("{\"id\":\"70B3D570500042D7-status\",\"data\":{\"measured\":[{ \"status\": \"The status of the device 1 is critical\",}]}}");
|
||||||
System.out.println(finalOutput);
|
System.out.println(finalOutput);
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
|
@ -16,5 +16,29 @@ rule "CriticalSoilMoisture"
|
||||||
HttpPost httpPost = new HttpPost();
|
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());
|
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);
|
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));
|
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
|
end
|
|
@ -16,8 +16,32 @@ rule "CriticalTemperature"
|
||||||
HttpPost httpPost = new HttpPost();
|
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());
|
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);
|
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);
|
httpPost.HttpCallPost("http://connector.dev.whysor.com/default/insert?access_token=3hosOhAeh4k0XmcuAMQGfYldvTuQDvtAj2PJJ4irKPBefD5Ijij6gnUkLtVLd4fW",deviceCritical);
|
||||||
System.out.println(deviceCritical);
|
System.out.println(deviceCritical);
|
||||||
insert(new Notification("temperature", sensorData, Severity.Critical));
|
insert(new Notification("temperature", sensorData, Severity.Critical));
|
||||||
|
|
||||||
|
// modify(device){
|
||||||
|
// setState(Severity.Critical)
|
||||||
|
// }
|
||||||
|
|
||||||
end
|
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();
|
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());
|
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);
|
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
|
end
|
||||||
|
|
|
@ -2,14 +2,14 @@ import eu.hsrw.ias.ggd.Notification;
|
||||||
import eu.hsrw.ias.ggd.Severity
|
import eu.hsrw.ias.ggd.Severity
|
||||||
import HttpCall.HttpPost;
|
import HttpCall.HttpPost;
|
||||||
|
|
||||||
rule "Green House Critical"
|
//rule "Green House Critical"
|
||||||
when
|
//when
|
||||||
warning: Notification(severity > Severity.Info)
|
// warning: Notification(severity > Severity.Warning)
|
||||||
then
|
//then
|
||||||
HttpPost httpPost = new HttpPost();
|
// HttpPost httpPost = new HttpPost();
|
||||||
final String criticalGreenhouse = String.format("{\"id\":\"germes-greenhouse-status\",\"data\":{\"measured\":[{ \"status\": \"The status of the greenhouse is critical\",}]}}");
|
// 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);
|
// httpPost.HttpCallPost("http://connector.dev.whysor.com/default/insert?access_token=3hosOhAeh4k0XmcuAMQGfYldvTuQDvtAj2PJJ4irKPBefD5Ijij6gnUkLtVLd4fW",criticalGreenhouse);
|
||||||
System.out.println(criticalGreenhouse);
|
// System.out.println(criticalGreenhouse);
|
||||||
System.out.println("Green House critical, because of: '"+warning.getType()+"'");
|
// System.out.println("Green House critical, because of: '"+warning.getType()+"'");
|
||||||
|
//
|
||||||
end
|
//end
|
Loading…
Reference in New Issue