forked from kevin.shehu/GGD
30 lines
1.4 KiB
Plaintext
30 lines
1.4 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 "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
|