Search in sources :

Example 11 with Variable

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

the class CcddApplicationSchedulerTableHandler method getMessageDefinitionTable.

/**
 ********************************************************************************************
 * Get the message definition table entries
 *
 * @return Array containing the message definition table entries
 ********************************************************************************************
 */
protected String[] getMessageDefinitionTable() {
    String[] scheduleCommands = new String[appHandler.getNumberOfTimeSlots()];
    String command;
    for (int mdtIndex = 0; mdtIndex < scheduleCommands.length; mdtIndex++) {
        command = null;
        for (Variable var : appList) {
            if (mdtIndex == Integer.decode(((ApplicationData) var).getWakeUpID())) {
                command = var.getFullName().toUpperCase() + "_WAKEUP_MID";
                break;
            }
        }
        if (command == null) {
            command = "SCH_UNUSED_MID";
        }
        scheduleCommands[mdtIndex] = command;
    }
    return scheduleCommands;
}
Also used : Variable(CCDD.CcddClassesDataTable.Variable) ApplicationData(CCDD.CcddClassesDataTable.ApplicationData)

Example 12 with Variable

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

the class CcddApplicationSchedulerTableHandler method removeInvalidData.

/**
 ********************************************************************************************
 * Remove data that is determined to be invalid
 *
 * @param removedVars
 *            list of invalid data
 *
 * @return Number of invalid entries that were found and removed
 ********************************************************************************************
 */
private int removeInvalidData(List<Variable> removedVars) {
    List<Integer> indices;
    // Remove the invalid variables from the variables list
    applications.removeAll(removedVars);
    // Step through the list of removed variables
    for (Variable var : removedVars) {
        // Get the indices of the messages to which the variable belongs
        indices = var.getMessageIndices();
        // Step through the messages in which the variable is contained
        for (int index : indices) {
            // Remove the variable from the general message
            timeSlots.get(index).removeVariable(var.getFullName());
        }
    }
    return removedVars.size();
}
Also used : Variable(CCDD.CcddClassesDataTable.Variable)

Example 13 with Variable

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

the class CcddApplicationSchedulerTableHandler method validateApplicationData.

/**
 ********************************************************************************************
 * Check all the stored application information for inconsistencies. Update or flag the
 * application for removal if any changes are found
 *
 * @return List of invalid applications
 ********************************************************************************************
 */
private List<Variable> validateApplicationData() {
    List<Variable> removedApps = new ArrayList<Variable>();
    // Create a group tree
    CcddGroupTreeHandler groupTree = new CcddGroupTreeHandler(ccddMain, null, ccddMain.getMainFrame());
    // Get a list of the current group's names
    String[] groupNames = groupTree.getGroupHandler().getGroupNames(true);
    // Create a data field handler to interact with the groups' fields
    CcddFieldHandler fieldHandler = new CcddFieldHandler(ccddMain);
    // Step through each application
    for (Variable app : applications) {
        boolean isValid = false;
        // Step through the group names
        for (String name : groupNames) {
            // Check if the group's name matches the application's name
            if (app.getFullName().equals(name)) {
                // Get the group's information and set the data field handler to contain the
                // current group's information
                GroupInformation groupInfo = groupTree.getGroupHandler().getGroupInformationByName(name);
                fieldHandler.setFieldInformation(groupInfo.getFieldInformation());
                // Get the application data field owner name
                String application = CcddFieldHandler.getFieldGroupName(groupInfo.getName());
                // Get the application's schedule rate
                FieldInformation appInfo = fieldHandler.getFieldInformationByName(application, DefaultApplicationField.SCHEDULE_RATE.getFieldName());
                // Check if the application's rate equals its field's rate
                if (Float.valueOf(appInfo.getValue()) == app.getRate()) {
                    ApplicationData appData = (ApplicationData) app;
                    // Set the applications's validity to true
                    isValid = true;
                    // Get the run time field information
                    appInfo = fieldHandler.getFieldInformationByName(application, DefaultApplicationField.EXECUTION_TIME.getFieldName());
                    // Check if the application's run time changed
                    if (appInfo != null && Integer.valueOf(appInfo.getValue()) != app.getSize()) {
                        // Update the run time to what the field has set
                        app.setSize(Integer.valueOf(appInfo.getValue()));
                    }
                    // Get the execution priority field information
                    appInfo = fieldHandler.getFieldInformationByName(application, DefaultApplicationField.PRIORITY.getFieldName());
                    // Check if the application's priority changed
                    if (appInfo != null && Integer.valueOf(appInfo.getValue()) != appData.getPriority()) {
                        // Update the application's priority
                        appData.setPriority(Integer.valueOf(appInfo.getValue()));
                    }
                    // Get the message rate field information
                    appInfo = fieldHandler.getFieldInformationByName(application, DefaultApplicationField.MESSAGE_RATE.getFieldName());
                    // Check if the application's message rate changed
                    if (appInfo != null && Integer.valueOf(appInfo.getValue()) != appData.getMessageRate()) {
                        // Update the application's message rate
                        appData.setMessageRate(Integer.valueOf(appInfo.getValue()));
                    }
                    // Get the wake-up name field information
                    appInfo = fieldHandler.getFieldInformationByName(application, DefaultApplicationField.WAKE_UP_NAME.getFieldName());
                    // Check if the application's wake-up name changed
                    if (appInfo != null && !appInfo.getValue().equals(appData.getWakeUpName())) {
                        // Update the application's wake-up name
                        appData.setWakeUpName(appInfo.getValue());
                    }
                    // Get the wake-up ID field information
                    appInfo = fieldHandler.getFieldInformationByName(application, DefaultApplicationField.WAKE_UP_ID.getFieldName());
                    // Check if the application's wake-up ID changed
                    if (appInfo != null && !appInfo.getValue().equals(appData.getWakeUpID())) {
                        // Update the application's wake-up ID
                        appData.setWakeUpID(appInfo.getValue());
                    }
                    // Get the HK send rate field information
                    appInfo = fieldHandler.getFieldInformationByName(application, DefaultApplicationField.HK_SEND_RATE.getFieldName());
                    // Check if the application's HK send rate changed
                    if (appInfo != null && Integer.valueOf(appInfo.getValue()) != appData.getHkSendRate()) {
                        // Update the application's HK send rate
                        appData.setHkSendRate(Integer.valueOf(appInfo.getValue()));
                    }
                    // Get the HK wake-up name field information
                    appInfo = fieldHandler.getFieldInformationByName(application, DefaultApplicationField.HK_WAKE_UP_NAME.getFieldName());
                    // Check if the application's HK wake-up name changed
                    if (appInfo != null && !appInfo.getValue().equals(appData.getHkWakeUpName())) {
                        // Update the application's HK wake-up name
                        appData.setHkWakeUpName(appInfo.getValue());
                    }
                    // Get the HK wake-up ID field information
                    appInfo = fieldHandler.getFieldInformationByName(application, DefaultApplicationField.HK_WAKE_UP_ID.getFieldName());
                    // Check if the application's HK wake-up ID changed
                    if (appInfo != null && !appInfo.getValue().equals(appData.getHkWakeUpID())) {
                        // Update the application's HK wake-up ID
                        appData.setHkWakeUpID(appInfo.getValue());
                    }
                    // Get the schedule group field information
                    appInfo = fieldHandler.getFieldInformationByName(application, DefaultApplicationField.SCH_GROUP.getFieldName());
                    // Check if the application's schedule group changed
                    if (appInfo != null && !appInfo.getValue().equals(appData.getSchGroup())) {
                        // Update the application's schedule group
                        appData.setSchGroup(appInfo.getValue());
                    }
                }
                break;
            }
        }
        // Check if the application is invalid
        if (!isValid) {
            // Add the application to the list of removed applications
            removedApps.add(app);
        }
    }
    return removedApps;
}
Also used : Variable(CCDD.CcddClassesDataTable.Variable) GroupInformation(CCDD.CcddClassesDataTable.GroupInformation) ArrayList(java.util.ArrayList) ApplicationData(CCDD.CcddClassesDataTable.ApplicationData) FieldInformation(CCDD.CcddClassesDataTable.FieldInformation)

Example 14 with Variable

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

the class CcddSchedulerDbIOHandler method getApplicationData.

/**
 ********************************************************************************************
 * Get the list of the current messages. Each list item is a string arrays containing the
 * message name and a space-separated list of applications in that message
 *
 * @param messages
 *            list of messages
 *
 * @return List of current messages
 ********************************************************************************************
 */
private List<String[]> getApplicationData(List<Message> messages) {
    List<String[]> currentMsg = new ArrayList<String[]>();
    // Step through each message
    for (Message message : messages) {
        // Check if the time slot has no applications assigned
        if (message.getVariables().isEmpty()) {
            // Create a placeholder for the application information
            currentMsg.add(new String[] { message.getName(), "" });
        } else // The time slot has applications assigned
        {
            // Step through each application in the message
            for (Variable variable : message.getVariables()) {
                ApplicationData appData = (ApplicationData) variable;
                // Create new array for the row
                String[] app = new String[2];
                // Store the message name, and application name, rate, run time, priority,
                // wake-up name, wake-up ID, send rate, housekeeping wake-up name, housekeeping
                // wake-up ID, and schedule group name
                app[AppSchedulerColumn.TIME_SLOT.ordinal()] = message.getName();
                app[AppSchedulerColumn.APP_INFO.ordinal()] = appData.getFullName() + "," + appData.getRate() + "," + appData.getSize() + "," + appData.getPriority() + "," + appData.getMessageRate() + "," + appData.getWakeUpName() + "," + appData.getWakeUpID() + "," + appData.getHkSendRate() + "," + appData.getHkWakeUpName() + "," + appData.getHkWakeUpID() + "," + appData.getSchGroup();
                // Add the application to the list
                currentMsg.add(app);
            }
        }
    }
    return currentMsg;
}
Also used : Variable(CCDD.CcddClassesDataTable.Variable) Message(CCDD.CcddClassesDataTable.Message) ArrayList(java.util.ArrayList) ApplicationData(CCDD.CcddClassesDataTable.ApplicationData)

Example 15 with Variable

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

the class CcddSchedulerDbIOHandler method addVariablesToMessage.

/**
 ********************************************************************************************
 * Get the list of the message definitions for the specified (sub-)message. Each list item is a
 * string array containing the rate name, message name, message ID, and a space-separated list
 * of variables in that message
 *
 * @param stream
 *            data stream
 *
 * @param message
 *            (sub-)message reference
 *
 * @return List of the specified message's definitions
 ********************************************************************************************
 */
private List<String[]> addVariablesToMessage(DataStream stream, Message message) {
    List<String[]> messageList = new ArrayList<String[]>();
    // Check if the message has no variables assigned to it
    if (message.getVariables().isEmpty()) {
        // Create a new array for the row
        String[] msg = new String[TlmSchedulerColumn.values().length];
        // Add the data stream, sub-message name, message ID, and a blank as a placeholder for
        // the rate and variable name
        msg[TlmSchedulerColumn.RATE_NAME.ordinal()] = stream.getRateName();
        msg[TlmSchedulerColumn.MESSAGE_NAME.ordinal()] = message.getName();
        msg[TlmSchedulerColumn.MESSAGE_ID.ordinal()] = message.getID();
        msg[TlmSchedulerColumn.MEMBER.ordinal()] = "";
        // Add the array to the list of arrays
        messageList.add(msg);
    } else // The message has a variable assigned
    {
        // Step through each variable in the message
        for (Variable var : message.getVariables()) {
            // Create a new array for the row
            String[] msg = new String[TlmSchedulerColumn.values().length];
            // Add the data stream, message name, message ID, and the rate and variable name
            msg[TlmSchedulerColumn.RATE_NAME.ordinal()] = stream.getRateName();
            msg[TlmSchedulerColumn.MESSAGE_NAME.ordinal()] = message.getName();
            msg[TlmSchedulerColumn.MESSAGE_ID.ordinal()] = message.getID();
            msg[TlmSchedulerColumn.MEMBER.ordinal()] = var.getRate() + TLM_SCH_SEPARATOR + var.getFullName();
            // Add the array to the list of arrays
            messageList.add(msg);
        }
    }
    return messageList;
}
Also used : Variable(CCDD.CcddClassesDataTable.Variable) ArrayList(java.util.ArrayList)

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