Contents

Disclaimer: This document is not in any way designed to be an exhaustive summary of the Java classes used to create the IceCube Oscilloscope. It includes a limited discussion of the most important elements in the package. It discusses only methods and their actions, not the fields of the classes that support these methods. It is designed only to provide an introduction to the software for a developer who wishes to produce extensions to the software that would be of limited interest to other members of the collaboration. If you have requirements that you believe would benefit the collaboration as a whole, please Contact the Author.


Java Docs



abstract class AnalysisType

protected AnalysisType(String analysisTitle)
This constructor allows the implementing classes to pass the desired title, which should be descriptive, for the analysis shell. The title is used to initialize the plotter, which shows this title in its display window.
public abstract void processRecord(HitRecord record);
This abstract method is used by the InputReader to pass records to the analysis implementation after they have been filtered.
public abstract void saveAnalysisData(File destinationFile) throws IOException;
This abstract method allows the oscilloscope to command any one running analysis to export the data it has collected to ASCII format on disk. The file is written to the file passed to the method. The purpose of this method is to export data that can then be used by Root or PAW to perform more complex analysis.

DataSourceInitializedUI extends JPanel implements ActionListener

protected DataSourceInitializedUI()
This method creates an intermediate display panel for use after the data source has been initialized but before the display has begun. Its primary purpose is to prevent the NullPointerExceptions that would otherwise result from trying to display GraphFrames without initializing them correctly. However, it also serves the purpose of disabling content that should not be available before the displays are running.
public void buildConstraints(GridBagConstraints gbc, int gy, int gx, int gw, int gh, int bx, by, wx, wy)
This is a convenience method for all GUI elements that rely on GridBagLayout to set their display structure.
gy and gx represent the row and column number of the grid element the object should go in, both starting from zero. gw and gh are the number of grid elements the object crosses, horizontally and vertically respectively. bx and by define a border around the object in pixels, bx is the top and bottom and by is the sides.
Finally, wx and wy are the weights of the given grid component in the x and y directions. For example, a grid element that should occupy 15% of the display in the horizontal direction and 5% in the vertical would get wx=15 and wy=5. However these numbers are proportional only, so if all the grid elements in a display should have the same height, they could all receive wy=1.
For more information about GridBagConstraints and their use,
view the java docs.
public void actionPerformed(ActionEvent event)
DataSourceInitializedUI implements the ActionListener interface, which defines this method.
private void displayData()
This method is the interface with the "display" button, and gives the commands necessary to begin displaying the data that is available from the data source. It starts a number of Threads, including separate threads for each active GraphFrame and InputReader. InputReader also initializes Threads indirectly in io .

DisplayProperties

protected DisplayProperties()
This constructor initializes an object whose fields will be written to an XML file on disk, used to store the display format of an open Oscilloscope. The constructor uses an ObjectFactory generated by JAXB to initialize objects bound to an XML schema.
protected static void save(String filename)
This method accepts the name of a destination file and calls class methods to set the fields in the Java content-tree represented in class fields before marshalling the values it stores in those fields to the given file.
protected static void open(String filename)
Unmarshalls a Java content tree from the given file and validates the contents of the file while reading. Once it has read the information and confirmed that it can be used to set the properties of the display, it calls the restore() method to set the display properties from the values it has read.
private synchronized static void update()
This method uses the getColorScheme() and getBackground() methods as well as direct examination of display properties to set the fields in the Format object before writing the XML format file. Examines the static fields in UI in order to get its data.
private synchronized static void restore()
This method uses setColorScheme(), setBackground(), setTogether and setSeparate() methods as well as direct manipulation of parameters to restore the display properties read from a file stored on disk to the active display.
private static void getColorScheme()
Examines the static color scheme defined in UI to initialize a group of schema-generated color objects.
private static void getBackground()
Examines the static background color defined in UI to initialize a schema-generated background color object.
private static void setColorScheme()
Uses a set of schema-derived color object, generated by unmarshalling an XML file, to set the static color scheme defined in UI.
private static void setBackground()
Uses a schema-derived color object, generated by unmarshalling an XML file, to set the static background color defined in UI.
private static void setSeparateProperties()
Uses a Java content-tree generated by unmarshalling an XML file to set the properties of the 9 active GraphFrame objects in the main display.
private static void setTogetherProperties()
Uses a Java content-tree generated by unmarshalling an XML file to set the properties of the 5 active GraphFrame objects in the main display.

Filter

protected Filter(FilterDefinition filter)
This constructor initializes a Filter object with the FilterDefinition it will use to make its examinations and to determine whether the HitRecord objects passed it should be displayed and included in analyses or not.
protected boolean applyFilter(HitRecord record)
This method is called by the InputReader to determine whether or not it should continue to use record or it should read another record from its input and see whether that one satisfies the requirements of the Filter

FilterDefinition

protected FilterDefinition(int type, String channel)
This constructor describes a filter without specifying any parameters, which differ widely by type. The filter created is one of several types defined by static integers within the Filter class, and the channel must also correspond to one of the static Strings defined in the Filter class.
protected Filter()
This constructor allows the creation of a default FilterDefinition which passes all of the records that it is given.
protected void definePedestal(int[] pedestal) throws Exception
This method allows the software to define the pedestal pattern on an existing FilterDefinition. Throws an Exception if the FilterDefinition is not a pedestal filter.
protected void setThreshold(int threshold) throws Exception
This method allows the software to define a threshold value on an exisitng FilterDefinition. Throws an Exception if the FilterDefinition is not a threshold filter.
protected void defineWindow(int begin, int end) throws Exception
This method allows the software to define a window on an existing FilterDefinition. Throws an Exception if the FilterDefinition is not a window filter.

GraphFrame extends JPanel implements Runnable

protected GraphFrame(int length, Waveform[] data, double[] times, boolean mode, boolean used)
Establishes a GraphFrame object with the possibility of displaying length number of Waveforms. data and times set the initial data set of the Graph object wrapped by the GraphFrame. mode determines whether new data will be appended at the end of previously existing data or simply replace it. Finally, used determines whether the channel whose data this GraphFrame will represent is actually used in the data stream and the user wishes to display it.
protected GraphFrame(int length, boolean mode, boolean used)
Performs the same as the constructor above, except that it does not initialize the data of its wrapped Graph, and uses ranges of 0 to 1 to start its axes.
buildConstraints()
protected void render()
Re-displays the three elements wrapped in this GraphFrame. Resets the labels in the scales and re-displays them, as well as re-displaying the graph itself.
public void run()
Calls render() and then sleeps for the time intervals specified by the user, or for the default value if no sleep time has been specified.
protected void add(Waveform newData)
Adds newData to the set of data in the wrapped Graph object and immediately calls render().
protected void setData(Waveform[] data, double[] times, boolean used)
Sets the data in the wrapped Graph object using data and times, and determines whether that data should be displayed with used.
private synchronized long getSleepTimer()
Returns the sleep timer defined in UI, ensuring that no other object changes its contents during the lookup.

Graph extends JPanel

protected Graph(int length, Waveform[] data, double[] times, boolean mode, boolean used)
Serves as a direct connection to the GraphFrame constructor with the same signature. However, if more Waveform objects are passed than are declared in length, they are ignored. Automatically initializes its properties from the range of the data it is passed.
protected Graph(int length, boolean mode, boolean used)
Serves as a direct connection to the GraphFrame constructor of the same signature. Automatically initializes its properties with ranges of 0 to 1 for both time and volt ranges.
protected void setFrame(GraphFrame graph)
Sets the parent GraphFrame of this object, allowing it to perform operations that require upward references.
protected void setData(Waveform[] data, double[] times, boolean used)
Serves as a direct connection to the GraphFrame method of the same signature. If this Graph is set in append mode, it finds the correct data set from the information it is passed and the information it already has. Otherwise, it simply sets its data to the information it is passed.
protected void add(Waveform newData)
Adds the given Waveform object to the data displayed in this Graph.
protected double getMaxVoltage()
Returns the largest voltage in all of the data stored in this Graph.
protected double getFirstTime()
Returns the value of the first time displayed in the Graph.
protected double getLastTime()
Returns the value of the last time displayed in the Graph.
protected void paintComponent(Graphics graphic)
Overrides the method in Component with the same signature. It is here that the actual display of data takes place. The method uses a Graphics2D object to generate a set of connected lines of various colors, one for each Waveform in its data set. The method uses the properties fields to determines scales and individually plots each point before connecting it.
protected void setProperties()
Uses the data it was passed to set the display properties. Specifically, it finds ranges that are the right size to fit the data in the window with only a small border on every side. (2%)
protected void setProperties(double tBegin, double tEnd, double vEnd)
Sets the display properties object with the given information. The beginning value of the volt range is always zero.
protected void recenter(Point center)
Changes the center of this display to to selected point. It uses the the volt and time ranges to compute an "amount" of the given quantity that should be displayed, and then establishes new time and volt ranges with the correct amounts around the new center.
protected void zoom(int direction)
Uses a switch-case conditional on direction to distinguish between three possibilities: zoom out, zoom in, and zoom to fit. The zoom out and zoom in algorithms are very closely related. The first multiplies the scale of the graph by two and the second divides it, but otherwise they are identical. Zoom to fit uses an algorithm similar to that of the re-center method, because re-centering is actually wrapped within the algorithm, by the nature of its function.
private double[] getPlotData(Waveform wave)
Determines a set of data points to be displayed on the volt-axis using an algorithm that extrapolates to points that lie outside the current range and determine points on the edge of the display range that maintain the correct line to the first data point within the frame. Essentially, this method prevents distortion of the data following zoom in or re-center operations.
protected void setAppendMode(boolean value)
Sets whether or not the append algorithm in setData() will be applied after the constructor has been called.
protected void setUsed(boolean value)
Sets whether the Graph is displayed in the long-term. This variable is used primarily for setting channels that are never displayed.

InputProvider

protected InputProvider(String hostname, int port)
Opens an InputProvider that connects to a socket specified by hostname and port to get data. This method serves as a connection between the InputChannelProvider class of io. Uses the static intermediate file "recordFile".
protected InputProvider(String filename)
Opens an InputProvider that connects to a file specified by the given filename to get data. This method serves a connection to the InputChannelProvider class of tesdaqio.
private void getAvailableDoms()
Connects to the getAvailableDoms() method in the InputChannelProvider it has connected to to request a list of available DOM Ids. Once is has this list, it uses it to start a DomSelectWindow, forcing the user to choose which DOM(s) will be displayed.
protected void close()
Disconnects the stream objects in this class and calls the close() method of its InputChannelProvider.

InputReader implements Runnable

protected InputReader(InputChannelProvider chan)
Connects this InputReader to chan to have the ability to close to stream and to get its data.
protected static void hold()
Commands all InputReader objects to stop reading data from the data stream.
protected static void stopDataStream(LinkedList list)
Commands the InputReaders in list to stop reading data and disconnect from the data source. Once this method is called, the process of connecting to a data source must be repeated from the beginning.
protected void resume(int number)
Resumes reading data from the data stream, but only reads number records from the data stream before stopping again.
public void run()
Reads data from the input stream until an Exception is encountered that requires the stream to stop reading or until the user instructs the Oscilloscope to pause or stop reading data.
private void writeData(int atwd)
Writes the data extracted from the data stream to the correct ATWD display, based on the integer it is passed. If the Oscilloscope is currently operating in separate display mode, the data is written to whichever ATWD display is appropriate for its source. However, if it is not, data is always written to the display for ATWD0.

OscilloscopeMain implements ActionListener

private OscilloscopeMain()
Starts the outside window of the Oscilloscope with an empty JPanel for its content. Also starts the menu bar, but many of the menu items are disabled until data acquisition starts.
public void actionPerformed(ActionEvent event)
OscilloscopeMain implements ActionListener, so this method is required. It listens to the menu items and when one is selected, takes appropriate action. Usually, this is opening a dialog box and writing a note to the logger.
protected void exit()
Uses the ExitWindow class defined in the display package to exit from the program gracefully.
protected void getHelp()
Uses the system Runtime to open a browser window with the help documents displayed after determining the correct browser by querying the operating system.
protected static void setInitialPanel()
Sets the OscilloscopeMain with a blank JPanel object for its content. This occurs at start-up (without a call to this method) and any time the stop command is issued.
protected static void setHoldingPanel()
Sets the content of this OscilloscopeMain with a DataSourceInitializedUI object as its content panel. This method is called any time a data source is selected.
protected static void setMainPanel()
Sets the content of this OscilloscopeMain to a fully functional UI. This is done any time a display command is issued.
public static void main(String[] args)
Calls the constructor for OscilloscopeMain.

RecordArchive

protected RecordArchive(List startingRecords, int depth)
Creates and fills a RecordArchive with size depth and initializes it with the records in startingRecords.
protected RecordArchive(int depth)
Creates a RecordArchive with size depth.
protected void addRecord(HitRecord record)
Adds record to the archive.
protected HitRecord advance(int numRecords)
Returns the HitRecord stored numRecords beyond the current position or the last available HitRecord if numRecords is beyond the end of the archive, and advances the pointer to the corresponding position in the record collection.
protected boolean atEndOfArchive()
Returns a boolean indicating whether the current position of the archive is at the end of its record collection.
protected HitRecord retreat(int numRecords)
Returns the HitRecord stored numRecords befor the current position or the first available HitRecord if numRecords is beyond the beginning of the archive, an moves the pointer to the corresponding position in the record collection.
protected void reset()
Removes all records from the collection and returns the current position pointer to zero.

SinglePeakWindow extends JFrame

protected SinglePeakWindow()
Starts a new window with a single GraphFrame object as its content, but with no data.
buildConstraints()
public void mouseClicked(MouseEvent event)
Serves as an interface to the operations that GraphFrame defines and are controlled from UI. Uses static variables in UI to interact with those functions effectively.
public void mouseEntered(MouseEvent event)
public void mouseExited(MouseEvent event)
public void mousePressed(MouseEvent event)
public void mouseReleased(MouseEvent event)
protected void setClickReadout(double time, double volt)
Converts time and volt coordinates in pixels to real time and volt coordinates before using them to set the text in the click interface boxes in UI.
protected static void addPeak(Waveform wave, double[] time)
If no peaks have been added yet, uses the input data and a boolean literal to set the data in the GraphFrame displayed in this window. Otherwise, simply adds wave to the data of the GraphFrame.

tScale extends JPanel

protected tScale(double begin, double end)
Construct a time scale using the specified begin and end times. The scale displays four labels out of six possible, omitting the labels that would align with the beginning and the end of the scale.
protected tScale()
A do-nothing constructor added as a convenience.
buildConstraints()
private void makeLabel(double value, JLabel target)
Uses a Java DecimalFormat object to convert the value into a string, before setting the text of target with that string.
private void redraw(double begin, double end)
Calculates new label values from begin and end and uses makeLabel() to set them to the labels in the scale.

UI extends JPanel implements ActionListener, MouseListener

protected UI()
Initializes and configures all of the GUI elements seen in the main display of the Oscilloscope. Relies heavily on GridBagConstraints to achieve the desired layout.
buildConstraints()
protected void displayData()
Activates the Threads that control the GraphFrame objects. These Threads are stored in an array that is one of the fields of the UI object. Also alters button configuration in the tool bar, enabling pause and stop.
protected void findDeltaV()
Includes the functionality of the delta-v button. The essential purpose of of this method is to work in concert with mouseClicked() to find the points of the display to be used for the calculation and then to convert those points to voltage and time values before opening a new window and displaying the results.
protected void pauseDisplay()
Stops the Threads controlling both the GraphFrame objects in the UI and the InputReader objects associated with them. Any InputReaders remain open, however, and can be re-started at the convenience of the user. This method also disables the pause button and enables the resume button.
protected void restoreProperties()
Extracts the values stored in a StandardProperties array, presumably set by opening a new Format from disk, and assigns the correct values to the GraphFrame objects held in the display.
protected void resumeDisplay()
Starts new Threads to control the flow of the GraphFrame objects included in the UI as well as new Threads for each of the InputReader objects associated with the display. Disables the resume button and enables the pause button.
protected void sample()
This is the interface to the sample button. Its only purpose is to set the instructions box and to set control variables needed in the mouseClicked() control of this feature.
protected void setClickReadout(double time, double volt)
Takes the two values it is given and converts them from pixels to the correct quantity using an algorithm similar to the one used to graph data before displaying the results of the calculation in the text boxes near the bottom of the display.
protected static void setStepMode(boolean test, UI source)
Sets the step through input property of the Oscilloscope to the value of test, using source to refer to non-static fields that it needs to access.
protected void step()
Gets the next available record from the data stream by calling the InputReader.resume(int number) method with an argument of 1.
protected void stopDisplay()
Stops the Threads controlling data display and data input. Then calls the close() methods needed to disconnect from the input stream.
protected void updateProperties()
Sets the values in an array of StandardProperties objects (generated by a schema) with the properties of the GraphFrame objects currently in use. The intended purpose of this method is to prepare for saving the format to disk.
public void actionPerformed(ActionEvent event)
Tests the source of event using an series of if-else if conditionals to take the proper action for the given action event.
public void mouseClicked(MouseEvent event)
Performs many of the more complex functions of the Oscilloscope GUI, as nearly all of the interesting functions that may be used by the user rely at least in part on clicking in GraphFrames. Uses tests to determine whether a process is currently running, and tests the current process to determine how it should behave and where it should direct the data it collects.
public void mouseEntered(MouseEvent event)
public void mouseExited(MouseEvent event)
public void mousePressed(MouseEvent event)
public void mouseReleased(MouseEvent event)

vScale extends JPanel

protected vScale(double max)
Accepts a single value, the maximum value it must display. The vScale object always starts at zero, so it needs only this one argument. Then, like the tScale, it calculates four labels out of six possible, omitting the first and last, and sets these labels in the proper position in its panel.
protected vScale()
A do-nothing constructor created for convenience purposes.
buildConstraints()
protected void makeLabel(double value, JLabel target)
Uses a Java DecimalFormat object to format value properly and produce a String from it. Then sets the text of target to the String it calculates.
protected void redraw(double end)
Produces new axis labels, calculating the proper values from the end argument and starting from zero. It then uses makeLabel() to set the new values into the labels in the scale.

Design Information

Creating an Analysis

The procedure to create a new analysis is quite straightforward; in fact, incorporating the new analysis into the GUI will most likely be far more time consuming than writing the actual analysis.

In order to create a new analysis class, all one needs to do is to extend AnalysisType. Implmenting the three abstract methods will guarantee that your analysis will function properly within the existing software. Some important things to remember when creating an analysis:

  • Make sure that it has some way of being visible to the user. This could involve either the AIDA IPlotter tool or a specialized GUI element.
  • Make sure that the processRecord method actually performs all of the actions needed to extract the important data from a record.
  • Make sure to distinguish between Flash ADC and ATWD channels, as their behaviors tend to be quite different, and it takes more information to specify an ATWD channel.
  • Make sure your analysis can distinguish between records from the DOM it should use and any other records that it receives. (It will often be the case, espcecially when reading from a file, that the Oscilloscope will receive records from multiple DOMs in no specific sequence.)

In order to make your analysis accessible to the user, several steps will be necessary. First, you must add a button to the Analysis menu in OscilloscopeMain with its name and give the button an action listener. The action listener will also need an implementation allowing the user to set the fields of the analysis (usually the input specification). This is best accomplished by opening a pop-up window.

This, of course, means that the pop-up window will have to be defined. The class PeakAreaWindow should serve as a useful template. When defining your window, make sure to allow the user to specify the DOM to which the analysis should be applied, as in most cases it will be a bad idea to apply the analysis to all incoming DOMs.

UML Documentation




This UML document describes the potential uses of the Oscilloscope as they were envisioned at the beginning of the design phase. The cases below the dotted line were reserved for Version 2, and have since been implemented.


This UML document describes the possible states of the Oscilloscope, from start-up to death of the application. It is important to note that during the display state, the system is setting the data in the displays and displaying that information in separate Threads, so it is possible for one procees to continue while the other is blocked for some reason. In fact, this was a necessary, and perhaps even desirable, consequence of the designed features of the application.


This UML document describes how the classes of the Oscilloscope interact with one another and how they behave as a whole unit. This information will be extremely important should any global changes or additions of extensive functionality be necessary.