ADD : NEW Format for all the code with prettier
This commit is contained in:
		
							
								
								
									
										24
									
								
								target/classes/rules/CriticalPrecipitation.drl
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										24
									
								
								target/classes/rules/CriticalPrecipitation.drl
									
									
									
									
									
										Normal file
									
								
							| @@ -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 | ||||
							
								
								
									
										7
									
								
								target/classes/rules/CriticalSoilConductivity.drl
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								target/classes/rules/CriticalSoilConductivity.drl
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,7 @@ | ||||
| package rules; | ||||
| dialect  "mvel" | ||||
|  | ||||
| rule "CriticalSoilConductivity" | ||||
|     when | ||||
|     then | ||||
| end | ||||
							
								
								
									
										7
									
								
								target/classes/rules/CriticalSoilTemperature.drl
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								target/classes/rules/CriticalSoilTemperature.drl
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,7 @@ | ||||
| package rules; | ||||
| dialect  "mvel" | ||||
|  | ||||
| rule "CriticalSoilTemperature" | ||||
|     when | ||||
|     then | ||||
| end | ||||
							
								
								
									
										31
									
								
								target/classes/rules/device-sensor-critical.drl
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										31
									
								
								target/classes/rules/device-sensor-critical.drl
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,31 @@ | ||||
| import eu.hsrw.ias.ggd.Device; | ||||
| import eu.hsrw.ias.ggd.Severity; | ||||
| import eu.hsrw.ias.ggd.SensorData; | ||||
|  | ||||
| rule "Sensor of device gone critical" | ||||
| when | ||||
|     sensorData: SensorData(state == Severity.Critical) | ||||
|     device: Device(sensorData contains(sensorData)) | ||||
| then | ||||
|     modify(device){ | ||||
|         setState(Severity.Critical) | ||||
|     } | ||||
|     System.out.println("Device: \n" + | ||||
|         "\tID: '" + device.getId() + "'" + | ||||
|         "\tState: '" + device.getState().toString() + "'" | ||||
|      ); | ||||
|     // Do something the info that a device is gone critical | ||||
| end | ||||
|  | ||||
| rule "Sensor of device gone optimal" | ||||
| when | ||||
|     sensorData: SensorData(state == Severity.Optimal) | ||||
|     device: Device(sensorData contains(sensorData)) | ||||
| then | ||||
|     modify(device){ | ||||
|         setState(Severity.Optimal) | ||||
|     } | ||||
|  | ||||
|     // Device is gone optimal | ||||
| end | ||||
|  | ||||
							
								
								
									
										25
									
								
								target/classes/rules/greenhouse_critical.drl
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								target/classes/rules/greenhouse_critical.drl
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,25 @@ | ||||
| import eu.hsrw.ias.ggd.Greenhouse; | ||||
| import eu.hsrw.ias.ggd.Device; | ||||
| import eu.hsrw.ias.ggd.Severity; | ||||
|  | ||||
| rule "Device of greenhouse gone critical" | ||||
| when | ||||
|     device: Device(state == Severity.Critical) | ||||
|     greenhouse: Greenhouse(devices contains(device)) | ||||
|     //greenhouse: Greenhouse(devices contains(Device(state == Severity.Critical))) | ||||
| then | ||||
|     modify(greenhouse){ | ||||
|         setState(Severity.Critical) | ||||
|     } | ||||
|     System.out.println("Greenhouse: '" + greenhouse.getId() + "' is '" + greenhouse.getState().toString() + "'"); | ||||
| end | ||||
|  | ||||
| rule "Device of greenhouse has gone optimal" | ||||
| when | ||||
|     device: Device(state == Severity.Optimal) | ||||
|     greenhouse: Greenhouse(devices contains(device)) | ||||
| then | ||||
|     modify(greenhouse){ | ||||
|         setState(Severity.Optimal) | ||||
|     } | ||||
| end | ||||
							
								
								
									
										15
									
								
								target/classes/rules/optimal.drl
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								target/classes/rules/optimal.drl
									
									
									
									
									
										Normal file
									
								
							| @@ -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 | ||||
		Reference in New Issue
	
	Block a user