use of org.omg.space.xtce.StringDataEncodingType 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);
}
use of org.omg.space.xtce.StringDataEncodingType in project CCDD by nasa.
the class CcddXTCEHandler method setArgumentDataType.
/**
********************************************************************************************
* Set the command argument data type and set the specified attributes
*
* @param spaceSystem
* space system
*
* @param commandName
* command name
*
* @param argumentName
* command argument name; null to not specify
*
* @param dataType
* command argument data type; null to not specify
*
* @param arraySize
* command argument array size; null or blank if the argument isn't an array
*
* @param bitLength
* command argument bit length
*
* @param enumeration
* command argument enumeration in the format <enum label>|<enum value>[|...][,...];
* null to not specify
*
* @param units
* command argument 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
* command argument description ; null to not specify
*
* @param stringSize
* string size in bytes; ignored if the command argument does not have a string data
* type
*
* @return Command description of the type corresponding to the primitive data type with the
* specified attributes set
*
* @param uniqueID
* text used to uniquely identify data types with the same name; blank if the data
* type has no name conflict
********************************************************************************************
*/
private NameDescriptionType setArgumentDataType(SpaceSystemType spaceSystem, String commandName, String argumentName, String dataType, String arraySize, String bitLength, String enumeration, String units, String minimum, String maximum, String description, int stringSize, String uniqueID) {
BaseDataType commandDescription = null;
// Check if the argument is an array
if (arraySize != null && !arraySize.isEmpty()) {
// Create an array type and set its attributes
ArrayDataTypeType arrayType = factory.createArrayDataTypeType();
arrayType.setName(argumentName + ARRAY);
arrayType.setNumberOfDimensions(BigInteger.valueOf(ArrayVariable.getArrayIndexFromSize(arraySize).length));
arrayType.setArrayTypeRef(argumentName + TYPE);
// Set the argument's array information
spaceSystem.getCommandMetaData().getArgumentTypeSet().getStringArgumentTypeOrEnumeratedArgumentTypeOrIntegerArgumentType().add(arrayType);
}
// 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) {
UnitSet unitSet = null;
// Check if units is provided
if (units != null && !units.isEmpty()) {
// Set the command units
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
EnumeratedDataType enumType = factory.createEnumeratedDataType();
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)));
}
// Set the enumeration list and units attributes
enumType.setEnumerationList(enumList);
enumType.setUnitSet(unitSet);
// 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");
}
// Set the bit order
intEncodingType.setBitOrder(endianess == EndianType.BIG_ENDIAN ? "mostSignificantBitFirst" : "leastSignificantBitFirst");
enumType.setIntegerDataEncoding(intEncodingType);
commandDescription = enumType;
} else // This is not an enumerated command argument
{
switch(xtceDataType) {
case INTEGER:
// Create an integer command argument and set its attributes
IntegerArgumentType integerType = factory.createArgumentTypeSetTypeIntegerArgumentType();
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 size in bits to the full size of the data type
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())) {
IntegerArgumentType.ValidRangeSet validRange = factory.createArgumentTypeSetTypeIntegerArgumentTypeValidRangeSet();
IntegerRangeType range = new IntegerRangeType();
// 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);
}
validRange.getValidRange().add(range);
integerType.setValidRangeSet(validRange);
}
commandDescription = integerType;
break;
case FLOAT:
// Create a float command argument and set its attributes
FloatArgumentType floatType = factory.createArgumentTypeSetTypeFloatArgumentType();
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())) {
FloatArgumentType.ValidRangeSet validRange = factory.createArgumentTypeSetTypeFloatArgumentTypeValidRangeSet();
FloatRangeType range = new FloatRangeType();
// Check if a minimum value is specified
if (minimum != null && !minimum.isEmpty()) {
// Set the minimum value
range.setMinExclusive(Double.valueOf(minimum));
}
// Check if a maximum value is specified
if (maximum != null && !maximum.isEmpty()) {
// Set the maximum value
range.setMaxExclusive(Double.valueOf(maximum));
}
validRange.getValidRange().add(range);
floatType.setValidRangeSet(validRange);
}
commandDescription = floatType;
break;
case STRING:
// Create a string command argument and set its attributes
StringDataType stringType = factory.createStringDataType();
stringType.setCharacterWidth(BigInteger.valueOf(stringSize));
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);
commandDescription = stringType;
break;
}
}
// Set the command name and argument name attributes
commandDescription.setName(argumentName + TYPE + uniqueID);
// Check is a description exists
if (description != null && !description.isEmpty()) {
// Set the command description attribute
commandDescription.setLongDescription(description);
}
}
return commandDescription;
}
Aggregations