stella.omc
Class MotorController

java.lang.Object
  extended by util.PropertyContainer
      extended by util.PropertyResources
          extended by util.PropertyBundles
              extended by io.AbstractDriver
                  extended by io.AbstractSerialDriver
                      extended by stella.omc.MotorController
All Implemented Interfaces:
Driver, Cloneable, Initializable, LocalizedSupplying, PropertySupplying, ResourceSupplying
Direct Known Subclasses:
FilterWheel, LinearPositioner, MiniWheel, RelativeWheel, WifsipWheel, WindmillShutter

public abstract class MotorController
extends AbstractSerialDriver

Communication class for the OMC 93-70 MINI stepper motor controller. The communication is carried out through the serial port. The class provides the basic commucation API for the controller:

REMARKS: the controller has to be left in local mode Last changed: 13.09.2004, JB. Last changed: 17.09.2005, TG.


Nested Class Summary
static class MotorController.AxesReset
          Resets the controller.
static class MotorController.Dump
          Dumps all parameters to system out.
static class MotorController.Reset
          Resets the controller.
static class MotorController.Set
          Reads the filter wheel configuration from a file and positions to the specified slot.
static class MotorController.Status
          Dumps the full status message to system out.
static class MotorController.Step
          Steps the filter wheel from the current position to the desired offset.
 
Nested classes/interfaces inherited from class io.AbstractSerialDriver
AbstractSerialDriver.Available
 
Nested classes/interfaces inherited from class util.PropertyResources
PropertyResources.URLResource
 
Field Summary
protected  List<String> axis
          The names of the axis the controller supports.
private static int DEFADDRESS
          Set the default address.
private static String DEFCONTROLLERTYPE
          Default controller type.
private static long DEFDELAY
          The default reading delay in ms.
private static boolean DEFEEPROMSTORE
          Storing in EEPROM is not possible per default.
private static int DEFFAILAXISMOVE
          The default axis movement failure maximum.
private static String DEFPROTOCOL
          Default protocol type.
private static int DEFRETRYPOS
           
private static int DEFSERIALRETRY
          The default reading delay in ms.
private static long DEFSLEEPAXISMOVE
          The default axis movement sleep time .
private static int DEFSTEPTOLERANCE
           
private static int DEFTELEGRAM
          Set the minimum reply length.
private static boolean DEFWORKAROUND
          Firmware error work-around.
static int FAILED
          Return code for failed.
private  List<Integer> fails
          The maximum failures allowed per axis.
static int HOME
          The HOME position.
static String KEY_ADDRESS
          Device address on the serial port.
static String KEY_AXES
          The names of the axis, upper case.
static String KEY_CONTROLLERTYPE
          Controller type .
static String KEY_DELAY
          The key to the reading delay in msec.
static String KEY_EEPROMSTORE
          If true, we can store the parameters in the EEPROM
static String KEY_FAILAXISMOVE
          The maximum number of failures allowed during axis movement.
static String KEY_PROTOCOL
          The telegram protocol to use as a string.
static String KEY_RETRYPOS
          Maximum number of repositioning tries at go to step.
static String KEY_SERIALRETRY
          The key to the maximum number of retries for critical reads.
static String KEY_SLEEPAXISMOVE
          Sleep until requery axis movement.
static String KEY_STEPTOLERANCE
          Maximum allowed difference between requested and achieved position.
static String KEY_TELEGRAM
          The minimum length of a telegram (a valid reply).
static String KEY_WORKAROUND
          Firmware error work-around.
static String MCC
          Protocoll type for MMC
static int OK
          Return code for o.k.
static String OMC
          Protocoll type for OMC
private  List<Long> sleeps
          The sleep interval per axis.
static int UNDEFINEDPOSITION
          The HOME position.
private  gnu.io.SerialPortEventListener wakeup
          This object notifies me on data available.
 
Fields inherited from class io.AbstractSerialDriver
inport, KEY_BAUDRATE, KEY_CLOSETIMEOUT, KEY_DATABIT, KEY_FLOWCONTROL, KEY_INBUFFER, KEY_NOTIFYCOOLDOWN, KEY_OUTBUFFER, KEY_PARITYBIT, KEY_PORTNAME, KEY_RECEIVEFRAMING, KEY_RECEIVETHRESHOLD, KEY_RECEIVETIMEOUT, KEY_STOPBIT, KEY_TIMEOUT, outport, staticlock
 
Fields inherited from class io.AbstractDriver
KEY_DRIVERNAME
 
Fields inherited from class util.PropertyBundles
KEY_LOCALECOUNTRY, KEY_LOCALELANGUAGE, KEY_RESOURCEBUNDLES
 
Fields inherited from class util.PropertyResources
KEY_NOINITONCREATE, localurl, locate, POSTFIX_DIR, POSTFIX_EXT, POSTFIX_FILE, POSTFIX_LIST, POSTFIX_URL, urlset
 
Fields inherited from class util.PropertyContainer
KEY_LISTSEPARATOR, KEY_MAPKEYVALUECHAR, KEY_MAPSEPARATOR
 
Fields inherited from interface util.ResourceSupplying
KEY_URLRESOURCES, KEY_URLUSECONFIG, KEY_URLUSECURRENT, KEY_URLUSEHOME
 
Fields inherited from interface util.PropertySupplying
CONFIG, KEY_CLASS
 
Constructor Summary
MotorController(Map<String,String> config)
          Constructs a new motor controller.
 
Method Summary
private  char axisIsMoving(String ax)
          Returns the moving state of the axis.
protected  boolean axisStop(String ax)
          Axis stop
protected  String encapsulate(String comm)
          Encapsulates a minilig command into a transmission telegram.
protected  String ensureCommand(String comm)
          Ensures command write by repeating for maximum KEY_SERIALRETRY times.
protected  boolean errorPower(String ax)
          Error in last stage.
protected  boolean errorStep(String ax)
          Error in last stage.
protected  boolean errorStop(String ax)
          Error in last stage.
 Collection<String> getAxesNames()
          Gets the names of the available axes.
protected  double getControllerParameter(String ax, String param)
          Returns a controller parameter.
protected  double[] getControllerParameterArray(String ax, int[] ipar)
          Returns the values of all parameters indicated in the list.
protected  String getControllerType()
          Returns the controller type string.
protected abstract  Map<String,?> getParametersFor(String axisname)
          Returns the appropriate parameters for the axis in question.
 String getStatus()
          Returns various status information about the controller.
protected  String getStatus(String ax, boolean all)
          Returns staus information.
 int getStep(String axis)
          Returns the currently attained step position via a direct query to the underlying driver.
protected  int getStepResolution(String ax)
          Returns the controller's step resolution compiled from the P45 controller parameter.
 void init()
          Initialies the parameter maps, the axis names and their timeouts.
 boolean isContinuous(String axis)
          Returns true, if this axis can be continuousely offset, which is likely the case for rotary stagets, and never the case for linear stages.
 boolean open()
          Initializes the driver.
protected  void powerOff(String axis)
          Deactivates the power stage of the given axis.
protected  void powerOn(String axis)
          Activates the power stage of the given axis.
 String readString()
          Reads and interprets the serial response.
 String readString(boolean nolog)
          Reads and interprets the serial response.
protected  void remote()
          Set the controller to remote
protected  void reset()
          Resets the controller.
protected  boolean resetAxis(String ax)
          Resets the axis.
protected  void setControllerParameter(String ax, String param, int value)
          Method to set a controller parameter.
protected  int waitWhileAxisMoving(int axnr)
          Waits until the given axis is moving.
protected  int waitWhileAxisMoving(String x)
           
 String writeCommand(String comm)
          Sends a MINILOG command to the controller.
 String writeCommand(String comm, boolean nolog)
          Sends a MINILOG command to the controller.
 String writeString(String cmd)
          Writes a string to the serial port.
 String writeString(String cmd, boolean nolog)
          Writes a string to the serial port.
 
Methods inherited from class io.AbstractSerialDriver
close, createPortEventListener, createPortEventListener, deregisterSoleEventListener, disableEvent, enableEvent, getDriverName, isOpen, registerSoleEventListener, resetOriginalParameters
 
Methods inherited from class io.AbstractDriver
createDriver, equals, hashCode
 
Methods inherited from class util.PropertyBundles
clone, getLocalized, getLocalized, getLocalizedString, getLocalizedString, loadResource
 
Methods inherited from class util.PropertyResources
createFrom, createFrom, createFrom, getApplet, getAsResources, getLocalClassLoader, getPropertiesToKey, getPropertiesToKey, getResource, getResourceAsStream, getResourceFromKey, getResources, keyCreate, keyCreate, reload, setApplet
 
Methods inherited from class util.PropertyContainer
augment, augment, augment, defaultBoolean, defaultChar, defaultDouble, defaultFloat, defaultInt, defaultLong, defaultObject, defaultObject, defaultProperties, defaultProperty, getAsBoolean, getAsChar, getAsDouble, getAsEnums, getAsFloat, getAsInt, getAsList, getAsLong, getAsMap, getAsMap, getAsObject, getAsObject, getProperties, getProperty, has, isNew, parseObject, reload, removeProperty, rescanned, setObject, setProperties, setProperty, stringProperties, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface util.ResourceSupplying
getResource, getResourceAsStream, getResources
 
Methods inherited from interface util.PropertySupplying
defaultBoolean, defaultChar, defaultDouble, defaultFloat, defaultInt, defaultLong, defaultObject, defaultObject, defaultProperties, defaultProperty, getAsBoolean, getAsChar, getAsDouble, getAsFloat, getAsInt, getAsList, getAsLong, getAsMap, getAsObject, getAsObject, getProperties, getProperty, has, parseObject, removeProperty, setObject, setProperty, stringProperties
 

Field Detail

OK

public static final int OK
Return code for o.k.

See Also:
Constant Field Values

FAILED

public static final int FAILED
Return code for failed.

See Also:
Constant Field Values

HOME

public static final int HOME
The HOME position.

See Also:
Constant Field Values

UNDEFINEDPOSITION

public static final int UNDEFINEDPOSITION
The HOME position.

See Also:
Constant Field Values

OMC

public static final String OMC
Protocoll type for OMC

See Also:
Constant Field Values

MCC

public static final String MCC
Protocoll type for MMC

See Also:
Constant Field Values

KEY_PROTOCOL

public static final String KEY_PROTOCOL
The telegram protocol to use as a string.

See Also:
Constant Field Values

KEY_DELAY

public static final String KEY_DELAY
The key to the reading delay in msec.

See Also:
Constant Field Values

KEY_SERIALRETRY

public static final String KEY_SERIALRETRY
The key to the maximum number of retries for critical reads.

See Also:
Constant Field Values

KEY_TELEGRAM

public static final String KEY_TELEGRAM
The minimum length of a telegram (a valid reply).

See Also:
Constant Field Values

KEY_AXES

public static final String KEY_AXES
The names of the axis, upper case. Simplest case 'X'.

See Also:
Constant Field Values

KEY_FAILAXISMOVE

public static final String KEY_FAILAXISMOVE
The maximum number of failures allowed during axis movement.

See Also:
Constant Field Values

KEY_RETRYPOS

public static final String KEY_RETRYPOS
Maximum number of repositioning tries at go to step.

See Also:
Constant Field Values

KEY_STEPTOLERANCE

public static final String KEY_STEPTOLERANCE
Maximum allowed difference between requested and achieved position.

See Also:
Constant Field Values

KEY_SLEEPAXISMOVE

public static final String KEY_SLEEPAXISMOVE
Sleep until requery axis movement.

See Also:
Constant Field Values

KEY_ADDRESS

public static final String KEY_ADDRESS
Device address on the serial port.

See Also:
Constant Field Values

KEY_WORKAROUND

public static final String KEY_WORKAROUND
Firmware error work-around.

See Also:
Constant Field Values

KEY_EEPROMSTORE

public static final String KEY_EEPROMSTORE
If true, we can store the parameters in the EEPROM

See Also:
Constant Field Values

KEY_CONTROLLERTYPE

public static final String KEY_CONTROLLERTYPE
Controller type .

See Also:
Constant Field Values

DEFFAILAXISMOVE

private static final int DEFFAILAXISMOVE
The default axis movement failure maximum.

See Also:
Constant Field Values

DEFSLEEPAXISMOVE

private static final long DEFSLEEPAXISMOVE
The default axis movement sleep time .

See Also:
Constant Field Values

DEFDELAY

private static final long DEFDELAY
The default reading delay in ms.

See Also:
Constant Field Values

DEFSERIALRETRY

private static final int DEFSERIALRETRY
The default reading delay in ms.

See Also:
Constant Field Values

DEFTELEGRAM

private static final int DEFTELEGRAM
Set the minimum reply length.

See Also:
Constant Field Values

DEFADDRESS

private static final int DEFADDRESS
Set the default address.

See Also:
Constant Field Values

DEFWORKAROUND

private static final boolean DEFWORKAROUND
Firmware error work-around.

See Also:
Constant Field Values

DEFEEPROMSTORE

private static final boolean DEFEEPROMSTORE
Storing in EEPROM is not possible per default.

See Also:
Constant Field Values

DEFCONTROLLERTYPE

private static final String DEFCONTROLLERTYPE
Default controller type.

See Also:
Constant Field Values

DEFPROTOCOL

private static final String DEFPROTOCOL
Default protocol type.

See Also:
Constant Field Values

DEFRETRYPOS

private static final int DEFRETRYPOS
See Also:
Constant Field Values

DEFSTEPTOLERANCE

private static final int DEFSTEPTOLERANCE
See Also:
Constant Field Values

wakeup

private gnu.io.SerialPortEventListener wakeup
This object notifies me on data available.


axis

protected List<String> axis
The names of the axis the controller supports.


fails

private List<Integer> fails
The maximum failures allowed per axis.


sleeps

private List<Long> sleeps
The sleep interval per axis.

Constructor Detail

MotorController

public MotorController(Map<String,String> config)
Constructs a new motor controller. The initalization is deferred to the init() section.

Method Detail

getAxesNames

public Collection<String> getAxesNames()
Gets the names of the available axes.


init

public void init()
Initialies the parameter maps, the axis names and their timeouts.

Specified by:
init in interface Initializable
Overrides:
init in class PropertyResources

isContinuous

public boolean isContinuous(String axis)
                     throws IOException
Returns true, if this axis can be continuousely offset, which is likely the case for rotary stagets, and never the case for linear stages.

Throws:
IOException

getStep

public int getStep(String axis)
            throws IOException
Returns the currently attained step position via a direct query to the underlying driver.

Throws:
IOException

open

public boolean open()
             throws IOException
Initializes the driver. Additionally to opening the serial port, we set the controller parameters.

Specified by:
open in interface Driver
Overrides:
open in class AbstractSerialDriver
Returns:
True if initialization was successful.
Throws:
IOException

getParametersFor

protected abstract Map<String,?> getParametersFor(String axisname)
Returns the appropriate parameters for the axis in question.


writeCommand

public String writeCommand(String comm)
                    throws IOException
Sends a MINILOG command to the controller.

Specified by:
writeCommand in class AbstractSerialDriver
Parameters:
comm - String representing the MINILOG command (like "X+200").
Returns:
String representing the controller's response.
Throws:
IOException

writeCommand

public String writeCommand(String comm,
                           boolean nolog)
                    throws IOException
Sends a MINILOG command to the controller.

Parameters:
comm - String representing the MINILOG command (like "X+200").
Returns:
String representing the controller's response.
Throws:
IOException

encapsulate

protected String encapsulate(String comm)
Encapsulates a minilig command into a transmission telegram. Especially the number of CR/LF at the end is varying from Controler to controler. Intervene here, if you have transmission problems that are related to send-telegram size.


ensureCommand

protected String ensureCommand(String comm)
                        throws IOException
Ensures command write by repeating for maximum KEY_SERIALRETRY times. If it fails permanently, an IOException is thrown.

Throws:
IOException

writeString

public String writeString(String cmd)
                   throws IOException
Writes a string to the serial port. No sync etc.

Specified by:
writeString in class AbstractSerialDriver
Returns:
The string as it was truely sent to the line, including LF etc.
Throws:
IOException

writeString

public String writeString(String cmd,
                          boolean nolog)
                   throws IOException
Writes a string to the serial port. No sync etc.

Throws:
IOException

readString

public String readString()
                  throws IOException
Reads and interprets the serial response. The motor controller returns control chars that are stripped from the reply.

Specified by:
readString in class AbstractSerialDriver
Throws:
IOException

readString

public String readString(boolean nolog)
                  throws IOException
Reads and interprets the serial response. The motor controller returns control chars that are stripped from the reply.

Throws:
IOException

waitWhileAxisMoving

protected int waitWhileAxisMoving(String x)

waitWhileAxisMoving

protected int waitWhileAxisMoving(int axnr)
Waits until the given axis is moving. This method should be called after each motor movig command to make sure the operation is finished before another operation starts.

Parameters:
axnr - Number of axis to move
Returns:
0, 1 whether or not the moving finished properly.

powerOff

protected void powerOff(String axis)
                 throws IOException
Deactivates the power stage of the given axis.

Throws:
IOException

powerOn

protected void powerOn(String axis)
                throws IOException
Activates the power stage of the given axis.

Throws:
IOException

axisIsMoving

private char axisIsMoving(String ax)
                   throws IOException
Returns the moving state of the axis.

Throws:
IOException

reset

protected void reset()
              throws IOException
Resets the controller.

Throws:
IOException

remote

protected void remote()
               throws IOException
Set the controller to remote

Throws:
IOException

resetAxis

protected boolean resetAxis(String ax)
                     throws IOException
Resets the axis.

Throws:
IOException

errorPower

protected boolean errorPower(String ax)
                      throws IOException
Error in last stage.

Throws:
IOException

errorStep

protected boolean errorStep(String ax)
                     throws IOException
Error in last stage.

Throws:
IOException

errorStop

protected boolean errorStop(String ax)
                     throws IOException
Error in last stage.

Throws:
IOException

axisStop

protected boolean axisStop(String ax)
                    throws IOException
Axis stop

Throws:
IOException

getControllerParameter

protected double getControllerParameter(String ax,
                                        String param)
                                 throws IOException,
                                        NullPointerException
Returns a controller parameter. If reading fails, it is repeated for KEY_SERIALRETRY times.

Parameters:
param - String specifying the requested parameter (like "P14");
Returns:
Double value of the requested parameter.
Throws:
IOException
NullPointerException

getControllerParameterArray

protected double[] getControllerParameterArray(String ax,
                                               int[] ipar)
                                        throws IOException,
                                               NullPointerException
Returns the values of all parameters indicated in the list.

Throws:
IOException
NullPointerException

getControllerType

protected String getControllerType()
                            throws IOException
Returns the controller type string. Values are either "MCC" or "OMC".

Returns:
String of the controller type.
Throws:
IOException

getStepResolution

protected int getStepResolution(String ax)
                         throws IOException,
                                NullPointerException
Returns the controller's step resolution compiled from the P45 controller parameter.

Returns:
Integer value of the step resolution.
Throws:
IOException
NullPointerException

setControllerParameter

protected void setControllerParameter(String ax,
                                      String param,
                                      int value)
                               throws IOException,
                                      NullPointerException
Method to set a controller parameter.

Parameters:
param - String specifying the requested parameter (like "P14").
value - Integer value of the given parameter to set.
Throws:
IOException
NullPointerException

getStatus

public String getStatus()
Returns various status information about the controller.

Returns:
A formatted string with the controllers status info.

getStatus

protected String getStatus(String ax,
                           boolean all)
Returns staus information. Depending on the flag passed over either lesser or all information is retrieved.