use of kutch.biff.marvin.utility.FrameworkNode in project Board-Instrumentation-Framework by intel.
the class ReceiveThreadMgr method HandleIncomingDatapoint.
private void HandleIncomingDatapoint(Node dpNode) {
NodeList Children = dpNode.getChildNodes();
String ID = null;
String Namespace = null;
String Data = null;
for (int iLoop = 0; iLoop < Children.getLength(); iLoop++) {
Node node = Children.item(iLoop);
if (node.getNodeName().equalsIgnoreCase("#Text") || node.getNodeName().equalsIgnoreCase("#comment")) {
continue;
} else if (node.getNodeName().equalsIgnoreCase("Version")) {
} else if (node.getNodeName().equalsIgnoreCase("Namespace")) {
Namespace = node.getTextContent();
} else if (node.getNodeName().equalsIgnoreCase("ID")) {
ID = node.getTextContent();
} else if (node.getNodeName().equalsIgnoreCase("Value")) {
Data = node.getTextContent();
FrameworkNode objNode = new FrameworkNode(node);
if (objNode.hasAttribute("LiveData")) {
String strLive = objNode.getAttribute("LiveData");
if (strLive.equalsIgnoreCase("True")) {
CONFIG.OnLiveDataReceived();
} else if (strLive.equalsIgnoreCase("False")) {
CONFIG.OnRecordedDataReceived();
} else {
LOGGER.warning("Received Data packet with unknown LiveData attribute: " + strLive);
}
}
} else {
LOGGER.warning("Unknown Tag in received Datapoint: " + node.getNodeName());
}
}
if (ID != null && Namespace != null && Data != null) {
_DataManager.ChangeValue(ID, Namespace, Data);
} else {
LOGGER.severe("Malformed Data Received: " + dpNode.getTextContent());
}
}
use of kutch.biff.marvin.utility.FrameworkNode in project Board-Instrumentation-Framework by intel.
the class TaskManager method BuildMathematicTaskTaskItem.
private PulseTask BuildMathematicTaskTaskItem(String taskID, FrameworkNode taskNode) {
/**
* * Example Task
* <TaskItem Type="Mathematic">
* <MarvinDataPoint ID="Text" Namespace="PK Laptop"/>
* <Operation Value=".1">Add</Operation> Subtract, Multiply
* </TaskItem>
*/
boolean errorLogged = false;
MathematicTask objTask = new MathematicTask();
for (FrameworkNode node : taskNode.getChildNodes()) {
if (node.getNodeName().equalsIgnoreCase("MarvinDataPoint")) {
Utility.ValidateAttributes(new String[] { "Namespace", "ID" }, node);
if (node.hasAttribute("Namespace") && node.hasAttribute("ID")) {
objTask.SetNamespaceAndID(node.getAttribute("Namespace"), node.getAttribute("ID"));
} else {
LOGGER.severe("Task with ID: " + taskID + " contains an invalid Mathematic Task - no Namespace and ID defined in MarvinDataPoint");
errorLogged = true;
}
} else if (node.getNodeName().equalsIgnoreCase("Operation")) {
Utility.ValidateAttributes(new String[] { "Value" }, node);
if (node.hasAttribute("Value")) {
if (!objTask.setValue(node.getAttribute("Value"))) {
LOGGER.severe("Task with ID: " + taskID + " contains an invalid Mathematic Task Operation Value: " + node.getAttribute("Value"));
errorLogged = true;
}
}
String strOperationType = node.getTextContent();
if (!objTask.SetOperation(strOperationType)) {
LOGGER.severe("Task with ID: " + taskID + " contains an invalid Mathematic Task Operation : " + strOperationType);
errorLogged = true;
}
}
}
if (!objTask.isValid()) {
objTask = null;
if (!errorLogged) {
LOGGER.severe("Task with ID: " + taskID + " contains an invalid Arithmatic Task - no MarvinDataPoint defined");
}
}
return objTask;
}
use of kutch.biff.marvin.utility.FrameworkNode in project Board-Instrumentation-Framework by intel.
the class TaskManager method BuildLaunchApplicationTaskItem.
private LaunchProgramTask BuildLaunchApplicationTaskItem(String taskID, FrameworkNode taskNode) {
/**
* <TaskList ID="TestLaunch">
* <TaskItem Type="LaunchProgram">
* <Application>foo.exe</Document>
* <Param>1</Param>
* <Param>2</Param>
* </TaskItem>
* </TaskList> *
*/
LaunchProgramTask objRunProgramTask = new LaunchProgramTask();
objRunProgramTask.setParams(GetParameters(taskNode));
for (FrameworkNode node : taskNode.getChildNodes()) {
if (node.getNodeName().equalsIgnoreCase("Application")) {
if (!objRunProgramTask.SetApplication(node.getTextContent())) {
LOGGER.severe("LaunchProgram task has invalid Application: " + node.getTextContent());
return null;
}
}
}
if (!objRunProgramTask.isValid()) {
objRunProgramTask = null;
LOGGER.severe("Task with ID: " + taskID + " contains an invalid LaunchProgram Task.");
}
return objRunProgramTask;
}
use of kutch.biff.marvin.utility.FrameworkNode in project Board-Instrumentation-Framework by intel.
the class TaskManager method GetParameters.
/**
* Common function for tasks, reads the <Param> sections
*
* @param taskNode
* @return an array of the parameters
*/
private ArrayList<Parameter> GetParameters(FrameworkNode taskNode) {
ArrayList<Parameter> Params = null;
for (FrameworkNode node : taskNode.getChildNodes()) {
if (0 == node.getNodeName().compareToIgnoreCase("#text") || 0 == node.getNodeName().compareToIgnoreCase("#comment")) {
} else if (node.getNodeName().equalsIgnoreCase("Param")) {
if (null == Params) {
Params = new ArrayList<>();
}
if (node.getTextContent().length() > 0) {
if (node.hasAttributes()) {
LOGGER.severe("Specified a value and an attribute for <Param>. They are mutually exclusive.");
}
Params.add(new Parameter(node.getTextContent()));
} else if (node.hasAttribute("Namespace") || node.hasAttribute("id")) {
if (!node.hasAttribute("Namespace")) {
LOGGER.severe("Specified a <Param> with intent to use Namespace & ID, but did not specify Namespace.");
// return an empty, but non-null list to know there was a problem.
Params.clear();
break;
}
if (!node.hasAttribute("id")) {
LOGGER.severe("Specified a <Param> with intent to use Namespace & ID, but did not specify ID.");
// return an empty, but non-null list to know there was a problem.
Params.clear();
break;
}
String NS = node.getAttribute("Namespace");
String ID = node.getAttribute("ID");
DataSrcParameter param = new DataSrcParameter(NS, ID, getDataMgr());
Params.add(param);
LOGGER.info("Creating <Param> with input from Namespace=" + NS + " and ID=" + ID);
} else {
// return an empty, but non-null list to know there was a problem.
Params.clear();
LOGGER.severe("Empty <Param> in task");
break;
}
}
}
return Params;
}
use of kutch.biff.marvin.utility.FrameworkNode in project Board-Instrumentation-Framework by intel.
the class TaskManager method BuildMarvinTaskItem.
/**
* Read the parameters from the xml file for a Marvin (local) task
*
* @param taskID ID of the task
* @param taskNode XML node
* @return A MarvinTask object
*/
private MarvinTask BuildMarvinTaskItem(String taskID, FrameworkNode taskNode) {
/**
* * Example Task
* <TaskItem Type="Marvin">
* <DataToInsert ID="Text" Namespace="PK Laptop" Data="First Text"/>
* </TaskItem>
*/
MarvinTask objMarvinTask = new MarvinTask();
objMarvinTask.setParams(GetParameters(taskNode));
if (objMarvinTask.getParams() != null && objMarvinTask.getParams().size() == 0) {
// means had problem loading params.
return null;
}
for (FrameworkNode node : taskNode.getChildNodes()) {
if (node.getNodeName().equalsIgnoreCase("DataToInsert")) {
Utility.ValidateAttributes(new String[] { "Namespace", "ID", "Data" }, node);
if (node.hasAttribute("Namespace") && node.hasAttribute("ID")) {
String strData = null;
if (node.hasAttribute("Data")) {
strData = node.getAttribute("Data");
} else {
for (FrameworkNode dataNode : node.getChildNodes()) {
if (dataNode.getNodeName().equalsIgnoreCase("Data")) {
strData = dataNode.getTextContent();
break;
}
}
}
if (strData != null) {
objMarvinTask.AddDataset(node.getAttribute("ID"), node.getAttribute("Namespace"), strData);
} else {
LOGGER.severe("Task with ID: " + taskID + " contains an invalid Marvin Task - no Data defined");
}
} else {
LOGGER.severe("Task with ID: " + taskID + " contains an invalid Marvin Task");
return null;
}
} else {
LOGGER.severe("Task with ID: " + taskID + " contains an unknown tag: " + node.getNodeName());
}
}
if (!objMarvinTask.isValid()) {
objMarvinTask = null;
LOGGER.severe("Task with ID: " + taskID + " contains an invalid Marvin Task");
}
return objMarvinTask;
}
Aggregations