use of org.omg.space.xtce.IntegerValueType in project CCDD by nasa.
the class CcddXTCEHandler method addParameterContainer.
/**
********************************************************************************************
* Add the parameter container
*
* @param spaceSystem
* space system
*
* @param tableInfo
* table information reference
*
* @param varColumn
* variable name column index (model coordinates)
*
* @param typeColumn
* data type column index (model coordinates)
*
* @param sizeColumn
* array size column index (model coordinates)
*
* @param isTlmHeader
* true if this table represents the CCSDS telemetry header
*
* @param applicationID
* application ID
********************************************************************************************
*/
private void addParameterContainer(SpaceSystemType spaceSystem, TableInformation tableInfo, int varColumn, int typeColumn, int sizeColumn, boolean isTlmHeader, String applicationID) {
ContainerSetType seqContainerSet = null;
SequenceContainerType seqContainer = null;
EntryListType entryList = factory.createEntryListType();
// Step through each row of data in the structure table
for (String[] rowData : tableInfo.getData()) {
// Check if the parameter is an array
if (!rowData[sizeColumn].isEmpty()) {
// Check if this is the array definition (array members are ignored)
if (!ArrayVariable.isArrayMember(rowData[varColumn])) {
DimensionList dimList = factory.createArrayParameterRefEntryTypeDimensionList();
// Set the array dimension start index (always 0)
IntegerValueType startVal = factory.createIntegerValueType();
startVal.setFixedValue(String.valueOf(0));
// Step through each array dimension
for (int arrayDim : ArrayVariable.getArrayIndexFromSize(rowData[sizeColumn])) {
// Create the dimension and set the start and end indices (the end index is
// the number of elements in this array dimension)
Dimension dim = factory.createArrayParameterRefEntryTypeDimensionListDimension();
IntegerValueType endVal = factory.createIntegerValueType();
endVal.setFixedValue(String.valueOf(arrayDim));
dim.setStartingIndex(startVal);
dim.setEndingIndex(endVal);
dimList.getDimension().add(dim);
}
// Store the array parameter array reference in the list
ArrayParameterRefEntryType arrayRef = factory.createArrayParameterRefEntryType();
arrayRef.setParameterRef(getNameByDataType(rowData[varColumn], rowData[typeColumn]));
arrayRef.setDimensionList(dimList);
entryList.getParameterRefEntryOrParameterSegmentRefEntryOrContainerRefEntry().add(arrayRef);
}
} else // structure)
if (dataTypeHandler.isPrimitive(rowData[typeColumn])) {
// Check if this isn't an array definition
if (rowData[sizeColumn].isEmpty() || ArrayVariable.isArrayMember(rowData[varColumn])) {
// Store the parameter reference in the list
ParameterRefEntryType parameterRef = factory.createParameterRefEntryType();
parameterRef.setParameterRef(rowData[varColumn]);
entryList.getParameterRefEntryOrParameterSegmentRefEntryOrContainerRefEntry().add(parameterRef);
}
} else // table
if (!rowData[typeColumn].equals(tlmHeaderTable)) {
// Get the name of the system to which this referenced structure belongs
String refSystemName = fieldHandler.getFieldValue(rowData[typeColumn], InputDataType.SYSTEM_PATH);
// Store the structure reference in the list
ContainerRefEntryType containerType = factory.createContainerRefEntryType();
containerType.setContainerRef("/" + project.getValue().getName() + (refSystemName == null || refSystemName.isEmpty() ? "" : "/" + refSystemName) + "/" + rowData[typeColumn] + "/" + rowData[typeColumn]);
entryList.getParameterRefEntryOrParameterSegmentRefEntryOrContainerRefEntry().add(containerType);
}
}
// Check if any parameters exist
if (!entryList.getParameterRefEntryOrParameterSegmentRefEntryOrContainerRefEntry().isEmpty()) {
// Check if the parameter sequence container hasn't been created
if (seqContainer == null) {
// Check if the parameter sequence container set hasn't been created
if (seqContainerSet == null) {
// Create the parameter sequence container set
seqContainerSet = factory.createContainerSetType();
}
// Create the parameter sequence container and set the name
seqContainer = factory.createSequenceContainerType();
// Check if this is the telemetry header
if (isTlmHeader) {
seqContainer.setName(tlmHeaderTable);
seqContainer.setAbstract(true);
} else // Not the telemetry header
{
seqContainer.setName(spaceSystem.getName());
// defined
if (tableInfo.isRootStructure() && tlmHeaderTable != null && !tlmHeaderTable.isEmpty()) {
// Create a reference to the telemetry header
BaseContainer baseContainer = factory.createSequenceContainerTypeBaseContainer();
baseContainer.setContainerRef("/" + project.getValue().getName() + (tlmHeaderPath == null || tlmHeaderPath.isEmpty() ? "" : "/" + tlmHeaderPath) + "/" + tlmHeaderTable + "/" + tlmHeaderTable);
RestrictionCriteria restrictCriteria = factory.createSequenceContainerTypeBaseContainerRestrictionCriteria();
ComparisonList compList = factory.createMatchCriteriaTypeComparisonList();
ComparisonType compType = factory.createComparisonType();
compType.setParameterRef(ccsdsAppID);
compType.setValue(applicationID);
compList.getComparison().add(compType);
restrictCriteria.setComparisonList(compList);
baseContainer.setRestrictionCriteria(restrictCriteria);
seqContainer.setBaseContainer(baseContainer);
}
}
}
// Store the parameters in the parameter sequence container
seqContainer.setEntryList(entryList);
seqContainerSet.getSequenceContainer().add(seqContainer);
}
// Check if any parameters exist
if (seqContainerSet != null) {
// Check if the telemetry metadata doesn't exit for this system
if (spaceSystem.getTelemetryMetaData() == null) {
// Create the telemetry metadata
createTelemetryMetadata(spaceSystem);
}
// Add the parameters to the system
spaceSystem.getTelemetryMetaData().setContainerSet(seqContainerSet);
}
}
use of org.omg.space.xtce.IntegerValueType in project CCDD by nasa.
the class CcddXTCEHandler method addCommand.
/**
********************************************************************************************
* Add a command metadata set to the command metadata
*
* @param spaceSystem
* space system
*
* @param commandName
* command name
*
* @param commandCode
* command code
*
* @param isCmdHeader
* true if this table represents the CCSDS command header
*
* @param argumentNames
* list of command argument names
*
* @param argArraySizes
* list of of command argument array sizes; the list item is null or blank if the
* corresponding argument isn't an array
*
* @param description
* description of the command
********************************************************************************************
*/
private void addCommand(SpaceSystemType spaceSystem, String commandName, String commandCode, boolean isCmdHeader, String applicationID, List<String> argumentNames, List<String> argArraySizes, String description) {
MetaCommandSet commandSet = spaceSystem.getCommandMetaData().getMetaCommandSet();
MetaCommandType command = factory.createMetaCommandType();
// Set the command name attribute
command.setName(commandName);
// Check is a command description exists
if (description != null && !description.isEmpty()) {
// Set the command description attribute
command.setLongDescription(description);
}
// Check if the command has any arguments
if (!argumentNames.isEmpty()) {
int index = 0;
ArgumentList argList = factory.createMetaCommandTypeArgumentList();
CommandContainerType cmdContainer = factory.createCommandContainerType();
CommandContainerEntryListType entryList = factory.createCommandContainerEntryListType();
// Step through each argument
for (String argumentName : argumentNames) {
// Set the flag to indicate that the argument is an array
boolean isArray = argArraySizes.get(index) != null && !argArraySizes.get(index).isEmpty();
// Add the argument to the the command's argument list
Argument arg = new Argument();
arg.setName(argumentName);
arg.setArgumentTypeRef(argumentName + (isArray ? ARRAY : TYPE));
argList.getArgument().add(arg);
// Store the argument reference in the list
ArgumentRefEntry argumentRef = factory.createCommandContainerEntryListTypeArgumentRefEntry();
argumentRef.setArgumentRef(argumentName);
JAXBElement<ArgumentRefEntry> argumentRefElem = factory.createCommandContainerEntryListTypeArgumentRefEntry(argumentRef);
entryList.getParameterRefEntryOrParameterSegmentRefEntryOrContainerRefEntry().add(argumentRefElem);
// Check if the command argument is an array
if (isArray) {
DimensionList dimList = factory.createArrayParameterRefEntryTypeDimensionList();
// Set the array dimension start index (always 0)
IntegerValueType startVal = factory.createIntegerValueType();
startVal.setFixedValue(String.valueOf(0));
// Step through each array dimension
for (int arrayDim : ArrayVariable.getArrayIndexFromSize(argArraySizes.get(index))) {
// Create the dimension and set the start and end indices (the end index is
// the number of elements in this array dimension)
Dimension dim = factory.createArrayParameterRefEntryTypeDimensionListDimension();
IntegerValueType endVal = factory.createIntegerValueType();
endVal.setFixedValue(String.valueOf(arrayDim));
dim.setStartingIndex(startVal);
dim.setEndingIndex(endVal);
dimList.getDimension().add(dim);
}
// Store the array parameter array reference in the list
ArrayParameterRefEntryType arrayRef = factory.createArrayParameterRefEntryType();
arrayRef.setParameterRef(argumentName);
arrayRef.setDimensionList(dimList);
JAXBElement<ArrayParameterRefEntryType> arrayRefElem = factory.createCommandContainerEntryListTypeArrayArgumentRefEntry(arrayRef);
entryList.getParameterRefEntryOrParameterSegmentRefEntryOrContainerRefEntry().add(arrayRefElem);
}
index++;
}
// Check if this table represents the CCSDS command header
if (isCmdHeader) {
command.setAbstract(true);
} else // Not the command header. Check if the command ID is provided
if (!isCmdHeader && applicationID != null && !applicationID.isEmpty() && cmdHeaderTable != null && !cmdHeaderTable.isEmpty()) {
// Create the reference to the base meta-command and set it to the empty base, in
// case no command header is defined
BaseMetaCommand baseCmd = factory.createMetaCommandTypeBaseMetaCommand();
baseCmd.setMetaCommandRef("/" + project.getValue().getName() + (cmdHeaderPath == null || cmdHeaderPath.isEmpty() ? "" : "/" + cmdHeaderPath) + "/" + cmdHeaderTable + "/" + cmdHeaderTable);
// Create the argument assignment list and store the application ID
ArgumentAssignmentList argAssnList = factory.createMetaCommandTypeBaseMetaCommandArgumentAssignmentList();
ArgumentAssignment argAssn = factory.createMetaCommandTypeBaseMetaCommandArgumentAssignmentListArgumentAssignment();
argAssn.setArgumentName(ccsdsAppID);
argAssn.setArgumentValue(applicationID);
argAssnList.getArgumentAssignment().add(argAssn);
// Check if a command code is provided
if (commandCode != null && !commandCode.isEmpty()) {
// Store the command code
argAssn = factory.createMetaCommandTypeBaseMetaCommandArgumentAssignmentListArgumentAssignment();
argAssn.setArgumentName(ccsdsFuncCode);
argAssn.setArgumentValue(commandCode);
argAssnList.getArgumentAssignment().add(argAssn);
}
baseCmd.setArgumentAssignmentList(argAssnList);
command.setBaseMetaCommand(baseCmd);
}
command.setArgumentList(argList);
cmdContainer.setEntryList(entryList);
command.setCommandContainer(cmdContainer);
}
commandSet.getMetaCommandOrMetaCommandRefOrBlockMetaCommand().add(command);
}
use of org.omg.space.xtce.IntegerValueType 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.IntegerValueType 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