Class PythonGenerator

    • Field Detail

      • pythonObject

        protected long pythonObject
        Part of JCC Python interface to object
    • Constructor Detail

      • PythonGenerator

        public PythonGenerator()
    • Method Detail

      • pythonExtension

        public void pythonExtension​(long pythonObject)
      • pythonExtension

        public long pythonExtension()
      • pythonDecRef

        public void pythonDecRef()
      • getOutputName

        public String getOutputName()
        Get the name of the output (for error messages).
        Specified by:
        getOutputName in interface Generator
        Returns:
        name of the output
      • getFormat

        public FileFormat getFormat()
        Get the generated file format.
        Specified by:
        getFormat in interface Generator
        Returns:
        generated file format
      • startMessage

        public void startMessage​(String root,
                                 String messageTypeKey,
                                 double version)
                          throws IOException
        Start CCSDS message.
        Specified by:
        startMessage in interface Generator
        Parameters:
        root - root element for XML files
        messageTypeKey - key for message type
        version - format version
        Throws:
        IOException - if an I/O error occurs.
      • writeEntry

        public void writeEntry​(String key,
                               String value,
                               Unit unit,
                               boolean mandatory)
                        throws IOException
        Write a single key/value entry.
        Specified by:
        writeEntry in interface Generator
        Parameters:
        key - the keyword to write
        value - the value to write
        unit - output unit (may be null)
        mandatory - if true, null values triggers exception, otherwise they are silently ignored
        Throws:
        IOException - if an I/O error occurs.
      • writeEntry

        public void writeEntry​(String key,
                               List<String> value,
                               boolean mandatory)
                        throws IOException
        Write a single key/value entry.
        Specified by:
        writeEntry in interface Generator
        Parameters:
        key - the keyword to write
        value - the value to write
        mandatory - if true, null values triggers exception, otherwise they are silently ignored
        Throws:
        IOException - if an I/O error occurs.
      • writeEntry

        public void writeEntry​(String key,
                               Enum<?> value,
                               boolean mandatory)
                        throws IOException
        Write a single key/value entry.
        Specified by:
        writeEntry in interface Generator
        Parameters:
        key - the keyword to write
        value - the value to write
        mandatory - if true, null values triggers exception, otherwise they are silently ignored
        Throws:
        IOException - if an I/O error occurs.
      • writeEntry

        public void writeEntry​(String key,
                               TimeConverter converter,
                               AbsoluteDate date,
                               boolean forceCalendar,
                               boolean mandatory)
                        throws IOException
        Description copied from interface: Generator
        Write a single key/value entry.
        Specified by:
        writeEntry in interface Generator
        Parameters:
        key - the keyword to write
        converter - converter to use for dates
        date - the date to write
        forceCalendar - if true, the date is forced to calendar format
        mandatory - if true, null values triggers exception, otherwise they are silently ignored
        Throws:
        IOException - if an I/O error occurs.
      • writeEntry

        public void writeEntry​(String key,
                               char value,
                               boolean mandatory)
                        throws IOException
        Write a single key/value entry.
        Specified by:
        writeEntry in interface Generator
        Parameters:
        key - the keyword to write
        value - the value to write
        mandatory - if true, null values triggers exception, otherwise they are silently ignored
        Throws:
        IOException - if an I/O error occurs.
      • writeEntry

        public void writeEntry​(String key,
                               int value,
                               boolean mandatory)
                        throws IOException
        Write a single key/value entry.
        Specified by:
        writeEntry in interface Generator
        Parameters:
        key - the keyword to write
        value - the value to write
        mandatory - if true, null values triggers exception, otherwise they are silently ignored
        Throws:
        IOException - if an I/O error occurs.
      • writeEntry

        public void writeEntry​(String key,
                               double value,
                               Unit unit,
                               boolean mandatory)
                        throws IOException
        Write a single key/value entry.
        Specified by:
        writeEntry in interface Generator
        Parameters:
        key - the keyword to write
        value - the value to write (in SI units)
        unit - output unit
        mandatory - if true, null values triggers exception, otherwise they are silently ignored
        Throws:
        IOException - if an I/O error occurs.
      • writeEntry

        public void writeEntry​(String key,
                               Double value,
                               Unit unit,
                               boolean mandatory)
                        throws IOException
        Write a single key/value entry.
        Specified by:
        writeEntry in interface Generator
        Parameters:
        key - the keyword to write
        value - the value to write (in SI units)
        unit - output unit
        mandatory - if true, null values triggers exception, otherwise they are silently ignored
        Throws:
        IOException - if an I/O error occurs.
      • writeRawData

        public void writeRawData​(char data)
                          throws IOException
        Write raw data.
        Specified by:
        writeRawData in interface Generator
        Parameters:
        data - raw data to write
        Throws:
        IOException - if an I/O error occurs.
      • dateToString

        public String dateToString​(TimeConverter converter,
                                   AbsoluteDate date)
        Convert a date to string value with high precision.
        Specified by:
        dateToString in interface Generator
        Parameters:
        converter - converter for dates
        date - date to write
        Returns:
        date as a string
      • dateToCalendarString

        public String dateToCalendarString​(TimeConverter converter,
                                           AbsoluteDate date)
        Description copied from interface: Generator
        Convert a date to calendar string value with high precision.
        Specified by:
        dateToCalendarString in interface Generator
        Parameters:
        converter - converter for dates
        date - date to write
        Returns:
        date as a calendar string
      • dateToString

        public String dateToString​(int year,
                                   int month,
                                   int day,
                                   int hour,
                                   int minute,
                                   double seconds)
        Convert a date to string value with high precision.
        Specified by:
        dateToString in interface Generator
        Parameters:
        year - year
        month - month
        day - day
        hour - hour
        minute - minute
        seconds - seconds
        Returns:
        date as a string
      • doubleToString

        public String doubleToString​(double value)
        Convert a double to string value with high precision.

        We don't want to loose internal accuracy when writing doubles but we also don't want to have ugly representations like STEP = 1.25000000000000000 so we try a few simple formats first and fall back to scientific notation if it doesn't work.

        Specified by:
        doubleToString in interface Generator
        Parameters:
        value - value to format
        Returns:
        formatted value, with all original value accuracy preserved, or null if value is null or Double.NaN
      • unitsListToString

        public String unitsListToString​(List<Unit> units)
        Convert a list of units to a bracketed string.
        Specified by:
        unitsListToString in interface Generator
        Parameters:
        units - lists to output (may be null or empty)
        Returns:
        bracketed string (null if units list is null or empty)
      • siToCcsdsName

        public String siToCcsdsName​(String siName)
        Convert a SI unit name to a CCSDS name.
        Specified by:
        siToCcsdsName in interface Generator
        Parameters:
        siName - si unit name
        Returns:
        CCSDS name for the unit