40 lines
2.0 KiB
Plaintext
40 lines
2.0 KiB
Plaintext
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
|
|
|
|
|
|
|
|
|