parent
141d474ef3
commit
2180026612
25
README.md
25
README.md
|
@ -13,16 +13,27 @@ The list of inferred active goals is offered to other services of the system.
|
|||
|
||||
**Rules (General structure, if premises then consequence)**
|
||||
1. Explicit given by expert (before and during runtime)
|
||||
2. Trained through AI
|
||||
1. Battery
|
||||
2. Dielectric Permittivity
|
||||
3. Precipitation
|
||||
4. Soil Conductivity
|
||||
5. Soil Moisture
|
||||
6. Soil Temperature
|
||||
7. Temperature
|
||||
2. All this information is considered as facts which are part of the entire knowledge graph
|
||||
3. One particular rule can be fire on multiple rules can be fired. User defined.
|
||||
|
||||
**Goals**
|
||||
1. Actions that should be taken by the user to be successful.
|
||||
2. Goals can be active and inactive.
|
||||
1. Goals are active rules which are able to change the fact
|
||||
2. Goals can be activated and deactivated based on the user preferences
|
||||
3. Goals can have priorities
|
||||
|
||||
#### **Build**
|
||||
|
||||
Run the MainExe.java which is part of the eu.hsrw.ias.ggd package
|
||||
#### **Usage**
|
||||
|
||||
You can reuse the project by changing the UserCredentials.java file located on the Credentials package.
|
||||
It is possible to create new rules tailored to the needs.
|
||||
#### **Examples**
|
||||
|
||||
#### **Dependencies**
|
||||
For each sensor mentioned in the list of rules an example is given. You may change the values based on the needs of the expert/user.
|
||||
#### **Dependencies**
|
||||
drools.org
|
|
@ -4,6 +4,7 @@ public class UserCredentials {
|
|||
private final String username = "kevin.shehu@hochschule-rhein-waal.de";
|
||||
private final String password = "DK7SxFkGJgnLhnU3";
|
||||
private final String baseURL = "https://api.whysor.com/";
|
||||
private final String devUrl = "https://api.dev.whysor.com/";
|
||||
private static final String homeRoot = "D:\\WORK\\GGD\\src\\main\\java\\Data\\";
|
||||
|
||||
public static String getHomeRoot() {
|
||||
|
@ -22,7 +23,9 @@ public class UserCredentials {
|
|||
return baseURL;
|
||||
}
|
||||
|
||||
|
||||
public String getDevUrl() {
|
||||
return devUrl;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
|
@ -30,6 +33,7 @@ public class UserCredentials {
|
|||
"username='" + username + '\'' +
|
||||
", password='" + password + '\'' +
|
||||
", baseURL='" + baseURL + '\'' +
|
||||
", devUrl='" + devUrl + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
[{"sensorId":"09a91c61-6572-4476-8bf1-310a2fb2eb02","datetimeMeasure":"2021-11-25T10:10:29.156Z","value":3.06,"groupId":null,"metadata":null}]externalTemperature,f9bb4a5c-f783-4bcf-8c34-0a7c3dd5a632
|
|
@ -0,0 +1 @@
|
|||
[{"sensorId":"1f49de66-0921-4583-ae68-ff0fcc070bd1","datetimeMeasure":"2021-11-25T10:13:23.813Z","value":21.64,"groupId":null,"metadata":null}]dielectricPermittivity,fd694041-581e-4c2c-9810-505e62b762e6
|
|
@ -0,0 +1 @@
|
|||
[{"sensorId":"22e5b1b0-b28c-4aa1-97c7-94ff12c51384","datetimeMeasure":"2021-11-25T10:13:23.813Z","value":2.1,"groupId":null,"metadata":null}]soilTemperature,fd694041-581e-4c2c-9810-505e62b762e6
|
|
@ -0,0 +1 @@
|
|||
[{"sensorId":"3b6a8c15-5cea-4994-954d-5b25c22e2c32","datetimeMeasure":"2021-11-25T10:13:23.813Z","value":36.5,"groupId":null,"metadata":null}]soilMoisture,fd694041-581e-4c2c-9810-505e62b762e6
|
|
@ -0,0 +1 @@
|
|||
[{"sensorId":"5209815d-974f-4729-ae1a-06bd1000db67","datetimeMeasure":"2021-11-25T10:13:23.813Z","value":0.15,"groupId":null,"metadata":null}]soilConductivity,fd694041-581e-4c2c-9810-505e62b762e6
|
|
@ -0,0 +1 @@
|
|||
[{"sensorId":"65e95c11-ec15-4039-840a-e9be3d77ca63","datetimeMeasure":"2021-11-25T10:04:44.298Z","value":705.4,"groupId":null,"metadata":null}]precipitation,e8c3fca3-c5cd-48e7-9224-0f8c294fa3c0
|
|
@ -0,0 +1 @@
|
|||
[{"sensorId":"69bcaae0-9ccd-4342-8a71-c72dca37cfe9","datetimeMeasure":"2021-11-25T10:13:22.838Z","value":5.064,"groupId":null,"metadata":null}]battery,6c9efd4a-db04-453d-8ab8-d480ec97dd26
|
|
@ -0,0 +1 @@
|
|||
[{"id":"77c174ad-37a8-4cc5-b690-570c3ac57c53","name":"","description":"","tag":"soilTemperature","hasForecast":false,"virtual":false,"deviceId":"b04821c6-ea7c-4e2e-9575-7c8e8ba9191a","sensorTemplateId":"f1ca68cc-cfd2-4f44-94cf-61138b71f5d2"},{"id":"a0d80d32-303a-460b-954a-2e4f7bd76b68","name":"","description":"","tag":"dielectricPermittivity","hasForecast":false,"virtual":false,"deviceId":"b04821c6-ea7c-4e2e-9575-7c8e8ba9191a","sensorTemplateId":"c04a55a7-51e8-4647-9b59-3d82966dd863"},{"id":"bdd1d27b-b2fb-4d9f-915f-ddc5a79be8b4","name":"","description":"","tag":"soilConductivity","hasForecast":false,"virtual":false,"deviceId":"b04821c6-ea7c-4e2e-9575-7c8e8ba9191a","sensorTemplateId":"057a689a-738a-4e78-bf73-6629ee56ab4c"},{"id":"d7c4c7a5-7010-489e-9526-999216fcf492","name":"","description":"","tag":"soilMoisture","hasForecast":false,"virtual":false,"deviceId":"b04821c6-ea7c-4e2e-9575-7c8e8ba9191a","sensorTemplateId":"8fac9339-de32-45a7-8df6-f38aca013e66"},{"id":"da62ffa0-56ad-44ee-a846-907357d0be8d","name":"","description":"","tag":"battery","hasForecast":false,"virtual":false,"deviceId":"b04821c6-ea7c-4e2e-9575-7c8e8ba9191a","sensorTemplateId":"978d7178-aa5a-41ca-a5c8-1868135ea928"}]
|
|
@ -0,0 +1 @@
|
|||
[{"id":"1f49de66-0921-4583-ae68-ff0fcc070bd1","name":"","description":"","tag":"dielectricPermittivity","hasForecast":false,"virtual":false,"deviceId":"fd694041-581e-4c2c-9810-505e62b762e6","sensorTemplateId":"c04a55a7-51e8-4647-9b59-3d82966dd863"},{"id":"22e5b1b0-b28c-4aa1-97c7-94ff12c51384","name":"","description":"","tag":"soilTemperature","hasForecast":false,"virtual":false,"deviceId":"fd694041-581e-4c2c-9810-505e62b762e6","sensorTemplateId":"f1ca68cc-cfd2-4f44-94cf-61138b71f5d2"},{"id":"3b6a8c15-5cea-4994-954d-5b25c22e2c32","name":"","description":"","tag":"soilMoisture","hasForecast":false,"virtual":false,"deviceId":"fd694041-581e-4c2c-9810-505e62b762e6","sensorTemplateId":"8fac9339-de32-45a7-8df6-f38aca013e66"},{"id":"5209815d-974f-4729-ae1a-06bd1000db67","name":"","description":"","tag":"soilConductivity","hasForecast":false,"virtual":false,"deviceId":"fd694041-581e-4c2c-9810-505e62b762e6","sensorTemplateId":"057a689a-738a-4e78-bf73-6629ee56ab4c"},{"id":"adba09f9-ab84-4252-bf1a-ac49b1b6bdd3","name":"","description":"","tag":"battery","hasForecast":false,"virtual":false,"deviceId":"fd694041-581e-4c2c-9810-505e62b762e6","sensorTemplateId":"978d7178-aa5a-41ca-a5c8-1868135ea928"}]
|
|
@ -0,0 +1 @@
|
|||
[{"id":"65e95c11-ec15-4039-840a-e9be3d77ca63","name":"","description":"","tag":"precipitation","hasForecast":false,"virtual":false,"deviceId":"e8c3fca3-c5cd-48e7-9224-0f8c294fa3c0","sensorTemplateId":"3985b5b6-92a4-41b1-b2e6-e553a663442c"},{"id":"812c6e62-e855-424b-8ec1-78fb424a94b5","name":"","description":"","tag":"soilMoisture","hasForecast":false,"virtual":false,"deviceId":"e8c3fca3-c5cd-48e7-9224-0f8c294fa3c0","sensorTemplateId":"dbe5fd37-85bd-4af1-b335-554baa3f6d49"},{"id":"ffca826c-d1b5-4ac8-869a-ec0da15d9076","name":"","description":"","tag":"battery","hasForecast":false,"virtual":false,"deviceId":"e8c3fca3-c5cd-48e7-9224-0f8c294fa3c0","sensorTemplateId":"71c8fcd4-3895-42e8-82d9-455366c956ef"}]
|
|
@ -0,0 +1 @@
|
|||
[{"id":"09a91c61-6572-4476-8bf1-310a2fb2eb02","name":"","description":"","tag":"externalTemperature","hasForecast":false,"virtual":false,"deviceId":"f9bb4a5c-f783-4bcf-8c34-0a7c3dd5a632","sensorTemplateId":"46bc5bf2-ad0c-4ec4-9df5-0bff12f911b6"},{"id":"88c8442f-62b9-4952-b28c-73790a555060","name":"","description":"","tag":"battery","hasForecast":false,"virtual":false,"deviceId":"f9bb4a5c-f783-4bcf-8c34-0a7c3dd5a632","sensorTemplateId":"71c8fcd4-3895-42e8-82d9-455366c956ef"},{"id":"bc08edce-d214-40db-ba51-a0802243c235","name":"","description":"","tag":"soilMoisture","hasForecast":false,"virtual":false,"deviceId":"f9bb4a5c-f783-4bcf-8c34-0a7c3dd5a632","sensorTemplateId":"dbe5fd37-85bd-4af1-b335-554baa3f6d49"}]
|
|
@ -0,0 +1 @@
|
|||
[{"id":"69bcaae0-9ccd-4342-8a71-c72dca37cfe9","name":"","description":"","tag":"battery","hasForecast":false,"virtual":false,"deviceId":"6c9efd4a-db04-453d-8ab8-d480ec97dd26","sensorTemplateId":"71c8fcd4-3895-42e8-82d9-455366c956ef"},{"id":"cd2e9ec6-ad80-477a-a510-6697b2953d19","name":"","description":"","tag":"coordinates","hasForecast":false,"virtual":false,"deviceId":"6c9efd4a-db04-453d-8ab8-d480ec97dd26","sensorTemplateId":"c3591348-8ef1-4e19-a2eb-c9a377e4199e"},{"id":"f75934dc-af98-4206-a5bd-22d23dd5f268","name":"","description":"","tag":"temperature","hasForecast":false,"virtual":false,"deviceId":"6c9efd4a-db04-453d-8ab8-d480ec97dd26","sensorTemplateId":"46bc5bf2-ad0c-4ec4-9df5-0bff12f911b6"},{"id":"ff6f11e0-c969-4cbb-829c-f44a13683918","name":"","description":"","tag":"precipitation","hasForecast":false,"virtual":false,"deviceId":"6c9efd4a-db04-453d-8ab8-d480ec97dd26","sensorTemplateId":"3985b5b6-92a4-41b1-b2e6-e553a663442c"}]
|
|
@ -0,0 +1 @@
|
|||
{"error":{"statusCode":403,"name":"AccessDeniedError","message":"Access denied","status":403,"code":"ACCESS_DENIED","stack":"AccessDeniedError: Access denied\n at Sensor.read (/usr/src/app/server/models/device/sensor.js:37:60)"}}soilTemperature,b04821c6-ea7c-4e2e-9575-7c8e8ba9191a
|
|
@ -0,0 +1 @@
|
|||
[{"sensorId":"812c6e62-e855-424b-8ec1-78fb424a94b5","datetimeMeasure":"2021-11-25T10:04:44.298Z","value":33.4,"groupId":null,"metadata":null}]soilMoisture,e8c3fca3-c5cd-48e7-9224-0f8c294fa3c0
|
|
@ -0,0 +1 @@
|
|||
[{"sensorId":"88c8442f-62b9-4952-b28c-73790a555060","datetimeMeasure":"2021-11-25T10:10:29.156Z","value":5.157,"groupId":null,"metadata":null}]battery,f9bb4a5c-f783-4bcf-8c34-0a7c3dd5a632
|
|
@ -0,0 +1 @@
|
|||
{"error":{"statusCode":403,"name":"AccessDeniedError","message":"Access denied","status":403,"code":"ACCESS_DENIED","stack":"AccessDeniedError: Access denied\n at Sensor.read (/usr/src/app/server/models/device/sensor.js:37:60)"}}dielectricPermittivity,b04821c6-ea7c-4e2e-9575-7c8e8ba9191a
|
|
@ -0,0 +1 @@
|
|||
[{"sensorId":"adba09f9-ab84-4252-bf1a-ac49b1b6bdd3","datetimeMeasure":"2021-11-25T10:13:23.813Z","value":5.826,"groupId":null,"metadata":null}]battery,fd694041-581e-4c2c-9810-505e62b762e6
|
|
@ -0,0 +1 @@
|
|||
[{"sensorId":"bc08edce-d214-40db-ba51-a0802243c235","datetimeMeasure":"2021-11-25T10:10:29.156Z","value":41.8,"groupId":null,"metadata":null}]soilMoisture,f9bb4a5c-f783-4bcf-8c34-0a7c3dd5a632
|
|
@ -0,0 +1 @@
|
|||
{"error":{"statusCode":403,"name":"AccessDeniedError","message":"Access denied","status":403,"code":"ACCESS_DENIED","stack":"AccessDeniedError: Access denied\n at Sensor.read (/usr/src/app/server/models/device/sensor.js:37:60)"}}soilConductivity,b04821c6-ea7c-4e2e-9575-7c8e8ba9191a
|
|
@ -0,0 +1 @@
|
|||
[]coordinates,6c9efd4a-db04-453d-8ab8-d480ec97dd26
|
|
@ -0,0 +1 @@
|
|||
{"error":{"statusCode":403,"name":"AccessDeniedError","message":"Access denied","status":403,"code":"ACCESS_DENIED","stack":"AccessDeniedError: Access denied\n at Sensor.read (/usr/src/app/server/models/device/sensor.js:37:60)"}}soilMoisture,b04821c6-ea7c-4e2e-9575-7c8e8ba9191a
|
|
@ -0,0 +1 @@
|
|||
{"error":{"statusCode":403,"name":"AccessDeniedError","message":"Access denied","status":403,"code":"ACCESS_DENIED","stack":"AccessDeniedError: Access denied\n at Sensor.read (/usr/src/app/server/models/device/sensor.js:37:60)"}}battery,b04821c6-ea7c-4e2e-9575-7c8e8ba9191a
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1 @@
|
|||
[{"sensorId":"f75934dc-af98-4206-a5bd-22d23dd5f268","datetimeMeasure":"2021-11-25T10:13:22.838Z","value":3,"groupId":null,"metadata":null}]temperature,6c9efd4a-db04-453d-8ab8-d480ec97dd26
|
|
@ -0,0 +1 @@
|
|||
[{"sensorId":"ff6f11e0-c969-4cbb-829c-f44a13683918","datetimeMeasure":"2021-11-25T10:13:22.838Z","value":17.75,"groupId":null,"metadata":null}]precipitation,6c9efd4a-db04-453d-8ab8-d480ec97dd26
|
|
@ -0,0 +1 @@
|
|||
[{"sensorId":"ffca826c-d1b5-4ac8-869a-ec0da15d9076","datetimeMeasure":"2021-11-25T10:04:44.298Z","value":5.135,"groupId":null,"metadata":null}]battery,e8c3fca3-c5cd-48e7-9224-0f8c294fa3c0
|
|
@ -1 +1 @@
|
|||
3jINGNigY2BcAHzSTU3K5734i1LvZzZq7ogMAVp4DYy4JkZtjzh0gHIdoqLeIV3n
|
||||
nRsSvFEYoGTEqSmnmtE0R0btgMW8J6C6VpKEefCfPerViKxV4usqGREOioUQ268G
|
|
@ -33,9 +33,11 @@ public class ScheduledTask extends TimerTask {
|
|||
KieSession kSession = kContainer.newKieSession("ksession-rule");
|
||||
FactHandle fact1;
|
||||
fact1 = kSession.insert(outputDevices);
|
||||
System.out.println(fact1);
|
||||
// System.out.println(fact1);
|
||||
kSession.insert(fact1);
|
||||
kSession.fireAllRules();
|
||||
|
||||
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
} catch (ExecutionException e) {
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
package rules;
|
||||
import java.util.List;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
|
|
@ -1,7 +1,33 @@
|
|||
package rules;
|
||||
dialect "mvel"
|
||||
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 "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
|
||||
then
|
||||
String fixedIdG1="8bdbe6ae-eafb-4e99-bb01-db8784dd9633";
|
||||
HttpPost httpPost = new HttpPost();
|
||||
if (level > 20 && 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);
|
||||
end
|
||||
|
|
|
@ -1,7 +1,33 @@
|
|||
package rules;
|
||||
dialect "mvel"
|
||||
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
|
||||
|
|
|
@ -19,11 +19,10 @@ when
|
|||
SensorData(id: deviceId) from v
|
||||
then
|
||||
String fixedIdG1="8bdbe6ae-eafb-4e99-bb01-db8784dd9633";
|
||||
String fixedTag="soil Conductivity";
|
||||
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\", \"soil conductivity\": %s}]}}", fixedIdG1, level,level);
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -22,16 +22,16 @@ when
|
|||
then
|
||||
HttpPost httpPost = new HttpPost();
|
||||
String fixedIdG1="8bdbe6ae-eafb-4e99-bb01-db8784dd9633";
|
||||
String fixedTag="soil Moisture";
|
||||
|
||||
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 \", \"soil moisture\": %s}]}}", fixedIdG1,fixedTag,level,level);
|
||||
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\", \"soil moisture\": %s}]}}", fixedIdG1,fixedTag,level,level);
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ rule "SoilTemperature"
|
|||
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 \", \"soil temperature\": %s}]}}", fixedIdG1,level, tag,level);
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<kmodule xmlns="http://jboss.org/kie/6.0.0/kmodule">
|
||||
<kbase name="rules" packages="rules">
|
||||
<ksession name="ksession-rule"/>
|
||||
</kbase>
|
||||
</kmodule>
|
|
@ -0,0 +1,3 @@
|
|||
groupId=com.javainuse
|
||||
artifactId=drools-hello-world
|
||||
version=0.0.1-SNAPSHOT
|
|
@ -0,0 +1,41 @@
|
|||
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
|
|
@ -0,0 +1,33 @@
|
|||
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 "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
|
||||
then
|
||||
String fixedIdG1="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);
|
||||
end
|
|
@ -0,0 +1,7 @@
|
|||
package rules;
|
||||
|
||||
|
||||
rule "ExternalTemperature"
|
||||
when
|
||||
then
|
||||
end
|
|
@ -0,0 +1,33 @@
|
|||
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
|
|
@ -0,0 +1,39 @@
|
|||
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
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
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
|
||||
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
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
|
|
@ -0,0 +1,40 @@
|
|||
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
|
Loading…
Reference in New Issue