use of org.ccsds.schema.sois.seds.DerivedTypeRangeType in project CCDD by nasa.
the class CcddEDSHandler method addNamespaceCommands.
/**
********************************************************************************************
* Add the command(s) from a table to the specified name space
*
* @param namespace
* name space 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
*
* @param ccsdsAppID
* name of the command header argument containing the application ID
*
* @param ccsdsFuncCode
* name of the command header argument containing the command function code
********************************************************************************************
*/
private void addNamespaceCommands(NamespaceType namespace, TableInformation tableInfo, boolean isCmdHeader, String applicationID, String ccsdsAppID, String ccsdsFuncCode) {
List<String> argumentNames = new ArrayList<String>();
// 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<CommandArgumentType> arguments = new ArrayList<CommandArgumentType>();
// 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 units = 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()];
// Add a command argument to the command metadata
CommandArgumentType argType = factory.createCommandArgumentType();
argType.setName(argumentName);
// Check if the description column exists
if (cmdArg.getDescription() != -1 && !rowData[cmdArg.getDescription()].isEmpty()) {
// Store the command argument description
argType.setLongDescription(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
DerivedTypeRangeType range = argType.getValidRange() == null ? factory.createDerivedTypeRangeType() : argType.getValidRange();
MinMaxRangeType minMax = range.getMinMaxRange() == null ? factory.createMinMaxRangeType() : range.getMinMaxRange();
minMax.setMin(BigDecimal.valueOf(Double.valueOf(rowData[cmdArg.getMinimum()])));
argType.setValidRange(range);
}
// Check if the maximum column exists
if (cmdArg.getMaximum() != -1 && !rowData[cmdArg.getMaximum()].isEmpty()) {
// Store the command argument maximum value
DerivedTypeRangeType range = argType.getValidRange() == null ? factory.createDerivedTypeRangeType() : argType.getValidRange();
MinMaxRangeType minMax = range.getMinMaxRange() == null ? factory.createMinMaxRangeType() : range.getMinMaxRange();
minMax.setMax(BigDecimal.valueOf(Double.valueOf(rowData[cmdArg.getMaximum()])));
argType.setValidRange(range);
}
// 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);
}
argType.setType(argumentName + TYPE + uniqueID);
// Add the name to the list
argumentNames.add(argumentName);
// Get the argument's data type information
setDataType(namespace, argumentName, dataType, arraySize, bitLength, enumeration, units, null, stringSize, uniqueID);
// Add the command argument to the list
arguments.add(argType);
}
}
// Add the command information
addCommand(namespace, commandName, commandCode, isCmdHeader, applicationID, ccsdsAppID, ccsdsFuncCode, arguments, commandDescription);
}
}
}
use of org.ccsds.schema.sois.seds.DerivedTypeRangeType in project CCDD by nasa.
the class CcddEDSHandler method importStructureTable.
/**
********************************************************************************************
* Build a structure table from the specified telemetry metadata
*
* @param namespace
* name space
*
* @param parameterSet
* reference to the parameter set from which to build the structure table
*
* @param table
* name table name, including the full system path
*
* @param hasCommand
* true if the name space also has a command set
*
* @throws CCDDException
* If an input error is detected
********************************************************************************************
*/
private void importStructureTable(NamespaceType namespace, List<InterfaceParameterType> parameterSet, String tableName, boolean hasCommand) throws CCDDException {
List<DescriptionType> memberList = null;
// Create a table definition for this structure table. If the name space also includes a
// command set (which creates a command table) then ensure the two tables have different
// names
TableDefinition tableDefn = new TableDefinition(tableName + (hasCommand ? "_tlm" : ""), namespace.getLongDescription());
// Check if a description exists for this structure table
if (namespace.getLongDescription() != null && !namespace.getLongDescription().isEmpty()) {
// Store the table's description
tableDefn.setDescription(namespace.getLongDescription());
}
// Set the new structure table's table type name
tableDefn.setTypeName(structureTypeDefn.getName());
// Extract the table's name, minus the path, from the name space name
String typeName = namespace.getName();
int index = typeName.lastIndexOf("/");
if (index != -1) {
typeName = typeName.substring(index + 1);
}
typeName += TYPE;
// container for this structure
for (RootDataType parmType : namespace.getDataTypeSet().getArrayDataTypeOrBinaryDataTypeOrBooleanDataType()) {
// Check if this is the container for the structure's members
if (parmType instanceof ContainerDataType && parmType.getName().equals(typeName)) {
// Check if the member list exists
if (((ContainerDataType) parmType).getEntryList() != null && !((ContainerDataType) parmType).getEntryList().getEntryOrFixedValueEntryOrPaddingEntry().isEmpty()) {
// Set the reference to the container's member list
memberList = ((ContainerDataType) parmType).getEntryList().getEntryOrFixedValueEntryOrPaddingEntry();
}
// Stop searching since the matching container was found
break;
}
}
// Step through each telemetry parameter
for (int parmIndex = 0; parmIndex < parameterSet.size(); parmIndex++) {
// Get the reference to the parameter in the parameter set
InterfaceParameterType parm = parameterSet.get(parmIndex);
// Create a new row of data in the table definition to contain
// this structure's information. Initialize all columns to
// blanks except for the variable name
String[] newRow = new String[structureTypeDefn.getColumnCountVisible()];
Arrays.fill(newRow, null);
newRow[variableNameIndex] = parm.getName();
// definition and that a description exists
if (descriptionIndex != -1 && parm.getLongDescription() != null) {
// Store the description for this variable
newRow[descriptionIndex] = parm.getLongDescription();
}
// Add the new row to the table definition
tableDefn.addData(newRow);
// name matches the parameter type reference from the parameter set
for (RootDataType parmType : namespace.getDataTypeSet().getArrayDataTypeOrBinaryDataTypeOrBooleanDataType()) {
// parameter type set's name
if (parm.getType().equals(parmType.getName())) {
String dataType = null;
String arraySize = null;
BigInteger bitLength = null;
long sizeInBytes = 0;
String enumeration = null;
String minimum = null;
String maximum = null;
Unit units = null;
// Check if the parameter is an array data type
if (parmType instanceof ArrayDataType) {
arraySize = "";
// Store the reference to the array parameter type
ArrayDataType arrayType = (ArrayDataType) parmType;
// Step through each dimension for the array variable
for (DimensionSizeType dim : ((ArrayDataType) parmType).getDimensionList().getDimension()) {
// Build the array size string
arraySize += String.valueOf(dim.getSize().longValue()) + ",";
}
arraySize = CcddUtilities.removeTrailer(arraySize, ",");
parmType = null;
// the parameter type set in order to locate this data type entry
for (RootDataType type : namespace.getDataTypeSet().getArrayDataTypeOrBinaryDataTypeOrBooleanDataType()) {
// type name
if (arrayType.getDataTypeRef().equals(type.getName())) {
// Store the reference to the array parameter's data type and stop
// searching
parmType = type;
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 IntegerDataType) {
// 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)
IntegerDataType itlm = (IntegerDataType) parmType;
// Get the number of bits occupied by the parameter
bitLength = itlm.getIntegerDataEncoding().getSizeInBits();
// Check if units exist for this parameter
if (itlm.getSemantics() != null && itlm.getSemantics().getUnit() != null) {
// Get the parameter units reference
units = itlm.getSemantics().getUnit();
}
// Check if integer encoding is set to 'unsigned'
if (itlm.getIntegerDataEncoding().getEncoding() == IntegerEncodingType.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;
// Check if the table's member list exists
if (memberList != null) {
// Step through each member in the member list
for (DescriptionType entry : memberList) {
// Check if this is the entry for this parameter
if (((EntryType) entry).getName().equals(parm.getName() + TYPE)) {
// Get the minimum and maximum values, if present
DerivedTypeRangeType range = ((EntryType) entry).getValidRange();
// Check if the range information exists
if (range != null) {
// Get the minimum and maximum information
MinMaxRangeType minMaxRange = range.getMinMaxRange();
// Check if the minimum value is specified
if (minMaxRange.getMin() != null) {
// Set the minimum value
minimum = minMaxRange.getMin().toString();
}
// Check if the maximum value is specified
if (minMaxRange.getMax() != null) {
// Set the maximum value
maximum = minMaxRange.getMax().toString();
}
}
// Stop searching since the matching parameter was located
break;
}
}
}
isInteger = true;
} else // Check if the parameter is a floating point data type
if (parmType instanceof FloatDataType) {
// Get the float parameter attributes
FloatDataType ftlm = (FloatDataType) parmType;
switch(ftlm.getFloatDataEncoding().getEncodingAndPrecision()) {
case IEEE_754_2008_SINGLE:
sizeInBytes = 4;
break;
case IEEE_754_2008_DOUBLE:
sizeInBytes = 8;
break;
case IEEE_754_2008_QUAD:
sizeInBytes = 16;
break;
default:
break;
}
// Check if units exist for this parameter
if (ftlm.getSemantics() != null && ftlm.getSemantics().getUnit() != null) {
// Get the parameter units reference
units = ftlm.getSemantics().getUnit();
}
// Check if the table's member list exists
if (memberList != null) {
// Step through each member in the member list
for (DescriptionType entry : memberList) {
// Check if this is the entry for this parameter
if (((EntryType) entry).getName().equals(parm.getName())) {
// Get the minimum and maximum values, if present
DerivedTypeRangeType range = ((EntryType) entry).getValidRange();
// Check if the range information exists
if (range != null) {
// Get the minimum and maximum information
MinMaxRangeType minMaxRange = range.getMinMaxRange();
// Check if the minimum value is specified
if (minMaxRange.getMin() != null) {
// Set the minimum value
minimum = minMaxRange.getMin().toString();
}
// Check if the maximum value is specified
if (minMaxRange.getMax() != null) {
// Set the maximum value
maximum = minMaxRange.getMax().toString();
}
}
// Stop searching since the matching parameter was located
break;
}
}
}
isFloat = true;
} else // Check if the parameter is a string data type
if (parmType instanceof StringDataType) {
// Get the string parameter attributes
StringDataType stlm = (StringDataType) parmType;
sizeInBytes = stlm.getLength().longValue();
// Check if units exist for this parameter
if (stlm.getSemantics() != null && stlm.getSemantics().getUnit() != null) {
// Get the parameter units reference
units = stlm.getSemantics().getUnit();
}
isString = true;
} else // Check if the parameter is an enumerated data type
if (parmType instanceof EnumeratedDataType) {
// Get the enumeration parameters
EnumeratedDataType etlm = (EnumeratedDataType) parmType;
EnumerationListType 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();
// Check if units exist for this parameter
if (etlm.getSemantics() != null && etlm.getSemantics().getUnit() != null) {
// Get the parameter units reference
units = etlm.getSemantics().getUnit();
}
// Check if integer encoding is set to 'unsigned'
if (etlm.getIntegerDataEncoding().getEncoding() == IntegerEncodingType.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 // reference
if (parmType instanceof ContainerDataType && ((ContainerDataType) parmType).getEntryList() != null) {
// Get the reference to the container's base type, which is the name
// space path
dataType = ((ContainerDataType) parmType).getBaseType();
// it begins with a '/'. This beginning '/' is stripped off
if (dataType.startsWith("/")) {
// Remove the initial '/'
dataType = dataType.substring(1);
}
// The variable name must be stripped from the name space 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 (parm.getLongDescription() != null) {
// Store the description
tableDefn.getData().set(parmIndex * numStructureColumns + descriptionIndex, parm.getLongDescription());
}
// Check if a units exists
if (units != null && !units.value().isEmpty()) {
// Store the units for this variable
tableDefn.getData().set(parmIndex * numStructureColumns + unitsIndex, units.value());
}
}
// 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;
}
}
}
// Add the structure table definition to the list
tableDefinitions.add(tableDefn);
}
use of org.ccsds.schema.sois.seds.DerivedTypeRangeType in project CCDD by nasa.
the class CcddEDSHandler method addParameterContainer.
/**
********************************************************************************************
* Add the parameter container
*
* @param namespace
* name space
*
* @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 minColumn
* minimum value column index (model coordinates)
*
* @param maxColumn
* maximum value column index (model coordinates)
*
* @param isTlmHeader
* true if this table represents the CCSDS telemetry header
*
* @param applicationID
* application ID
*
* @param ccsdsAppID
* name of the command header argument containing the application ID
********************************************************************************************
*/
private void addParameterContainer(NamespaceType namespace, TableInformation tableInfo, int varColumn, int typeColumn, int sizeColumn, int minColumn, int maxColumn, boolean isTlmHeader, // TODO WHERE DOES THIS GET PUT?
String applicationID, // TODO WHERE DOES THIS GET PUT?
String ccsdsAppID) {
ContainerDataType containerType = null;
EntryListType entryList = factory.createEntryListType();
// Step through each row of data in the structure table
for (String[] rowData : tableInfo.getData()) {
// used to create the list)
if (!ArrayVariable.isArrayMember(rowData[varColumn])) {
// TODO A REFERENCE IN A CONTAINER TO A STRUCTURE THAT CONTAINS AN ARRAY THROWS A
// NULL POINTER EXCEPTION IN THE EDS VIEWER (UNDER THE DATA TYPES TAB WHEN THE
// CONTAINER IS EXPANDED)
// Store the parameter reference in the list
EntryType entryType = factory.createEntryType();
entryType.setName(rowData[varColumn]);
entryType.setType(getReferenceByDataType(rowData[varColumn], rowData[typeColumn], !dataTypeHandler.isPrimitive(rowData[typeColumn])) + getObjectIdentifier(rowData[sizeColumn]));
// Check if a minimum or maximum value exists
if ((minColumn != -1 && !rowData[minColumn].isEmpty()) || (maxColumn != -1 && !rowData[maxColumn].isEmpty())) {
DerivedTypeRangeType range = factory.createDerivedTypeRangeType();
MinMaxRangeType minMaxRange = factory.createMinMaxRangeType();
minMaxRange.setRangeType(RangeType.INCLUSIVE_MIN_INCLUSIVE_MAX);
// Set the flag if the parameter is in integer data type
boolean isInteger = dataTypeHandler.isInteger(rowData[typeColumn]);
// Check if a minimum value is specified
if (minColumn != -1 && !rowData[minColumn].isEmpty()) {
// Set the minimum value
minMaxRange.setMin(isInteger ? BigDecimal.valueOf(Integer.valueOf(rowData[minColumn])) : BigDecimal.valueOf(Float.valueOf(rowData[minColumn])));
}
// Check if a maximum value is specified
if (maxColumn != -1 && !rowData[maxColumn].isEmpty()) {
// Set the maximum value
minMaxRange.setMax(isInteger ? BigDecimal.valueOf(Integer.valueOf(rowData[maxColumn])) : BigDecimal.valueOf(Float.valueOf(rowData[maxColumn])));
}
// Set the range
range.setMinMaxRange(minMaxRange);
entryType.setValidRange(range);
}
entryList.getEntryOrFixedValueEntryOrPaddingEntry().add(entryType);
}
}
// Check if any parameters exist
if (!entryList.getEntryOrFixedValueEntryOrPaddingEntry().isEmpty()) {
// Check if the parameter sequence container set hasn't been created
if (containerType == null) {
// Create the parameter sequence container set
containerType = factory.createContainerDataType();
}
// Check if this is the telemetry header
if (isTlmHeader) {
containerType.setName(tlmHeaderTable + TYPE);
containerType.setAbstract(true);
} else // Not the telemetry header
{
containerType.setName(tableInfo.getPrototypeName() + TYPE);
}
// Store the parameters in the parameter sequence container
containerType.setEntryList(entryList);
}
// Check if any parameters exist
if (containerType != null) {
// Get the data type set for this name space
DataTypeSetType dataTypeSet = namespace.getDataTypeSet();
// enumerated parameter
if (dataTypeSet == null) {
// Create the data type set
dataTypeSet = factory.createDataTypeSetType();
}
// Add the parameters to the system
dataTypeSet.getArrayDataTypeOrBinaryDataTypeOrBooleanDataType().add(containerType);
namespace.setDataTypeSet(dataTypeSet);
}
}
Aggregations