Package gda.hrpd.data

Class MacDataWriter

All Implemented Interfaces:
DataWriter, IDataWriterExtender, Configurable, Findable

public class MacDataWriter extends DataWriterBase implements Findable, Configurable
This class writes files of tabulated data from Multiple Analyser Crystal Detectors, along with a header and footer if needed, in ASCII format. The files created use names which are an increment from the last name.
  • Field Details

    • thisFileNumber

      protected int thisFileNumber
      the current file number being written to, which is managed by the NumTracker Class
    • fileExtension

      protected String fileExtension
      file extension to use
    • filePrefix

      protected String filePrefix
      file prefix to use (if any)
    • fileSuffix

      protected String fileSuffix
      file suffix to use (if any)
    • file

      protected FileWriter file
      file handle of currently open file
    • fileUrl

      protected String fileUrl
      the full path name of the data file
    • firstData

      protected boolean firstData
      first data marker used to determine whether to write out column headers
    • currentFileName

      protected String currentFileName
      the full file name of the current data file
  • Constructor Details

    • MacDataWriter

      public MacDataWriter()
      Constructor which determines the name of the next file and creates it.
  • Method Details

    • configure

      public void configure()
      Description copied from interface: Configurable
      Perform operations that must be done after Spring initialisation i.e. anything that goes beyond setting member variables.
      Specified by:
      configure in interface Configurable
    • reconfigure

      public void reconfigure() throws FactoryException
      Description copied from interface: Configurable
      Re-initialisation of values and states.

      Moved from Reconfigurable which has been deleted

      Specified by:
      reconfigure in interface Configurable
      Throws:
      FactoryException
    • isConfigured

      public boolean isConfigured()
      Description copied from interface: Configurable
      Checks to see if the object is already configured.
      Specified by:
      isConfigured in interface Configurable
      Returns:
      return true if configured false otherwise
    • isConfigureAtStartup

      public boolean isConfigureAtStartup()
      Description copied from interface: Configurable
      Indicates whether this object should be configured at startup.

      Moved from ConditionallyConfigurable which has been deleted

      Specified by:
      isConfigureAtStartup in interface Configurable
    • addData

      public void addData(IScanDataPoint dataPoint)
      Description copied from interface: DataWriter
      for incremental addition of data
      Specified by:
      addData in interface DataWriter
      Overrides:
      addData in class DataWriterBase
      Parameters:
      dataPoint - Object
    • addData

      public String addData(int rows, Vector<Scannable> parentScannables, Vector<Scannable> allScannables, Vector<Detector> allDetectors, double[] path1, double[] path2, double[] path3, double[] path4, double[] path5, double[] path6, double[] path7, double[] path8, int[][] data, double[] error2, double scantime)
      MAC specific data writer
      Parameters:
      rows -
      parentScannables -
      allScannables -
      allDetectors -
      path1 -
      path2 -
      path3 -
      path4 -
      path5 -
      path6 -
      path7 -
      path8 -
      data -
      error2 -
      scantime -
      Returns:
      filename
    • prepareForCollection

      public void prepareForCollection()
      Open files and writes out headers.
    • createNextFile

      public void createNextFile()
      Closes current file and opens a new file with an incremental number. For use when many files being created instead of a single file being appended to.
    • getData

      public FileWriter getData()
      Returns the file reference to the data file
      Returns:
      FileWriter
    • completeCollection

      public void completeCollection() throws Exception
      Writes any file footers and closes file.
      Specified by:
      completeCollection in interface DataWriter
      Overrides:
      completeCollection in class DataWriterBase
      Throws:
      Exception
    • releaseFile

      public void releaseFile()
      Releases the file handle.
    • writeHeader

      public void writeHeader()
      Standard header for synchrotron experiments at beamline I11 at DLS written in the format of name/key-value pair, placed in between the markers of invalid input: '&DLS' and invalid input: '&END'
       &DLS
       <dt>
       CarouselNo=1
       SampleID=S537
       SampleName=Silicon
       Description='Silicon Standard'
       Title='Calibration SampleInfo Scan'
       Comment='any comments added by the users'
       RunNumber=245
       Date=dd-mmm-yy
       Time=hr:min:sec
       BeamlineInfo=I11
       Project=HRPD
       Experiment=MAC
       Wavelength=1.2
       Temperature=295
       </dt>
       &END
       
    • writeColumnHeadings

      public void writeColumnHeadings()
      This should be extended by inheriting classes.
    • writeFooter

      public void writeFooter()
      This should be extended by inheriting classes.
    • getDataDir

      public String getDataDir()
      Returns the full path of the folder which data files are written to.
      Returns:
      the full path of the folder which data files are written
    • getDelimiter

      public String getDelimiter()
      Get the delimiter used between columns
      Returns:
      the delimiter used between columns
    • setDelimiter

      public void setDelimiter(String delimiter)
      Set the delimiter used between columns (default is a tab '\t')
      Parameters:
      delimiter - String
    • getFileNumber

      public int getFileNumber()
      Returns the number of the last file written to.
      Returns:
      int
    • getCurrentFileName

      public String getCurrentFileName()
      Description copied from interface: DataWriter
      Get the absFilePath for this scan
      Specified by:
      getCurrentFileName in interface DataWriter
      Returns:
      String
    • setHeader

      public void setHeader(String header)
      Description copied from interface: DataWriter
      Sets the header of the datahandler
      Specified by:
      setHeader in interface DataWriter
      Parameters:
      header - String
    • getName

      public String getName()
      Description copied from interface: Findable
      Get the object name. Used by Castor to check if the object name has been set before calling the Findable.setName(String) method.
      Specified by:
      getName in interface Findable
      Returns:
      a String containing the object name.
    • setName

      public void setName(String name)
      Description copied from interface: Findable
      Set or change the name of the object (as defined in XML).
      Specified by:
      setName in interface Findable
      Parameters:
      name - the object name
    • getCurrentScanIdentifier

      public int getCurrentScanIdentifier()
      Description copied from interface: DataWriter
      Get the current scan identifier (ie scan number)
      Specified by:
      getCurrentScanIdentifier in interface DataWriter
      Returns:
      String