Search in sources :

Example 51 with FrameworkNode

use of kutch.biff.marvin.utility.FrameworkNode in project Board-Instrumentation-Framework by intel.

the class TaskManager method BuildDataSetFileTaskItem.

private DataSetFileTask BuildDataSetFileTaskItem(String taskID, FrameworkNode taskNode) {
    /**
     * <TaskItem Type="DataSetFile" File="Foo.csv" DataRate="1000">
     * <Options RepeatCount="forever"> <!-- Forever, or count -->
     * <Range Min="0" Max="9.3"/> <Flux>10</Flux> <Flux>1%</Flux> </Options>
     * </TaskItem>
     */
    int DataRate;
    String FileName;
    // <Options RepeatCount="forever"> <!-- Forever, or count -->
    if (false == taskNode.hasAttribute("File")) {
        LOGGER.severe("Task with ID: " + taskID + " contains an invalid definition. File Required");
        return null;
    }
    if (false == taskNode.hasAttribute("DataRate")) {
        LOGGER.severe("Task with ID: " + taskID + " contains an invalid definition. DataRate Required");
        return null;
    }
    FileName = taskNode.getAttribute("File");
    DataRate = taskNode.getIntegerAttribute("DataRate", -3232);
    if (DataRate < 100) {
        LOGGER.severe("Task with ID: " + taskID + " contains an invalid DataRate  of " + taskNode.getAttribute("DataRate"));
        return null;
    }
    DataSetFileTask objTask = new DataSetFileTask(FileName, DataRate);
    if (taskNode.hasChild("Options")) {
        FrameworkNode optionsNode = taskNode.getChild("Options");
        if (optionsNode.hasAttribute("RepeatCount")) {
            int repeatCount = optionsNode.getIntegerAttribute("RepeatCount", 0);
            if (repeatCount < 1) {
                LOGGER.severe("DataSetFileTask with ID: " + taskID + " contains an invalid RepeatCount  of " + taskNode.getAttribute("RepeatCount"));
                return null;
            }
            objTask.setRepeatCount(repeatCount);
        }
        if (// <RandomFluxRange Lower=\"-.24\" Upper=\".4\"/>"))
        optionsNode.hasChild("RandomFluxRange")) {
            FrameworkNode fluxNode = optionsNode.getChild("RandomFluxRange");
            Double lower, upper;
            if (!(fluxNode.hasAttribute("Lower") && fluxNode.hasAttribute("Upper"))) {
                LOGGER.severe("DataSetFileTask with ID: " + taskID + " specified RandomFlux range without Lower and Upper values");
                return null;
            }
            lower = fluxNode.getDoubleAttribute("Lower", -323232);
            if (lower == 323232) {
                LOGGER.severe("DataSetFileTask with ID: " + taskID + " specified Invalid RandomFlux lower: " + fluxNode.getAttribute("Lower"));
                return null;
            }
            upper = fluxNode.getDoubleAttribute("Upper", -323232);
            if (lower == 323232) {
                LOGGER.severe("DataSetFileTask with ID: " + taskID + " specified Invalid RandomFlux upper: " + fluxNode.getAttribute("upper"));
                return null;
            }
            objTask.setFluxRange(lower, upper);
        }
    }
    return objTask;
}
Also used : FrameworkNode(kutch.biff.marvin.utility.FrameworkNode)

Example 52 with FrameworkNode

use of kutch.biff.marvin.utility.FrameworkNode in project Board-Instrumentation-Framework by intel.

the class TaskManager method BuildRandomTaskItem.

private RandomTask BuildRandomTaskItem(String taskID, FrameworkNode taskNode) {
    /**
     * * Example Task <TaskItem Type="Random">
     *
     * <Task>TaskID</Task> <Task Weight="50">TaskID2</Task> <Task>TaskID3</Task>
     * </TaskItem>
     */
    RandomTask objRandomTask = new RandomTask();
    double TotalWeight = 0;
    for (FrameworkNode node : taskNode.getChildNodes()) {
        if (node.getNodeName().equalsIgnoreCase("Task")) {
            Utility.ValidateAttributes(new String[] { "Weight" }, node);
            String strTaskID;
            double Weight = 0;
            if (node.hasAttribute("Weight")) {
                Weight = node.getDoubleAttribute("Weight", 0);
                if (Weight >= 100 || Weight <= 0) {
                    LOGGER.severe("RandomTask [" + taskID + "] has a Task with an invalid weight: " + node.getAttribute("Weight"));
                    return null;
                }
                TotalWeight += Weight;
            }
            strTaskID = node.getTextContent();
            objRandomTask.AddTask(strTaskID, Weight);
        }
    }
    if (TotalWeight > 100) {
        LOGGER.severe("RandomTask [" + taskID + "] has a cummulative weight of > 100.");
        return null;
    }
    return objRandomTask;
}
Also used : FrameworkNode(kutch.biff.marvin.utility.FrameworkNode)

Example 53 with FrameworkNode

use of kutch.biff.marvin.utility.FrameworkNode in project Board-Instrumentation-Framework by intel.

the class BaseWidget method HandleToolTipConfig.

public boolean HandleToolTipConfig(FrameworkNode baseNode) {
    /*
	 * <ToolTip>My Tool Tip</ToolTop> or <ToolTip> <DisplayString>My Tool
	 * Tip</DisplayString>
	 * <StyleOverride><Item>-fx-background-color:blue</Item></StyleOverride>
	 * </ToolTip>
	 */
    String strDisplay;
    if (baseNode.getChildNodes().size() == 0) {
        strDisplay = baseNode.getTextContent();
        if (strDisplay.length() > 0) {
            SetToolTip(strDisplay);
            return true;
        }
        LOGGER.severe("Invalid ToolTop specified.");
        return false;
    }
    if (baseNode.hasChild("DisplayString")) {
        strDisplay = baseNode.getChild("DisplayString").getTextContent();
        if (strDisplay.length() > 0) {
            SetToolTip(strDisplay);
        } else {
            LOGGER.severe("Invalid ToolTop specified.");
            return false;
        }
    }
    if (baseNode.hasChild("StyleOverride")) {
        FrameworkNode styleNode = baseNode.getChild("StyleOverride");
        _ToolTipStyle = new ArrayList<>();
        for (FrameworkNode node : styleNode.getChildNodes()) {
            if (node.getNodeName().equalsIgnoreCase("#Text") || node.getNodeName().equalsIgnoreCase("#comment")) {
                continue;
            }
            if (node.getNodeName().equalsIgnoreCase("Item")) {
                _ToolTipStyle.add(node.getTextContent());
            } else {
                LOGGER.severe("Unknown Tag under <ToolTip> <StyleOverride>: " + node.getNodeName());
                return false;
            }
        }
    }
    return true;
}
Also used : FrameworkNode(kutch.biff.marvin.utility.FrameworkNode)

Example 54 with FrameworkNode

use of kutch.biff.marvin.utility.FrameworkNode in project Board-Instrumentation-Framework by intel.

the class BaseWidget method HandleSelectionConfig.

public boolean HandleSelectionConfig(FrameworkNode styleNode) {
    /*
	 * <SelectedStyle> <Item>-fx-background-color:yellow</Item> </SelectedStyle>
	 */
    _SelectedStyle = new ArrayList<>();
    Utility.ValidateAttributes(new String[] { "File", "ID" }, styleNode);
    if (styleNode.hasAttribute("File")) {
        _SelectedStyleCSS = styleNode.getAttribute("File");
    }
    if (styleNode.hasAttribute("ID")) {
        _SelectedStyleID = styleNode.getAttribute("ID");
    }
    for (FrameworkNode node : styleNode.getChildNodes()) {
        if (node.getNodeName().equalsIgnoreCase("#Text") || node.getNodeName().equalsIgnoreCase("#comment")) {
            continue;
        }
        if (node.getNodeName().equalsIgnoreCase("Item")) {
            _SelectedStyle.add(node.getTextContent());
        } else {
            LOGGER.severe("Unknown Tag under Selected : " + node.getNodeName());
            return false;
        }
    }
    return true;
}
Also used : FrameworkNode(kutch.biff.marvin.utility.FrameworkNode)

Example 55 with FrameworkNode

use of kutch.biff.marvin.utility.FrameworkNode in project Board-Instrumentation-Framework by intel.

the class LineChartWidget_MS method HandleWidgetSpecificSettings.

@Override
public boolean HandleWidgetSpecificSettings(FrameworkNode node) {
    if (true == HandleChartSpecificAppSettings(node)) {
        return true;
    }
    if (node.getNodeName().equalsIgnoreCase("Series")) {
        String ID, Namespace, Label;
        if (node.hasAttribute("Label")) {
            Label = node.getAttribute("Label");
        } else {
            Label = "";
        }
        for (FrameworkNode newNode : node.getChildNodes()) {
            if (newNode.getNodeName().equalsIgnoreCase("MinionSrc")) {
                Utility.ValidateAttributes(new String[] { "ID", "Namespace", "Scale" }, newNode);
                if (newNode.hasAttribute("ID")) {
                    ID = newNode.getAttribute("ID");
                } else {
                    LOGGER.severe("Series defined with invalid MinionSrc - no ID");
                    return false;
                }
                if (newNode.hasAttribute("Namespace")) {
                    Namespace = newNode.getAttribute("Namespace");
                } else {
                    LOGGER.severe("Series defined with invalid MinionSrc - no Namespace");
                    return false;
                }
                SeriesDataSet objDS = new SeriesDataSet(Label, ID, Namespace);
                if (newNode.hasAttribute("Scale")) {
                    double scaleVal = newNode.getDoubleAttribute("Scale", 0);
                    if (scaleVal <= 0) {
                        LOGGER.severe("Series defined with invalid scale value" + newNode.getAttribute("Scale"));
                        return false;
                    }
                    objDS.setScaleValue(scaleVal);
                }
                getSeries().add(objDS);
            }
        }
        return true;
    }
    return false;
}
Also used : SeriesDataSet(kutch.biff.marvin.utility.SeriesDataSet) FrameworkNode(kutch.biff.marvin.utility.FrameworkNode)

Aggregations

FrameworkNode (kutch.biff.marvin.utility.FrameworkNode)65 ArrayList (java.util.ArrayList)11 IOException (java.io.IOException)8 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)8 SAXException (org.xml.sax.SAXException)8 NodeList (org.w3c.dom.NodeList)6 List (java.util.List)4 BaseWidget (kutch.biff.marvin.widget.BaseWidget)4 Document (org.w3c.dom.Document)4 Pair (javafx.util.Pair)3 DynamicItemInfoContainer (kutch.biff.marvin.utility.DynamicItemInfoContainer)3 DynamicGridWidget (kutch.biff.marvin.widget.DynamicGridWidget)3 GridWidget (kutch.biff.marvin.widget.GridWidget)3 OnDemandGridWidget (kutch.biff.marvin.widget.OnDemandGridWidget)3 Node (org.w3c.dom.Node)3 File (java.io.File)2 ValueRange (java.time.temporal.ValueRange)2 DocumentBuilder (javax.xml.parsers.DocumentBuilder)2 DocumentBuilderFactory (javax.xml.parsers.DocumentBuilderFactory)2 SeriesDataSet (kutch.biff.marvin.utility.SeriesDataSet)2