Search in sources :

Example 1 with SpaceSystemType

use of org.omg.space.xtce.SpaceSystemType in project CCDD by nasa.

the class CcddXTCEHandler method unbuildSpaceSystems.

/**
 ********************************************************************************************
 * Extract the telemetry and/or command information from the space system. This is a recursive
 * method
 *
 * @param system
 *            space system
 *
 * @param parentPath
 *            full path name for this space system (based on its nesting within other space
 *            systems)
 *
 * @param importFileName
 *            import file name
 *
 * @throws CCDDException
 *             If an input error is detected
 ********************************************************************************************
 */
private void unbuildSpaceSystems(SpaceSystemType system, String parentPath, ImportType importType) throws CCDDException {
    // Get the table name based on the space system name and the path to this system. Convert
    // the name to be a valid table name
    String tableName = convertPathToTableName(parentPath + "_" + system.getName());
    // Get the child system's telemetry metadata information
    TelemetryMetaDataType tlmMetaData = system.getTelemetryMetaData();
    // that this is a structure table
    if (tlmMetaData != null) {
        // Build the structure table from the telemetry data
        importStructureTable(system, tlmMetaData, tableName);
    }
    // Get the child system's command metadata information
    CommandMetaDataType cmdMetaData = system.getCommandMetaData();
    // that this is a command table
    if (cmdMetaData != null) {
        // Build the structure table from the telemetry data
        importCommandTable(system, cmdMetaData, tableName);
    }
    // far
    if (importType == ImportType.IMPORT_ALL || tableDefinitions.isEmpty()) {
        // Step through each child system, if any
        for (SpaceSystemType childSystem : system.getSpaceSystem()) {
            // Process this system's children, if any
            unbuildSpaceSystems(childSystem, tableName, importType);
        }
    }
}
Also used : TelemetryMetaDataType(org.omg.space.xtce.TelemetryMetaDataType) CommandMetaDataType(org.omg.space.xtce.CommandMetaDataType) SpaceSystemType(org.omg.space.xtce.SpaceSystemType)

Example 2 with SpaceSystemType

use of org.omg.space.xtce.SpaceSystemType in project CCDD by nasa.

the class CcddXTCEHandler method addSpaceSystem.

/**
 ********************************************************************************************
 * Create a new space system as a child of the specified space system. If the specified system
 * is null then this is the root space system
 *
 * @param parentSystem
 *            parent space system for the new system; null for the root space system
 *
 * @param systemName
 *            name for the new space system
 *
 * @param description
 *            space system description
 *
 * @param classification
 *            XML document classification
 *
 * @param validationStatus
 *            XML document validation status
 *
 * @param version
 *            XML document version
 *
 * @return Reference to the new space system
 ********************************************************************************************
 */
private SpaceSystemType addSpaceSystem(SpaceSystemType parentSystem, String systemName, String description, String classification, String validationStatus, String version) {
    // Create the new space system and set the name attribute
    SpaceSystemType childSystem = factory.createSpaceSystemType();
    childSystem.setName(systemName);
    // Check if a description is provided
    if (description != null && !description.isEmpty()) {
        // Set the description attribute
        childSystem.setLongDescription(description);
    }
    // Set the new space system's header attributes
    setHeader(childSystem, classification, validationStatus, version, (parentSystem == null ? new Date().toString() : null));
    // Check if this is the root space system
    if (parentSystem == null) {
        // Set this space system as the root system
        project = factory.createSpaceSystem(childSystem);
    } else // Not the root space system
    {
        // Add the new space system as a child of the specified system
        parentSystem.getSpaceSystem().add(childSystem);
    }
    return childSystem;
}
Also used : SpaceSystemType(org.omg.space.xtce.SpaceSystemType) Date(java.util.Date)

Example 3 with SpaceSystemType

use of org.omg.space.xtce.SpaceSystemType in project CCDD by nasa.

the class CcddXTCEHandler method convertTablesToXTCE.

/**
 ********************************************************************************************
 * Convert the project database contents to XTCE XML format
 *
 * @param tableNames
 *            array of table names to convert
 *
 * @param replaceMacros
 *            true to replace any embedded macros with their corresponding values
 *
 * @param includeReservedMsgIDs
 *            true to include the contents of the reserved message ID table in the export file
 *
 * @param includeVariablePaths
 *            true to include the variable path for each variable in a structure table, both in
 *            application format and using the user-defined separator characters
 *
 * @param variableHandler
 *            variable handler class reference; null if includeVariablePaths is false
 *
 * @param separators
 *            string array containing the variable path separator character(s), show/hide data
 *            types flag ('true' or 'false'), and data type/variable name separator
 *            character(s); null if includeVariablePaths is false
 *
 * @param endianess
 *            EndianType.BIG_ENDIAN for big endian, EndianType.LITTLE_ENDIAN for little endian
 *
 * @param version
 *            version attribute
 *
 * @param validationStatus
 *            validation status attribute
 *
 * @param classification1
 *            first level classification attribute
 *
 * @param classification2
 *            second level classification attribute
 *
 * @param classification3
 *            third level classification attribute
 ********************************************************************************************
 */
private void convertTablesToXTCE(String[] tableNames, CcddVariableSizeAndConversionHandler variableHandler, String[] separators, EndianType endianess, String version, String validationStatus, String classification1, String classification2, String classification3) {
    this.endianess = endianess;
    // Store the attributes
    versionAttr = version;
    validationStatusAttr = validationStatus;
    classification1Attr = classification1;
    classification2Attr = classification2;
    classification3Attr = classification3;
    // Create the root space system
    SpaceSystemType rootSystem = addSpaceSystem(null, dbControl.getProjectName(), dbControl.getDatabaseDescription(dbControl.getDatabaseName()), classification1Attr, validationStatusAttr, versionAttr);
    // Set the project's build information
    AuthorSet author = factory.createHeaderTypeAuthorSet();
    author.getAuthor().add(dbControl.getUser());
    rootSystem.getHeader().setAuthorSet(author);
    NoteSet note = factory.createHeaderTypeNoteSet();
    note.getNote().add("Generated by CCDD " + ccddMain.getCCDDVersionInformation());
    note.getNote().add("Date: " + new Date().toString());
    note.getNote().add("Project: " + dbControl.getProjectName());
    note.getNote().add("Host: " + dbControl.getServer());
    note.getNote().add("Endianess: " + (endianess == EndianType.BIG_ENDIAN ? "big" : "little"));
    rootSystem.getHeader().setNoteSet(note);
    // Get the names of the tables representing the CCSDS telemetry and command headers
    tlmHeaderTable = fieldHandler.getFieldValue(CcddFieldHandler.getFieldProjectName(), InputDataType.XML_TLM_HDR);
    cmdHeaderTable = fieldHandler.getFieldValue(CcddFieldHandler.getFieldProjectName(), InputDataType.XML_CMD_HDR);
    // 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);
    // Check if the application ID argument column name isn't set in the project
    if (ccsdsAppID == null) {
        // Use the default application ID argument column name
        ccsdsAppID = ArgumentColumnName.APP_ID.getDefaultArgColName();
    }
    // Check if the command function code argument column name isn't set in the project
    if (ccsdsFuncCode == null) {
        // Use the default command function code argument column name
        ccsdsFuncCode = ArgumentColumnName.FUNC_CODE.getDefaultArgColName();
    }
    // The application ID or command function code argument column names are stored as
    // ancillary data which is used if the export file is imported into CCDD
    AncillaryDataSet ancillarySet = factory.createDescriptionTypeAncillaryDataSet();
    AncillaryData appID = factory.createDescriptionTypeAncillaryDataSetAncillaryData();
    appID.setName(ArgumentColumnName.APP_ID.getAncillaryName());
    appID.setValue(ccsdsAppID);
    ancillarySet.getAncillaryData().add(appID);
    project.getValue().setAncillaryDataSet(ancillarySet);
    AncillaryData funcCode = factory.createDescriptionTypeAncillaryDataSetAncillaryData();
    funcCode.setName(ArgumentColumnName.FUNC_CODE.getAncillaryName());
    funcCode.setValue(ccsdsFuncCode);
    ancillarySet.getAncillaryData().add(funcCode);
    project.getValue().setAncillaryDataSet(ancillarySet);
    // Add the project's space systems, parameters, and commands
    buildSpaceSystems(tableNames, variableHandler, separators);
}
Also used : NoteSet(org.omg.space.xtce.HeaderType.NoteSet) AuthorSet(org.omg.space.xtce.HeaderType.AuthorSet) AncillaryDataSet(org.omg.space.xtce.DescriptionType.AncillaryDataSet) AncillaryData(org.omg.space.xtce.DescriptionType.AncillaryDataSet.AncillaryData) SpaceSystemType(org.omg.space.xtce.SpaceSystemType) Date(java.util.Date)

Example 4 with SpaceSystemType

use of org.omg.space.xtce.SpaceSystemType in project CCDD by nasa.

the class CcddXTCEHandler method findMetaData.

/**
 ********************************************************************************************
 * Recursively scan the import file in order to determine if any structure or command tables
 * exist. If a command table determine the maximum number of command arguments its commands
 * require
 *
 * @param system
 *            space system
 *
 * @param importFileName
 *            import file name
 ********************************************************************************************
 */
private void findMetaData(SpaceSystemType system, ImportType importType) {
    // Get the child system's telemetry metadata information
    TelemetryMetaDataType tlmMetaData = system.getTelemetryMetaData();
    // that this is a structure table
    if (tlmMetaData != null) {
        isTelemetry = true;
    }
    // Get the child system's command metadata information
    CommandMetaDataType cmdMetaData = system.getCommandMetaData();
    // that this is a command table
    if (cmdMetaData != null) {
        isCommand = true;
        // Get the reference to the meta-command set
        MetaCommandSet commandSet = cmdMetaData.getMetaCommandSet();
        // Check if the meta-command set exists
        if (commandSet != null) {
            // Step through each entry in the meta-command set
            for (Object metaCommand : commandSet.getMetaCommandOrMetaCommandRefOrBlockMetaCommand()) {
                // Check if the entry is a meta-command type
                if (metaCommand instanceof MetaCommandType) {
                    // The number of entries in the meta-command type is the number of command
                    // arguments required by this command. Store the largest number of command
                    // arguments required by all commands in the import file
                    maxNumArguments = Math.max(maxNumArguments, ((MetaCommandType) metaCommand).getArgumentList().getArgument().size());
                }
            }
        }
    }
    // but none has been found
    if (importType == ImportType.IMPORT_ALL || (!isTelemetry && !isCommand)) {
        // Step through each child system, if any
        for (SpaceSystemType childSystem : system.getSpaceSystem()) {
            // Process this system's children, if any
            findMetaData(childSystem, importType);
        }
    }
}
Also used : MetaCommandSet(org.omg.space.xtce.CommandMetaDataType.MetaCommandSet) TelemetryMetaDataType(org.omg.space.xtce.TelemetryMetaDataType) CommandMetaDataType(org.omg.space.xtce.CommandMetaDataType) SpaceSystemType(org.omg.space.xtce.SpaceSystemType) MetaCommandType(org.omg.space.xtce.MetaCommandType)

Example 5 with SpaceSystemType

use of org.omg.space.xtce.SpaceSystemType in project CCDD by nasa.

the class CcddXTCEHandler method importFromFile.

/**
 ********************************************************************************************
 * Import the the table definitions from an XTCE 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 top-level space system
        SpaceSystemType rootSystem = (SpaceSystemType) 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);
        AncillaryDataSet ancillarySet = rootSystem.getAncillaryDataSet();
        // Check if the root system contains ancillary data
        if (ancillarySet != null) {
            // Step through each ancillary data item
            for (AncillaryData data : ancillarySet.getAncillaryData()) {
                // name indicator
                if (data.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 = data.getValue();
                } else // column name indicator
                if (data.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 = data.getValue();
                }
            }
        }
        // import file
        if (ccsdsAppID == null) {
            // Use the default application ID argument column name
            ccsdsAppID = ArgumentColumnName.APP_ID.getDefaultArgColName();
        }
        // 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(rootSystem, 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 (SpaceSystemType system : rootSystem.getSpaceSystem()) {
                // Recursively step through the XTCE-formatted data and extract the telemetry
                // and command information
                unbuildSpaceSystems(system, rootSystem.getName(), 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 XTCE XML from file<br>'</b>" + importFile.getAbsolutePath() + "<b>'; cause '" + je.getMessage() + "'", "File Error", JOptionPane.ERROR_MESSAGE, DialogOption.OK_OPTION);
    }
}
Also used : JAXBException(javax.xml.bind.JAXBException) TableDefinition(CCDD.CcddClassesDataTable.TableDefinition) AncillaryDataSet(org.omg.space.xtce.DescriptionType.AncillaryDataSet) AncillaryData(org.omg.space.xtce.DescriptionType.AncillaryDataSet.AncillaryData) JAXBElement(javax.xml.bind.JAXBElement) SpaceSystemType(org.omg.space.xtce.SpaceSystemType)

Aggregations

SpaceSystemType (org.omg.space.xtce.SpaceSystemType)7 Date (java.util.Date)2 CommandMetaDataType (org.omg.space.xtce.CommandMetaDataType)2 AncillaryDataSet (org.omg.space.xtce.DescriptionType.AncillaryDataSet)2 AncillaryData (org.omg.space.xtce.DescriptionType.AncillaryDataSet.AncillaryData)2 TelemetryMetaDataType (org.omg.space.xtce.TelemetryMetaDataType)2 TableDefinition (CCDD.CcddClassesDataTable.TableDefinition)1 TableInformation (CCDD.CcddClassesDataTable.TableInformation)1 ArrayList (java.util.ArrayList)1 JAXBElement (javax.xml.bind.JAXBElement)1 JAXBException (javax.xml.bind.JAXBException)1 AggregateDataType (org.omg.space.xtce.AggregateDataType)1 MemberList (org.omg.space.xtce.AggregateDataType.MemberList)1 Member (org.omg.space.xtce.AggregateDataType.MemberList.Member)1 MetaCommandSet (org.omg.space.xtce.CommandMetaDataType.MetaCommandSet)1 AuthorSet (org.omg.space.xtce.HeaderType.AuthorSet)1 NoteSet (org.omg.space.xtce.HeaderType.NoteSet)1 MetaCommandType (org.omg.space.xtce.MetaCommandType)1 NameDescriptionType (org.omg.space.xtce.NameDescriptionType)1