use of CCDD.CcddClassesDataTable.Message in project CCDD by nasa.
the class CcddSchedulerEditorHandler method getSelectedMessage.
/**
********************************************************************************************
* Get the (sub-)message currently selected in the scheduler table
*
* @return The currently selected (sub-)message; null if none is selected
********************************************************************************************
*/
private Message getSelectedMessage() {
Message message = null;
// Get the selected row
int row = schedulerTable.getSelectedRow();
// Check if a row is selected
if (row != -1) {
// Convert the row index to model coordinates in case the rows are sorted by the column
// header
row = schedulerTable.convertRowIndexToModel(row);
// Get the message for the selected row
message = messages.get(row);
// Check if this is the telemetry scheduler
if (schedulerHndlr.getSchedulerOption() == TELEMETRY_SCHEDULER) {
// Get the selected column
int column = schedulerTable.getSelectedColumn();
// Calculate the index of the selected sub-message
int subMsgIndex = column - SchedulerColumn.ID.ordinal();
// Check if a valid sub-message is selected
if (subMsgIndex > 0 && message.getNumberOfSubMessages() > 1 && subMsgIndex <= message.getNumberOfSubMessages()) {
// Get the message for the selected row
message = messages.get(row).getSubMessage(subMsgIndex - 1);
}
}
}
return message;
}
use of CCDD.CcddClassesDataTable.Message in project CCDD by nasa.
the class CcddSchedulerEditorHandler method deleteSubMessage.
/**
********************************************************************************************
* Delete the sub-message associated with the currently selected assignment tab
********************************************************************************************
*/
protected void deleteSubMessage() {
// Get the currently selected (sub-)message
Message message = getSelectedMessage();
// Check if a message is selected
if (message != null) {
// Check if a sub-message tab is selected
if (message.getParentMessage() != null) {
// Change the reference to the sub-messages parent message
message = message.getParentMessage();
}
// Get the number of sub-messages
int index = message.getNumberOfSubMessages();
// there are variables in the sub-messages
if (index > 1 && deAllocateSubVariables(message)) {
// Store the selected row and column indices
int row = schedulerTable.getSelectedRow();
int column = schedulerTable.getSelectedColumn();
// Remove the sub-message from the message
message.removeSubMessage(index - 1);
// 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();
// Recalculate the total bytes remaining in each message and update the Scheduler
// table Bytes column
calculateTotalBytesRemaining();
// Update the remaining bytes column values
updateRemainingBytesColumn();
// Update the scheduler table to reflect the deleted sub-message
updateSchedulerTable(true);
// Adjust the selected column index in case the one that had been selected was
// removed
column = Math.min(column, schedulerTable.getColumnCount() - 1);
// 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 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);
}
}
}
}
use of CCDD.CcddClassesDataTable.Message in project CCDD by nasa.
the class CcddSchedulerEditorHandler method getSubOptions.
/**
********************************************************************************************
* Find all the options for sub-hertz
*
* @param rate
* hertz of the selected variable
*
* @return List of all the combinations
********************************************************************************************
*/
private List<String> getSubOptions(float rate) {
List<String> msgs = new ArrayList<String>();
// Current message option
String msg = "";
// Step through each existing message
for (Message message : messages) {
// Calculate the number of cycles per sample, which equates to the number of possible
// options as well as the spacing between sub-messages
int numOptions = Math.round(1 / rate / period);
// available options
if (message.getNumberOfSubMessages() > 1 && message.getNumberOfSubMessages() % numOptions == 0.0) {
// Build the text identifying the sub-message(s)
String subMsgText = " sub-msg" + (message.getNumberOfSubMessages() / numOptions == 1 ? "" : "s") + " ";
// Step through the number of options
for (int index = 1; index <= numOptions; index++) {
int msgIndex = index;
// Create the start of the option
msg = message.getName() + subMsgText;
// Step through each sub-message in an option
for (int s = 0; s < message.getNumberOfSubMessages(); s += numOptions) {
// Add the message to the option
msg += msgIndex + ", ";
// Assign next message
msgIndex += numOptions;
}
// Remove the trailing comma
msg = CcddUtilities.removeTrailer(msg.trim(), ",");
// Add the option to the list of options
msgs.add(msg);
}
}
}
return msgs;
}
use of CCDD.CcddClassesDataTable.Message in project CCDD by nasa.
the class CcddSchedulerEditorHandler method deAllocateSubVariables.
/**
********************************************************************************************
* Deallocate any sub-message variables if the number of sub-messages is changed
*
* @param message
* message for which the variables are deallocated from each sub-message
*
* @return true if the variable is deallocated or there are no variables to deallocate; false
* if there are variable to deallocate but the user cancels the operation
********************************************************************************************
*/
private boolean deAllocateSubVariables(Message message) {
boolean isDeallocated = true;
boolean isSubVariable = false;
// Check if this message has sub-messages (i.e., is a parent message)
if (message.getNumberOfSubMessages() != 0) {
// Step through each sub-message
for (Message msg : message.getSubMessages()) {
// Check if the sub-message has a variable
if (msg.getNumberOfVariables() != 0) {
// Set the flag to indicate a sub-message contains a variable and stop
// searching
isSubVariable = true;
break;
}
}
}
// Check if a sub-message has a variable
if (isSubVariable) {
// Check if the user confirms deallocating the variables from the sub-messages
if (new CcddDialogHandler().showMessageDialog(schedulerHndlr.getSchedulerDialog().getDialog(), "<html><b>Note: All of this message's sub-message<br>" + "variables will be de-assigned!<br><br>Proceed?", "Confirmation", JOptionPane.QUESTION_MESSAGE, DialogOption.OK_CANCEL_OPTION) == OK_BUTTON) {
List<String> excludedVars = new ArrayList<String>();
// Step through each sub-message
for (Message subMsg : message.getSubMessages()) {
// Step through each variable in the sub-message
for (Variable var : subMsg.getVariables()) {
// Check if the variable has not been added to the excluded variables list
if (!excludedVars.contains(var.getFullName())) {
// Add the variable name to the exclude list
excludedVars.add(var.getFullName());
}
}
// Remove the variables
subMsg.getVariables().clear();
}
// Set the variable(s) to available
schedulerHndlr.makeVariableAvailable(excludedVars);
} else // User canceled the operation
{
// Set the flag to indicate that the user canceled changing the number of
// sub-messages
isDeallocated = false;
}
}
return isDeallocated;
}
Aggregations