stella.calibunit
Class CalibUnit

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 io.SerialDriver
                          extended by stella.calibunit.CalibUnit
All Implemented Interfaces:
Driver, Cloneable, ExitCleaning, Initializable, LocalizedSupplying, PropertySupplying, ResourceSupplying

public class CalibUnit
extends SerialDriver


Nested Class Summary
static class CalibUnit.gohome
           
static class CalibUnit.Relative
          Steps the motor relatively for the given number of steps.
static class CalibUnit.setpos1
           
static class CalibUnit.setpos2
           
static class CalibUnit.setpos3
           
static class CalibUnit.setpos4
           
static class CalibUnit.setpos5
           
static class CalibUnit.Status
          Retrieves all of the status there is and pipe it to standard out.
static class CalibUnit.Test
          Test the class.
 
Nested classes/interfaces inherited from class io.SerialDriver
SerialDriver.Debug, SerialDriver.Scan
 
Nested classes/interfaces inherited from class io.AbstractSerialDriver
AbstractSerialDriver.Available
 
Nested classes/interfaces inherited from class util.PropertyResources
PropertyResources.URLResource
 
Field Summary
static int BADPOSITION
          The return code for an unknown position at movement.
private  String current
          This is the current position.
private static int DEFACCELERATION
          Default acceleration.
static String DEFDRIVERNAME
          driver generic name.
private static int DEFHOMESPEED
          Default speed to move to home (rpm).
private static boolean DEFINITHOME
          Default zero-positioning on init.
private static int DEFMAXSPEED
          Default maximal speed (rpm).
private static String DEFPOSITIONS
          Default position names and offsets.
static long DEFPOSITIONTIMEOUT
          Default position wait timeout.
private static long DEFSTATUSTIMEOUT
          Default status time out.
static String HOMEPOSITION
          The reserved home position name.
static String KEY_ACCELERATION
          Acceleration at changing position.
static String KEY_HOMESPEED
          The speed at which the home position will be reached (rpm).
static String KEY_INITHOME
          If true, we move to the zero position on init.
static String KEY_MAXSPEED
          Maximum speed at changing position (rpm).
static String KEY_POSITIONS
          A lookup-table linking position names to slider position.
static String KEY_POSITIONTIMEOUT
          Time out for positioning.
static String KEY_STATUSTIMEOUT
          Time out for status queries.
private  Map lookup
          The lookup table linking position names to offsets.
static int OK
          The return code for correct movement.
static int TIMEOUT
          The return code for time out at movement.
private  gnu.io.SerialPortEventListener wakeup
          This object notifies me on data available.
 
Fields inherited from class io.SerialDriver
KEY_DELAY, KEY_RWCOOLDOWN, KEY_STATICLOCK
 
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
CalibUnit(Map info)
          Constructor.
 
Method Summary
private static boolean consistsOf(String response, char p)
          Checks if a response string consists of only a single char, in arbitrary repetition.
 String getCurrentPosition()
          Returns the current position as a string or null if we are moving or not initialized.
 String getStatus()
          Returns the status of the calibration unit.
private  String getStatus(boolean all)
          Returns the status of the calibration unit.
private  String getStatusCommand(String statcom)
          Sends the specified status command to the controller and waits for the response.
 int goHomePosition()
          Go to the home (= 0) position.
 int goRelative(int steps)
          Moves the stage relatively to the current position.
 int goToPosition(String posID)
          Set the position.
 boolean open()
          Initializing the communication port.
 String writeString(String comm)
          We add a cr before sending with the parental method.
 
Methods inherited from class io.SerialDriver
close, exit, readString, readString, writeCommand
 
Methods inherited from class io.AbstractSerialDriver
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, init, 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
 
Methods inherited from interface util.Initializable
init
 

Field Detail

OK

public static final int OK
The return code for correct movement.

See Also:
Constant Field Values

TIMEOUT

public static final int TIMEOUT
The return code for time out at movement.

See Also:
Constant Field Values

BADPOSITION

public static final int BADPOSITION
The return code for an unknown position at movement.

See Also:
Constant Field Values

HOMEPOSITION

public static final String HOMEPOSITION
The reserved home position name.

See Also:
Constant Field Values

KEY_POSITIONS

public static final String KEY_POSITIONS
A lookup-table linking position names to slider position.

See Also:
Constant Field Values

KEY_POSITIONTIMEOUT

public static final String KEY_POSITIONTIMEOUT
Time out for positioning.

See Also:
Constant Field Values

KEY_STATUSTIMEOUT

public static final String KEY_STATUSTIMEOUT
Time out for status queries.

See Also:
Constant Field Values

KEY_ACCELERATION

public static final String KEY_ACCELERATION
Acceleration at changing position.

See Also:
Constant Field Values

KEY_MAXSPEED

public static final String KEY_MAXSPEED
Maximum speed at changing position (rpm).

See Also:
Constant Field Values

KEY_HOMESPEED

public static final String KEY_HOMESPEED
The speed at which the home position will be reached (rpm).

See Also:
Constant Field Values

KEY_INITHOME

public static final String KEY_INITHOME
If true, we move to the zero position on init.

See Also:
Constant Field Values

DEFDRIVERNAME

public static final String DEFDRIVERNAME
driver generic name.

See Also:
Constant Field Values

DEFPOSITIONS

private static final String DEFPOSITIONS
Default position names and offsets.

See Also:
Constant Field Values

DEFPOSITIONTIMEOUT

public static final long DEFPOSITIONTIMEOUT
Default position wait timeout.

See Also:
Constant Field Values

DEFSTATUSTIMEOUT

private static final long DEFSTATUSTIMEOUT
Default status time out.

See Also:
Constant Field Values

DEFACCELERATION

private static final int DEFACCELERATION
Default acceleration.

See Also:
Constant Field Values

DEFMAXSPEED

private static final int DEFMAXSPEED
Default maximal speed (rpm).

See Also:
Constant Field Values

DEFHOMESPEED

private static final int DEFHOMESPEED
Default speed to move to home (rpm).

See Also:
Constant Field Values

DEFINITHOME

private static final boolean DEFINITHOME
Default zero-positioning on init.

See Also:
Constant Field Values

lookup

private Map lookup
The lookup table linking position names to offsets.


wakeup

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


current

private String current
This is the current position.

Constructor Detail

CalibUnit

public CalibUnit(Map info)
Constructor. Opening of the serial port is delayed until init. Here only properties are read and defaulted, and a look-up table linking position names to absoulte postitions is constructed.

Method Detail

open

public boolean open()
             throws IOException
Initializing the communication port. Gets the port identifier, opens the port and the I/O streams and send start-up commands.

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

goToPosition

public int goToPosition(String posID)
                 throws IOException
Set the position.

Parameters:
posID - string ID of the requested position.
Returns:
1 if positioning was successfull, -1 if the operation was timed out, -2 if bad posID was specified.
Throws:
IOException

goRelative

public int goRelative(int steps)
Moves the stage relatively to the current position. The argument specifies the steps to move, with sign. This method is intended for diagnostics.


goHomePosition

public int goHomePosition()
                   throws IOException
Go to the home (= 0) position.

Returns:
1 if positioning was successfull, -1 if the operation was timed out.
Throws:
IOException

getStatus

public String getStatus()
Returns the status of the calibration unit. Various get commands are sent to the controller. The responses are not parsed to be clearly readable, refer to the Faulhaber manual MCDC 2805 for the concrete meaning.


getStatus

private String getStatus(boolean all)
Returns the status of the calibration unit. Depending on the parameter, only some or all information available is queried.


getStatusCommand

private String getStatusCommand(String statcom)
Sends the specified status command to the controller and waits for the response. No check for open, private method.


consistsOf

private static boolean consistsOf(String response,
                                  char p)
Checks if a response string consists of only a single char, in arbitrary repetition.


getCurrentPosition

public String getCurrentPosition()
Returns the current position as a string or null if we are moving or not initialized.


writeString

public String writeString(String comm)
                   throws IOException
We add a cr before sending with the parental method.

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