Search in sources :

Example 11 with AssociatedColumns

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

the class CcddScriptDataAccessHandler method getCommandArgBitLength.

/**
 ********************************************************************************************
 * Get the argument bit length for the command argument specified at the specified row in the
 * command data. Macro expansion is controlled by the input flag
 *
 * @param argumentNumber
 *            command argument index. The first argument is 0
 *
 * @param row
 *            table data row index
 *
 * @param expandMacros
 *            true to replace any macros with their corresponding value; false to return the
 *            data with any macro names in place
 *
 * @return Argument bit length for the command argument specified at the specified row in the
 *         command data; null if the argument number or row index is invalid
 ********************************************************************************************
 */
private String getCommandArgBitLength(int argumentNumber, int row, boolean expandMacros) {
    String argBitLength = null;
    // Get the table type definition for the command table referenced in the specified row
    TypeDefinition typeDefn = tableTypeHandler.getTypeDefinition(getCommandTypeNameByRow(row));
    // Check if the table type exists and represents a command
    if (typeDefn != null && typeDefn.isCommand()) {
        // Get the list of command arguments associated with this command table type
        List<AssociatedColumns> commandArguments = typeDefn.getAssociatedCommandArgumentColumns(false);
        // Check if the argument number is valid and that the argument bit length exists
        if (argumentNumber < commandArguments.size() && commandArguments.get(argumentNumber).getBitLength() != -1) {
            // Get the reference to the table information
            TableInformation tableInfo = getTableInformation(TYPE_COMMAND);
            // Get the argument bit length
            argBitLength = tableInfo.getData()[row][commandArguments.get(argumentNumber).getBitLength()];
            // Check if any macros should be expanded
            if (expandMacros) {
                // Expand any macros
                argBitLength = macroHandler.getMacroExpansion(argBitLength);
            }
        }
    }
    return argBitLength;
}
Also used : AssociatedColumns(CCDD.CcddClassesDataTable.AssociatedColumns) TableInformation(CCDD.CcddClassesDataTable.TableInformation) TypeDefinition(CCDD.CcddTableTypeHandler.TypeDefinition)

Example 12 with AssociatedColumns

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

the class CcddScriptDataAccessHandler method getCommandArgDataType.

/**
 ********************************************************************************************
 * Get the argument data type for the command argument specified at the specified row in the
 * command data
 *
 * @param argumentNumber
 *            command argument index. The first argument is 0
 *
 * @param row
 *            table data row index
 *
 * @return Argument data type for the command argument specified at the specified row in the
 *         command data; null if the argument number or row index is invalid
 ********************************************************************************************
 */
public String getCommandArgDataType(int argumentNumber, int row) {
    String argDataType = null;
    // Get the table type definition for the command table referenced in the specified row
    TypeDefinition typeDefn = tableTypeHandler.getTypeDefinition(getCommandTypeNameByRow(row));
    // Check if the table type exists and represents a command
    if (typeDefn != null && typeDefn.isCommand()) {
        // Get the list of command arguments associated with this command table type
        List<AssociatedColumns> commandArguments = typeDefn.getAssociatedCommandArgumentColumns(false);
        // Check if the argument number is valid and that the argument data type exists
        if (argumentNumber < commandArguments.size() && commandArguments.get(argumentNumber).getDataType() != -1) {
            // Get the reference to the table information
            TableInformation tableInfo = getTableInformation(TYPE_COMMAND);
            // Get the argument data type
            argDataType = tableInfo.getData()[row][commandArguments.get(argumentNumber).getDataType()];
        }
    }
    return argDataType;
}
Also used : AssociatedColumns(CCDD.CcddClassesDataTable.AssociatedColumns) TableInformation(CCDD.CcddClassesDataTable.TableInformation) TypeDefinition(CCDD.CcddTableTypeHandler.TypeDefinition)

Example 13 with AssociatedColumns

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

the class CcddScriptDataAccessHandler method getCommandArgByColumnName.

/**
 ********************************************************************************************
 * Get the argument value (as a string) for the column belonging to the specified command
 * argument at the specified row in the command data. Macro expansion is controlled by the
 * input flag
 *
 * @param argumentNumber
 *            command argument index. The first argument is 0
 *
 * @param row
 *            table data row index
 *
 * @param columnName
 *            name of the argument column for which the value is requested
 *
 * @param expandMacros
 *            true to replace any macros with their corresponding value; false to return the
 *            data with any macro names in place
 *
 * @return Argument value (as a string) for the column belonging to the specified command
 *         argument at the specified row in the command data; null if the argument number, row
 *         index, or column name is invalid
 ********************************************************************************************
 */
private String getCommandArgByColumnName(int argumentNumber, int row, String columnName, boolean expandMacros) {
    String argValue = null;
    // Get the table type definition for the command table referenced in the specified row
    TypeDefinition typeDefn = tableTypeHandler.getTypeDefinition(getCommandTypeNameByRow(row));
    // Check if the table type exists and represents a command
    if (typeDefn != null && typeDefn.isCommand()) {
        // Get the list of command arguments associated with this command table type
        List<AssociatedColumns> commandArguments = typeDefn.getAssociatedCommandArgumentColumns(false);
        // Check if the argument number is valid
        if (argumentNumber < commandArguments.size()) {
            AssociatedColumns cmdColumns = commandArguments.get(argumentNumber);
            // Get the index of the specified column
            int tgtColumn = typeDefn.getColumnIndexByUserName(columnName);
            // Check if the column belongs to the specified command argument
            if (tgtColumn == cmdColumns.getName() || tgtColumn == cmdColumns.getDataType() || tgtColumn == cmdColumns.getArraySize() || tgtColumn == cmdColumns.getBitLength() || tgtColumn == cmdColumns.getDescription() || tgtColumn == cmdColumns.getUnits() || tgtColumn == cmdColumns.getEnumeration() || tgtColumn == cmdColumns.getMinimum() || tgtColumn == cmdColumns.getMaximum() || cmdColumns.getOther().contains(tgtColumn)) {
                // Get the reference to the table information
                TableInformation tableInfo = getTableInformation(TYPE_COMMAND);
                // Get the argument value
                argValue = tableInfo.getData()[row][tgtColumn];
                // Check if any macros should be expanded
                if (expandMacros) {
                    // Expand any macros
                    argValue = macroHandler.getMacroExpansion(argValue);
                }
            }
        }
    }
    return argValue;
}
Also used : AssociatedColumns(CCDD.CcddClassesDataTable.AssociatedColumns) TableInformation(CCDD.CcddClassesDataTable.TableInformation) TypeDefinition(CCDD.CcddTableTypeHandler.TypeDefinition)

Example 14 with AssociatedColumns

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

the class CcddScriptDataAccessHandler method getCommandArgColumnNames.

/**
 ********************************************************************************************
 * Get the array of column names belonging to the specified command argument at the specified
 * row in the command data
 *
 * @param argumentNumber
 *            command argument index. The first argument is 0
 *
 * @param row
 *            table data row index
 *
 * @return Array of column names belonging to the specified command argument at the specified
 *         row in the command data; null if the argument number or row index is invalid
 ********************************************************************************************
 */
public String[] getCommandArgColumnNames(int argumentNumber, int row) {
    List<String> argColumns = new ArrayList<String>();
    // Get the table type definition for the command table referenced in the specified row
    TypeDefinition typeDefn = tableTypeHandler.getTypeDefinition(getCommandTypeNameByRow(row));
    // Check if the table type exists and represents a command
    if (typeDefn != null && typeDefn.isCommand()) {
        // Get the list of command arguments associated with this command table type
        List<AssociatedColumns> commandArguments = typeDefn.getAssociatedCommandArgumentColumns(false);
        // Check if the argument number is valid
        if (argumentNumber < commandArguments.size()) {
            AssociatedColumns cmdColumns = commandArguments.get(argumentNumber);
            // Add the argument name column name (this column must be present)
            argColumns.add(typeDefn.getColumnNamesUser()[cmdColumns.getName()]);
            // Check if the argument data type column is present
            if (cmdColumns.getDataType() != -1) {
                // Add the argument data type column name
                argColumns.add(typeDefn.getColumnNamesUser()[cmdColumns.getDataType()]);
            }
            // Check if the argument array size column is present
            if (cmdColumns.getArraySize() != -1) {
                // Add the argument array size column name
                argColumns.add(typeDefn.getColumnNamesUser()[cmdColumns.getArraySize()]);
            }
            // Check if the argument bit length column is present
            if (cmdColumns.getBitLength() != -1) {
                // Add the argument bit length column name
                argColumns.add(typeDefn.getColumnNamesUser()[cmdColumns.getBitLength()]);
            }
            // Check if the argument description column is present
            if (cmdColumns.getDescription() != -1) {
                // Add the argument description column name
                argColumns.add(typeDefn.getColumnNamesUser()[cmdColumns.getDescription()]);
            }
            // Check if the argument units column is present
            if (cmdColumns.getUnits() != -1) {
                // Add the argument units column name
                argColumns.add(typeDefn.getColumnNamesUser()[cmdColumns.getUnits()]);
            }
            // Check if the argument enumeration column is present
            if (cmdColumns.getEnumeration() != -1) {
                // Add the argument enumeration column name
                argColumns.add(typeDefn.getColumnNamesUser()[cmdColumns.getEnumeration()]);
            }
            // Check if the argument minimum column is present
            if (cmdColumns.getMinimum() != -1) {
                // Add the argument minimum column name
                argColumns.add(typeDefn.getColumnNamesUser()[cmdColumns.getMinimum()]);
            }
            // Check if the argument maximum column is present
            if (cmdColumns.getMaximum() != -1) {
                // Add the argument maximum column name
                argColumns.add(typeDefn.getColumnNamesUser()[cmdColumns.getMaximum()]);
            }
            // Step through the other columns associated with this command argument
            for (Integer otherColumn : cmdColumns.getOther()) {
                // Add the argument column name
                argColumns.add(typeDefn.getColumnNamesUser()[otherColumn]);
            }
        }
    }
    return argColumns.toArray(new String[0]);
}
Also used : AssociatedColumns(CCDD.CcddClassesDataTable.AssociatedColumns) ArrayList(java.util.ArrayList) TypeDefinition(CCDD.CcddTableTypeHandler.TypeDefinition)

Example 15 with AssociatedColumns

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

the class CcddXTCEHandler method addSpaceSystemCommands.

/**
 ********************************************************************************************
 * Add the command(s) from a table to the specified space system
 *
 * @param spaceSystem
 *            parent space system for this node
 *
 * @param tableInfo
 *            TableInformation reference for the current node
 *
 * @param isCmdHeader
 *            true if this table represents the CCSDS command header
 *
 * @param applicationID
 *            application ID
 ********************************************************************************************
 */
private void addSpaceSystemCommands(SpaceSystemType spaceSystem, TableInformation tableInfo, boolean isCmdHeader, String applicationID) {
    // Get the column indices for the command name, code, and description
    int cmdNameCol = typeDefn.getColumnIndexByInputType(InputDataType.COMMAND_NAME);
    int cmdCodeCol = typeDefn.getColumnIndexByInputType(InputDataType.COMMAND_CODE);
    int cmdDescCol = typeDefn.getColumnIndexByInputType(InputDataType.DESCRIPTION);
    // Step through each command argument column grouping
    for (AssociatedColumns cmdArg : typeDefn.getAssociatedCommandArgumentColumns(false)) {
        // command description
        if (cmdArg.getDescription() != -1 && cmdArg.getDescription() == cmdDescCol) {
            // There is no column for the command description, so reset its column index and
            // stop searching
            cmdDescCol = -1;
            break;
        }
    }
    // Step through each row in the table
    for (String[] rowData : tableInfo.getData()) {
        // Check if the command name exists
        if (cmdNameCol != -1 && !rowData[cmdNameCol].isEmpty()) {
            // Initialize the command attributes and argument names list
            String commandCode = null;
            String commandDescription = null;
            List<String> argumentNames = new ArrayList<String>();
            List<String> argArraySizes = new ArrayList<String>();
            // Check if this system doesn't yet have its command metadata created
            if (spaceSystem.getCommandMetaData() == null) {
                // Create the command metadata
                createCommandMetadata(spaceSystem);
            }
            // Store the command name
            String commandName = rowData[cmdNameCol];
            // Check if the command code exists
            if (cmdCodeCol != -1 && !rowData[cmdCodeCol].isEmpty()) {
                // Store the command code
                commandCode = rowData[cmdCodeCol];
            }
            // Check if the command description exists
            if (cmdDescCol != -1 && !rowData[cmdDescCol].isEmpty()) {
                // Store the command description
                commandDescription = rowData[cmdDescCol];
            }
            // Step through each command argument column grouping
            for (AssociatedColumns cmdArg : typeDefn.getAssociatedCommandArgumentColumns(false)) {
                // Initialize the command argument attributes
                String argumentName = null;
                String dataType = null;
                String arraySize = null;
                String bitLength = null;
                String enumeration = null;
                String minimum = null;
                String maximum = null;
                String units = null;
                String description = null;
                int stringSize = 1;
                // Check if the command argument name and data type exist
                if (cmdArg.getName() != -1 && !rowData[cmdArg.getName()].isEmpty() && cmdArg.getDataType() != -1 && !rowData[cmdArg.getDataType()].isEmpty()) {
                    String uniqueID = "";
                    int dupCount = 0;
                    // Store the command argument name and data type
                    argumentName = rowData[cmdArg.getName()];
                    dataType = rowData[cmdArg.getDataType()];
                    // Check if the description column exists
                    if (cmdArg.getDescription() != -1 && !rowData[cmdArg.getDescription()].isEmpty()) {
                        // Store the command argument description
                        description = rowData[cmdArg.getDescription()];
                    }
                    // Check if the array size column exists
                    if (cmdArg.getArraySize() != -1 && !rowData[cmdArg.getArraySize()].isEmpty()) {
                        // Store the command argument array size value
                        arraySize = rowData[cmdArg.getArraySize()];
                        // Check if the command argument has a string data type
                        if (rowData[cmdArg.getDataType()].equals(DefaultPrimitiveTypeInfo.STRING.getUserName())) {
                            // Separate the array dimension values and get the string size
                            int[] arrayDims = ArrayVariable.getArrayIndexFromSize(arraySize);
                            stringSize = arrayDims[0];
                        }
                    }
                    // Check if the bit length column exists
                    if (cmdArg.getBitLength() != -1 && !rowData[cmdArg.getBitLength()].isEmpty()) {
                        // Store the command argument bit length value
                        bitLength = rowData[cmdArg.getBitLength()];
                    }
                    // Check if the enumeration column exists
                    if (cmdArg.getEnumeration() != -1 && !rowData[cmdArg.getEnumeration()].isEmpty()) {
                        // Store the command argument enumeration value
                        enumeration = rowData[cmdArg.getEnumeration()];
                    }
                    // Check if the units column exists
                    if (cmdArg.getUnits() != -1 && !rowData[cmdArg.getUnits()].isEmpty()) {
                        // Store the command argument units
                        units = rowData[cmdArg.getUnits()];
                    }
                    // Check if the minimum column exists
                    if (cmdArg.getMinimum() != -1 && !rowData[cmdArg.getMinimum()].isEmpty()) {
                        // Store the command argument minimum value
                        minimum = rowData[cmdArg.getMinimum()];
                    }
                    // Check if the maximum column exists
                    if (cmdArg.getMaximum() != -1 && !rowData[cmdArg.getMaximum()].isEmpty()) {
                        // Store the command argument maximum value
                        maximum = rowData[cmdArg.getMaximum()];
                    }
                    // Step through the list of argument names used so far
                    for (String argName : argumentNames) {
                        // Check if the current argument name matches an existing one
                        if (argumentName.equals(argName)) {
                            // Increment the duplicate name count
                            dupCount++;
                        }
                    }
                    // Check if a duplicate argument name exists
                    if (dupCount != 0) {
                        // Set the unique ID to the counter value
                        uniqueID = String.valueOf(dupCount + 1);
                    }
                    // Add the name and array status to the lists
                    argumentNames.add(argumentName);
                    argArraySizes.add(arraySize);
                    // Set the command argument data type information
                    NameDescriptionType type = setArgumentDataType(spaceSystem, commandName, argumentName, dataType, arraySize, bitLength, enumeration, units, minimum, maximum, description, stringSize, uniqueID);
                    // Add the command to the command space system
                    ArgumentTypeSetType argument = spaceSystem.getCommandMetaData().getArgumentTypeSet();
                    argument.getStringArgumentTypeOrEnumeratedArgumentTypeOrIntegerArgumentType().add(type);
                }
            }
            // Add the command metadata set information
            addCommand(spaceSystem, commandName, commandCode, isCmdHeader, applicationID, argumentNames, argArraySizes, commandDescription);
        }
    }
}
Also used : AssociatedColumns(CCDD.CcddClassesDataTable.AssociatedColumns) ArgumentTypeSetType(org.omg.space.xtce.ArgumentTypeSetType) ArrayList(java.util.ArrayList) NameDescriptionType(org.omg.space.xtce.NameDescriptionType)

Aggregations

AssociatedColumns (CCDD.CcddClassesDataTable.AssociatedColumns)16 TypeDefinition (CCDD.CcddTableTypeHandler.TypeDefinition)10 TableInformation (CCDD.CcddClassesDataTable.TableInformation)9 ArrayList (java.util.ArrayList)5 CCDDException (CCDD.CcddClassesDataTable.CCDDException)2 MinMaxPair (CCDD.CcddClassesDataTable.MinMaxPair)2 TableDefinition (CCDD.CcddClassesDataTable.TableDefinition)2 Point (java.awt.Point)2 BigInteger (java.math.BigInteger)2 List (java.util.List)2 CommandArgumentType (org.ccsds.schema.sois.seds.CommandArgumentType)2 MinMaxRangeType (org.ccsds.schema.sois.seds.MinMaxRangeType)2 ArgumentTypeSetType (org.omg.space.xtce.ArgumentTypeSetType)2 NameDescriptionType (org.omg.space.xtce.NameDescriptionType)2 GroupInformation (CCDD.CcddClassesDataTable.GroupInformation)1 InputDataType (CCDD.CcddConstants.InputDataType)1 InputTypeFormat (CCDD.CcddConstants.InputTypeFormat)1 UndoableTableModel (CCDD.CcddUndoHandler.UndoableTableModel)1 Component (java.awt.Component)1 Dimension (java.awt.Dimension)1