Search in sources :

Example 1 with TelemetryData

use of CCDD.CcddClassesDataTable.TelemetryData 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)

Example 2 with TelemetryData

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

the class CcddSchedulerEditorHandler method copyMessages.

/**
 ********************************************************************************************
 * Copy the specified (sub-)messages to the specified copy location
 *
 * @param messageList
 *            list of (sub-)messages to copy
 *
 * @param copyList
 *            reference to the list to which to copy the (sub-)messages
 *
 * @param parentMessage
 *            parent of the sub-message; null if this is not a sub-message
 ********************************************************************************************
 */
private void copyMessages(List<Message> messageList, List<Message> copyList, Message parentMessage) {
    // Step through each (sub-)message
    for (Message message : messageList) {
        // Create and store a copy of the (sub-)message
        copyList.add(new Message(message.getName(), message.getID(), message.getBytesRemaining(), parentMessage, parentMessage == null ? new ArrayList<Message>() : null));
        // Step through each variable in the (sub-)message
        for (Variable variable : message.getVariables()) {
            Variable copyVar = null;
            // Check if this is a telemetry scheduler
            if (schedulerHndlr.getSchedulerOption() == TELEMETRY_SCHEDULER) {
                TelemetryData tlmData = (TelemetryData) variable;
                // Create a copy of the telemetry data
                copyVar = VariableGenerator.generateTelemetryData(tlmData.getRate() + TLM_SCH_SEPARATOR + tlmData.getFullName());
            } else // Check if this is an application scheduler
            if (schedulerHndlr.getSchedulerOption() == APPLICATION_SCHEDULER) {
                ApplicationData appData = (ApplicationData) variable;
                // Create a copy of the application data
                copyVar = VariableGenerator.generateApplicationData(appData.getFullName() + "," + appData.getRate() + "," + appData.getSize() + "," + appData.getPriority() + "," + appData.getMessageRate() + "," + appData.getWakeUpID() + "," + appData.getWakeUpName() + "," + appData.getHkSendRate() + "," + appData.getHkWakeUpID() + "," + appData.getHkWakeUpName() + "," + appData.getSchGroup());
            }
            // Check if a copy was produced
            if (copyVar != null) {
                // Add the variable to the copy
                copyList.get(copyList.size() - 1).addVariable(copyVar);
            }
        }
    }
}
Also used : Variable(CCDD.CcddClassesDataTable.Variable) Message(CCDD.CcddClassesDataTable.Message) ApplicationData(CCDD.CcddClassesDataTable.ApplicationData) TelemetryData(CCDD.CcddClassesDataTable.TelemetryData)

Example 3 with TelemetryData

use of CCDD.CcddClassesDataTable.TelemetryData 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

TelemetryData (CCDD.CcddClassesDataTable.TelemetryData)3 Variable (CCDD.CcddClassesDataTable.Variable)3 AssociatedVariable (CCDD.CcddClassesDataTable.AssociatedVariable)2 ArrayList (java.util.ArrayList)2 ToolTipTreeNode (CCDD.CcddClassesComponent.ToolTipTreeNode)1 ApplicationData (CCDD.CcddClassesDataTable.ApplicationData)1 BitPackNodeIndex (CCDD.CcddClassesDataTable.BitPackNodeIndex)1 Message (CCDD.CcddClassesDataTable.Message)1