use of CCDD.CcddClassesDataTable.RateInformation in project CCDD by nasa.
the class CcddScriptDataAccessHandler method getLinkRate.
/**
********************************************************************************************
* Return the sample rate for the specified link
*
* @param streamName
* data stream name
*
* @param linkName
* link name
*
* @return Text representation of the sample rate, in samples per second, of the specified
* link. For rates equal to or faster than 1 sample per second the string represents a
* whole number; for rates slower than 1 sample per second the string is in the form
* number of samples / number of seconds; returns a blank if the data stream or link
* don't exist
********************************************************************************************
*/
public String getLinkRate(String streamName, String linkName) {
String sampleRate = "";
// Get the rate information based on the supplied data stream name
RateInformation rateInfo = rateHandler.getRateInformationByStreamName(streamName);
// Check if the rate information exists with this stream name
if (rateInfo != null) {
// Get the link sample rate based on the rate column and link names
sampleRate = linkHandler.getLinkRate(rateInfo.getRateName(), linkName);
}
return sampleRate;
}
use of CCDD.CcddClassesDataTable.RateInformation in project CCDD by nasa.
the class CcddTelemetrySchedulerDialog method initialize.
/**
********************************************************************************************
* Create the telemetry scheduler dialog. This is executed in a separate thread since it can
* take a noticeable amount time to complete, and by using a separate thread the GUI is allowed
* to continue to update. The GUI menu commands, however, are disabled until the telemetry
* scheduler initialization completes execution
********************************************************************************************
*/
private void initialize() {
// Build the telemetry scheduler dialog in the background
CcddBackgroundCommand.executeInBackground(ccddMain, new BackgroundCommand() {
// Create a button panel
JPanel buttonPnl = new JPanel();
/**
************************************************************************************
* Build the telemetry scheduler dialog
************************************************************************************
*/
@Override
protected void execute() {
// Create a tree containing all of the variables. This is used for determining
// bit-packing and variable relative position
allVariableTree = new CcddTableTreeHandler(ccddMain, TableTreeType.INSTANCE_STRUCTURES_WITH_PRIMITIVES_AND_RATES, ccddMain.getMainFrame());
// Expand the tree so that all nodes are 'visible'
allVariableTree.setTreeExpansion(true);
allVariableTreePaths = new ArrayList<String>();
// Step through all of the nodes in the variable tree
for (Enumeration<?> element = allVariableTree.getRootNode().preorderEnumeration(); element.hasMoreElements(); ) {
// Convert the variable path to a string and add it to the list
allVariableTreePaths.add(allVariableTree.getFullVariablePath(((ToolTipTreeNode) element.nextElement()).getPath()));
}
// Load the stored telemetry scheduler data from the project database
schedulerDb.loadStoredData();
// Auto-fill button
btnAutoFill = CcddButtonPanelHandler.createButton("Auto-fill", AUTO_CREATE_ICON, KeyEvent.VK_F, "Auto-fill the message table with the variables");
// Create a listener for the Auto-fill button
btnAutoFill.addActionListener(new ValidateCellActionListener() {
/**
****************************************************************************
* Auto-fill the variables into the telemetry scheduler for the currently
* selected data stream
****************************************************************************
*/
@Override
protected void performAction(ActionEvent ae) {
// Run auto-fill
activeSchHandler.autoFill();
}
/**
****************************************************************************
* Get the reference to the currently displayed table
****************************************************************************
*/
@Override
protected CcddJTableHandler getTable() {
return activeSchHandler.getSchedulerEditor().getTable();
}
});
// Clear Rate button
btnClearRate = CcddButtonPanelHandler.createButton("Clear Rate", UNDO_ICON, KeyEvent.VK_R, "Remove the variables of the currently selected rate from all messages");
// Add a listener for the Clear Rate button
btnClearRate.addActionListener(new ValidateCellActionListener() {
/**
****************************************************************************
* Remove the variables of the currently selected rate from all messages in the
* currently selected data stream
****************************************************************************
*/
@Override
protected void performAction(ActionEvent ae) {
activeSchHandler.getSchedulerEditor().clearVariablesFromMessages(activeSchHandler.getSchedulerInput().getSelectedRate());
}
/**
****************************************************************************
* Get the reference to the currently displayed table
****************************************************************************
*/
@Override
protected CcddJTableHandler getTable() {
return activeSchHandler.getSchedulerEditor().getTable();
}
});
// Clear Msgs button
btnClear = CcddButtonPanelHandler.createButton("Clear Msgs", UNDO_ICON, KeyEvent.VK_R, "Remove the variables from all messages");
// Add a listener for the Clear Msgs button
btnClear.addActionListener(new ValidateCellActionListener() {
/**
****************************************************************************
* Remove the variables from all messages in the currently selected data stream
****************************************************************************
*/
@Override
protected void performAction(ActionEvent ae) {
activeSchHandler.getSchedulerEditor().clearVariablesFromMessages(null);
}
/**
****************************************************************************
* Get the reference to the currently displayed table
****************************************************************************
*/
@Override
protected CcddJTableHandler getTable() {
return activeSchHandler.getSchedulerEditor().getTable();
}
});
// Add Sub-msg button
btnAddSubMessage = CcddButtonPanelHandler.createButton("Add Sub-msg", INSERT_ICON, KeyEvent.VK_A, "Add a sub-message to the currently selected message");
// Create a listener for the Add Sub-msg button
btnAddSubMessage.addActionListener(new ValidateCellActionListener() {
/**
****************************************************************************
* Add a sub-message to the current message
****************************************************************************
*/
@Override
protected void performAction(ActionEvent ae) {
activeSchHandler.getSchedulerEditor().addSubMessage();
}
/**
****************************************************************************
* Get the reference to the currently displayed table
****************************************************************************
*/
@Override
protected CcddJTableHandler getTable() {
return activeSchHandler.getSchedulerEditor().getTable();
}
});
// Del Sub-msg button
btnDeleteSubMessage = CcddButtonPanelHandler.createButton("Del Sub-msg", DELETE_ICON, KeyEvent.VK_D, "Delete the currently selected sub-message");
// Create a listener for the Del Sub-msg button
btnDeleteSubMessage.addActionListener(new ValidateCellActionListener() {
/**
****************************************************************************
* Delete the current sub-message
****************************************************************************
*/
@Override
protected void performAction(ActionEvent ae) {
activeSchHandler.getSchedulerEditor().deleteSubMessage();
}
/**
****************************************************************************
* Get the reference to the currently displayed table
****************************************************************************
*/
@Override
protected CcddJTableHandler getTable() {
return activeSchHandler.getSchedulerEditor().getTable();
}
});
// Assign message names and IDs button
btnAssign = CcddButtonPanelHandler.createButton("Assign Msgs", AUTO_CREATE_ICON, KeyEvent.VK_M, "Automatically assign message names and/or IDs to the messages and sub-messages");
// Add a listener for the Assign Msgs button
btnAssign.addActionListener(new ValidateCellActionListener() {
/**
****************************************************************************
* Automatically assign names and/or IDs to the telemetry messages and
* sub-messages
****************************************************************************
*/
@Override
protected void performAction(ActionEvent ae) {
new CcddAssignMessageIDDialog(ccddMain, activeSchHandler.getCurrentMessages(), CcddTelemetrySchedulerDialog.this);
}
/**
****************************************************************************
* Get the reference to the currently displayed table
****************************************************************************
*/
@Override
protected CcddJTableHandler getTable() {
return activeSchHandler.getSchedulerEditor().getTable();
}
});
// Store button
btnStore = CcddButtonPanelHandler.createButton("Store", STORE_ICON, KeyEvent.VK_S, "Store the message updates in the project database");
// Add a listener for the Store button
btnStore.addActionListener(new ValidateCellActionListener() {
/**
****************************************************************************
* Store the data from the various data streams into the database
****************************************************************************
*/
@Override
protected void performAction(ActionEvent ae) {
// storing the changes
if (isChanges() && new CcddDialogHandler().showMessageDialog(CcddTelemetrySchedulerDialog.this, "<html><b>Store changes?", "Store Changes", JOptionPane.QUESTION_MESSAGE, DialogOption.OK_CANCEL_OPTION) == OK_BUTTON) {
// Store the messages in the project database
storeData();
}
}
/**
****************************************************************************
* Get the reference to the currently displayed table
****************************************************************************
*/
@Override
protected CcddJTableHandler getTable() {
return activeSchHandler.getSchedulerEditor().getTable();
}
});
// Create a button to close the dialog
btnClose = CcddButtonPanelHandler.createButton("Close", CLOSE_ICON, KeyEvent.VK_C, "Close the telemetry scheduler");
// Add a listener for the Close button
btnClose.addActionListener(new ValidateCellActionListener() {
/**
****************************************************************************
* Close the telemetry scheduler dialog
****************************************************************************
*/
@Override
protected void performAction(ActionEvent ae) {
windowCloseButtonAction();
}
/**
****************************************************************************
* Get the reference to the currently displayed table
****************************************************************************
*/
@Override
protected CcddJTableHandler getTable() {
return activeSchHandler.getSchedulerEditor().getTable();
}
});
// Add buttons in the order in which they'll appear (left to right, top to bottom)
buttonPnl.add(btnAutoFill);
buttonPnl.add(btnClearRate);
buttonPnl.add(btnAddSubMessage);
buttonPnl.add(btnStore);
buttonPnl.add(btnAssign);
buttonPnl.add(btnClear);
buttonPnl.add(btnDeleteSubMessage);
buttonPnl.add(btnClose);
// Create two rows of buttons
setButtonRows(2);
// Create a tabbed pane in which to place the scheduler handlers
tabbedPane = new DnDTabbedPane(SwingConstants.TOP) {
/**
****************************************************************************
* Update the scheduler list order following a tab move
****************************************************************************
*/
@Override
protected Object tabMoveCleanup(int oldTabIndex, int newTabIndex, Object tabContents) {
// Adjust the new tab index if moving the tab to a higher index
newTabIndex -= newTabIndex > oldTabIndex ? 1 : 0;
// Re-order the rate information based on the new tab order
// Re-order the rate information based on the new tab order
RateInformation[] rateInfoArray = rateHandler.getRateInformation().toArray(new RateInformation[0]);
rateInfoArray = (RateInformation[]) CcddUtilities.moveArrayMember(rateInfoArray, oldTabIndex, newTabIndex);
List<RateInformation> rateInfoList = new ArrayList<RateInformation>(rateInfoArray.length);
rateInfoList.addAll(Arrays.asList(rateInfoArray));
rateHandler.setRateInformation(rateInfoList);
// Get the reference to the moved tab's original location in the list
CcddSchedulerHandler editor = schHandlers.get(oldTabIndex);
// Remove the tab
schHandlers.remove(oldTabIndex);
// Add the tab at its new location
schHandlers.add(newTabIndex, editor);
// Update the active tab pointer to the moved tab
activeSchHandler = schHandlers.get(tabbedPane.getSelectedIndex());
return editor;
}
};
tabbedPane.setFont(ModifiableFontInfo.LABEL_BOLD.getFont());
// Listen for tab selection changes
tabbedPane.addChangeListener(new ChangeListener() {
/**
****************************************************************************
* Update the editor to the one associated with the selected tab
****************************************************************************
*/
@Override
public void stateChanged(ChangeEvent ce) {
// Set the active editor to the one indicated by the currently selected tab
activeSchHandler = schHandlers.get(tabbedPane.getSelectedIndex());
}
});
// Add the scheduler handlers to the tabbed pane
addDataStreams();
// Set the first tab as the active editor
activeSchHandler = schHandlers.get(0);
}
/**
************************************************************************************
* Telemetry scheduler dialog creation complete
************************************************************************************
*/
@Override
protected void complete() {
// Display the telemetry scheduler dialog
showOptionsDialog(ccddMain.getMainFrame(), tabbedPane, buttonPnl, btnClose, "Telemetry Scheduler", true);
}
});
}
use of CCDD.CcddClassesDataTable.RateInformation in project CCDD by nasa.
the class CcddDbTableCommandHandler method storeRateParameters.
/**
********************************************************************************************
* Store the rate parameters in the project database and update the database structure-related
* functions
*
* @param parent
* component calling this method, used for positioning any error dialogs
********************************************************************************************
*/
protected void storeRateParameters(Component parent) {
// Build the string containing the rate parameters
String comment = rateHandler.getMaxSecondsPerMsg() + "," + rateHandler.getMaxMsgsPerSecond() + "," + rateHandler.isIncludeUneven();
// Step through each stream
for (RateInformation rateInfo : rateHandler.getRateInformation()) {
// Build the string containing the rate name and parameters. The name is placed within
// double quotes
comment += ",\"" + rateInfo.getRateName() + "\",\"" + rateInfo.getStreamName() + "\"," + rateInfo.getMaxMsgsPerCycle() + "," + rateInfo.getMaxBytesPerSec();
}
// Update the the stored rate parameters
setTableComment(InternalTable.TLM_SCHEDULER.getTableName(), comment, parent);
}
use of CCDD.CcddClassesDataTable.RateInformation 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.RateInformation in project CCDD by nasa.
the class CcddTableEditorHandler method setUpSampleRateColumn.
/**
********************************************************************************************
* Set up or update the combo box containing the allowable sample rates for display in the
* table's "Rate" column cells
********************************************************************************************
*/
protected void setUpSampleRateColumn() {
// Step through each rate column defined for this table
for (int index = 0; index < rateIndex.size(); index++) {
// Get the column reference for the rate column
TableColumn rateColumn = table.getColumnModel().getColumn(table.convertColumnIndexToView(rateIndex.get(index)));
// Set to true if this is an update to the combo box content update and not the
// original combo box setup at table creation)
boolean isUpdate = (DefaultCellEditor) rateColumn.getCellEditor() != null && ((DefaultCellEditor) rateColumn.getCellEditor()).getComponent() instanceof PaddedComboBox;
// Check if this is a combo box content update
if (isUpdate) {
// End editing on the rate cell in case a rate cell is selected. This causes the
// selected cell to be updated with the new rates
((DefaultCellEditor) rateColumn.getCellEditor()).stopCellEditing();
}
// Create a combo box and set the color and font
PaddedComboBox comboBox = new PaddedComboBox(table.getFont());
// Set the column table editor to the combo box
rateColumn.setCellEditor(new DefaultCellEditor(comboBox));
// Get the rate information for this rate column
RateInformation rateInfo = rateHandler.getRateInformationByRateName(typeDefn.getColumnNamesUser()[rateIndex.get(index)]);
// Check if the rate information exists for this column
if (rateInfo != null) {
// Make the first item a blank
comboBox.addItem("");
// Step through each sample rate
for (String rate : rateInfo.getSampleRates()) {
// Add the sample rate to the combo box list
comboBox.addItem(rate);
}
}
// Check if this is a combo box content update
if (isUpdate) {
// Force the table to redraw in case the rates have been altered such that a rate
// cell's validity changes and the background color needs to be updated
table.repaint();
}
}
}
Aggregations