forked from kevin.shehu/GGD
48 lines
2.6 KiB
Plaintext
48 lines
2.6 KiB
Plaintext
import java.util.HashMap;
|
|
import java.util.Map;
|
|
import eu.hsrw.ias.ggd.SensorData
|
|
import javax.swing.JOptionPane
|
|
import HttpCall.HttpPost
|
|
import eu.hsrw.ias.ggd.Notification
|
|
import eu.hsrw.ias.ggd.Severity;
|
|
import eu.hsrw.ias.ggd.Device;
|
|
|
|
rule "CriticalTemperature"
|
|
when
|
|
device: Device(sensorDatas: sensorData)
|
|
sensorData: SensorData(tag == "temperature", value < 10.0 || value > 30.0) from sensorDatas
|
|
then
|
|
String greenhouse1="8bdbe6ae-eafb-4e99-bb01-db8784dd9633";
|
|
HttpPost httpPost = new HttpPost();
|
|
final String criticalTemperatureOutput = String.format("{\"id\":\"%s\",\"data\":{\"measured\":[{ \"status\": \"Critical Temperature %s in the following device %s \", \"temperature\": %s}]}}",greenhouse1, sensorData.getValue(),sensorData.getTag(),sensorData.getValue());
|
|
httpPost.HttpCallPost("http://connector.dev.whysor.com/default/insert?access_token=3hosOhAeh4k0XmcuAMQGfYldvTuQDvtAj2PJJ4irKPBefD5Ijij6gnUkLtVLd4fW",criticalTemperatureOutput);
|
|
final String deviceCritical = String.format("{\"id\":\"%s-status\",\"data\":{\"measured\":[{ \"criticalStatus\": \"The status of %s device is critical\"}]}}",device.IdMapper(device.getId()),device.getId());
|
|
httpPost.HttpCallPost("http://connector.dev.whysor.com/default/insert?access_token=3hosOhAeh4k0XmcuAMQGfYldvTuQDvtAj2PJJ4irKPBefD5Ijij6gnUkLtVLd4fW",deviceCritical);
|
|
System.out.println(deviceCritical);
|
|
insert(new Notification("temperature", sensorData, Severity.Critical));
|
|
|
|
// modify(device){
|
|
// setState(Severity.Critical)
|
|
// }
|
|
|
|
end
|
|
|
|
rule "OptimalTemperature"
|
|
when
|
|
device: Device(sensorDatas: sensorData)
|
|
sensorData: SensorData(tag == "temperature", value > 10.0 && value < 30.0) from sensorDatas
|
|
then
|
|
String greenhouse1="8bdbe6ae-eafb-4e99-bb01-db8784dd9633";
|
|
HttpPost httpPost = new HttpPost();
|
|
final String optimalTemperatureOutput = String.format("{\"id\":\"%s\",\"data\":{\"measured\":[{ \"status\": \"Optimal Temperature %s in the following device %s \", \"temperature\": %s}]}}",greenhouse1, sensorData.getValue(),sensorData.getTag(),sensorData.getValue());
|
|
httpPost.HttpCallPost("http://connector.dev.whysor.com/default/insert?access_token=3hosOhAeh4k0XmcuAMQGfYldvTuQDvtAj2PJJ4irKPBefD5Ijij6gnUkLtVLd4fW",optimalTemperatureOutput);
|
|
insert(new Notification("temperature", sensorData, Severity.Optimal));
|
|
System.out.println("Optimal");
|
|
|
|
// modify(sensorData){
|
|
// setState(Severity.Optimal)
|
|
// }
|
|
|
|
end
|
|
|