use of org.ccsds.schema.sois.seds.InterfaceDeclarationType in project CCDD by nasa.
the class CcddEDSHandler method importFromFile.
/**
********************************************************************************************
* Import the the table definitions from an EDS XML formatted file
*
* @param importFile
* reference to the user-specified XML input file
*
* @param importType
* ImportType.IMPORT_ALL to import the table type, data type, and macro definitions,
* and the data from all the table definitions; ImportType.FIRST_DATA_ONLY to load
* only the data for the first table defined
*
* @throws CCDDException
* If a data is missing, extraneous, or in error in the import file
*
* @throws IOException
* If an import file I/O error occurs
*
* @throws Exception
* For any unanticipated errors
********************************************************************************************
*/
@Override
public void importFromFile(FileEnvVar importFile, ImportType importType) throws CCDDException, IOException, Exception {
try {
// Import the XML from the specified file
JAXBElement<?> jaxbElement = (JAXBElement<?>) unmarshaller.unmarshal(importFile);
// Get the data sheet reference
dataSheet = (DataSheetType) jaxbElement.getValue();
tableDefinitions = new ArrayList<TableDefinition>();
structureTypeDefn = null;
commandTypeDefn = null;
// Get the telemetry and command header argument column names for the application ID
// and the command function code. These are stored as project-level data fields
ccsdsAppID = fieldHandler.getFieldValue(CcddFieldHandler.getFieldProjectName(), InputDataType.XML_APP_ID);
ccsdsFuncCode = fieldHandler.getFieldValue(CcddFieldHandler.getFieldProjectName(), InputDataType.XML_FUNC_CODE);
// Step through each name space in the data sheet
for (NamespaceType namespace : dataSheet.getNamespace()) {
// Step through the interfaces
for (InterfaceDeclarationType intfcDecType : namespace.getDeclaredInterfaceSet().getInterface()) {
// Check if this interface contains a generic type set
if (intfcDecType.getGenericTypeSet() != null && !intfcDecType.getGenericTypeSet().getGenericType().isEmpty()) {
// Step through each generic type data
for (GenericTypeType genType : intfcDecType.getGenericTypeSet().getGenericType()) {
// column name indicator
if (genType.getName().equals(ArgumentColumnName.APP_ID.getAncillaryName())) {
// Store the item value as the application ID argument column name.
// Note that this overrides the value extracted from the project
// data field
ccsdsAppID = genType.getBaseType();
} else // argument column name indicator
if (genType.getName().equals(ArgumentColumnName.FUNC_CODE.getAncillaryName())) {
// Store the item value as the command function code argument
// column name. Note that this overrides the value extracted from
// the project data field
ccsdsFuncCode = genType.getBaseType();
}
// project or the import file
if (ccsdsAppID == null) {
// Use the default application ID argument column name
ccsdsAppID = ArgumentColumnName.APP_ID.getDefaultArgColName();
}
// the project or the import file
if (ccsdsFuncCode == null) {
// Use the default command function code argument column name
ccsdsFuncCode = ArgumentColumnName.FUNC_CODE.getDefaultArgColName();
}
}
}
}
}
// Create the table type definitions for any new structure and command tables
createTableTypeDefinitions(importType);
// Check if at least one structure or command table needs to be built
if (structureTypeDefn != null || commandTypeDefn != null) {
// Step through each space system
for (NamespaceType namespace : dataSheet.getNamespace()) {
// Recursively step through the EDS-formatted data and extract the telemetry
// and command information
unbuildSpaceSystems(namespace, importType);
// Check if only the data from the first table is to be read
if (importType == ImportType.FIRST_DATA_ONLY) {
// Stop reading table definitions
break;
}
}
}
} catch (JAXBException je) {
// Inform the user that the database import failed
new CcddDialogHandler().showMessageDialog(parent, "<html><b>Cannot import EDS XML from file<br>'</b>" + importFile.getAbsolutePath() + "<b>'; cause '" + je.getMessage() + "'", "File Error", JOptionPane.ERROR_MESSAGE, DialogOption.OK_OPTION);
}
}
use of org.ccsds.schema.sois.seds.InterfaceDeclarationType in project CCDD by nasa.
the class CcddEDSHandler method addParameter.
/**
********************************************************************************************
* Add a telemetry parameter to the name space's parameter set. Create the parameter set for
* the name space if it does not exist
*
* @param namespace
* name space
*
* @param parameterName
* parameter name
*
* @param dataType
* parameter primitive data type
*
* @param arraySize
* parameter array size; null or blank if the parameter isn't an array
*
* @param bitLength
* parameter bit length; null or blank if not a bit-wise parameter
*
* @param enumeration
* enumeration in the format <enum label>|<enum value>[|...][,...]; null to not
* specify
*
* @param units
* parameter units
*
* @param description
* parameter description
*
* @param stringSize
* size, in characters, of a string parameter; ignored if not a string or character
********************************************************************************************
*/
private void addParameter(NamespaceType namespace, String parameterName, String dataType, String arraySize, String bitLength, String enumeration, String units, String description, int stringSize) {
// appears under the ParameterTypeSet, but it will appear under the ParameterSet
if (dataType != null) {
// Get the parameter's data type information
setDataType(namespace, parameterName, dataType, arraySize, bitLength, enumeration, units, description, stringSize, "");
// Build the parameter attributes
InterfaceParameterType parameter = factory.createInterfaceParameterType();
parameter.setName(parameterName);
parameter.setType(getReferenceByDataType(parameterName, dataType, false) + getObjectIdentifier(arraySize));
// Check if a description is provided for this parameter
if (description != null && !description.isEmpty()) {
// Set the parameter's description
parameter.setLongDescription(description);
}
InterfaceDeclarationType intParmType = null;
// Step through the interfaces in order to locate the name space's parameter set
for (InterfaceDeclarationType intfcDecType : namespace.getDeclaredInterfaceSet().getInterface()) {
// Check if the interface contains a parameter set
if (intfcDecType.getParameterSet() != null) {
// Get the parameter set reference and stop searching
intParmType = intfcDecType;
break;
}
}
// Check if a parameter set exists
if (intParmType == null) {
// Create the parameter set for this name space
intParmType = createParameterSet(namespace);
}
// Add the parameter to the parameter set
intParmType.getParameterSet().getParameter().add(parameter);
}
}
use of org.ccsds.schema.sois.seds.InterfaceDeclarationType in project CCDD by nasa.
the class CcddEDSHandler method createParameterSet.
/**
********************************************************************************************
* Create the parameter set for the specified name space
*
* @param namespace
* name space
*
* @return Reference to the parameter set
********************************************************************************************
*/
private InterfaceDeclarationType createParameterSet(NamespaceType namespace) {
InterfaceDeclarationType intParmType = factory.createInterfaceDeclarationType();
intParmType.setName(TELEMETRY);
// Check if this is the interface for the telemetry header
if (namespace.getName().equals((tlmHeaderPath != null && !tlmHeaderPath.isEmpty() ? tlmHeaderPath + "/" : "") + tlmHeaderTable)) {
intParmType.setAbstract(true);
}
intParmType.setParameterSet(factory.createParameterSetType());
namespace.getDeclaredInterfaceSet().getInterface().add(intParmType);
return intParmType;
}
use of org.ccsds.schema.sois.seds.InterfaceDeclarationType in project CCDD by nasa.
the class CcddEDSHandler method createCommandSet.
/**
********************************************************************************************
* Create the command set for the specified name space
*
* @param namespace
* name space
*
* @return Reference to the command set
********************************************************************************************
*/
private InterfaceDeclarationType createCommandSet(NamespaceType namespace) {
InterfaceDeclarationType intCmdType = factory.createInterfaceDeclarationType();
intCmdType.setName(COMMAND);
// Check if this is the interface for the command header
if (namespace.getName().equals((cmdHeaderPath != null && !cmdHeaderPath.isEmpty() ? cmdHeaderPath + "/" : "") + cmdHeaderTable)) {
intCmdType.setAbstract(true);
}
intCmdType.setCommandSet(factory.createCommandSetType());
namespace.getDeclaredInterfaceSet().getInterface().add(intCmdType);
return intCmdType;
}
use of org.ccsds.schema.sois.seds.InterfaceDeclarationType in project CCDD by nasa.
the class CcddEDSHandler method addCommand.
/**
********************************************************************************************
* Add a command metadata set to the command metadata
*
* @param namespace
* name space
*
* @param commandName
* command name
*
* @param commandCode
* command code
*
* @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
*
* @param argumentNames
* list of command argument names
*
* @param description
* description of the command
********************************************************************************************
*/
private void addCommand(NamespaceType namespace, String commandName, // TODO WHERE DOES THIS GET PUT?
String commandCode, boolean isCmdHeader, // TODO WHERE DOES THIS GET PUT?
String applicationID, // TODO WHERE DOES THIS GET PUT?
String ccsdsAppID, // TODO WHERE DOES THIS GET PUT?
String ccsdsFuncCode, List<CommandArgumentType> arguments, String description) {
// Build the command attributes
InterfaceCommandType command = factory.createInterfaceCommandType();
command.setName(commandName);
// Check if a command description is provided
if (description != null && !description.isEmpty()) {
// Set the command description
command.setLongDescription(description);
}
// Check if any arguments are supplied for this command
if (!arguments.isEmpty()) {
// Step through each argument type
for (CommandArgumentType argType : arguments) {
// Add the argument information to the command
command.getArgument().add(argType);
}
}
InterfaceDeclarationType intCmdType = null;
// Step through the interfaces in order to locate the name space's command set
for (InterfaceDeclarationType intfcDecType : namespace.getDeclaredInterfaceSet().getInterface()) {
// Check if the interface contains a command set
if (intfcDecType.getCommandSet() != null) {
// Get the command set reference and stop searching
intCmdType = intfcDecType;
break;
}
}
// Check if a command set exists
if (intCmdType == null) {
// Create the command set for this name space
intCmdType = createCommandSet(namespace);
}
// Check if this isn't the command header table
if (!namespace.getName().equals(cmdHeaderTable)) {
// Set the command header as the base
BaseTypeSetType baseType = factory.createBaseTypeSetType();
InterfaceRefType intfcType = factory.createInterfaceRefType();
intfcType.setType(cmdHeaderTable + "/" + COMMAND);
baseType.getBaseType().add(intfcType);
intCmdType.setBaseTypeSet(baseType);
}
// Add the command to the command set
intCmdType.getCommandSet().getCommand().add(command);
}
Aggregations