Search in sources :

Example 1 with NameDescriptionType

use of org.omg.space.xtce.NameDescriptionType in project CCDD by nasa.

the class CcddXTCEHandler method setParameterDataType.

/**
 ********************************************************************************************
 * Create the telemetry parameter data type and set the specified attributes
 *
 * @param spaceSystem
 *            space system
 *
 * @param parameterName
 *            parameter name; null to not specify
 *
 * @param dataType
 *            data type; null to not specify
 *
 * @param arraySize
 *            parameter array size; null or blank if the parameter isn't an array
 *
 * @param bitLength
 *            parameter bit length; null or empty if not a bit-wise parameter
 *
 * @param enumeration
 *            enumeration in the format <enum label>|<enum value>[|...][,...]; null to not
 *            specify
 *
 * @param units
 *            parameter units; null to not specify
 *
 * @param minimum
 *            minimum parameter value; null to not specify
 *
 * @param maximum
 *            maximum parameter value; null to not specify
 *
 * @param description
 *            parameter description; null to not specify
 *
 * @param description
 *            parameter description; null or blank to not specify
 *
 * @param stringSize
 *            size, in characters, of a string parameter; ignored if not a string or character
 ********************************************************************************************
 */
private void setParameterDataType(SpaceSystemType spaceSystem, String parameterName, String dataType, String arraySize, String bitLength, String enumeration, String units, String minimum, String maximum, String description, int stringSize) {
    NameDescriptionType parameterDescription = null;
    // Check if the parameter is an array
    if (arraySize != null && !arraySize.isEmpty()) {
        // Create an array type and set its attributes
        ArrayDataTypeType arrayType = factory.createArrayDataTypeType();
        String name = getNameByDataType(parameterName, dataType);
        arrayType.setName(name + ARRAY);
        arrayType.setArrayTypeRef(name + TYPE);
        arrayType.setNumberOfDimensions(BigInteger.valueOf(ArrayVariable.getArrayIndexFromSize(arraySize).length));
        // Set the parameter's array information
        spaceSystem.getTelemetryMetaData().getParameterTypeSet().getStringParameterTypeOrEnumeratedParameterTypeOrIntegerParameterType().add(arrayType);
    }
    // Check if the parameter has a primitive data type
    if (dataTypeHandler.isPrimitive(dataType)) {
        // Get the XTCE data type corresponding to the primitive data type
        XTCEDataType xtceDataType = getXTCEDataType(dataType);
        // Check if the a corresponding XTCE data type exists
        if (xtceDataType != null) {
            // Set the parameter units
            UnitSet unitSet = createUnitSet(units);
            // Check if enumeration parameters are provided
            if (enumeration != null && !enumeration.isEmpty()) {
                // Create an enumeration type and enumeration list, and add any extra
                // enumeration parameters as column data
                EnumeratedParameterType enumType = factory.createParameterTypeSetTypeEnumeratedParameterType();
                EnumerationList enumList = createEnumerationList(spaceSystem, enumeration);
                // Set the integer encoding (the only encoding available for an enumeration)
                // and the size in bits
                IntegerDataEncodingType intEncodingType = factory.createIntegerDataEncodingType();
                // Check if the parameter has a bit length
                if (bitLength != null && !bitLength.isEmpty()) {
                    // Set the size in bits to the value supplied
                    intEncodingType.setSizeInBits(BigInteger.valueOf(Integer.parseInt(bitLength)));
                } else // Not a bit-wise parameter
                {
                    // Set the size in bits to the full size of the data type
                    intEncodingType.setSizeInBits(BigInteger.valueOf(dataTypeHandler.getSizeInBits(dataType)));
                }
                // Check if the data type is an unsigned integer
                if (dataTypeHandler.isUnsignedInt(dataType)) {
                    // Set the encoding type to indicate an unsigned integer
                    intEncodingType.setEncoding("unsigned");
                }
                // TODO ISSUE: THE CCSDS HEADER IS ALWAYS BIG ENDIAN - HOW AN THIS BE
                // DETECTED? OR JUST ASSUME IT'S IGNORED BY THE USER FOR THAT CASE?
                // Set the bit order
                intEncodingType.setBitOrder(endianess == EndianType.BIG_ENDIAN ? "mostSignificantBitFirst" : "leastSignificantBitFirst");
                enumType.setIntegerDataEncoding(intEncodingType);
                // Set the enumeration list and units attributes
                enumType.setEnumerationList(enumList);
                enumType.setUnitSet(unitSet);
                parameterDescription = enumType;
            } else // Not an enumeration
            {
                switch(xtceDataType) {
                    case INTEGER:
                        // Create an integer parameter and set its attributes
                        IntegerParameterType integerType = factory.createParameterTypeSetTypeIntegerParameterType();
                        integerType.setUnitSet(unitSet);
                        IntegerDataEncodingType intEncodingType = factory.createIntegerDataEncodingType();
                        // Check if the parameter has a bit length
                        if (bitLength != null && !bitLength.isEmpty()) {
                            // Set the size in bits to the value supplied
                            integerType.setSizeInBits(BigInteger.valueOf(Integer.parseInt(bitLength)));
                            intEncodingType.setSizeInBits(BigInteger.valueOf(Integer.parseInt(bitLength)));
                        } else // Not a bit-wise parameter
                        {
                            // Set the encoding type to indicate an unsigned integer
                            integerType.setSizeInBits(BigInteger.valueOf(dataTypeHandler.getSizeInBits(dataType)));
                            intEncodingType.setSizeInBits(BigInteger.valueOf(dataTypeHandler.getSizeInBits(dataType)));
                        }
                        // Check if the data type is an unsigned integer
                        if (dataTypeHandler.isUnsignedInt(dataType)) {
                            // Set the encoding type to indicate an unsigned integer
                            integerType.setSigned(false);
                            intEncodingType.setEncoding("unsigned");
                        }
                        // Set the bit order
                        intEncodingType.setBitOrder(endianess == EndianType.BIG_ENDIAN ? "mostSignificantBitFirst" : "leastSignificantBitFirst");
                        integerType.setIntegerDataEncoding(intEncodingType);
                        // Check if a minimum or maximum value is specified
                        if ((minimum != null && !minimum.isEmpty()) || (maximum != null && !maximum.isEmpty())) {
                            IntegerRangeType range = factory.createIntegerRangeType();
                            // Check if a minimum value is specified
                            if (minimum != null && !minimum.isEmpty()) {
                                // Set the minimum value
                                range.setMinInclusive(minimum);
                            }
                            // Check if a maximum value is specified
                            if (maximum != null && !maximum.isEmpty()) {
                                // Set the maximum value
                                range.setMaxInclusive(maximum);
                            }
                            integerType.setValidRange(range);
                        }
                        parameterDescription = integerType;
                        break;
                    case FLOAT:
                        // Create a float parameter and set its attributes
                        FloatParameterType floatType = factory.createParameterTypeSetTypeFloatParameterType();
                        floatType.setUnitSet(unitSet);
                        FloatDataEncodingType floatEncodingType = factory.createFloatDataEncodingType();
                        floatEncodingType.setSizeInBits(BigInteger.valueOf(dataTypeHandler.getSizeInBits(dataType)));
                        floatEncodingType.setEncoding("IEEE754_1985");
                        floatType.setFloatDataEncoding(floatEncodingType);
                        // Check if a minimum or maximum value is specified
                        if ((minimum != null && !minimum.isEmpty()) || (maximum != null && !maximum.isEmpty())) {
                            FloatRangeType range = factory.createFloatRangeType();
                            // Check if a minimum value is specified
                            if (minimum != null && !minimum.isEmpty()) {
                                // Set the minimum value
                                range.setMinInclusive(Double.valueOf(minimum));
                            }
                            // Check if a maximum value is specified
                            if (maximum != null && !maximum.isEmpty()) {
                                // Set the maximum value
                                range.setMaxInclusive(Double.valueOf(maximum));
                            }
                            floatType.setValidRange(range);
                        }
                        parameterDescription = floatType;
                        break;
                    case STRING:
                        // Create a string parameter and set its attributes
                        StringParameterType stringType = factory.createParameterTypeSetTypeStringParameterType();
                        stringType.setUnitSet(unitSet);
                        StringDataEncodingType stringEncodingType = factory.createStringDataEncodingType();
                        // Set the string's size in bits based on the number of characters in
                        // the string with each character occupying a single byte
                        IntegerValueType intValType = new IntegerValueType();
                        intValType.setFixedValue(String.valueOf(stringSize * 8));
                        SizeInBits sizeInBits = new SizeInBits();
                        sizeInBits.setFixed(intValType);
                        stringEncodingType.setSizeInBits(sizeInBits);
                        stringEncodingType.setEncoding("UTF-8");
                        stringType.setStringDataEncoding(stringEncodingType);
                        stringType.setCharacterWidth(BigInteger.valueOf(stringSize));
                        parameterDescription = stringType;
                        break;
                }
            }
        }
    } else // Structure data type
    {
        // Create an aggregate type for the structure
        AggregateDataType aggregateType = factory.createAggregateDataType();
        parameterName = dataType;
        parameterDescription = aggregateType;
    }
    // Set the parameter type name
    parameterDescription.setName(parameterName + TYPE);
    // Check is a description exists
    if (description != null && !description.isEmpty()) {
        // Set the description attribute
        parameterDescription.setLongDescription(description);
    }
    // Set the parameter's data type information
    spaceSystem.getTelemetryMetaData().getParameterTypeSet().getStringParameterTypeOrEnumeratedParameterTypeOrIntegerParameterType().add(parameterDescription);
}
Also used : EnumerationList(org.omg.space.xtce.EnumeratedDataType.EnumerationList) StringParameterType(org.omg.space.xtce.ParameterTypeSetType.StringParameterType) IntegerDataEncodingType(org.omg.space.xtce.IntegerDataEncodingType) IntegerParameterType(org.omg.space.xtce.ParameterTypeSetType.IntegerParameterType) IntegerRangeType(org.omg.space.xtce.IntegerRangeType) SizeInBits(org.omg.space.xtce.StringDataEncodingType.SizeInBits) IntegerValueType(org.omg.space.xtce.IntegerValueType) NameDescriptionType(org.omg.space.xtce.NameDescriptionType) ArrayDataTypeType(org.omg.space.xtce.ArrayDataTypeType) FloatParameterType(org.omg.space.xtce.ParameterTypeSetType.FloatParameterType) FloatDataEncodingType(org.omg.space.xtce.FloatDataEncodingType) AggregateDataType(org.omg.space.xtce.AggregateDataType) UnitSet(org.omg.space.xtce.BaseDataType.UnitSet) StringDataEncodingType(org.omg.space.xtce.StringDataEncodingType) EnumeratedParameterType(org.omg.space.xtce.ParameterTypeSetType.EnumeratedParameterType) FloatRangeType(org.omg.space.xtce.FloatRangeType)

Example 2 with NameDescriptionType

use of org.omg.space.xtce.NameDescriptionType in project CCDD by nasa.

the class CcddXTCEHandler method importStructureTable.

/**
 ********************************************************************************************
 * Build a structure table from the specified telemetry metadata
 *
 * @param system
 *            space system
 *
 * @param tlmMetaData
 *            reference to the telemetry metadata from which to build the structure table
 *
 * @param table
 *            name table name, including the full system path
 *
 * @throws CCDDException
 *             If an input error is detected
 ********************************************************************************************
 */
private void importStructureTable(SpaceSystemType system, TelemetryMetaDataType tlmMetaData, String tableName) throws CCDDException {
    // Create a table definition for this structure table. If the name space also includes a
    // command metadata (which creates a command table) then ensure the two tables have
    // different names
    TableDefinition tableDefn = new TableDefinition(tableName + (system.getCommandMetaData() == null ? "" : "_tlm"), system.getLongDescription());
    // Check if a description exists for this structure table
    if (system.getLongDescription() != null && !system.getLongDescription().isEmpty()) {
        // Store the table's description
        tableDefn.setDescription(system.getLongDescription());
    }
    // Set the new structure table's table type name
    tableDefn.setTypeName(structureTypeDefn.getName());
    // Get the telemetry information
    ParameterSetType parmSetType = tlmMetaData.getParameterSet();
    ParameterTypeSetType parmTypeSetType = tlmMetaData.getParameterTypeSet();
    // Check if the telemetry information exists
    if (parmSetType != null && parmTypeSetType != null) {
        // Get the references to the parameter set and parameter type set
        List<Object> parmSet = parmSetType.getParameterOrParameterRef();
        List<NameDescriptionType> parmTypeSet = parmTypeSetType.getStringParameterTypeOrEnumeratedParameterTypeOrIntegerParameterType();
        // Step through each telemetry parameter
        for (int parmIndex = 0; parmIndex < parmSet.size(); parmIndex++) {
            // Get the reference to the parameter in the parameter set
            Parameter parm = (Parameter) parmSet.get(parmIndex);
            // Create a new row of data in the table definition to contain this
            // structures's information. Initialize all columns to blanks except for the
            // variable name
            String[] newRow = new String[numStructureColumns];
            Arrays.fill(newRow, null);
            newRow[variableNameIndex] = parm.getName();
            tableDefn.addData(newRow);
            // name matches the parameter type reference from the parameter set
            for (NameDescriptionType parmType : parmTypeSet) {
                // parameter type set's name
                if (parm.getParameterTypeRef().equals(parmType.getName())) {
                    String dataType = null;
                    String arraySize = null;
                    BigInteger bitLength = null;
                    long sizeInBytes = 0;
                    String enumeration = null;
                    String minimum = null;
                    String maximum = null;
                    UnitSet unitSet = null;
                    // Check if the parameter is an array data type
                    if (parmType instanceof ArrayDataTypeType) {
                        // The size of each array dimension is located in a container set.
                        // The array parameter reference containing the dimensions for the
                        // parameter matches the parameter name. Get the container set
                        // reference
                        ContainerSetType containerSet = tlmMetaData.getContainerSet();
                        // Check if the container set exists
                        if (containerSet != null) {
                            // Step through each sequence container in the container set
                            for (SequenceContainerType seqContainer : containerSet.getSequenceContainer()) {
                                // system
                                if (system.getName().equals(seqContainer.getName())) {
                                    // Step through each entry in the sequence
                                    for (SequenceEntryType entry : seqContainer.getEntryList().getParameterRefEntryOrParameterSegmentRefEntryOrContainerRefEntry()) {
                                        // parameter reference matches the target parameter
                                        if (entry instanceof ArrayParameterRefEntryType && parm.getName().equals(((ArrayParameterRefEntryType) entry).getParameterRef())) {
                                            arraySize = "";
                                            // Store the reference to the array parameter
                                            // type
                                            ArrayDataTypeType arrayType = (ArrayDataTypeType) parmType;
                                            parmType = null;
                                            // variable
                                            for (Dimension dim : ((ArrayParameterRefEntryType) entry).getDimensionList().getDimension()) {
                                                // Build the array size string
                                                arraySize += String.valueOf(dim.getEndingIndex().getFixedValue()) + ",";
                                            }
                                            arraySize = CcddUtilities.removeTrailer(arraySize, ",");
                                            // to locate this data type entry
                                            for (NameDescriptionType type : parmTypeSet) {
                                                // name
                                                if (arrayType.getArrayTypeRef().equals(type.getName())) {
                                                    // Store the reference to the array
                                                    // parameter's data type and stop
                                                    // searching
                                                    parmType = type;
                                                    break;
                                                }
                                            }
                                        }
                                    }
                                    break;
                                }
                            }
                        }
                    }
                    // locate the data type entry for the individual array members)
                    if (parmType != null) {
                        boolean isInteger = false;
                        boolean isUnsigned = false;
                        boolean isFloat = false;
                        boolean isString = false;
                        // Check if the parameter is an integer data type
                        if (parmType instanceof IntegerParameterType) {
                            // The 'sizeInBits' references are the integer size for
                            // non-bit-wise parameters, but equal the number of bits
                            // assigned to the parameter for a bit-wise parameter. It
                            // doens't appear that the size of the integer used to contain
                            // the parameter is stored. The assumption is made that the
                            // smallest integer required to store the bits is used.
                            // However, this can alter the originally intended bit-packing
                            // (e.g., a 3-bit and a 9-bit fit within a single 16-bit
                            // integer, but the code below assigns the first to an 8-bit
                            // integer and the second to a 16-bit integer)
                            IntegerParameterType itlm = (IntegerParameterType) parmType;
                            // Get the number of bits occupied by the parameter
                            bitLength = itlm.getSizeInBits();
                            // Get the parameter units reference
                            unitSet = itlm.getUnitSet();
                            // Check if integer encoding is set to 'unsigned'
                            if (itlm.getIntegerDataEncoding().getEncoding().equalsIgnoreCase("unsigned")) {
                                isUnsigned = true;
                            }
                            // Determine the smallest integer size that contains the number
                            // of bits occupied by the parameter
                            sizeInBytes = 8;
                            while (bitLength.longValue() > sizeInBytes) {
                                sizeInBytes *= 2;
                            }
                            sizeInBytes /= 8;
                            // Get the parameter range
                            IntegerRangeType range = itlm.getValidRange();
                            // Check if the parameter has a range
                            if (range != null) {
                                // Check if the minimum value exists
                                if (range.getMinInclusive() != null) {
                                    // Store the minimum
                                    minimum = range.getMinInclusive();
                                }
                                // Check if the maximum value exists
                                if (range.getMaxInclusive() != null) {
                                    // Store the maximum
                                    maximum = range.getMaxInclusive();
                                }
                            }
                            isInteger = true;
                        } else // Check if the parameter is a floating point data type
                        if (parmType instanceof FloatParameterType) {
                            // Get the float parameter attributes
                            FloatParameterType ftlm = (FloatParameterType) parmType;
                            sizeInBytes = ftlm.getSizeInBits().longValue() / 8;
                            unitSet = ftlm.getUnitSet();
                            // Get the parameter range
                            FloatRangeType range = ftlm.getValidRange();
                            // Check if the parameter has a range
                            if (range != null) {
                                // Check if the minimum value exists
                                if (range.getMinInclusive() != null) {
                                    // Store the minimum
                                    minimum = String.valueOf(range.getMinInclusive());
                                }
                                // Check if the maximum exists
                                if (range.getMaxInclusive() != null) {
                                    // Store the maximum
                                    maximum = String.valueOf(range.getMaxInclusive());
                                }
                            }
                            isFloat = true;
                        } else // Check if the parameter is a string data type
                        if (parmType instanceof StringParameterType) {
                            // Get the string parameter attributes
                            StringParameterType stlm = (StringParameterType) parmType;
                            sizeInBytes = stlm.getCharacterWidth().longValue();
                            unitSet = stlm.getUnitSet();
                            isString = true;
                        } else // Check if the parameter is an enumerated data type
                        if (parmType instanceof EnumeratedParameterType) {
                            // Get the enumeration parameters
                            EnumeratedParameterType etlm = (EnumeratedParameterType) parmType;
                            EnumerationList enumList = etlm.getEnumerationList();
                            // Check if any enumeration parameters are defined
                            if (enumList != null) {
                                // Step through each enumeration parameter
                                for (ValueEnumerationType enumType : enumList.getEnumeration()) {
                                    // Check if this is the first parameter
                                    if (enumeration == null) {
                                        // Initialize the enumeration string
                                        enumeration = "";
                                    } else // Not the first parameter
                                    {
                                        // Add the separator for the enumerations
                                        enumeration += ",";
                                    }
                                    // Begin building this enumeration
                                    enumeration += enumType.getValue() + " | " + enumType.getLabel();
                                }
                                bitLength = etlm.getIntegerDataEncoding().getSizeInBits();
                                unitSet = etlm.getUnitSet();
                                // Check if integer encoding is set to 'unsigned'
                                if (etlm.getIntegerDataEncoding().getEncoding().equalsIgnoreCase("unsigned")) {
                                    isUnsigned = true;
                                }
                                // Determine the smallest integer size that contains the
                                // number of bits occupied by the parameter
                                sizeInBytes = 8;
                                while (bitLength.longValue() > sizeInBytes) {
                                    sizeInBytes *= 2;
                                }
                                sizeInBytes /= 8;
                                isInteger = true;
                            }
                        } else // structure reference
                        if (parmType instanceof AggregateDataType) {
                            // The aggregate type contains a member list of the parameters
                            // belonging to the referenced structure. Each list parameter
                            // has the path to the space system defining the structure;
                            // this path is used to get the structure data type
                            // Get the reference to the aggregate's member list
                            List<Member> memberList = ((AggregateDataType) parmType).getMemberList().getMember();
                            // Check if the member list exists
                            if (!memberList.isEmpty()) {
                                // Get the type reference of the structure's first
                                // parameter which is the path to its space system
                                dataType = memberList.get(0).getTypeRef();
                                // beginning '/' is stripped off
                                if (dataType.startsWith("/")) {
                                    // Remove the initial '/'
                                    dataType = dataType.substring(1);
                                }
                                // The variable name must be stripped from the space system
                                // path. Get the index of the beginning of the variable
                                // name
                                int end = dataType.lastIndexOf("/");
                                // Check if the beginning of the variable name was found
                                if (end != -1) {
                                    // Strip off the variable name from the path
                                    dataType = dataType.substring(0, end);
                                }
                                // Convert the path to a valid structure name, replacing
                                // invalid characters with underscores
                                dataType = convertPathToTableName(dataType);
                            }
                        }
                        // Check if the data type isn't a structure reference
                        if (dataType == null) {
                            // Get the name of the data type from the data type table that
                            // matches the base type and size of the parameter
                            dataType = getDataType(dataTypeHandler, sizeInBytes, isInteger, isUnsigned, isFloat, isString);
                        }
                        // Check if a data type exists
                        if (dataType != null) {
                            // Store the data type
                            tableDefn.getData().set(parmIndex * numStructureColumns + dataTypeIndex, dataType);
                        }
                        // Check if a array size exists
                        if (arraySize != null) {
                            // Store the array size
                            tableDefn.getData().set(parmIndex * numStructureColumns + arraySizeIndex, arraySize);
                        }
                        // Check if a bit length exists
                        if (bitLength != null && bitLength.longValue() != sizeInBytes) {
                            // Store the bit length
                            tableDefn.getData().set(parmIndex * numStructureColumns + bitLengthIndex, bitLength.toString());
                        }
                        // Check if a description exists
                        if (parmType.getLongDescription() != null) {
                            // Store the description
                            tableDefn.getData().set(parmIndex * numStructureColumns + descriptionIndex, parmType.getLongDescription());
                        }
                        // Check if a units exists and
                        if (unitSet != null) {
                            List<UnitType> unitType = unitSet.getUnit();
                            // Check if the units exist
                            if (!unitType.isEmpty()) {
                                // Store the units for this variable
                                tableDefn.getData().set(parmIndex * numStructureColumns + unitsIndex, unitType.get(0).getContent());
                            }
                        }
                        // Check if an enumeration exists
                        if (enumeration != null) {
                            // Store the enumeration parameters. This accounts only for the
                            // first enumeration for a variable
                            tableDefn.getData().set(parmIndex * numStructureColumns + enumerationIndex, enumeration);
                        }
                        // Check if a minimum value exists
                        if (minimum != null) {
                            // Store the minimum value
                            tableDefn.getData().set(parmIndex * numStructureColumns + minimumIndex, minimum);
                        }
                        // Check if a maximum value exists
                        if (maximum != null) {
                            // Store the maximum value
                            tableDefn.getData().set(parmIndex * numStructureColumns + maximumIndex, maximum);
                        }
                    }
                    break;
                }
            }
        }
        ContainerSetType containerSet;
        // Check if the application ID data field name and the container set exist
        if ((containerSet = tlmMetaData.getContainerSet()) != null) {
            // Step through each sequence container in the container set
            for (SequenceContainerType seqContainer : containerSet.getSequenceContainer()) {
                // Check if this is the sequence container for the target system
                if (system.getName().equals(seqContainer.getName())) {
                    BaseContainer baseContainer;
                    RestrictionCriteria restrictionCriteria;
                    ComparisonList comparisonList;
                    // Check if the comparison list exists
                    if (((baseContainer = seqContainer.getBaseContainer()) != null) && ((restrictionCriteria = baseContainer.getRestrictionCriteria()) != null) && ((comparisonList = restrictionCriteria.getComparisonList()) != null)) {
                        // Step through each item in the comparison list
                        for (ComparisonType comparison : comparisonList.getComparison()) {
                            // application ID name
                            if (comparison.getParameterRef().equals(ccsdsAppID)) {
                                // Create a data field for the table containing the application
                                // ID. Once a match is found the search is discontinued
                                tableDefn.addDataField(new String[] { tableName, comparison.getParameterRef(), "Message ID", String.valueOf(comparison.getValue().length()), InputDataType.MESSAGE_ID.getInputName(), String.valueOf(false), ApplicabilityType.ROOT_ONLY.getApplicabilityName(), comparison.getValue() });
                                break;
                            }
                        }
                    }
                    break;
                }
            }
        }
    }
    // Add the structure table definition to the list
    tableDefinitions.add(tableDefn);
}
Also used : EnumerationList(org.omg.space.xtce.EnumeratedDataType.EnumerationList) ValueEnumerationType(org.omg.space.xtce.ValueEnumerationType) SequenceContainerType(org.omg.space.xtce.SequenceContainerType) ComparisonType(org.omg.space.xtce.ComparisonType) StringParameterType(org.omg.space.xtce.ParameterTypeSetType.StringParameterType) IntegerParameterType(org.omg.space.xtce.ParameterTypeSetType.IntegerParameterType) IntegerRangeType(org.omg.space.xtce.IntegerRangeType) RestrictionCriteria(org.omg.space.xtce.SequenceContainerType.BaseContainer.RestrictionCriteria) SequenceEntryType(org.omg.space.xtce.SequenceEntryType) NameDescriptionType(org.omg.space.xtce.NameDescriptionType) BaseContainer(org.omg.space.xtce.SequenceContainerType.BaseContainer) FloatParameterType(org.omg.space.xtce.ParameterTypeSetType.FloatParameterType) UnitType(org.omg.space.xtce.UnitType) ArrayParameterRefEntryType(org.omg.space.xtce.ArrayParameterRefEntryType) TableDefinition(CCDD.CcddClassesDataTable.TableDefinition) ParameterTypeSetType(org.omg.space.xtce.ParameterTypeSetType) ComparisonList(org.omg.space.xtce.MatchCriteriaType.ComparisonList) Member(org.omg.space.xtce.AggregateDataType.MemberList.Member) ParameterSetType(org.omg.space.xtce.ParameterSetType) Dimension(org.omg.space.xtce.ArrayParameterRefEntryType.DimensionList.Dimension) ArrayDataTypeType(org.omg.space.xtce.ArrayDataTypeType) ContainerSetType(org.omg.space.xtce.ContainerSetType) AggregateDataType(org.omg.space.xtce.AggregateDataType) Parameter(org.omg.space.xtce.ParameterSetType.Parameter) BigInteger(java.math.BigInteger) UnitSet(org.omg.space.xtce.BaseDataType.UnitSet) FloatRangeType(org.omg.space.xtce.FloatRangeType) EnumeratedParameterType(org.omg.space.xtce.ParameterTypeSetType.EnumeratedParameterType)

Example 3 with NameDescriptionType

use of org.omg.space.xtce.NameDescriptionType in project CCDD by nasa.

the class CcddXTCEHandler method buildSpaceSystems.

/**
 ********************************************************************************************
 * Build the space systems
 *
 * @param node
 *            current tree node
 *
 * @param variableHandler
 *            variable handler class reference; null if includeVariablePaths is false
 *
 * @param separators
 *            string array containing the variable path separator character(s), show/hide data
 *            types flag ('true' or 'false'), and data type/variable name separator
 *            character(s); null if includeVariablePaths is false
 ********************************************************************************************
 */
private void buildSpaceSystems(String[] tableNames, CcddVariableSizeAndConversionHandler variableHandler, String[] separators) {
    List<StructureMemberList> memberLists = new ArrayList<StructureMemberList>();
    // Step through each table name
    for (String tableName : tableNames) {
        // Check if this is a child (instance) table
        if (!TableInformation.isPrototype(tableName)) {
            // TODO THIS NEEDS TO CHANGE SO THAT INSTANCE VALUES CAN BE USED
            // Get the prototype of the instance table. Only prototypes of the tables are
            // used to create the space systems
            tableName = TableInformation.getPrototypeName(tableName);
            // created
            if (getSpaceSystemByName(tableName, project.getValue()) != null) {
                // Skip this table since it's space system has already been created
                continue;
            }
        }
        // Get the information from the database for the specified table
        TableInformation tableInfo = dbTable.loadTableData(tableName, true, false, true, parent);
        // Check if the table's data successfully loaded
        if (!tableInfo.isErrorFlag()) {
            // TODO IF RATE INFORMATION GETS USED THEN THE PROTOTYPE DATA IS REQUIRED. SEPARATE
            // SPACE SYSTEMS FOR EACH INSTANCE MAY THEN BE NEEDED. THE SAME ISSUE APPLIES TO
            // OTHER INSTANCE VALUES (E.G., MIN & MAX) - CAN'T REFERENCE THE PROTOTYPE TO GET
            // THIS INFORMATION; INSTEAD NEED A SPACE SYSTEM FOR THE INSTANCE
            // Get the table type and from the type get the type definition. The type
            // definition can be a global parameter since if the table represents a structure,
            // then all of its children are also structures, and if the table represents
            // commands or other table type then it is processed within this nest level
            typeDefn = tableTypeHandler.getTypeDefinition(tableInfo.getType());
            // Check if the table type represents a structure or command
            if (typeDefn != null && (typeDefn.isStructure() || typeDefn.isCommand())) {
                // Replace all macro names with their corresponding values
                tableInfo.setData(macroHandler.replaceAllMacros(tableInfo.getData()));
                // Get the application ID data field value, if present
                String applicationID = fieldHandler.getFieldValue(tableName, InputDataType.MESSAGE_ID);
                // Get the name of the system to which this table belongs from the table's
                // system path data field (if present)
                String systemPath = fieldHandler.getFieldValue(tableName, InputDataType.SYSTEM_PATH);
                // Initialize the parent system to be the root (top-level) system
                SpaceSystemType parentSystem = project.getValue();
                // Check if a system path exists
                if (systemPath != null) {
                    // Step through each system name in the path
                    for (String systemName : systemPath.split("\\s*/\\s*")) {
                        // if present)
                        if (!systemName.isEmpty()) {
                            // Search the existing space systems for one with this system's
                            // name (if none exists then use the root system's name)
                            SpaceSystemType existingSystem = getSpaceSystemByName(systemName, parentSystem);
                            // Set the parent system to the existing system if found, else
                            // create a new space system using the name from the table's system
                            // path data field
                            parentSystem = existingSystem == null ? addSpaceSystem(parentSystem, systemName, null, classification2Attr, validationStatusAttr, versionAttr) : existingSystem;
                        }
                    }
                }
                // Add the space system
                parentSystem = addSpaceSystem(parentSystem, tableName, tableInfo.getDescription(), classification3Attr, validationStatusAttr, versionAttr);
                // Check if this is a structure table
                if (typeDefn.isStructure()) {
                    MemberList memberList = factory.createAggregateDataTypeMemberList();
                    // Get the default column indices
                    int varColumn = typeDefn.getColumnIndexByInputType(InputDataType.VARIABLE);
                    int typeColumn = typeDefn.getColumnIndexByInputType(InputDataType.PRIM_AND_STRUCT);
                    int sizeColumn = typeDefn.getColumnIndexByInputType(InputDataType.ARRAY_INDEX);
                    int bitColumn = typeDefn.getColumnIndexByInputType(InputDataType.BIT_LENGTH);
                    int enumColumn = typeDefn.getColumnIndexByInputType(InputDataType.ENUMERATION);
                    int descColumn = typeDefn.getColumnIndexByInputType(InputDataType.DESCRIPTION);
                    int unitsColumn = typeDefn.getColumnIndexByInputType(InputDataType.UNITS);
                    int minColumn = typeDefn.getColumnIndexByInputType(InputDataType.MINIMUM);
                    int maxColumn = typeDefn.getColumnIndexByInputType(InputDataType.MAXIMUM);
                    // Set the flag to indicate if this is the telemetry header table
                    boolean isTlmHeaderTable = tableName.equals(tlmHeaderTable);
                    // Check if this is the telemetry header table
                    if (isTlmHeaderTable) {
                        // Store the telemetry header's path
                        tlmHeaderPath = systemPath;
                    }
                    // Export the parameter container for this structure
                    addParameterContainer(parentSystem, tableInfo, varColumn, typeColumn, sizeColumn, isTlmHeaderTable, applicationID);
                    // Step through each row in the structure table
                    for (String[] rowData : tableInfo.getData()) {
                        // used to define the array)
                        if (!ArrayVariable.isArrayMember(rowData[varColumn])) {
                            // Add the variable to the space system
                            addParameter(parentSystem, rowData[varColumn], rowData[typeColumn], rowData[sizeColumn], rowData[bitColumn], (enumColumn != -1 && !rowData[enumColumn].isEmpty() ? rowData[enumColumn] : null), (unitsColumn != -1 && !rowData[unitsColumn].isEmpty() ? rowData[unitsColumn] : null), (minColumn != -1 && !rowData[minColumn].isEmpty() ? rowData[minColumn] : null), (maxColumn != -1 && !rowData[maxColumn].isEmpty() ? rowData[maxColumn] : null), (descColumn != -1 && !rowData[descColumn].isEmpty() ? rowData[descColumn] : null), (dataTypeHandler.isString(rowData[typeColumn]) && !rowData[sizeColumn].isEmpty() ? Integer.valueOf(rowData[sizeColumn].replaceAll("^.*(\\d+)$", "$1")) : 1));
                            // Use the variable name to create an aggregate list member and add
                            // it to the member list. The list is used if this structure is
                            // referenced as a data type in another structure
                            Member member = new Member();
                            member.setName(rowData[varColumn]);
                            member.setTypeRef("/" + project.getValue().getName() + (systemPath == null || systemPath.isEmpty() ? "" : "/" + systemPath) + "/" + tableName + "/" + getNameByDataType(rowData[varColumn], rowData[typeColumn]) + TYPE);
                            memberList.getMember().add(member);
                        }
                    }
                    // Check if any variables exists in the structure table
                    if (!memberList.getMember().isEmpty()) {
                        // Create a structure member list using the table's aggregate member
                        // list
                        memberLists.add(new StructureMemberList(tableName, memberList));
                    }
                } else // This is a command table
                {
                    // Get the list containing the associated column indices for each argument
                    // grouping
                    commandArguments = typeDefn.getAssociatedCommandArgumentColumns(false);
                    // Set the flag to indicate if this is the command header table
                    boolean isCmdHeaderTable = tableName.equals(cmdHeaderTable);
                    // Check if this is the command header table
                    if (isCmdHeaderTable) {
                        // Store the command header's path
                        cmdHeaderPath = systemPath;
                    }
                    // Add the command(s) from this table to the parent system
                    addSpaceSystemCommands(parentSystem, tableInfo, tableName.equals(cmdHeaderTable), applicationID);
                }
            }
        }
    }
    // Step through each table name
    for (String tableName : tableNames) {
        // Get the prototype for the child
        tableName = TableInformation.getPrototypeName(tableName);
        // Get the space system for this table
        SpaceSystemType spaceSystem = getSpaceSystemByName(tableName, project.getValue());
        // Check if the system was found and it has telemetry data
        if (spaceSystem != null && spaceSystem.getTelemetryMetaData() != null) {
            // Step through each parameter type
            for (NameDescriptionType type : spaceSystem.getTelemetryMetaData().getParameterTypeSet().getStringParameterTypeOrEnumeratedParameterTypeOrIntegerParameterType()) {
                // Check if the type is an aggregate (i.e., a structure reference)
                if (type instanceof AggregateDataType) {
                    // Remove the trailing text added to the table name that flags it as a type
                    // or array
                    String typeName = type.getName().substring(0, type.getName().lastIndexOf("_"));
                    // Step through each structure member list
                    for (StructureMemberList structMemList : memberLists) {
                        // Check if the aggregate refers to this structure
                        if (typeName.equals(structMemList.structureName)) {
                            // Set the aggregate's member list to this structure member list
                            // and stop searching
                            ((AggregateDataType) type).setMemberList(structMemList.memberList);
                            break;
                        }
                    }
                }
            }
        }
    }
}
Also used : MemberList(org.omg.space.xtce.AggregateDataType.MemberList) ArrayList(java.util.ArrayList) SpaceSystemType(org.omg.space.xtce.SpaceSystemType) NameDescriptionType(org.omg.space.xtce.NameDescriptionType) AggregateDataType(org.omg.space.xtce.AggregateDataType) TableInformation(CCDD.CcddClassesDataTable.TableInformation) Member(org.omg.space.xtce.AggregateDataType.MemberList.Member)

Example 4 with NameDescriptionType

use of org.omg.space.xtce.NameDescriptionType 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)

Example 5 with NameDescriptionType

use of org.omg.space.xtce.NameDescriptionType in project CCDD by nasa.

the class CcddXTCEHandler method importCommandTable.

/**
 ********************************************************************************************
 * Build a command table from the specified command metadata
 *
 * @param system
 *            space system
 *
 * @param cmdMetaData
 *            reference to the command metadata from which to build the command table
 *
 * @param table
 *            name table name, including the full system path
 *
 * @throws CCDDException
 *             If an input error is detected
 ********************************************************************************************
 */
private void importCommandTable(SpaceSystemType system, CommandMetaDataType cmdMetaData, String tableName) throws CCDDException {
    // Create a table definition for this command table. If the name space also includes a
    // telemetry metadata (which creates a structure table) then ensure the two tables have
    // different names
    TableDefinition tableDefn = new TableDefinition(tableName + (system.getTelemetryMetaData() == null ? "" : "_cmd"), system.getLongDescription());
    // Check if a description exists for this command table
    if (system.getLongDescription() != null && !system.getLongDescription().isEmpty()) {
        // Store the table's description
        tableDefn.setDescription(system.getLongDescription());
    }
    // Set the new command table's table type name
    tableDefn.setTypeName(commandTypeDefn.getName());
    // Check if the description column belongs to a command argument
    if (commandArguments.size() != 0 && cmdDescriptionIndex > commandArguments.get(0).getName()) {
        // Reset the command description index to indicate no description exists
        cmdDescriptionIndex = -1;
    }
    // Get the command set information
    MetaCommandSet metaCmdSet = cmdMetaData.getMetaCommandSet();
    // Check if the command set information exists
    if (metaCmdSet != null) {
        // Get the command argument information
        ArgumentTypeSetType argTypeSetType = cmdMetaData.getArgumentTypeSet();
        List<NameDescriptionType> argTypeSet = null;
        // Check if there are any arguments for this command
        if (argTypeSetType != null) {
            // Get the list of this command's argument data types
            argTypeSet = argTypeSetType.getStringArgumentTypeOrEnumeratedArgumentTypeOrIntegerArgumentType();
        }
        // Step through each command set
        for (Object cmd : metaCmdSet.getMetaCommandOrMetaCommandRefOrBlockMetaCommand()) {
            // Check if the command represents a meta command type (all of these should)
            if (cmd instanceof MetaCommandType) {
                // Get the command type as a meta command type to shorten subsequent calls
                MetaCommandType metaCmd = (MetaCommandType) cmd;
                // Create a new row of data in the table definition to contain this command's
                // information. Initialize all columns to blanks except for the command name
                String[] newRow = new String[numCommandColumns];
                Arrays.fill(newRow, null);
                newRow[commandNameIndex] = metaCmd.getName();
                // Get the base meta-command reference
                BaseMetaCommand baseMetaCmd = metaCmd.getBaseMetaCommand();
                // Check if the base meta-command exists
                if (baseMetaCmd != null) {
                    // Step through each argument assignment
                    for (ArgumentAssignment argAssn : baseMetaCmd.getArgumentAssignmentList().getArgumentAssignment()) {
                        // column name
                        if (argAssn.getArgumentName().equals(ccsdsAppID)) {
                            boolean isExists = false;
                            // Step through the data fields already added to this table
                            for (String[] fieldInfo : tableDefn.getDataFields()) {
                                // subsequent ones are ignored to prevent duplicates
                                if (fieldInfo[FieldsColumn.FIELD_NAME.ordinal()].equals(argAssn.getArgumentName())) {
                                    // Set the flag indicating the field already exists and
                                    // stop searching
                                    isExists = true;
                                    break;
                                }
                            }
                            // Check if the application ID data field doesn't exist
                            if (!isExists) {
                                // Create a data field for the table containing the application
                                // ID and stop searching
                                tableDefn.addDataField(new String[] { tableName, argAssn.getArgumentName(), "Message ID", String.valueOf(argAssn.getArgumentValue().length()), InputDataType.MESSAGE_ID.getInputName(), String.valueOf(false), ApplicabilityType.ALL.getApplicabilityName(), argAssn.getArgumentValue() });
                            }
                        } else // argument column name
                        if (argAssn.getArgumentName().equals(ccsdsFuncCode)) {
                            // Store the command function code and stop searching
                            newRow[commandCodeIndex] = argAssn.getArgumentValue();
                            break;
                        }
                    }
                }
                // exists in the table type definition
                if (metaCmd.getLongDescription() != null && cmdDescriptionIndex != -1) {
                    // Store the command description in the row's description column
                    newRow[cmdDescriptionIndex] = metaCmd.getLongDescription();
                }
                // Check if the command has any arguments
                if (metaCmd.getArgumentList() != null && argTypeSet != null) {
                    int cmdArgIndex = 0;
                    CommandContainerType cmdContainer = metaCmd.getCommandContainer();
                    // Step through each of the command's arguments
                    for (Argument argList : metaCmd.getArgumentList().getArgument()) {
                        // Step through each command argument type
                        for (NameDescriptionType argType : argTypeSet) {
                            // between the two)
                            if (argList.getArgumentTypeRef().equals(argType.getName())) {
                                boolean isInteger = false;
                                boolean isUnsigned = false;
                                boolean isFloat = false;
                                boolean isString = false;
                                String dataType = null;
                                String arraySize = null;
                                BigInteger bitLength = null;
                                long sizeInBytes = 0;
                                String enumeration = null;
                                String description = null;
                                UnitSet unitSet = null;
                                String units = null;
                                String minimum = null;
                                String maximum = null;
                                // Check if the argument is an array data type
                                if (argType instanceof ArrayDataTypeType && metaCmd != null && cmdContainer != null) {
                                    // set
                                    for (JAXBElement<? extends SequenceEntryType> seqEntry : cmdContainer.getEntryList().getParameterRefEntryOrParameterSegmentRefEntryOrContainerRefEntry()) {
                                        // reference matches the target parameter
                                        if (seqEntry.getValue() instanceof ArrayParameterRefEntryType && argList.getName().equals(((ArrayParameterRefEntryType) seqEntry.getValue()).getParameterRef())) {
                                            arraySize = "";
                                            // Store the reference to the array parameter type
                                            ArrayDataTypeType arrayType = (ArrayDataTypeType) argType;
                                            argType = null;
                                            // the array variable
                                            for (Dimension dim : ((ArrayParameterRefEntryType) seqEntry.getValue()).getDimensionList().getDimension()) {
                                                // Build the array size string
                                                arraySize += String.valueOf(dim.getEndingIndex().getFixedValue()) + ",";
                                            }
                                            arraySize = CcddUtilities.removeTrailer(arraySize, ",");
                                            // data type entry
                                            for (NameDescriptionType type : argTypeSet) {
                                                // reference matches the data type name
                                                if (arrayType.getArrayTypeRef().equals(type.getName())) {
                                                    // Store the reference to the array
                                                    // parameter's data type and stop searching
                                                    argType = type;
                                                    break;
                                                }
                                            }
                                            break;
                                        }
                                    }
                                }
                                // individual array members)
                                if (argType != null) {
                                    // Check if the argument is an integer data type
                                    if (argType instanceof IntegerArgumentType) {
                                        IntegerArgumentType icmd = (IntegerArgumentType) argType;
                                        // Get the number of bits occupied by the argument
                                        bitLength = icmd.getSizeInBits();
                                        // Get the argument units reference
                                        unitSet = icmd.getUnitSet();
                                        // Check if integer encoding is set to 'unsigned'
                                        if (icmd.getIntegerDataEncoding().getEncoding().equalsIgnoreCase("unsigned")) {
                                            isUnsigned = true;
                                        }
                                        // Determine the smallest integer size that contains
                                        // the number of bits occupied by the argument
                                        sizeInBytes = 8;
                                        while (bitLength.longValue() > sizeInBytes) {
                                            sizeInBytes *= 2;
                                        }
                                        sizeInBytes /= 8;
                                        // Get the argument alarm
                                        IntegerArgumentType.ValidRangeSet alarmType = icmd.getValidRangeSet();
                                        // Check if the argument has an alarm
                                        if (alarmType != null) {
                                            // Get the alarm range
                                            List<IntegerRangeType> alarmRange = alarmType.getValidRange();
                                            // Check if the alarm range exists
                                            if (alarmRange != null) {
                                                // Store the minimum alarm value
                                                minimum = alarmRange.get(0).getMinInclusive();
                                                // Store the maximum alarm value
                                                maximum = alarmRange.get(0).getMaxInclusive();
                                            }
                                        }
                                        isInteger = true;
                                    } else // Check if the argument is a floating point data type
                                    if (argType instanceof FloatArgumentType) {
                                        // Get the float argument attributes
                                        FloatArgumentType fcmd = (FloatArgumentType) argType;
                                        sizeInBytes = fcmd.getSizeInBits().longValue() / 8;
                                        unitSet = fcmd.getUnitSet();
                                        // Get the argument alarm
                                        FloatArgumentType.ValidRangeSet alarmType = fcmd.getValidRangeSet();
                                        // Check if the argument has an alarm
                                        if (alarmType != null) {
                                            // Get the alarm range
                                            List<FloatRangeType> alarmRange = alarmType.getValidRange();
                                            // Check if the alarm range exists
                                            if (alarmRange != null) {
                                                // Get the minimum value
                                                Double min = alarmRange.get(0).getMinInclusive();
                                                // Check if a minimum value exists
                                                if (min != null) {
                                                    // Get the minimum alarm value
                                                    minimum = String.valueOf(min);
                                                }
                                                // Get the maximum value
                                                Double max = alarmRange.get(0).getMaxInclusive();
                                                // Check if a maximum value exists
                                                if (max != null) {
                                                    // Get the maximum alarm value
                                                    maximum = String.valueOf(max);
                                                }
                                            }
                                        }
                                        isFloat = true;
                                    } else // Check if the argument is a string data type
                                    if (argType instanceof StringDataType) {
                                        // Get the string argument attributes
                                        StringDataType scmd = (StringDataType) argType;
                                        sizeInBytes = scmd.getCharacterWidth().longValue();
                                        unitSet = scmd.getUnitSet();
                                        isString = true;
                                    } else // Check if the argument is an enumerated data type
                                    if (argType instanceof EnumeratedDataType) {
                                        EnumeratedDataType ecmd = (EnumeratedDataType) argType;
                                        EnumerationList enumList = ecmd.getEnumerationList();
                                        // Check if any enumeration parameters are defined
                                        if (enumList != null) {
                                            // Step through each enumeration parameter
                                            for (ValueEnumerationType enumType : enumList.getEnumeration()) {
                                                // Check if this is the first parameter
                                                if (enumeration == null) {
                                                    // Initialize the enumeration string
                                                    enumeration = "";
                                                } else // Not the first parameter
                                                {
                                                    // Add the separator for the
                                                    // enumerations
                                                    enumeration += ", ";
                                                }
                                                // Begin building this enumeration
                                                enumeration += enumType.getValue() + " | " + enumType.getLabel();
                                            }
                                            bitLength = ecmd.getIntegerDataEncoding().getSizeInBits();
                                            unitSet = ecmd.getUnitSet();
                                            // 'unsigned'
                                            if (ecmd.getIntegerDataEncoding().getEncoding().equalsIgnoreCase("unsigned")) {
                                                isUnsigned = true;
                                            }
                                            // Determine the smallest integer size that
                                            // contains the number of bits occupied by the
                                            // argument
                                            sizeInBytes = 8;
                                            while (bitLength.longValue() > sizeInBytes) {
                                                sizeInBytes *= 2;
                                            }
                                            sizeInBytes /= 8;
                                            isInteger = true;
                                        }
                                    }
                                    // Get the name of the data type from the data type table
                                    // that matches the base type and size of the parameter
                                    dataType = getDataType(dataTypeHandler, sizeInBytes, isInteger, isUnsigned, isFloat, isString);
                                    // Check if the description exists
                                    if (argType.getLongDescription() != null) {
                                        // Store the description
                                        description = argType.getLongDescription();
                                    }
                                    // Check if the units exists
                                    if (unitSet != null) {
                                        List<UnitType> unitType = unitSet.getUnit();
                                        // Check if the units is set
                                        if (!unitType.isEmpty()) {
                                            // Store the units
                                            units = unitType.get(0).getContent();
                                        }
                                    }
                                    // dictated by the table type definition
                                    if (cmdArgIndex < commandArguments.size()) {
                                        // Get the command argument reference
                                        AssociatedColumns acmdArg = commandArguments.get(cmdArgIndex);
                                        // Check if the command argument name is present
                                        if (acmdArg.getName() != -1) {
                                            // Store the command argument name
                                            newRow[acmdArg.getName()] = argList.getName();
                                        }
                                        // Check if the command argument data type is present
                                        if (acmdArg.getDataType() != -1 && dataType != null) {
                                            // Store the command argument data type
                                            newRow[acmdArg.getDataType()] = dataType;
                                        }
                                        // Check if the command argument array size is present
                                        if (acmdArg.getArraySize() != -1 && arraySize != null) {
                                            // Store the command argument array size
                                            newRow[acmdArg.getArraySize()] = arraySize;
                                        }
                                        // Check if the command argument bit length is present
                                        if (acmdArg.getBitLength() != -1 && bitLength != null) {
                                            // Store the command argument bit length
                                            newRow[acmdArg.getBitLength()] = bitLength.toString();
                                        }
                                        // Check if the command argument enumeration is present
                                        if (acmdArg.getEnumeration() != -1 && enumeration != null) {
                                            // Store the command argument enumeration
                                            newRow[acmdArg.getEnumeration()] = enumeration;
                                        }
                                        // Check if the command argument description is present
                                        if (acmdArg.getDescription() != -1 && description != null) {
                                            // Store the command argument description
                                            newRow[acmdArg.getDescription()] = description;
                                        }
                                        // Check if the command argument units is present
                                        if (acmdArg.getUnits() != -1 && units != null) {
                                            // Store the command argument units
                                            newRow[acmdArg.getUnits()] = units;
                                        }
                                        // Check if the command argument minimum is present
                                        if (acmdArg.getMinimum() != -1 && minimum != null) {
                                            // Store the command argument minimum
                                            newRow[acmdArg.getMinimum()] = minimum;
                                        }
                                        // Check if the command argument maximum is present
                                        if (acmdArg.getMaximum() != -1 && maximum != null) {
                                            // Store the command argument maximum
                                            newRow[acmdArg.getMaximum()] = maximum;
                                        }
                                    }
                                }
                                // Increment the argument index
                                cmdArgIndex++;
                                break;
                            }
                        }
                    }
                }
                // Add the new row to the table definition
                tableDefn.addData(newRow);
            }
        }
    }
    // Add the command table definition to the list
    tableDefinitions.add(tableDefn);
}
Also used : MetaCommandSet(org.omg.space.xtce.CommandMetaDataType.MetaCommandSet) EnumerationList(org.omg.space.xtce.EnumeratedDataType.EnumerationList) ValueEnumerationType(org.omg.space.xtce.ValueEnumerationType) ArgumentTypeSetType(org.omg.space.xtce.ArgumentTypeSetType) Argument(org.omg.space.xtce.MetaCommandType.ArgumentList.Argument) IntegerRangeType(org.omg.space.xtce.IntegerRangeType) CommandContainerType(org.omg.space.xtce.CommandContainerType) NameDescriptionType(org.omg.space.xtce.NameDescriptionType) StringDataType(org.omg.space.xtce.StringDataType) BaseMetaCommand(org.omg.space.xtce.MetaCommandType.BaseMetaCommand) UnitType(org.omg.space.xtce.UnitType) ArrayParameterRefEntryType(org.omg.space.xtce.ArrayParameterRefEntryType) TableDefinition(CCDD.CcddClassesDataTable.TableDefinition) MemberList(org.omg.space.xtce.AggregateDataType.MemberList) ArgumentList(org.omg.space.xtce.MetaCommandType.ArgumentList) ArgumentAssignmentList(org.omg.space.xtce.MetaCommandType.BaseMetaCommand.ArgumentAssignmentList) EnumerationList(org.omg.space.xtce.EnumeratedDataType.EnumerationList) List(java.util.List) DimensionList(org.omg.space.xtce.ArrayParameterRefEntryType.DimensionList) ComparisonList(org.omg.space.xtce.MatchCriteriaType.ComparisonList) ArrayList(java.util.ArrayList) EnumeratedDataType(org.omg.space.xtce.EnumeratedDataType) Dimension(org.omg.space.xtce.ArrayParameterRefEntryType.DimensionList.Dimension) ArrayDataTypeType(org.omg.space.xtce.ArrayDataTypeType) ArgumentAssignment(org.omg.space.xtce.MetaCommandType.BaseMetaCommand.ArgumentAssignmentList.ArgumentAssignment) FloatArgumentType(org.omg.space.xtce.ArgumentTypeSetType.FloatArgumentType) IntegerArgumentType(org.omg.space.xtce.ArgumentTypeSetType.IntegerArgumentType) AssociatedColumns(CCDD.CcddClassesDataTable.AssociatedColumns) BigInteger(java.math.BigInteger) UnitSet(org.omg.space.xtce.BaseDataType.UnitSet) MetaCommandType(org.omg.space.xtce.MetaCommandType)

Aggregations

NameDescriptionType (org.omg.space.xtce.NameDescriptionType)5 ArrayList (java.util.ArrayList)3 AggregateDataType (org.omg.space.xtce.AggregateDataType)3 ArrayDataTypeType (org.omg.space.xtce.ArrayDataTypeType)3 UnitSet (org.omg.space.xtce.BaseDataType.UnitSet)3 EnumerationList (org.omg.space.xtce.EnumeratedDataType.EnumerationList)3 IntegerRangeType (org.omg.space.xtce.IntegerRangeType)3 AssociatedColumns (CCDD.CcddClassesDataTable.AssociatedColumns)2 TableDefinition (CCDD.CcddClassesDataTable.TableDefinition)2 BigInteger (java.math.BigInteger)2 MemberList (org.omg.space.xtce.AggregateDataType.MemberList)2 Member (org.omg.space.xtce.AggregateDataType.MemberList.Member)2 ArgumentTypeSetType (org.omg.space.xtce.ArgumentTypeSetType)2 ArrayParameterRefEntryType (org.omg.space.xtce.ArrayParameterRefEntryType)2 Dimension (org.omg.space.xtce.ArrayParameterRefEntryType.DimensionList.Dimension)2 FloatRangeType (org.omg.space.xtce.FloatRangeType)2 ComparisonList (org.omg.space.xtce.MatchCriteriaType.ComparisonList)2 EnumeratedParameterType (org.omg.space.xtce.ParameterTypeSetType.EnumeratedParameterType)2 FloatParameterType (org.omg.space.xtce.ParameterTypeSetType.FloatParameterType)2 UnitType (org.omg.space.xtce.UnitType)2