Search in sources :

Example 21 with Variable

use of CCDD.CcddClassesDataTable.Variable in project CCDD by nasa.

the class CcddSchedulerEditorHandler method deAllocateSubVariables.

/**
 ********************************************************************************************
 * Deallocate any sub-message variables if the number of sub-messages is changed
 *
 * @param message
 *            message for which the variables are deallocated from each sub-message
 *
 * @return true if the variable is deallocated or there are no variables to deallocate; false
 *         if there are variable to deallocate but the user cancels the operation
 ********************************************************************************************
 */
private boolean deAllocateSubVariables(Message message) {
    boolean isDeallocated = true;
    boolean isSubVariable = false;
    // Check if this message has sub-messages (i.e., is a parent message)
    if (message.getNumberOfSubMessages() != 0) {
        // Step through each sub-message
        for (Message msg : message.getSubMessages()) {
            // Check if the sub-message has a variable
            if (msg.getNumberOfVariables() != 0) {
                // Set the flag to indicate a sub-message contains a variable and stop
                // searching
                isSubVariable = true;
                break;
            }
        }
    }
    // Check if a sub-message has a variable
    if (isSubVariable) {
        // Check if the user confirms deallocating the variables from the sub-messages
        if (new CcddDialogHandler().showMessageDialog(schedulerHndlr.getSchedulerDialog().getDialog(), "<html><b>Note: All of this message's sub-message<br>" + "variables will be de-assigned!<br><br>Proceed?", "Confirmation", JOptionPane.QUESTION_MESSAGE, DialogOption.OK_CANCEL_OPTION) == OK_BUTTON) {
            List<String> excludedVars = new ArrayList<String>();
            // Step through each sub-message
            for (Message subMsg : message.getSubMessages()) {
                // Step through each variable in the sub-message
                for (Variable var : subMsg.getVariables()) {
                    // Check if the variable has not been added to the excluded variables list
                    if (!excludedVars.contains(var.getFullName())) {
                        // Add the variable name to the exclude list
                        excludedVars.add(var.getFullName());
                    }
                }
                // Remove the variables
                subMsg.getVariables().clear();
            }
            // Set the variable(s) to available
            schedulerHndlr.makeVariableAvailable(excludedVars);
        } else // User canceled the operation
        {
            // Set the flag to indicate that the user canceled changing the number of
            // sub-messages
            isDeallocated = false;
        }
    }
    return isDeallocated;
}
Also used : Variable(CCDD.CcddClassesDataTable.Variable) Message(CCDD.CcddClassesDataTable.Message) ArrayList(java.util.ArrayList)

Example 22 with Variable

use of CCDD.CcddClassesDataTable.Variable in project CCDD by nasa.

the class CcddTelemetrySchedulerInput method getSelectedVariable.

/**
 ********************************************************************************************
 * Get the selected variable(s) from the variable tree
 *
 * @return List containing the selected variable(s)
 ********************************************************************************************
 */
@Override
public List<Variable> getSelectedVariable() {
    // Create a list to hold the variables
    List<Variable> varList = new ArrayList<Variable>();
    // Get the node path(s) of the selected variable(s)
    List<Object[]> paths = variableTree.getSelectedVariables(variableTree.isFilteredByGroup() ? 1 : 0, true);
    // Step through all the selected paths
    for (Object[] path : paths) {
        boolean isLinked = false;
        // Set the start of the variable path
        int index = variableTree.getHeaderNodeLevel();
        // Check if the variable is linked
        if (path[1].toString().trim().equals(LINKED_VARIABLES_NODE_NAME)) {
            // Set the start of the variable path to skip the root, link header, and link name
            // nodes
            index = 3;
            // Set the flag to indicate the variable is linked
            isLinked = true;
        }
        // Check if the path contains a variable
        if (path.length > index) {
            boolean isFound = false;
            // Step through the created variables
            for (Variable var : varList) {
                // Get the variable name from the path
                String name = allVariableTree.createNameFromPath(path, index);
                // Check if the variable has already been created
                if (var.getFullName().equals(name)) {
                    // Set the flag to indicate the variable already exists and stop searching
                    isFound = true;
                    break;
                }
            }
            // Check if the variable was found in the created list
            if (!isFound) {
                // Check if the variable is linked
                if (isLinked) {
                    // Gets the link's definitions
                    List<String[]> definitions = linkTree.getLinkHandler().getLinkDefinitionsByName(path[2].toString(), rateName);
                    // Step through the link's definitions
                    for (int defnIndex = 0; defnIndex < definitions.size(); defnIndex++) {
                        // Add each variable in the link by first creating the variable
                        varList.add(VariableGenerator.generateTelemetryData(definitions.get(defnIndex)[LinksColumn.MEMBER.ordinal()].split(","), CcddUtilities.convertStringToFloat(selectedRate)));
                    }
                } else // Not linked
                {
                    // Add the variable to the variable list
                    varList.add(VariableGenerator.generateTelemetryData(Arrays.copyOfRange(path, variableTree.getHeaderNodeLevel(), path.length), CcddUtilities.convertStringToFloat(selectedRate)));
                }
            }
        }
    }
    return varList;
}
Also used : AssociatedVariable(CCDD.CcddClassesDataTable.AssociatedVariable) Variable(CCDD.CcddClassesDataTable.Variable) ArrayList(java.util.ArrayList)

Example 23 with Variable

use of CCDD.CcddClassesDataTable.Variable in project CCDD by nasa.

the class CcddTelemetrySchedulerInput method getVariablesAtRate.

/**
 ********************************************************************************************
 * Get a list of variables at the specified rate
 *
 * @param rate
 *            rate column name
 *
 * @return List of variables at the specified rate
 ********************************************************************************************
 */
@Override
public List<Variable> getVariablesAtRate(String rate) {
    List<Variable> varList = new ArrayList<Variable>();
    List<String> pathList = new ArrayList<String>();
    // Convert the rate string to a float
    float rateVal = CcddUtilities.convertStringToFloat(rate);
    // Update the tree to have the variables of the given rate
    updateVariableTree(rate);
    // Get all the paths of the variables in the current variable tree
    pathList.addAll(variableTree.getPrimitiveVariablePaths(variableTree.getRootNode(), true));
    // Step through each path in the list
    for (String path : pathList) {
        // Split the path (project name , linked/unlinked node header, and variable path)
        String[] pathParts = path.split(",");
        // Check if the variable is linked
        if (pathParts[1].trim().equals(LINKED_VARIABLES_NODE_NAME)) {
            // Create the variable
            TelemetryData variable = VariableGenerator.generateTelemetryData(Arrays.copyOfRange(pathParts, 3, pathParts.length), rateVal);
            // Set the link to which the variable belongs
            variable.setLink(pathParts[2]);
            // Add it to the list of variables
            varList.add(variable);
        } else // Variable isn't linked
        {
            // Create the variable and add it to the list of variables
            varList.add(VariableGenerator.generateTelemetryData(Arrays.copyOfRange(pathParts, variableTree.getHeaderNodeLevel(), pathParts.length), rateVal));
        }
    }
    return varList;
}
Also used : AssociatedVariable(CCDD.CcddClassesDataTable.AssociatedVariable) Variable(CCDD.CcddClassesDataTable.Variable) ArrayList(java.util.ArrayList) TelemetryData(CCDD.CcddClassesDataTable.TelemetryData)

Aggregations

Variable (CCDD.CcddClassesDataTable.Variable)23 ArrayList (java.util.ArrayList)17 Message (CCDD.CcddClassesDataTable.Message)8 AssociatedVariable (CCDD.CcddClassesDataTable.AssociatedVariable)6 ApplicationData (CCDD.CcddClassesDataTable.ApplicationData)5 TelemetryData (CCDD.CcddClassesDataTable.TelemetryData)3 DataStream (CCDD.CcddClassesDataTable.DataStream)2 FieldInformation (CCDD.CcddClassesDataTable.FieldInformation)2 SchedulerType (CCDD.CcddConstants.SchedulerType)2 BackgroundCommand (CCDD.CcddBackgroundCommand.BackgroundCommand)1 ToolTipTreeNode (CCDD.CcddClassesComponent.ToolTipTreeNode)1 BitPackNodeIndex (CCDD.CcddClassesDataTable.BitPackNodeIndex)1 GroupInformation (CCDD.CcddClassesDataTable.GroupInformation)1 RateInformation (CCDD.CcddClassesDataTable.RateInformation)1 GridBagConstraints (java.awt.GridBagConstraints)1 GridBagLayout (java.awt.GridBagLayout)1 Insets (java.awt.Insets)1 List (java.util.List)1 JLabel (javax.swing.JLabel)1 JList (javax.swing.JList)1