use of org.omg.space.xtce.ParameterRefEntryType 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);
}
}
Aggregations