use of kutch.biff.marvin.utility.FrameworkNode in project Board-Instrumentation-Framework by intel.
the class Prompt_ListBox method HandlePromptSpecificConfig.
/**
* @param baseNode
* @return
*/
@Override
public boolean HandlePromptSpecificConfig(FrameworkNode baseNode) {
if (baseNode.getNodeName().equalsIgnoreCase("List")) {
int itemIndex = 0;
for (FrameworkNode node : baseNode.getChildNodes(true)) {
if (node.getNodeName().equalsIgnoreCase("#Text") || node.getNodeName().equalsIgnoreCase("#Comment")) {
continue;
}
if (node.getNodeName().equalsIgnoreCase("Item")) {
@SuppressWarnings("unused") String strDisplayText;
if (node.hasAttribute("Text")) {
strDisplayText = node.getAttribute("Text");
} else {
strDisplayText = node.getTextContent();
}
/*
* Beginning of work, but not yet done
*/
List<DataPointGenerator> dataPoints = null;
if (node.hasAttribute("CreateDataPoint")) {
dataPoints = ConfigurationReader.ReadDataPointsForTask(itemIndex++, node.getAttribute("CreateDataPoint"), node.getAttribute("Text"), node.getAttribute("Task"));
}
AddListItem(strDisplayText, node.getTextContent(), dataPoints);
} else {
LOGGER.severe("Invalid list item in prompt ID: " + this.toString() + " [" + node.getNodeName() + "]");
return false;
}
}
return true;
}
return false;
}
use of kutch.biff.marvin.utility.FrameworkNode in project Board-Instrumentation-Framework by intel.
the class TaskManager method BuildDesktopTaskItem.
private DesktopTask BuildDesktopTaskItem(String taskID, FrameworkNode taskNode) {
/**
* <TaskList ID="TestDesktop"> <TaskItem Type="Desktop">
* <Document Action="Open">foo.html</Document> </TaskItem> </TaskList>
*/
DesktopTask objDesktopTask = new DesktopTask();
for (FrameworkNode node : taskNode.getChildNodes()) {
if (node.getNodeName().equalsIgnoreCase("Document")) {
Utility.ValidateAttributes(new String[] { "Action" }, node);
if (!objDesktopTask.SetDocument(node.getTextContent())) {
LOGGER.severe("Desktop task has invalid document: " + node.getTextContent());
return null;
}
if (node.hasAttribute("Action")) {
if (!objDesktopTask.SetAction(node.getAttribute("Action"))) {
LOGGER.severe("Desktop task has invalid Actiont: " + node.getAttribute("Action"));
}
} else {
objDesktopTask.SetAction("Open");
}
}
}
if (!objDesktopTask.isValid()) {
objDesktopTask = null;
LOGGER.severe("Task with ID: " + taskID + " contains an invalid Desktop Task.");
}
return objDesktopTask;
}
use of kutch.biff.marvin.utility.FrameworkNode in project Board-Instrumentation-Framework by intel.
the class TaskManager method BuildMarvinPlaybackTaskItem.
/**
* Read the parameters from the xml file for a Oscar task
*
* @param taskID ID of the task
* @param taskNode XML node
* @return A OscarTask object
*/
private MarvinPlaybackTask BuildMarvinPlaybackTaskItem(String taskID, FrameworkNode taskNode) {
// objMinionTask.setParams(GetParameters(taskNode));
MarvinPlaybackTask pbT = null;
String PlayerID = null;
MarvinPlaybackTask.PlaybackAction action = MarvinPlaybackTask.PlaybackAction.INVALID;
ArrayList<Parameter> Params = GetParameters(taskNode);
for (FrameworkNode node : taskNode.getChildNodes()) {
if (node.getNodeName().equalsIgnoreCase("Task")) {
Utility.ValidateAttributes(new String[] { "PlayerID" }, node);
if (node.hasAttribute("PlayerID")) {
PlayerID = node.getAttribute("PlayerID");
} else {
LOGGER.severe("MarvinPlayback Task [" + taskID + "] defined without PlayerID");
return null;
}
String strAction = node.getTextContent();
switch(strAction.toUpperCase()) {
case "PLAY":
action = MarvinPlaybackTask.PlaybackAction.PLAY;
break;
case "STOP":
action = MarvinPlaybackTask.PlaybackAction.STOP;
if (null != Params) {
LOGGER.severe("MarvinPlayback Task [" + taskID + "] Invalid. No Params allowed for task of " + strAction);
return null;
}
break;
case "PAUSE":
action = MarvinPlaybackTask.PlaybackAction.PAUSE;
if (null != Params) {
LOGGER.severe("MarvinPlayback Task [" + taskID + "] Invalid. No Params allowed for task of " + strAction);
return null;
}
break;
case "RESUME":
action = MarvinPlaybackTask.PlaybackAction.RESUME;
if (null != Params) {
LOGGER.severe("MarvinPlayback Task [" + taskID + "] Invalid. No Params allowed for task of " + strAction);
return null;
}
break;
case "SET OPTIONS":
action = MarvinPlaybackTask.PlaybackAction.SET_OPTIONS;
if (null == Params) {
LOGGER.severe("MarvinPlayback Task [" + taskID + "] Invalid. No Params specified for task of " + strAction);
return null;
}
break;
case "PLAY FILE":
action = MarvinPlaybackTask.PlaybackAction.PLAY_FILE;
if (null == Params) {
LOGGER.severe("MarvinPlayback Task [" + taskID + "] Invalid. No Params specified for task of " + strAction);
return null;
}
break;
case "LOAD FILE":
action = MarvinPlaybackTask.PlaybackAction.LOAD_FILE;
if (null == Params) {
LOGGER.severe("MarvinPlayback Task [" + taskID + "] Invalid. No Params specified for task of " + strAction);
return null;
}
break;
default:
LOGGER.severe("MarvinPlayback Task [" + taskID + "] defined with invalid Task: " + strAction);
return null;
}
}
}
pbT = new MarvinPlaybackTask(PlayerID, action);
if (null != Params) {
for (Parameter p : Params) {
if (!p.toString().contains("=")) {
LOGGER.severe("MarvinPlayback Task [" + taskID + "] defined with invalid Param: " + p.toString());
return null;
}
String[] parts = p.toString().split("=");
String What = parts[0];
if (What.equalsIgnoreCase("File")) {
if (!pbT.set_fileName(parts[1])) {
return null;
}
} else if (What.equalsIgnoreCase("Speed")) {
try {
pbT.set_Speed(Double.parseDouble(parts[1]));
} catch (Exception e) {
LOGGER.severe("MarvinPlayback Task [" + taskID + "] defined with invalid Param: " + p.toString());
return null;
}
} else if (What.equalsIgnoreCase("Repeat")) {
if (parts[1].equalsIgnoreCase("true")) {
pbT.set_Loop(true);
} else if (parts[1].equalsIgnoreCase("false")) {
pbT.set_Loop(false);
} else {
LOGGER.severe("MarvinPlayback Task [" + taskID + "] defined with invalid Param: " + p.toString());
return null;
}
}
}
}
return pbT;
}
use of kutch.biff.marvin.utility.FrameworkNode in project Board-Instrumentation-Framework by intel.
the class TaskManager method CreateTask.
public boolean CreateTask(String ID, FrameworkNode masterNode) {
boolean retVal = false;
boolean OnStartup = false;
boolean OnConnected = false;
double IntervalTime = 0;
TaskList objTask = null;
if (true == masterNode.hasAttribute("Stepped") && masterNode.getBooleanAttribute("Stepped")) {
SteppedTaskList objSteppedTask = new SteppedTaskList();
if (true == masterNode.hasAttribute("LoopTasks")) {
objSteppedTask.setLooped(masterNode.getBooleanAttribute("PerformOnStartup"));
}
objTask = objSteppedTask;
} else {
objTask = new TaskList();
}
if (true == masterNode.hasAttribute("Interval")) {
IntervalTime = masterNode.getDoubleAttribute("Interval", -1.0);
if (IntervalTime < 0.0) {
IntervalTime = 0.0;
}
// specified in seconds, checked in ms
IntervalTime = IntervalTime * 1000.0;
objTask.SetInterval(IntervalTime);
}
if (true == masterNode.hasAttribute("PerformOnStartup")) {
OnStartup = masterNode.getBooleanAttribute("PerformOnStartup");
}
if (true == masterNode.hasAttribute("PerformOnConnect")) {
OnConnected = masterNode.getBooleanAttribute("PerformOnConnect");
}
for (FrameworkNode node : masterNode.getChildNodes()) {
long Postpone = 0;
if (0 == node.getNodeName().compareToIgnoreCase("#text") || 0 == node.getNodeName().compareToIgnoreCase("#comment")) {
continue;
}
if (node.getNodeName().equalsIgnoreCase("TaskItem")) {
if (false == node.hasAttribute("Type")) {
LOGGER.severe("Task with ID: " + ID + " contains a TaskItem with no Type");
continue;
}
if (node.hasAttribute("Postpone")) {
Postpone = ReadTaskPostpone(node.getAttribute("Postpone"));
}
String taskType = node.getAttribute("Type");
BaseTask objTaskItem = null;
if (0 == taskType.compareToIgnoreCase("Oscar")) {
objTaskItem = BuildOscarTaskItem(ID, node);
} else if (taskType.equalsIgnoreCase("OscarBind")) {
objTaskItem = BuildOscarBindTask(ID, node);
} else if (0 == taskType.compareToIgnoreCase("Minion")) {
objTaskItem = BuildMinionTaskItem(ID, node);
} else if (0 == taskType.compareToIgnoreCase("Marvin")) {
objTaskItem = BuildMarvinTaskItem(ID, node);
} else if (0 == taskType.compareToIgnoreCase("Mathematic")) {
objTaskItem = BuildMathematicTaskTaskItem(ID, node);
} else if (0 == taskType.compareToIgnoreCase("DeltaValue")) {
objTaskItem = BuildDeltaValueTaskItem(ID, node);
} else if (0 == taskType.compareToIgnoreCase("DataPulse")) {
objTaskItem = BuildPulseTaskItem(ID, node);
} else if (0 == taskType.compareToIgnoreCase("OtherTask")) {
objTaskItem = BuildChainedTaskItem(ID, node);
} else if (0 == taskType.compareToIgnoreCase("MarvinAdmin")) {
objTaskItem = BuildMarvinAdminTaskItem(ID, node);
} else if (0 == taskType.compareToIgnoreCase("RemoteMarvinTask")) {
objTaskItem = BuildRemoteMarvinTaskItem(ID, node);
} else if (taskType.equalsIgnoreCase("RandomTask") || taskType.equalsIgnoreCase("Random")) {
objTaskItem = BuildRandomTaskItem(ID, node);
} else if (taskType.equalsIgnoreCase("Desktop")) {
objTaskItem = BuildDesktopTaskItem(ID, node);
} else if (taskType.equalsIgnoreCase("UpdateProxy")) {
objTaskItem = BuildUpdateProxyTask(ID, node);
} else if (taskType.equalsIgnoreCase("DataSetFile")) {
objTaskItem = BuildDataSetFileTaskItem(ID, node);
} else if (taskType.equalsIgnoreCase("SaveScreenshot")) {
objTaskItem = BuildSaveScreenshotTaskItem(ID, node);
} else if (taskType.equalsIgnoreCase("MarvinPlayback")) {
objTaskItem = BuildMarvinPlaybackTaskItem(ID, node);
} else if (taskType.equalsIgnoreCase("LaunchApplication") || taskType.equalsIgnoreCase("LaunchApp") || taskType.equalsIgnoreCase("LaunchProgram") || taskType.equalsIgnoreCase("RunProgram") || taskType.equalsIgnoreCase("RunApp")) {
objTaskItem = BuildLaunchApplicationTaskItem(ID, node);
} else {
LOGGER.severe("Task with ID: " + ID + " contains a TaskItem of unknown Type of " + taskType + ".");
}
if (null != objTaskItem) {
objTaskItem.setPostponePeriod(Postpone);
objTask.AddTaskItem(objTaskItem);
retVal = true;
}
}
}
if (true == retVal) {
if (false == AddNewTask(ID, objTask, OnStartup, OnConnected)) {
retVal = false;
}
} else {
LOGGER.severe("Task with ID: " + ID + " is invalid.");
}
return retVal;
}
use of kutch.biff.marvin.utility.FrameworkNode in project Board-Instrumentation-Framework by intel.
the class TaskManager method BuildDeltaValueTaskItem.
private PulseTask BuildDeltaValueTaskItem(String taskID, FrameworkNode taskNode) {
/**
* * Example Task <TaskItem Type="DeltaValue">
* <MarvinDataPoint ID="AppStartupSeconds" Namespace="PK Laptop"/>
* <MarvinDataPoint ID="Currseconds" Namespace="PK Laptop"/>
* <Operation ID="Uptime" Namespace="PK Laptop">Delta | DeltaPercent</Operation>
* </TaskItem>
*/
boolean errorLogged = false;
DeltaValueTask objTask = new DeltaValueTask();
boolean firstDPFound = false;
boolean secondDPFound = false;
for (FrameworkNode node : taskNode.getChildNodes()) {
if (node.getNodeName().equalsIgnoreCase("MarvinDataPoint")) {
Utility.ValidateAttributes(new String[] { "Namespace", "ID" }, node);
if (node.hasAttribute("Namespace") && node.hasAttribute("ID")) {
if (!firstDPFound) {
firstDPFound = true;
objTask.SetFirstDatapoint(node.getAttribute("Namespace"), node.getAttribute("ID"));
} else if (!secondDPFound) {
secondDPFound = true;
objTask.SetSecondDatapoint(node.getAttribute("Namespace"), node.getAttribute("ID"));
} else {
LOGGER.severe("Task with ID: " + taskID + " contains an invalid Delta Task - more than 2 MarvinDataPoints defined. Ignoring extras");
errorLogged = true;
}
} 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[] { "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 Delta Task Operation. Namespace and ID required ");
errorLogged = true;
}
String strOperationType = node.getTextContent();
if (!objTask.SetOperation(strOperationType)) {
LOGGER.severe("Task with ID: " + taskID + " contains an invalid Delta Task Task Operation : " + strOperationType);
errorLogged = true;
}
}
}
if (!objTask.isValid()) {
objTask = null;
if (!errorLogged) {
LOGGER.severe("Task with ID: " + taskID + " contains an invalid Delta Task - no MarvinDataPoint defined");
}
}
return objTask;
}
Aggregations