use of kutch.biff.marvin.utility.FrameworkNode in project Board-Instrumentation-Framework by intel.
the class ConfigurationReader method ReadPrompts.
private static boolean ReadPrompts(Document doc) {
PromptManager PROMPTMAN = PromptManager.getPromptManager();
boolean retVal = true;
NodeList prompts = doc.getElementsByTagName("Prompt");
if (prompts.getLength() < 1) {
// LOGGER.info("No Tasks defined in config file.");
return true;
}
for (int iLoop = 0; iLoop < prompts.getLength(); iLoop++) {
FrameworkNode promptNode = new FrameworkNode(prompts.item(iLoop));
if (!ReadPrompt(promptNode)) {
retVal = false;
break;
}
}
return retVal;
}
use of kutch.biff.marvin.utility.FrameworkNode in project Board-Instrumentation-Framework by intel.
the class DynamicGridWidget method BuildGrid.
private GridWidget BuildGrid(FrameworkNode node) {
// DynamicGrid is a superset, so can do this
GridWidget retWidget = new DynamicGrid();
if (true == node.hasAttribute("Source") || node.hasAttribute("Macro")) {
FrameworkNode GridNode = null;
AliasMgr.getAliasMgr().PushAliasList(true);
AliasMgr.getAliasMgr().AddAliasFromAttibuteList(node, new String[] { "hgap", "vgap", "Align", "Source", "ID" });
if (node.hasAttribute("Source")) {
if (false == AliasMgr.ReadAliasFromExternalFile(node.getAttribute("Source"))) {
AliasMgr.getAliasMgr().PopAliasList();
return null;
}
WidgetBuilder.StartReadingExternalFile(node);
GridNode = WidgetBuilder.OpenDefinitionFile(node.getAttribute("Source"), "Grid");
if (// could also be tasks defined in external file
!ConfigurationReader.ReadTasksFromExternalFile(node.getAttribute("Source"))) {
return null;
}
WidgetBuilder.DoneReadingExternalFile();
} else {
GridNode = GridMacroMgr.getGridMacroMgr().getGridMacro(node.getAttribute("Macro"));
if (null == GridNode) {
LOGGER.severe("Unknown Grid Macro [" + node.getAttribute("Macro") + "] specified for Dynamic Grid Source");
}
}
if (null == GridNode) {
return null;
}
// read grid from external file
retWidget = ReadGridInfo(GridNode, retWidget, null);
if (null == retWidget) {
return null;
}
if (node.hasAttribute("hgap")) {
if (retWidget.parsehGapValue(node)) {
LOGGER.config("Setting hGap for DynamicGrid :" + node.getAttribute("hgap"));
} else {
LOGGER.warning("hgap for DynamicGrid invalid: " + node.getAttribute("hgap") + ". Ignoring");
return null;
}
}
if (node.hasAttribute("vgap")) {
if (retWidget.parsevGapValue(node)) {
LOGGER.config("Setting vGap for DynamicGrid :" + node.getAttribute("vgap"));
} else {
LOGGER.warning("vgap for DynamicGrid invalid: " + node.getAttribute("vgap") + ". Ignoring");
return null;
}
}
if (true == node.hasAttribute("Align")) {
String str = node.getAttribute("Align");
retWidget.setAlignment(str);
} else {
// if one wasn't specifice for the grid file, use whatever the master for the widget is.
retWidget.setAlignment(getAlignment());
}
if (node.hasAttribute("Task")) {
retWidget.setTaskID(node.getAttribute("Task"));
} else if (null != getTaskID()) {
// if no task setup for individual grid, use the one for this grid
retWidget.setTaskID(getTaskID());
}
AliasMgr.getAliasMgr().PopAliasList();
}
return retWidget;
}
use of kutch.biff.marvin.utility.FrameworkNode in project Board-Instrumentation-Framework by intel.
the class BaseChartWidget method ReadSeriesSet.
protected boolean ReadSeriesSet(FrameworkNode setNode) {
String title = "";
if (setNode.hasAttributes()) {
Utility.ValidateAttributes(new String[] { "Title" }, setNode);
if (setNode.hasAttribute("Title")) {
title = setNode.getAttribute("Title");
}
}
for (FrameworkNode node : setNode.getChildNodes()) {
if (node.getNodeName().equalsIgnoreCase("MinionSrc")) {
Utility.ValidateAttributes(new String[] { "ID", "Namespace", "SeriesID" }, node);
String ID, Namespace, SeriesID;
if (node.hasAttribute("ID")) {
ID = node.getAttribute("ID");
} else {
LOGGER.severe("Chart SeriesSet defined with invalid MinionSrc - no ID");
return false;
}
if (node.hasAttribute("Namespace")) {
Namespace = node.getAttribute("Namespace");
} else {
LOGGER.severe("hart SeriesSedefined with invalid MinionSrc - no Namespace");
return false;
}
if (node.hasAttribute("SeriesID")) {
SeriesID = node.getAttribute("SeriesID");
} else {
LOGGER.severe("Chart SeriesSet defined with invalid MinionSrc - no SeriesID");
return false;
}
if (false == _SeriesMap.containsKey(SeriesID.toUpperCase())) {
LOGGER.severe("Chart SeriesSet defined with invalid MinionSrc - the Series ID has not been defined in a <Series> section. SeriesID=" + SeriesID);
return false;
}
SeriesDataSet objDS = new SeriesDataSet(title, ID, Namespace);
_SeriesMap.get(SeriesID.toUpperCase()).AddSeries(objDS);
}
}
return true;
}
use of kutch.biff.marvin.utility.FrameworkNode in project Board-Instrumentation-Framework by intel.
the class BaseWidget method HandleMarvinPeekaboo.
private void HandleMarvinPeekaboo(String strRequest) {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db;
Document doc;
FrameworkNode baseNode;
// Can't pass XML within XML, so for this, change < for [ and ] for >
String strMassaged = strRequest.substring("Marvin:".length()).replace('[', '<').replace(']', '>');
// strMassaged = toEscaped(strMassaged);
try {
try {
db = dbf.newDocumentBuilder();
} catch (ParserConfigurationException ex) {
LOGGER.severe(ex.toString());
return;
}
doc = db.parse(new ByteArrayInputStream(strMassaged.getBytes()));
NodeList appStuff = doc.getChildNodes();
baseNode = new FrameworkNode(appStuff.item(0));
} catch (SAXException | IOException ex) {
LOGGER.severe(ex.toString());
LOGGER.severe("Invalid Peekaboo Marvin data received: " + strRequest);
LOGGER.severe(strMassaged);
return;
}
if (baseNode.getNodeName().equalsIgnoreCase("StyleOverride")) {
HandleRemoteStyleOverride(baseNode);
} else if (baseNode.getNodeName().equalsIgnoreCase("Title")) {
HandleRemoteTitleUpdate(baseNode);
} else {
LOGGER.warning("Received unknown Peekaboo Marvin data: " + strRequest);
}
}
use of kutch.biff.marvin.utility.FrameworkNode in project Board-Instrumentation-Framework by intel.
the class ReceiveThreadMgr method HandleIncomingRemoteMarvinTaskPacket.
private void HandleIncomingRemoteMarvinTaskPacket(Node baseNode) {
/*
<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<RemoteMarvinTask>
<Version>1.0</Version>
<Requester> 192.168.1.1</Requester>
<MarvinID>DemoApp</MarvinID>
<Task>Button2Push</Task>
</RemoteMarvinTask>
*/
FrameworkNode node = new FrameworkNode(baseNode);
try {
String Version = node.getChild("Version").getTextContent();
String Remote = node.getChild("Requester").getTextContent();
String MarvinID = node.getChild("MarvinID").getTextContent();
String Task = node.getChild("Task").getTextContent();
if (!Version.equalsIgnoreCase("1.0")) {
String RequestNumber = node.getChild("RequestNumber").getTextContent();
if (LastMarvinTaskReceived.containsKey(Remote)) {
if (LastMarvinTaskReceived.get(Remote).equalsIgnoreCase(RequestNumber)) {
// Already received this one, remember is UDP so it is sent a few times
return;
}
}
LastMarvinTaskReceived.put(Remote, RequestNumber);
}
if (false == MarvinID.equalsIgnoreCase(CONFIG.GetApplicationID()) && false == MarvinID.equalsIgnoreCase("Broadcast")) {
LOGGER.info("Received Remote Marvin Task, but is not targeted at this Marvin, is going to :" + MarvinID);
return;
}
LOGGER.info("Received RemoteMarvinTask [" + Task + " ]from [" + Remote + "]");
// can't run it here, because in worker thread, so queue it up for later
TASKMAN.AddDeferredTask(Task);
} catch (Exception ex) {
LOGGER.warning("Received invalid RemoteMarvinTask:" + baseNode.toString());
}
}
Aggregations