code formatting

revert-dabc3590
Nirothipan 8 years ago
parent 40a28f965f
commit 2c3462006e

@ -115,7 +115,7 @@ public class FireAlarmMQTTCommunicator extends MQTTTransportHandler {
try { try {
receivedMessage = message.toString(); receivedMessage = message.toString();
if(!receivedMessage.contains("policyDefinition")){ if (!receivedMessage.contains("policyDefinition")) {
receivedMessage = AgentUtilOperations.extractMessageFromPayload(receivedMessage); receivedMessage = AgentUtilOperations.extractMessageFromPayload(receivedMessage);
String[] controlSignal = receivedMessage.split(":"); String[] controlSignal = receivedMessage.split(":");
@ -150,7 +150,7 @@ public class FireAlarmMQTTCommunicator extends MQTTTransportHandler {
log.info(AgentConstants.LOG_APPENDER + replyHumidity); log.info(AgentConstants.LOG_APPENDER + replyHumidity);
String humidPublishTopic = String.format( String humidPublishTopic = String.format(
AgentConstants.MQTT_PUBLISH_TOPIC,tenantDomain, deviceID); AgentConstants.MQTT_PUBLISH_TOPIC, tenantDomain, deviceID);
replyMessage = AgentConstants.HUMIDITY_CONTROL + ":" + currentHumidity; replyMessage = AgentConstants.HUMIDITY_CONTROL + ":" + currentHumidity;
securePayLoad = AgentUtilOperations.prepareSecurePayLoad(replyMessage); securePayLoad = AgentUtilOperations.prepareSecurePayLoad(replyMessage);
@ -176,7 +176,6 @@ public class FireAlarmMQTTCommunicator extends MQTTTransportHandler {
} else { } else {
JSONObject jsonMessage = new JSONObject(receivedMessage); JSONObject jsonMessage = new JSONObject(receivedMessage);
updateCEPPolicy(jsonMessage.getString("policyDefinition")); updateCEPPolicy(jsonMessage.getString("policyDefinition"));
} }
log.info(AgentConstants.LOG_APPENDER + "Message [" + receivedMessage + "] was received"); log.info(AgentConstants.LOG_APPENDER + "Message [" + receivedMessage + "] was received");
} catch (AgentCoreOperationException e) { } catch (AgentCoreOperationException e) {

@ -69,15 +69,9 @@ public class SidhdhiQuery implements Runnable {
//Start the execution plan with pre-defined or previously persisted Siddhi query //Start the execution plan with pre-defined or previously persisted Siddhi query
File f = new File(sidhdhiQueryPath); File f = new File(sidhdhiQueryPath);
while (true) { while (true) {
if (f.exists()) { if (f.exists()) {
//AgentUtilOperations.writeToFile("", sidhdhiQueryPath); //AgentUtilOperations.writeToFile("", sidhdhiQueryPath);
StartExecutionPlan startExecutionPlan = new StartExecutionPlan().invoke(); StartExecutionPlan startExecutionPlan = new StartExecutionPlan().invoke();
//Check if there is new policy update available //Check if there is new policy update available
if (AgentManager.isUpdated()) { if (AgentManager.isUpdated()) {
System.out.print("### Policy Update Detected!"); System.out.print("### Policy Update Detected!");
@ -86,7 +80,6 @@ public class SidhdhiQuery implements Runnable {
startExecutionPlan = new StartExecutionPlan().invoke(); startExecutionPlan = new StartExecutionPlan().invoke();
} }
InputHandler inputHandler = startExecutionPlan.getInputHandler(); InputHandler inputHandler = startExecutionPlan.getInputHandler();
//Sending events to Siddhi //Sending events to Siddhi
try { try {
int humidityReading = AgentManager.getInstance().getTemperature(); int humidityReading = AgentManager.getInstance().getTemperature();
@ -119,7 +112,7 @@ public class SidhdhiQuery implements Runnable {
public static String readFile(String path, Charset encoding) { public static String readFile(String path, Charset encoding) {
byte[] encoded = new byte[0]; byte[] encoded = new byte[0];
try { try {
if(new File(sidhdhiQueryPath).exists()){ if (new File(sidhdhiQueryPath).exists()) {
encoded = Files.readAllBytes(Paths.get(path)); encoded = Files.readAllBytes(Paths.get(path));
} }
} catch (IOException e) { } catch (IOException e) {
@ -197,10 +190,8 @@ public class SidhdhiQuery implements Runnable {
} }
}); });
//Retrieving InputHandler to push events into Siddhi //Retrieving InputHandler to push events into Siddhi
inputHandler = siddhiManager.getInputHandler("fireAlarmEventStream"); inputHandler = siddhiManager.getInputHandler("fireAlarmEventStream");
//Starting event processing //Starting event processing
// System.out.println("Execution Plan Started!"); // System.out.println("Execution Plan Started!");
return this; return this;

Loading…
Cancel
Save