Search in sources :

Example 6 with Variable

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

the class CcddSchedulerHandler method addVariableToMessage.

/**
 ********************************************************************************************
 * Add one or more variables to the specified message
 *
 * @param variables
 *            list of variables to be added
 *
 * @param messageIndices
 *            (sub-)message indices to which the variable will be added
 *
 * @param parentIndex
 *            parent message index if this is a sub-message; -1 if this is not a sub-message
 *
 * @return List containing the names of the variables added
 ********************************************************************************************
 */
private List<String> addVariableToMessage(List<Variable> variables, Integer[] messageIndices, int parentIndex) {
    List<String> addedVariables = new ArrayList<String>();
    // Step through each variable in the list of variables to be added
    for (Variable variable : variables) {
        // Step through each message in the option
        for (int index = 0; index < messageIndices.length; index++) {
            // Add the variable to the telemetry table
            schedulerEditor.addVariableToMessage(variable, messageIndices[index], parentIndex);
        }
        // Set the variable's messages it is contained in
        variable.setMessageIndices(messageIndices);
        // Add the variable to the list of excluded variables
        addedVariables.add(variable.getFullName());
    }
    // Update the total bytes remaining for each message
    schedulerEditor.calculateTotalBytesRemaining();
    return addedVariables;
}
Also used : AssociatedVariable(CCDD.CcddClassesDataTable.AssociatedVariable) Variable(CCDD.CcddClassesDataTable.Variable) ArrayList(java.util.ArrayList)

Example 7 with Variable

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

the class CcddSchedulerHandler method getVariableList.

/**
 ********************************************************************************************
 * Get the list of variables for the data stream
 *
 * @return List of variables; null if the scheduler dialog type is not recognized
 ********************************************************************************************
 */
protected List<Variable> getVariableList() {
    List<Variable> variables = null;
    // Get the scheduler dialog type
    SchedulerType option = getSchedulerOption();
    // Check if this is a telemetry scheduler
    if (option == SchedulerType.TELEMETRY_SCHEDULER) {
        variables = schedulerDb.getVariableList(rateHandler.getRateInformationIndexByRateName(rateName));
    } else // Check if this is an application scheduler
    if (option == SchedulerType.APPLICATION_SCHEDULER) {
        variables = schedulerDb.getVariableList(Integer.valueOf(rateName));
    }
    return variables;
}
Also used : AssociatedVariable(CCDD.CcddClassesDataTable.AssociatedVariable) Variable(CCDD.CcddClassesDataTable.Variable) SchedulerType(CCDD.CcddConstants.SchedulerType)

Example 8 with Variable

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

the class CcddApplicationSchedulerTableHandler method createSchedulerTableDefines.

/**
 ********************************************************************************************
 * Build the application wake-up message ID define statement parameters
 ********************************************************************************************
 */
private void createSchedulerTableDefines() {
    List<Variable> appsSorted = new ArrayList<Variable>();
    // Copy the list of applications
    appsSorted.addAll(appList);
    // Sort the applications based on wake-up ID
    Collections.sort(appsSorted, new Comparator<Variable>() {

        /**
         ************************************************************************************
         * Compare the wake-up IDs for two applications
         ************************************************************************************
         */
        @Override
        public int compare(Variable var, Variable otherVar) {
            return Integer.decode(((ApplicationData) var).getWakeUpID()).compareTo(Integer.decode(((ApplicationData) otherVar).getWakeUpID()));
        }
    });
    defines = new String[appsSorted.size()][2];
    int index = 0;
    // Step through the sorted applications
    for (Variable app : appsSorted) {
        // Store the application wake-up message ID define statement parameters
        defines[index][0] = app.getFullName().toUpperCase() + "_WAKEUP_MID";
        defines[index][1] = Integer.decode(((ApplicationData) app).getWakeUpID()).toString();
        index++;
    }
}
Also used : Variable(CCDD.CcddClassesDataTable.Variable) ArrayList(java.util.ArrayList)

Example 9 with Variable

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

the class CcddApplicationSchedulerInput method getApplicationFields.

/**
 ********************************************************************************************
 * Get the selected node in the application tree
 *
 * @param applications
 *            array of application names
 *
 * @param rate
 *            currently selected rate
 *
 * @return List of variable object(s) representing the specified application(s)
 ********************************************************************************************
 */
private List<Variable> getApplicationFields(String[] applications, String rate) {
    List<Variable> appList = new ArrayList<Variable>();
    // Step through each application
    for (String application : applications) {
        // Remove any HTML tags, if present
        application = applicationTree.removeExtraText(application);
        // Use the application's data to create an application data object
        appList.add(new ApplicationData(application, CcddUtilities.convertStringToFloat(rate), Integer.valueOf(getDataFieldValue(application, DefaultApplicationField.EXECUTION_TIME)), Integer.valueOf(getDataFieldValue(application, DefaultApplicationField.PRIORITY)), Integer.valueOf(getDataFieldValue(application, DefaultApplicationField.MESSAGE_RATE)), getDataFieldValue(application, DefaultApplicationField.WAKE_UP_NAME), getDataFieldValue(application, DefaultApplicationField.WAKE_UP_ID), Integer.valueOf(getDataFieldValue(application, DefaultApplicationField.HK_SEND_RATE)), getDataFieldValue(application, DefaultApplicationField.HK_WAKE_UP_NAME), getDataFieldValue(application, DefaultApplicationField.HK_WAKE_UP_ID), getDataFieldValue(application, DefaultApplicationField.SCH_GROUP)));
    }
    return appList;
}
Also used : Variable(CCDD.CcddClassesDataTable.Variable) ArrayList(java.util.ArrayList) ApplicationData(CCDD.CcddClassesDataTable.ApplicationData)

Example 10 with Variable

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

the class CcddTelemetrySchedulerInput method getAssociatedVariables.

/**
 ********************************************************************************************
 * For the specified list of variables, get (1) the total size in bytes of the variables that
 * are associated with the first variable in the list, and (2) a list of Variable objects of
 * the associated variables. Variables are considered 'associated' if (a) they are all bit-wise
 * variables that are packed together, or (b) they are members of a string. If the first
 * variable isn't associated with the succeeding variables then the return value references
 * only the first variable
 *
 * @param variables
 *            list of variables where the first member of the list if the one to be checked for
 *            associates
 *
 * @return AssociatedVariable object containing the total size in bytes of the variables
 *         associated with the first variable in the specified list and the list of the
 *         associated variables
 ********************************************************************************************
 */
protected AssociatedVariable getAssociatedVariables(List<Variable> variables) {
    // Get a reference to the lead variable. This is the variable that is checked for
    // associated variables
    Variable variable = variables.get(0);
    // Store the size of the variable
    int totalSize = variable.getSize();
    // Create a list to store the lead variable and its associates and add the lead variable to
    // the list
    List<Variable> associatedVars = new ArrayList<Variable>();
    associatedVars.add(variable);
    // Set flag to true if the lead variable is a bit-wise variable
    boolean isBitPack = variable.getFullName().contains(":");
    // variables associated with it)
    if (isBitPack || dataTypeHandler.isString(((TelemetryData) variable).getDataType())) {
        // Get the variable's row index in the tree containing all variables
        int treeIndex = allVariableTreePaths.indexOf(variable.getFullName()) - 1;
        // Get the variable's tree node
        ToolTipTreeNode last = (ToolTipTreeNode) allVariableTree.getPathForRow(treeIndex).getLastPathComponent();
        // Get the indices of the other variables associated with this variable (i.e., other
        // variable bit-packed or other members of the string)
        BitPackNodeIndex nodeIndex = isBitPack ? allVariableTree.getBitPackedVariables(last) : allVariableTree.getStringVariableMembers(last);
        // Calculate the number of other variables associated with the lead variable
        int numVars = nodeIndex.getLastIndex() - nodeIndex.getFirstIndex();
        // in the list provided
        if (numVars <= variables.size()) {
            // Step through the associated variables
            for (int index = 1; index <= numVars; index++) {
                // Check that this isn't a bit-wise variable (i.e, it's a string variable)
                if (!isBitPack) {
                    // Add the variable's size to the total
                    totalSize += variables.get(index).getSize();
                }
                // Add the variable to the list of associated variables
                associatedVars.add(variables.get(index));
            }
        } else // More associated variables were detected than were provided. This can only occur if
        // the rates for associated variables don't match - this shouldn't be possible
        {
            // Inform the user if there is a rate assignment issue
            new CcddDialogHandler().showMessageDialog(schedulerDlg.getDialog(), "<html><b> Auto-fill detected mismatched " + "rates for variable(s) associated with </b>" + variables.get(0).getFullName(), "Assign Failure", JOptionPane.WARNING_MESSAGE, DialogOption.OK_OPTION);
        }
    }
    return new AssociatedVariable(totalSize, associatedVars);
}
Also used : BitPackNodeIndex(CCDD.CcddClassesDataTable.BitPackNodeIndex) AssociatedVariable(CCDD.CcddClassesDataTable.AssociatedVariable) Variable(CCDD.CcddClassesDataTable.Variable) ArrayList(java.util.ArrayList) AssociatedVariable(CCDD.CcddClassesDataTable.AssociatedVariable) TelemetryData(CCDD.CcddClassesDataTable.TelemetryData) ToolTipTreeNode(CCDD.CcddClassesComponent.ToolTipTreeNode)

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