use of kutch.biff.marvin.utility.FrameworkNode in project Board-Instrumentation-Framework by intel.
the class SteelSimpleGaugeBuilder method Build.
public static SteelSimpleGaugeWidget Build(FrameworkNode masterNode, String widgetDefFilename) {
SteelSimpleGaugeWidget sg = new SteelSimpleGaugeWidget();
for (FrameworkNode node : masterNode.getChildNodes()) {
if (BaseWidget.HandleCommonDefinitionFileConfig(sg, node)) {
continue;
} else if (node.getNodeName().equalsIgnoreCase("MinValue")) {
String str = node.getTextContent();
try {
sg.setMinValue(Double.parseDouble(str));
} catch (Exception ex) {
LOGGER.severe("Invalid MinValue in Widget Definition File");
return null;
}
} else if (node.getNodeName().equalsIgnoreCase("MaxValue")) {
String str = node.getTextContent();
try {
sg.setMaxValue(Double.parseDouble(str));
} catch (Exception ex) {
LOGGER.severe("Invalid MaxValue in SteelSimpleGauge Widget Definition File");
return null;
}
} else if (node.getNodeName().equalsIgnoreCase("Decimals")) {
String str = node.getTextContent();
try {
sg.setDecimalPlaces(Integer.parseInt(str));
} catch (Exception ex) {
LOGGER.severe("Invalid Decimals in SteelSimpleGauge Widget Definition File");
return null;
}
} else if (node.getNodeName().equalsIgnoreCase("UnitText")) {
String str = node.getTextContent();
sg.setUnitText(str);
} else if (node.getNodeName().equalsIgnoreCase("Sections")) {
ArrayList<Section> sectList = ProcessSections(node);
if (null != sectList) {
sg.setSections(sectList);
} else {
return null;
}
} else {
LOGGER.severe("Invalid SteelSimpleGauge Widget Definition File. Unknown Tag: " + node.getNodeName());
return null;
}
}
return sg;
}
use of kutch.biff.marvin.utility.FrameworkNode in project Board-Instrumentation-Framework by intel.
the class SVG_WidgetBuilder method Build.
public static SVG_Widget Build(FrameworkNode masterNode, String widgetDefFilename) {
SVG_Widget _widget = new SVG_Widget();
_widget = (SVG_Widget) TextBuilder.ReadTextWidgetInfo(_widget, masterNode, widgetDefFilename);
for (FrameworkNode node : masterNode.getChildNodes()) {
if (BaseWidget.HandleCommonDefinitionFileConfig(_widget, node)) {
} else if (node.getNodeName().equalsIgnoreCase("#comment")) {
}
}
return _widget;
}
use of kutch.biff.marvin.utility.FrameworkNode in project Board-Instrumentation-Framework by intel.
the class ConfigurationReader method ReadAppSettings.
private boolean ReadAppSettings(Document doc, boolean basicInfoOnly) {
NodeList appStuff = doc.getElementsByTagName("Application");
if (appStuff.getLength() < 1) {
LOGGER.severe("No <Application> section of config file");
return false;
}
if (appStuff.getLength() > 1) {
LOGGER.warning("More than one <Application> section found, only using first.");
}
boolean NetworkSettingsRead = false;
FrameworkNode baseNode = new FrameworkNode(appStuff.item(0));
FetchDimenstions(baseNode);
AliasMgr.getAliasMgr().addMarvinInfo();
AliasMgr.ReadAliasFromRootDocument(doc);
ReadAppAttributes(baseNode);
ArrayList<String> TabList = new ArrayList<String>();
for (FrameworkNode node : baseNode.getChildNodes()) {
if (node.getNodeName().equalsIgnoreCase("#Text") || node.getNodeName().equalsIgnoreCase("#Comment")) {
continue;
} else if (node.getNodeName().equalsIgnoreCase("Title")) {
_Configuration.setAppTitle(node.getTextContent());
LOGGER.config("Application Title = " + _Configuration.getAppTitle());
} else if (node.getNodeName().equalsIgnoreCase("Heartbeat")) {
if (node.hasAttribute("rate")) {
_Configuration.setHeartbeatInterval(node.getIntegerAttribute("rate", _Configuration.getHeartbeatInterval()));
}
} else if (node.getNodeName().equalsIgnoreCase("StyleSheet")) {
_Configuration.setCSSFile(node.getTextContent());
LOGGER.config("Setting application CSS to " + _Configuration.getCSSFile());
} else if (node.getNodeName().equalsIgnoreCase("IgnoreWebCerts")) {
_Configuration.setIgnoreWebCerts(node.getBooleanValue());
LOGGER.config("Ignoring Web Certifications");
} else if (node.getNodeName().equalsIgnoreCase("MonitorNumber")) {
try {
int monitorNum = Integer.parseInt(node.getTextContent());
int count = Screen.getScreens().size();
if (monitorNum <= Screen.getScreens().size()) {
Screen primary = Screen.getScreens().get(monitorNum - 1);
_Configuration.setPrimaryScreen(primary);
if (false == basicInfoOnly) {
LOGGER.config("Setting Primary Screen to monitor #" + node.getTextContent());
}
} else if (false == basicInfoOnly) {
LOGGER.warning("<MonitorNumber> set to " + node.getTextContent() + " however there are only " + Integer.toHexString(count) + " monitors. Ignoring");
}
} catch (Exception Ex) {
LOGGER.severe("Invalid MonitorNumber specified. Ignoring.");
// return false;
}
} else if (node.getNodeName().equalsIgnoreCase("CreationSize")) {
Utility.ValidateAttributes(new String[] { "Height", "Width" }, node);
if (node.hasAttribute("Height") && node.hasAttribute("Width")) {
_Configuration.setCreationWidth(node.getIntegerAttribute("Width", 0));
_Configuration.setCreationHeight(node.getIntegerAttribute("Height", 0));
} else if (false == basicInfoOnly) {
LOGGER.severe("Invalid CreationSize specified");
}
} else if (node.getNodeName().equalsIgnoreCase("Tasks")) {
if (basicInfoOnly) {
continue;
}
Utility.ValidateAttributes(new String[] { "Enabled" }, node);
if (node.hasAttribute("Enabled")) {
String str = node.getAttribute("Enabled");
if (str.equalsIgnoreCase("True")) {
_Configuration.setAllowTasks(true);
LOGGER.config("Tasks Enabled");
} else {
_Configuration.setAllowTasks(false);
LOGGER.config("Tasks Disabled");
}
}
} else if (node.getNodeName().equalsIgnoreCase("Network")) {
if (basicInfoOnly) {
continue;
}
Utility.ValidateAttributes(new String[] { "IP", "Port" }, node);
boolean fPort = false;
if (node.hasAttribute("IP")) {
String str = node.getAttribute("IP");
_Configuration.setAddress(str);
} else {
LOGGER.config("No IP specified in <Network> settings. Will listen on all interfaces");
_Configuration.setAddress("0.0.0.0");
}
if (node.hasAttribute("Port")) {
String str = node.getAttribute("Port");
try {
_Configuration.setPort(Integer.parseInt(str));
fPort = true;
} catch (Exception ex) {
LOGGER.severe("Invalid Network port: " + str);
}
} else {
LOGGER.info("Port not attribute for <Network> settings.");
}
if (fPort) {
NetworkSettingsRead = true;
} else {
return false;
}
for (FrameworkNode oscarNode : node.getChildNodes()) {
if (oscarNode.getNodeName().equalsIgnoreCase("#Text") || oscarNode.getNodeName().equalsIgnoreCase("#Comment")) {
continue;
} else if (oscarNode.getNodeName().equalsIgnoreCase("Oscar")) {
if (false == ReadOscarConnection(oscarNode)) {
return false;
}
}
}
} else if (node.getNodeName().equalsIgnoreCase("Padding")) {
if (basicInfoOnly) {
continue;
}
Utility.ValidateAttributes(new String[] { "top", "bottom", "left", "right", "legacymode" }, node);
String strTop = "-1";
String strBottom = "-1";
String strLeft = "-1";
String strRight = "-1";
if (node.hasAttribute("top")) {
strTop = node.getAttribute("top");
}
if (node.hasAttribute("bottom")) {
strBottom = node.getAttribute("bottom");
}
if (node.hasAttribute("left")) {
strLeft = node.getAttribute("left");
}
if (node.hasAttribute("right")) {
strRight = node.getAttribute("right");
}
try {
_Configuration.setInsetTop(Integer.parseInt(strTop));
_Configuration.setInsetBottom(Integer.parseInt(strBottom));
_Configuration.setInsetLeft(Integer.parseInt(strLeft));
_Configuration.setInsetRight(Integer.parseInt(strRight));
} catch (NumberFormatException ex) {
LOGGER.severe("Invalid Application <Inset> configuration.");
return false;
}
if (node.hasAttribute("legacymode")) {
_Configuration.setLegacyInsetMode(node.getBooleanAttribute("legacymode"));
if (_Configuration.getLegacyInsetMode()) {
LOGGER.config("Using LEGACY mode of padding.");
}
}
} else if (node.getNodeName().equalsIgnoreCase("MainMenu")) {
if (false == ReadAppMenu(node, basicInfoOnly)) {
return false;
}
} else if (node.getNodeName().equalsIgnoreCase("UnregisteredData")) {
if (basicInfoOnly) {
continue;
}
if (false == ReadUnregisteredDataInfo(node)) {
return false;
}
} else if (node.getNodeName().equalsIgnoreCase("Tabs")) {
Utility.ValidateAttributes(new String[] { "side" }, node);
if (// where the tabs should be located.
node.hasAttribute("Side")) {
String sideStr = node.getAttribute("Side");
if (sideStr.equalsIgnoreCase("Top")) {
_Configuration.setSide(Side.TOP);
} else if (sideStr.equalsIgnoreCase("Bottom")) {
_Configuration.setSide(Side.BOTTOM);
} else if (sideStr.equalsIgnoreCase("Left")) {
_Configuration.setSide(Side.LEFT);
} else if (sideStr.equalsIgnoreCase("Right")) {
_Configuration.setSide(Side.RIGHT);
} else {
LOGGER.warning("Invalid <Tabs Side=> attribute: " + sideStr + ". Ignoring");
}
}
if (basicInfoOnly) {
continue;
}
for (FrameworkNode tabNode : node.getChildNodes(true)) {
if (tabNode.getNodeName().equalsIgnoreCase("#Text")) {
continue;
}
if (tabNode.getNodeName().equalsIgnoreCase("Tab")) {
if (tabNode.hasAttributes()) {
String ID = tabNode.getAttribute("ID");
if (ID != null && ID.length() > 0) {
TabList.add(ID);
} else {
LOGGER.warning("Tab defined in <Tabs> without an ID");
}
}
}
}
} else if (node.getNodeName().equalsIgnoreCase("RefreshInterval")) {
if (basicInfoOnly) {
continue;
}
String strInterval = node.getTextContent();
try {
_Configuration.setTimerInterval(Long.parseLong(strInterval));
} catch (NumberFormatException ex) {
LOGGER.severe("Invalid Application <RefreshInterval> configuration.");
return false;
}
} else {
LOGGER.warning("Unexpected section in <Application>: " + node.getNodeName());
}
}
if (basicInfoOnly) {
return true;
}
if (TabList.size() < 1) {
LOGGER.severe("No Tabs defined in <Application> section of configuration file.");
return false;
}
_Configuration.setPrimaryScreenDetermined(true);
if (VerifyTabList(TabList)) {
_tabs = ReadTabs(doc, TabList);
if (null == _tabs) {
return false;
}
}
if (false == NetworkSettingsRead) {
LOGGER.severe("No <Network> section found in Application.xml");
}
return NetworkSettingsRead;
}
use of kutch.biff.marvin.utility.FrameworkNode in project Board-Instrumentation-Framework by intel.
the class ConfigurationReader method ReadTabs.
private List<TabWidget> ReadTabs(Document doc, List<String> TabID_List) {
FrameworkNode appNode = new FrameworkNode(doc.getChildNodes().item(0));
ArrayList<TabWidget> TabList = new ArrayList<>();
for (FrameworkNode node : appNode.getChildNodes(true)) {
if (node.getNodeName().equalsIgnoreCase("#Text") || node.getNodeName().equalsIgnoreCase("#comment")) {
continue;
}
if (node.getNodeName().equalsIgnoreCase("DemoFramework")) {
LOGGER.warning("DemoFramework XML tag is deprecated. Use 'Marvin'");
continue;
}
if (node.getNodeName().equalsIgnoreCase("Marvin")) {
continue;
}
if (node.getNodeName().equalsIgnoreCase("Application")) {
continue;
}
if (node.getNodeName().equalsIgnoreCase("Tab")) {
TabWidget tab = null;
if (node.hasAttributes()) {
if (node.hasAttribute("ID")) {
boolean found = false;
String id = node.getAttribute("ID");
if (TabAlreadyLoaded(TabList, id)) {
LOGGER.severe("<Tab ID=" + id + "> defined twice in <Tabs>.");
return null;
}
for (String string : TabID_List) {
if (0 == string.compareToIgnoreCase(id)) {
found = true;
tab = new TabWidget(id);
FrameworkNode tabNode = null;
AliasMgr.getAliasMgr().PushAliasList(true);
// Make TabID an alias = to the ID :-)
AliasMgr.getAliasMgr().AddAlias("TabID", id);
if (// can externally define widgets within
node.hasAttribute("File")) {
WidgetBuilder.StartReadingExternalFile(node);
tabNode = OpenTabDefinitionFile(node.getAttribute("File"));
if (null == tabNode) {
LOGGER.severe("Invalid tab definition file: " + node.getAttribute("File"));
return null;
}
AliasMgr.getAliasMgr().AddAliasFromAttibuteList(node, new String[] { "ID", "File", "Align", "hgap", "vgap" });
if (false == AliasMgr.getAliasMgr().ReadAliasFromExternalFile(node.getAttribute("File"))) {
return null;
}
if (!ConfigurationReader.ReadTasksFromExternalFile(node.getAttribute("File"))) {
return null;
}
} else {
Utility.ValidateAttributes(new String[] { "ID", "File", "Align", "hgap", "vgap" }, node);
tabNode = node;
}
if (null == tabNode) {
return null;
}
if (false == tab.LoadConfiguration(tabNode)) {
return null;
}
if (node.hasAttribute("File")) {
WidgetBuilder.DoneReadingExternalFile();
}
break;
}
}
if (true == found) {
AliasMgr.getAliasMgr().PopAliasList();
} else {
LOGGER.warning("<Tab ID=" + id + "> found, but not used in <Tabs>.");
continue;
}
} else {
LOGGER.warning("<Tab> with no ID found.");
return null;
}
if (true == node.hasAttribute("Align")) {
String str = node.getAttribute("Align");
tab.setAlignment(str);
}
if (node.hasAttribute("hgap")) {
try {
if (!tab.parsehGapValue(node)) {
LOGGER.config("Setting hGap for Tab ID=" + tab.getMinionID() + " to " + node.getAttribute("hgap"));
}
// tab.sethGap(Integer.parseInt(node.getAttribute("hgap")));
} catch (Exception ex) {
LOGGER.warning("Tab ID=" + tab.getMinionID() + " has invalid hgap. Ignoring");
}
}
if (node.hasAttribute("vgap")) {
try {
if (!tab.parsevGapValue(node)) {
LOGGER.config("Setting vGap for Tab ID=" + tab.getMinionID() + " to " + node.getAttribute("vgap"));
}
// tab.setvGap(Integer.parseInt(node.getAttribute("vgap")));
// LOGGER.config("Setting vGap for Tab ID=" + tab.getMinionID() + " to " + node.getAttribute("vgap"));
} catch (Exception ex) {
LOGGER.warning("Tab ID=" + tab.getMinionID() + " has invalid vgap. Ignoring");
}
}
}
if (null == tab) {
LOGGER.severe("Malformed <Tab> found in configuration file");
return null;
}
TabList.add(tab);
} else if (node.getNodeName().equalsIgnoreCase("TaskList")) {
ConfigurationReader.ReadTaskList(node);
} else if (node.getNodeName().equalsIgnoreCase("Prompt")) {
ConfigurationReader.ReadPrompt(node);
} else if (node.getNodeName().equalsIgnoreCase("AliasList")) {
} else {
LOGGER.warning("Unexpected Tag Type in configuration file: " + node.getNodeName());
}
}
if (false == VerifyDesiredTabsPresent(TabList, TabID_List)) {
return null;
}
return SortTabs(TabList, TabID_List);
}
use of kutch.biff.marvin.utility.FrameworkNode in project Board-Instrumentation-Framework by intel.
the class ConfigurationReader method ReadTaskList.
public static boolean ReadTaskList(FrameworkNode taskNode) {
TaskManager TASKMAN = TaskManager.getTaskManager();
boolean retVal = true;
String taskID = null;
String externFile = null;
FrameworkNode nodeToPass = taskNode;
Utility.ValidateAttributes(new String[] { "ID", "File", "PerformOnStartup", "PerformOnConnect", "stepped" }, taskNode);
if (false == taskNode.hasAttribute("ID")) {
LOGGER.warning("Task defined with no ID, ignoring");
return false;
}
taskID = taskNode.getAttribute("ID");
if (taskNode.hasAttribute("File")) {
externFile = taskNode.getAttribute("File");
if (// could also be tasks defined in external file
!ConfigurationReader.ReadTasksFromExternalFile(externFile)) {
return false;
}
// TODO, likely need to make path OS independent in OpenXMLFile app
Document externDoc = OpenXMLFile(externFile);
if (externDoc != null) {
nodeToPass = new FrameworkNode((Node) externDoc);
} else {
// something wrong with file, already notified in OpenXMLFile. Continue processing, looking for more issues
retVal = false;
}
}
if (TASKMAN.CreateTask(taskID, nodeToPass)) {
} else {
retVal = false;
}
return retVal;
}
Aggregations