use of CCDD.CcddClassesDataTable.Message 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));
}
}
}
}
}
}
use of CCDD.CcddClassesDataTable.Message 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));
}
use of CCDD.CcddClassesDataTable.Message in project CCDD by nasa.
the class CcddSchedulerEditorHandler method initializeSchedulerTable.
/**
********************************************************************************************
* Initialize the scheduler table. Add values to the current data which is used when creating
* the table. The message list is also initialized
********************************************************************************************
*/
private void initializeSchedulerTable() {
// Initialize the messages lists
messages = new ArrayList<Message>();
// Load the stored variables
List<Variable> excludedVars = schedulerHndlr.getVariableList();
// Get the messages from the stored data
List<Message> storedMsgs = schedulerHndlr.getStoredData();
// Check if the stored data is either not accurate or not set
if (storedMsgs.size() != totalMessages) {
Message msg;
currentData = new Object[totalMessages][SchedulerColumn.values().length];
// Step through each row
for (int row = 0; row < currentData.length; row++) {
// Create a new message. The space in the name is necessary when parsing the
// message row for the message indices
msg = new Message((schedulerHndlr.getSchedulerOption() == TELEMETRY_SCHEDULER ? "Message" : "Time Slot") + "_" + (row + 1), "", emptyMessageSize);
// Add the message to the existing list
messages.add(msg);
// Add message name, size, and ID to the table's current data
currentData[row][SchedulerColumn.NAME.ordinal()] = msg.getName();
currentData[row][SchedulerColumn.SIZE.ordinal()] = msg.getBytesRemaining();
currentData[row][SchedulerColumn.ID.ordinal()] = msg.getID();
}
} else // The data stored in the database is accurate
{
// Add the messages to the existing list
messages.addAll(storedMsgs);
// Set the scheduler table data array to the current message information
updateSchedulerTable(false);
// Check if there are any excluded variables
if (excludedVars != null && !excludedVars.isEmpty()) {
List<String> varNames = new ArrayList<String>();
// Step through each variable in the list of excluded variables
for (Variable var : excludedVars) {
// Add the variable name with path to the list
varNames.add(var.getFullName());
}
// Make each variable in the excluded variables list unavailable in the variable
// tree
schedulerHndlr.setVariableUnavailable(varNames);
}
}
// Copy the current messages for change comparison purposes
copyMessages();
}
use of CCDD.CcddClassesDataTable.Message in project CCDD by nasa.
the class CcddSchedulerEditorHandler method addSubMessage.
/**
********************************************************************************************
* Add a sub-message to the message currently selected in the scheduler table
********************************************************************************************
*/
protected void addSubMessage() {
// Get the currently selected (sub-)message
Message message = getSelectedMessage();
// Check if a sub-message is selected
if (message != null && message.getNumberOfSubMessages() == 0) {
// Get the sub-message's parent message
message = message.getParentMessage();
}
// deallocate them if present
if (message != null && deAllocateSubVariables(message)) {
// Store the selected row and column indices
int row = schedulerTable.getSelectedRow();
int column = schedulerTable.getSelectedColumn();
// Check if a sub-message tab is selected
if (message.getParentMessage() != null) {
// Change the reference to the sub-messages parent message
message = message.getParentMessage();
}
// Add a sub-message to the message object
message.addNewSubMessage("");
// Update the tabbed pane for the selected message
updateAssignedVariablesTabs();
// Update the assignment tree/list
updateAssignmentList();
// Update the options panel to display the options for the selected rate
schedulerHndlr.getTelemetryOptions();
// Update the scheduler table to reflect the added sub-message
updateSchedulerTable(true);
// Reselect the original row and column indices
schedulerTable.setRowSelectionInterval(row, row);
schedulerTable.setColumnSelectionInterval(column, column);
}
}
use of CCDD.CcddClassesDataTable.Message in project CCDD by nasa.
the class CcddSchedulerEditorHandler method updateAssignmentList.
/**
********************************************************************************************
* Update the assignment tree/list based on the currently selected message
********************************************************************************************
*/
protected void updateAssignmentList() {
// Get the selected message
Message message = getSelectedMessage();
// Check if a message is selected
if (message != null) {
// Update the package list
updateAssignmentList(message);
} else // No message is selected
{
// Check if this is the telemetry scheduler
if (schedulerHndlr.getSchedulerOption() == TELEMETRY_SCHEDULER) {
// Set the flag indicating a tabbed pane update is in progress. This flag is used
// to inhibit tab selection changes while the tabbed pane is updated
isTabUpdate = true;
// Step backwards through each tab that represents a sub-message in the tabbed pane
for (int index = tabbedPane.getTabCount() - 1; index > 0; index--) {
// Remove the sub-message tab
tabbedPane.remove(index);
}
// Reenable tab selection changes
isTabUpdate = false;
// Remove any nodes and display the 'empty message' text
assignmentTree.getRootNode().removeAllChildren();
((DefaultTreeModel) assignmentTree.getModel()).reload();
} else // Check if this is the application scheduler
if (schedulerHndlr.getSchedulerOption() == APPLICATION_SCHEDULER) {
DefaultListModel<String> packageModel = (DefaultListModel<String>) assignmentList.getModel();
// Clear the package list and display the 'empty message' text
packageModel.clear();
}
}
}
Aggregations