Overview

This section aims to provide a guide to adding a new MeasurementTool to OptSuite. You should be familiar with the basic concepts of OptSuite itself and the pluginframework of OptSuite.

MeasurementTool provider

OptSuite manages MeasurementToolProviders rather than MeasurementTools. So in order to add a new tool to the suite your first step will be to implement imtek.optsuite.acquisition.mtools.MeasurementToolProvider. This is a small interface responsible for getting a list of available tools of a certain type and selecting one out of them. Here are the methods you have to implement along with their JavaDoc:

 
 /**
  * Return a list of all available MeasurementTools for the given
  * toolType.
  * 
  * @param toolType The toolType a List of available tools should be returned.
  * @return A list of all available MeasurementTools.
  */
 public Collection getMeasurementTools(String toolType);
 
 /**
  * Return the MeasurementTool referenced by the given toolType and toolID.
  * ToolType and ToolID uniquely identify a MeasurementTool.
  * The returned tool should be a singleton within the Workbench.
  * 
  * @param toolType ToolType of the returned tool.
  * @param toolID ToolID of the returned tool.
  * @return MeasurementTool referenced by the given toolType and toolID.
  */
 public MeasurementTool getMeasurementTool(String toolType, String toolID);
 
 /**
  * Create a Composite that lets users choose one tool out of list of 
  * available tools for the given toolType.
  * @param parent The parent Composite of the newly created Composite.
  */
 public MeasurementToolSelectionComposite createMeasurementSelectionComposite(
   String toolType, Composite parent
 );

Normally a MeasurementTool would allow several implementations of itself so the MeasurementToolProvider will itself be a registry or extension-point processor and serve only with extensions. See the PhaseShifter MeasurementTool for an example of such a tool.

A much simpler implementation could be a provider that will only know one MeasurementTool.

The MeasurementTool itself

Of course you’ll need to provide an implementation of the imtek.optsuite.acquisition.mtools.MeasurementTool interface as well. This interface is a little longer than its provider, so it is not quoted here. It holds methods for getting tool metadata like name, description etc., retrieving tool preferences, tool representation in the routine browser, tool locking etc. Most new MeasurementTool can sublcass imtek.optsuite.acquisition.mtools.AbstractMeasurementTool that already implements some basic issues of a tool like holding values for description and locking.

The measurement tool itself does all the work within a routine. MeasurementTools are singletons in OptSuite and have to be locked exclusively before usage. Each tool has to check itself whether it was locked before performing any actions though.

Some of the methods of MeasurementTool we need to discuss in more detail:

 /**
  * Should create a new instance of the preferences class of the
  * implementing tool. The framework will register the returned object in
  * {@link MeasurementToolPrefsStore}.
  * 
  * @return New MeasurementToolPreferences with default values for this tool.
  */
 public MeasurementToolPreferences createNewDefaultPreferences();
 
 /**
  * Adapt the given preferences for this tool.
  * 
  * @param prefs The preferences to be adapted.
  */
 public void adaptPreferences(MeasurementToolPreferences prefs);
 

Each MeasurementTool can provide a custom Object that is capable of holding configuration information specific to that tool. That way tools can be configured once for different puposes and these configuration can be reused. The only restriction on these objects are that they have to be a sublcass of imtek.optsuite.acquisition.mtools.MeasurementToolPreferences and all data that should be stored has to comply with the Java Beans getter and setter pattern as it is serialized by the Java Beans serializer. When a new preferences object for a tool is needed createNewDefaultPreferences() will be called. adaptPreferences() will be called every time a tool is locked. It should then change its settings/behaviour according to the given preferences.

Registering the new MeasurementTool

To register your new implementaion of a measurement tool you have to make an extension to the extension-point imtek.optsuite.acquisitioin.measurementtool and register the type and the provider of your new tool. Here is how your extension declaration could look like:

<code xml> <extension

point=”imtek.optsuite.acquisition.measurementtool”>

<measurementTool

toolType=”my.extension.newTool”

toolProvider=”my.extension.newToolProvider”/>

</extension> <code>

The measurementTool element in the extension requires a string a java class for both toolType and toolProvider. Here you should use the implementations mentioned in the above section.

 
documentation/howto_measurementtool.txt · Last modified: 2006/09/05 14:27 by fleque
Recent changes · Show pagesource · Login