Concepts

The Version Reader System is designed to read various versions of formatted input data without prior knowledge of the specific version of the Data. In the case of output from the Data Collector, that is, testdaq .zip files, the system uses version numbers encoded in the Run Header to determine the format of the data sequences, including the Run Header itself. Because of this structure, the possible format changes to the Run Header are somewhat restricted. We require that every format of the Run Header contain a version tag for the run header itself as its first element. By setting this requirement, it becomes possible to use SAX to parse the beginning of the Run Header and extract the needed information about its version, allowing us to call a versioned-reader for the Run Header. This is the only part of the system that requires a new reader for every new version of the data it reads, because it relies on JAXB to read and validate XML data.

The remainder of the system relies on XML sequence descriptors to extract fields from the data stream in the correct sequence. This means that for every new format version, another XML sequence descriptor must be written and the correct version tag appended to its filename. It is also necessary to create new data element classes whenever the new version is not simply a re-arrangement of the existing data elements. This will be the case if entirely new data elements are added to the data structure or if the meaning of and existing data element is changed. However, this requires significantly less programmer time than writing a new reader class for every new data format. It is also much simpler, and can be done by the developer of the new version rather than by the original writer of the reader software. Thus, we have the additional advantage that the developers of the reading software need not provide constant software upgrades and may spend their time on other, more useful tasks. For a full description of how to write a version upgrade, please visit the Version Upgrade page.

An XML sequence descriptor is a list of data elements, whose names are the fully-qualified names of data element classes. For example, there is a class called FlashData in the versionSystem subpackage of testdaqio, where all the data element classes are located. The XML sequence descriptor file that has this data element would contain the following listing:
" icecube.testdaq.testdaqio.versionSystem.FlashData"

The XML sequence descriptor also has a descriptive name. For example, the name of the XML sequence descriptor for a DomHitRecord, version 1 release 0, is "DomHitRecordV1R0.xml".

The most important part of the entire system is a collection of data element classes, located in icecube.testdaq.testdaqio.versionSystem. These classes have constructors that accept a reference to their parent reader, and then extract the data they need from the ByteBuffer in their parent reader. Some of these classes then call private read() methods that interpret the data the constructor extracts from the ByteBuffer before reporting the results to the parent reader, while other classes simply return their results directly. For an example of a data element class, click here . If a new piece of information is added to the data stream, or the format of an existing piece of information is added, a new data element with an entirely different name must be created, so that the data element to read old data still exists and functions properly. Once they are created, data element classes may never be deleted or altered in any way.

The reader classes in the system parse their associated XML sequence descriptor and store the data in a Vector that tells the reader in which order to call data element constructors. The reader also has a set of fields necessary to construct a data storage object associated with its data type. Each of these fields is currently filled by a data element during reading. However, when a new field is added to the Java data-storage object, older versions of the data sequence will be unable to fill that field. Consequently, a default value for that field must be provided, and must be encoded in the reader class so that it may continue to treat all input in the same way.

When reading occurs, the reader class "walks" over the Vector of data elements and calls the constructor of each one in turn. The reader then constructs the data storage object for its data type and returns it in the manner specified by the infrastructure of testdaqio. For information about specifying return types, please see the package documentation for testdaqio.


Classes

All classes described here are found within the package icecube.testdaq.testdaqio unless a subpackage is indicated. Though these classes are public because they must be accessable from withing subpackages of testdaqio, software designers are strongly discouraged from using these classes directly, and should instead rely on the infrastructure within testdaqio to produce data.

DomHitRecordReader
This class reads bytes from the Dom Engineering Format, defined by LBNL, and returns DomHitRecord objects. This reader is associated with the XML sequence descriptor DomHitRecordV#R#.xml where the # represent integers.
HitDataReader
This class reads bytes from the Hit Data format, defined by the University of Wisconsin-Madison, and created in the Data Collector. This reader is associated with the XML sequence descriptor HitDataV#R#.xml where the # represent integers, and returns HitData objects.
MonitorDataReader
This class reads bytes from the Monitor Data format, defined by the University of Wisconsin-Madison, and created in the Data Collector. This reader is associated with the XML sequence descriptor MonitorDataV#R#.xml where the # represent integers, and returns MonitorData objects.
MonitorRecordReader
This class reads bytes from the Monitor Data Engineering Format, defined by LBNL, and returns MonitorRecord objects. It is associated with the XML sequence descriptor MonitorRecordV#R#.xml where the # represent integers.
RunHeaderReader
This class uses SAX to find the RunHeaderVersion tag in the Run Header file, produced by the Data Collector. The position of this tag is required to be the first in the Run Header. Once it has found this tag, it extracts the version data found in it and calls the constructor for the appropriate versioned run header reader.
versionSystem.RunHeaderReaderV1R0
This class relies on JAXB to read XML in the format defined by its schema. It extracts the data needed to call the appropriate readers and creates a RunHeader object of the correct version that contains the fields in the Run Header. This class also implements format validation, meaning that if the XML in the Run Header does not conform to the appropriate XML schema for any reason, it throws an exception. This class also uses the array of integers passed into the testdaqio infrastructure to call the correct readers in the correct sequence.
versionSystem.RunHeaderWriterV1R0
This class relies on JAXB to write valid XML in the format defined by its schema description. It is passed the data it needs to set its fields by means of setter methods and then produces a Java content-tree from that data, before validating the information in the content tree and exporting it to XML format.
TimeCalDataRecordReader
This class reads bytes from the Time Calibration Format, defined by LBNL, and returns TimeCalDataRecord objects. This reader is associated with the XML sequence description TimeCalDataRecordV#R#.xml where the # represent integers.
TimeCalReader
This class reads bytes from the Time Cal format, defined by the University of Wisconsin-Madison and produced in the Data Collector. This reader is associated with the XML sequence description TimeCalV#R#.xml where the # represent integers. This reader returns TimeCal objects.
ZipFileReader
This class is an administrative class, designed to locate and extract the Run Header file from the ZIP file produced by the Data Collector. It also has a field that holds all of the ZipEntry objects from the ZIP file so that they may be easily accessed by the appropriate readers further along in the reader system. This reader is the one accessed by the infrastructre in testdaqio, and it calls RunHeaderReader.

Note on Format Encoding and Decoding

There are currently five format bytes that need to be decoded by the Version Reader System. They are the Flash ADC format byte, the ATWD 0 and 1 format byte, the ATWD 2 and 3 format byte, the miscellaneous byte, and the trigger byte. Each of these bytes is decoded in a data element class with a descriptive name. An excellent example of one of these classes can be found by viewing AtwdFormat0_1.java.

Since each of these classes use a similar method to decode their respective bytes, I will explain how the process works here.
Each byte contains 8 bits, and the bit encoding of each byte is defined by LBNL. It is possible to compare individual bits by using the bitwise-and operator found in Java. Its character is "&".

Using this operator and a knowledge of the binary number system, the decoding process individually tests each bit for a value of 1 or 0, and using this information, the reader class can determine the information encoded in the given bit sequence.