Search in sources :

Example 1 with AncillaryData

use of org.omg.space.xtce.DescriptionType.AncillaryDataSet.AncillaryData 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 2 with AncillaryData

use of org.omg.space.xtce.DescriptionType.AncillaryDataSet.AncillaryData 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

AncillaryDataSet (org.omg.space.xtce.DescriptionType.AncillaryDataSet)2 AncillaryData (org.omg.space.xtce.DescriptionType.AncillaryDataSet.AncillaryData)2 SpaceSystemType (org.omg.space.xtce.SpaceSystemType)2 TableDefinition (CCDD.CcddClassesDataTable.TableDefinition)1 Date (java.util.Date)1 JAXBElement (javax.xml.bind.JAXBElement)1 JAXBException (javax.xml.bind.JAXBException)1 AuthorSet (org.omg.space.xtce.HeaderType.AuthorSet)1 NoteSet (org.omg.space.xtce.HeaderType.NoteSet)1