-
-
Save andrewgdunn/542627 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static void ProcessRecievedData() { | |
Vector<Map<String, Value>> errorSensors = new Vector<Map<String, Value>>(); | |
for(Object keySet : allSensors.keySet()) { | |
// Snag the individual sensor | |
Sensor individualSensor = (Sensor) allSensors.get(keySet); | |
// remove the outliers | |
individualSensor.removeOutliers(); | |
//Send the individual sensor to our filters, if there is a detected error we will make sure to set the falutIndex. | |
Map<String, Value> filterSensor = ErrorFinder.errorParams(individualSensor); | |
if(filterSensor.containsKey("faultIndex")) { | |
filterSensor.put("FaultTime", Value.v(individualSensor.timestamps.elementAt(( (IntegerValue) (filterSensor.get("faultIndex") ) ).get() ) - individualSensor.timestamps.elementAt(0) ) ); | |
filterSensor.remove("faultIndex"); | |
System.out.println(individualSensor.id + ":"); | |
filterSensor.put("sensorId", Value.v(individualSensor.id)); | |
errorSensors.add(filterSensor); | |
} | |
printMap(filterSensor); | |
} | |
// based on which sensors found faults, determine which component is problematic | |
if(errorSensors.size() == 1) { | |
reportError( errorSensors.elementAt(0) ); | |
} | |
else { | |
// more than one Sensor in errorSensors... what to do?! | |
} | |
// wait for the Oracle response ... | |
try { | |
Thread.sleep(threadSleep); | |
} catch (Exception e) { | |
System.out.append(e.toString() + " " + e.getMessage()); | |
} | |
// ... and then choose the lowest-cost action we have | |
if(recommendedAction != null) { | |
mainConnector.sendMessage(new CommandData(recommendedAction)); | |
System.out.println("DA recommendation: " + ((Command)(recommendedAction.toArray()[0])).getValue() + "\n" ); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static void ProcessRecievedData() { | |
Vector<Map<String, Value>> errorSensors = new Vector<Map<String, Value>>(); | |
for(Object keySet : allSensors.keySet()) { | |
Sensor individualSensor = (Sensor)allSensors.get(keySet); | |
individualSensor.removeOutliers(); | |
/** Send the individual sensor to our filters, if there is a detected error we will | |
* make sure to set the falutIndex. | |
*/ | |
Map<String, Value> filterSensor = ErrorFinder.errorParams(individualSensor); | |
if(filterSensor.containsKey("faultIndex")) { | |
filterSensor.put("sensorId", Value.v(individualSensor.id)); | |
errorSensors.add(filterSensor); | |
} | |
//printMap(filterSensor); | |
} | |
// based on which sensors found faults, determine which component is problematic | |
Map<String, Value> finalError = ComponentError.finalError(errorSensors, allSensors); | |
//printMap(finalError); | |
if(finalError.size() >0) | |
reportError(finalError); | |
// wait for the Oracle response ... | |
try { | |
Thread.sleep(threadSleep); | |
} catch (Exception e) { | |
System.out.append(e.toString() + " " + e.getMessage()); | |
} | |
// ... and then choose the lowest-cost action we have | |
if(recommendedAction != null) { | |
mainConnector.sendMessage(new CommandData(recommendedAction)); | |
//System.out.println("DA recommendation: " + ((Command)(recommendedAction.toArray()[0])).getValue() + "\n" ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment