Search in sources :

Example 1 with DataStream

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

the class CcddApplicationSchedulerDialog method storeData.

/**
 ********************************************************************************************
 * Store the data into the database
 ********************************************************************************************
 */
private void storeData() {
    // Create a data stream to pass into the schedule database handler
    List<DataStream> stream = new ArrayList<DataStream>();
    // Add the messages to the data stream
    stream.add(new DataStream(schedulerHndlr.getCurrentMessages(), new ArrayList<Variable>()));
    // Update the copy of the messages so that subsequent changes can be detected
    schedulerHndlr.getSchedulerEditor().copyMessages();
    // Pass the data stream into the scheduler database handler
    schedulerDb.storeData(stream);
}
Also used : DataStream(CCDD.CcddClassesDataTable.DataStream) ArrayList(java.util.ArrayList)

Example 2 with DataStream

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

the class CcddTelemetrySchedulerDialog method storeData.

/**
 ********************************************************************************************
 * Store the data from the various data streams into the database
 ********************************************************************************************
 */
private void storeData() {
    // Create a list to hold the data streams
    List<DataStream> streams = new ArrayList<DataStream>();
    // Step through all the current scheduler handlers
    for (CcddSchedulerHandler handler : schHandlers) {
        // Add a new data stream for each scheduler handler
        streams.add(new DataStream(handler.getCurrentMessages(), handler.getRateName()));
        // Update the copy of the messages so that subsequent changes can be detected
        handler.getSchedulerEditor().copyMessages();
    }
    // Store the data streams
    schedulerDb.storeData(streams);
}
Also used : DataStream(CCDD.CcddClassesDataTable.DataStream) ArrayList(java.util.ArrayList)

Example 3 with DataStream

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

the class CcddSchedulerDbIOHandler method loadTelemetryData.

/**
 ********************************************************************************************
 * Load the stored data from the project database and initialize the telemetry table
 ********************************************************************************************
 */
private void loadTelemetryData() {
    // Load the data from the database
    List<String[]> storedData = dbTable.retrieveInformationTable(InternalTable.TLM_SCHEDULER, ccddMain.getMainFrame());
    // Check if there is data stored
    if (!storedData.isEmpty()) {
        List<Message> msgList = null;
        List<Variable> varList;
        // Get the maximum messages per second in floating point format
        float msgsPerSec = Float.valueOf(rateHandler.getMaxMsgsPerSecond());
        // Step through each row in from the table
        for (String[] data : storedData) {
            RateInformation info = null;
            msgList = null;
            varList = null;
            // Get the rate column name, message name, message ID, and members
            String rateName = data[TlmSchedulerColumn.RATE_NAME.ordinal()];
            String messageName = data[TlmSchedulerColumn.MESSAGE_NAME.ordinal()];
            String messageID = data[TlmSchedulerColumn.MESSAGE_ID.ordinal()];
            String member = data[TlmSchedulerColumn.MEMBER.ordinal()];
            // Step through the existing data streams
            for (DataStream dataStream : dataStreams) {
                // Check if the data stream already exists
                if (rateName.equals(dataStream.getRateName())) {
                    // Get the rate information for the data stream
                    info = rateHandler.getRateInformationByRateName(dataStream.getRateName());
                    // Get the messages for this the data stream
                    msgList = dataStream.getMessages();
                    // Get the variables for this the data stream
                    varList = dataStream.getVariableList();
                    break;
                }
            }
            // exist
            if (msgList == null) {
                // Get the rate information for this rate column
                info = rateHandler.getRateInformationByRateName(rateName);
                // Check if the rate exists
                if (info != null) {
                    // Create a new data stream for the data
                    DataStream stream = new DataStream(rateName);
                    // Add the stream to the existing list
                    dataStreams.add(stream);
                    // Get a reference to the created data stream message list
                    msgList = stream.getMessages();
                    // Get a reference to the created data stream variable list
                    varList = stream.getVariableList();
                }
            }
            // Check if the rate exists
            if (info != null) {
                int subIndex = -1;
                Message message = null;
                Variable variable = null;
                // Separate the message's name and the sub-index, if any
                String[] nameAndIndex = messageName.split("\\.");
                // Calculate the period (= total messages / total messages per second)
                float period = Float.valueOf(info.getMaxMsgsPerCycle()) / Float.valueOf(msgsPerSec);
                // Step through the created messages
                for (Message msg : msgList) {
                    // Check if the message has already been created
                    if (msg.getName().equals(nameAndIndex[0])) {
                        // Store the message object
                        message = msg;
                        // Check if this is a sub-message definition
                        if (nameAndIndex.length == 2) {
                            // Step through all the message's sub-messages
                            for (Message subMessage : message.getSubMessages()) {
                                // Check if the sub-message already exists
                                if (subMessage.getName().equals(messageName)) {
                                    // Get the sub-message's index and assign the sub-message's
                                    // ID
                                    subIndex = Integer.valueOf(nameAndIndex[1]);
                                    message.getSubMessage(subIndex).setID(messageID);
                                }
                            }
                            // Check if no sub-index was found
                            if (subIndex == -1) {
                                // Get the sub-index from the message name
                                subIndex = Integer.valueOf(nameAndIndex[1]);
                                // Create a new sub-message and assign the sub-message's ID
                                message.addNewSubMessage(messageID);
                            }
                        }
                        break;
                    }
                }
                // Check if no message object was found
                if (message == null) {
                    // Create a new parent message
                    message = new Message(nameAndIndex[0], messageID, info.getMaxBytesPerSec() / info.getMaxMsgsPerCycle());
                    subIndex = 0;
                    // Add the message to the existing message list
                    msgList.add(message);
                }
                // Check if the message has a member
                if (!member.isEmpty()) {
                    // Split the member column to remove the rate and extract the variable name
                    String varName = member.split("\\" + TLM_SCH_SEPARATOR, 2)[1];
                    // Step through the variables
                    for (Variable var : varList) {
                        // Check if the variable has already been created
                        if (var.getFullName().equals(varName)) {
                            // Store the variable and stop searching
                            variable = var;
                            break;
                        }
                    }
                    // Check if the variable doesn't already exist
                    if (variable == null) {
                        // Create a new variable
                        variable = VariableGenerator.generateTelemetryData(member);
                        // Add the variable to the existing variable list
                        varList.add(variable);
                    }
                    // Check if the rate is a sub-rate
                    if (variable.getRate() < period) {
                        // Assign the variable to the sub-message and store the message index
                        message.getSubMessage(subIndex).addVariable(variable);
                        variable.addMessageIndex(subIndex);
                    } else // The rate isn't a sub-rate
                    {
                        // Check if the variable has not already been assigned to the message
                        if (!message.getAllVariables().contains(variable)) {
                            // Add the variable to the general message
                            message.addVariable(variable);
                        }
                        // Store the message index
                        variable.addMessageIndex(msgList.indexOf(message));
                    }
                }
            }
        }
    }
}
Also used : Variable(CCDD.CcddClassesDataTable.Variable) Message(CCDD.CcddClassesDataTable.Message) DataStream(CCDD.CcddClassesDataTable.DataStream) RateInformation(CCDD.CcddClassesDataTable.RateInformation)

Example 4 with DataStream

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

the class CcddSchedulerDbIOHandler method loadApplicationData.

/**
 ********************************************************************************************
 * Get the stored data from the project database and initialize the application table
 ********************************************************************************************
 */
private void loadApplicationData() {
    List<Message> messages = new ArrayList<Message>();
    List<Variable> varList = new ArrayList<Variable>();
    // Load the application scheduler table
    List<String[]> storedData = dbTable.retrieveInformationTable(InternalTable.APP_SCHEDULER, ccddMain.getMainFrame());
    // Check if any stored data exists
    if (!storedData.isEmpty()) {
        // Calculate the message's time usage
        int time = 1000 / appHandler.getMaxMsgsPerSecond();
        for (String[] row : storedData) {
            Message msg = null;
            Variable var = null;
            // Step through all the created message
            for (Message message : messages) {
                // Check if the message has already been created
                if (message.getName().equals(row[AppSchedulerColumn.TIME_SLOT.ordinal()])) {
                    // Assign the existing message to the message object and stop searching
                    msg = message;
                    break;
                }
            }
            // Check if the message object is still null
            if (msg == null) {
                // Create a new message
                msg = new Message(row[AppSchedulerColumn.TIME_SLOT.ordinal()], "", time);
                // Add the message to the existing message list
                messages.add(msg);
            }
            // Check if the member column contains application information
            if (!row[AppSchedulerColumn.APP_INFO.ordinal()].isEmpty()) {
                // Split the member column to extract the application name
                String name = row[AppSchedulerColumn.APP_INFO.ordinal()].split(",", DefaultApplicationField.values().length)[0];
                // Step through all created variables
                for (Variable variable : varList) {
                    // Check if the variable has already been created
                    if (variable.getFullName().equals(name)) {
                        // Assign the existing variable to the variable object
                        var = variable;
                        break;
                    }
                }
                // Check if the variable is still null
                if (var == null) {
                    // Create a new variable
                    var = VariableGenerator.generateApplicationData(row[AppSchedulerColumn.APP_INFO.ordinal()]);
                    // Add the variable to the existing variable list
                    varList.add(var);
                }
                // Add the variable to the general message
                msg.addVariable(var);
                var.addMessageIndex(Integer.valueOf(msg.getName().trim().split("_")[1]) - 1);
            }
        }
    }
    // Create a data stream object for the application information
    dataStreams.add(new DataStream(messages, varList));
}
Also used : Variable(CCDD.CcddClassesDataTable.Variable) Message(CCDD.CcddClassesDataTable.Message) DataStream(CCDD.CcddClassesDataTable.DataStream) ArrayList(java.util.ArrayList)

Aggregations

DataStream (CCDD.CcddClassesDataTable.DataStream)4 ArrayList (java.util.ArrayList)3 Message (CCDD.CcddClassesDataTable.Message)2 Variable (CCDD.CcddClassesDataTable.Variable)2 RateInformation (CCDD.CcddClassesDataTable.RateInformation)1