vfstagecontroller
Class StageController

java.lang.Object
  |
  +--vfstagecontroller.StageController
All Implemented Interfaces:
java.lang.Runnable

public class StageController
extends java.lang.Object
implements java.lang.Runnable

Title: Stage controller class

Description: By the use of this class the programmer shold be able to control a microscope stage (x,y,z).

Copyright: Copyright (c) 2003

Company: Policlinico universitario di Udine


Field Summary
(package private)  java.awt.Dialog dlgToHide
           
static int N_BOOKMARK
          Max number of Bookmarks
(package private) static java.util.Enumeration portList
           
(package private) static char X_COOR
          To get x axis position
(package private) static char Y_COOR
          To get y axis position
(package private) static char Z_COOR
          To get z axis position
 
Constructor Summary
StageController()
          Construct a stage controller setting default connection parameters and no command area: "", 9600 baud,Flow control: NONE, 8 data bits, parity:NONE, 1 Stop bits
StageController(SerialParameters connPar)
          Construct a stage controller.
StageController(SerialParameters connPar, java.awt.TextArea area)
          Construct a stage controller.
StageController(java.awt.TextArea area)
          Construct a stage controller setting default connection parameters: "", 9600 baud,Flow control: NONE, 8 data bits, parity:NONE, 1 Stop bits
 
Method Summary
(package private) static void ()
           
 int addBookmark(java.lang.String name, long x, long y, long z)
          Add a position bookmark on bookmark array.
 void closeConnection()
          Close the connection with the stage controller.
 java.lang.String enableStageBackLash(boolean b)
          Enable or disable X,Y stage axis backlash
 java.lang.String enableZBackLash(boolean b)
          Enable or disable Z stage axis backlash
 boolean getBacklashFocusStat()
          Get Backlash focus status.
 boolean getBacklashStageStat()
          Get Backlash stage X-Y status.
 long getBookmarkCoord(java.lang.String name, char kind)
          Return bookmark coordinate selected by kind param
 java.lang.String getBookmarkName(int i)
          Retrive the bookmark name of position i
 java.lang.String[] getCommPortFounded()
          Get com port currently on board
 SerialParameters getConnectionParameters()
          Get current serial connection parameters to estabilish serial connection with openConnection command
 long getCurrentPos(char kind)
          Get current position of requested axis:
 java.lang.String getDefaultPortName()
          Gets default port for connection i.e. the port where connection will be attempted.
 int getMode()
          Send a request to stage controller questioning about its mode: usually COMPATIBILITY or STANDARD.
 int getStatus()
          Get status of the stage.
 long getXStepSize()
          Gets current X Step size.
 int getXYAcc()
          Return Stage XY acceleration.
 int getXYSpeed()
          Get stage speed range.
 long getYStepSize()
          Gets current Y Step size.
 int getZAcc()
          Return Z axis acceleration.
 int getZSpeed()
          Get z axis speed range.
 long getZStepSize()
          Gets Z Step size in decimal micron.
 void initBookmarks()
          Init bookmark array
 java.lang.String moveStageTo(long x, long y)
          Move stage to absolute position x,y
 void moveStageTo(long x, long y, long z)
          Move Stage to Absolute position x,y,z
 java.lang.String moveXYStep(java.lang.String command)
          Move stage in the selected direction by the size defined in the step dim:
 void moveZAxisTo(long z)
          Move Z to Absolute position z
 java.lang.String moveZStep(java.lang.String command)
          Move Z axis by one step:
 boolean openConnection()
          Estabilish connection with the controller and ping the controller to check its functionality
 void run()
          Launch searchSetLimits method. serchSetLimits() have to run in async mode to give to the user the possibility of process stopping.
 java.lang.String setAbsPos(int x, int y, int z)
          Set current stage position to absolute position x,y,z.
 void setConnectionParameters(SerialParameters sp)
          Set current serial connection parameters to estabilish serial connection with openConnection command
 void setDefaultPortName(java.lang.String dfpn)
          Sets default port for connection i.e. the port where connection will be attempted.
 void setDialogToHide(java.awt.Dialog d)
          Set the dialog to hide at the end of seachLimits methods
 java.lang.String setMode(int m)
          Send to the stage the request to swap in mode m
 void setStageSpeed(int speed)
          Deprecated. No enougth information on stage protocol manual
 void setXStepSize(long v)
          Sets X-Step size of stage in micron.
 java.lang.String setXYAcc(int acc)
          Set stage X,Y-axis acceleration.
 java.lang.String setXYSpeed(int speed)
          Set stage XY-axis speed range. set X-Y Stage speed range
 java.lang.String setXYStepSize(long u, long v)
          Set X and Y Step size of stage in micron.
 java.lang.String setXYZStepSize(long u, long v, long w)
          Set X, Y, Z Step size of stage in micron.
 void setYStepSize(long v)
          Set Y-Step size of stage in micron.
 java.lang.String setZAcc(int acc)
          Set stage Z-axis acceleration.
 java.lang.String setZSpeed(int speed)
          Set stage Z-axis speed range. set Z Stage speed range
 java.lang.String setZStepSize(long v)
          Set Z-Step size of stage in micron.
 java.lang.String stopStage()
          Stop the stage if is moving.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

X_COOR

static char X_COOR
To get x axis position

Y_COOR

static char Y_COOR
To get y axis position

Z_COOR

static char Z_COOR
To get z axis position

N_BOOKMARK

public static int N_BOOKMARK
Max number of Bookmarks

portList

static java.util.Enumeration portList

dlgToHide

java.awt.Dialog dlgToHide
Constructor Detail

StageController

public StageController()
Construct a stage controller setting default connection parameters and no command area: "", 9600 baud,Flow control: NONE, 8 data bits, parity:NONE, 1 Stop bits

StageController

public StageController(java.awt.TextArea area)
Construct a stage controller setting default connection parameters: "", 9600 baud,Flow control: NONE, 8 data bits, parity:NONE, 1 Stop bits
Parameters:
area - echo commands TextArea

StageController

public StageController(SerialParameters connPar)
Construct a stage controller.
Parameters:
connPar - connection parameters for serial connection with the stage controller

StageController

public StageController(SerialParameters connPar,
                       java.awt.TextArea area)
Construct a stage controller.
Parameters:
connPar - connection parameters for serial connection with the stage controller
area - echo commands TextArea
Method Detail

static void ()

getDefaultPortName

public java.lang.String getDefaultPortName()
Gets default port for connection i.e. the port where connection will be attempted.
Returns:
default port for connection
See Also:
openConnection()

setDefaultPortName

public void setDefaultPortName(java.lang.String dfpn)
Sets default port for connection i.e. the port where connection will be attempted.
Parameters:
dfpn - SERIAL PORT NAME to be setted
See Also:
openConnection()

openConnection

public boolean openConnection()
                       throws SerialConnectionException
Estabilish connection with the controller and ping the controller to check its functionality
Returns:
true if ping was ccompleted with happening, false otherwise
Throws:
SerialConnectionException -  
See Also:
moveStageTo(long, long, long), closeConnection()

closeConnection

public void closeConnection()
Close the connection with the stage controller.
See Also:
openConnection()

getCommPortFounded

public java.lang.String[] getCommPortFounded()
Get com port currently on board
Returns:
com port list.

getConnectionParameters

public SerialParameters getConnectionParameters()
Get current serial connection parameters to estabilish serial connection with openConnection command
Returns:
serial parameters
See Also:
openConnection(), setConnectionParameters(vfstagecontroller.SerialParameters)

setConnectionParameters

public void setConnectionParameters(SerialParameters sp)
Set current serial connection parameters to estabilish serial connection with openConnection command
Parameters:
sp - serial parameters
See Also:
openConnection(), getConnectionParameters()

initBookmarks

public void initBookmarks()
Init bookmark array

addBookmark

public int addBookmark(java.lang.String name,
                       long x,
                       long y,
                       long z)
Add a position bookmark on bookmark array. Bookmark array have a limeted allocation space. This imply the insertion of bookmark on array space is circular
Parameters:
name - Bookrmark name
x - coordinate of the bookmark
y - coordinate
z - coordinate
Returns:
bookrmar array index
See Also:
getBookmarkName, getBookmarkCood

getBookmarkName

public java.lang.String getBookmarkName(int i)
Retrive the bookmark name of position i
Parameters:
i - bookmark position inside bookmark array
Returns:
bookmark name

getBookmarkCoord

public long getBookmarkCoord(java.lang.String name,
                             char kind)
Return bookmark coordinate selected by kind param
Parameters:
name - Bookmark name
kind - x or y or z coordinate respecvely using X_COOR, Y_COOR, Z_COOR constant
Returns:
-999999 if no right value can be returned

getCurrentPos

public long getCurrentPos(char kind)
Get current position of requested axis:
Parameters:
kind - X_COOR return x position, Y_COOR return y position, Z_COOR return z position
Returns:
x or y or z position

getXStepSize

public long getXStepSize()
Gets current X Step size.
Returns:
current x step size

getYStepSize

public long getYStepSize()
Gets current Y Step size.
Returns:
current y step size

getZStepSize

public long getZStepSize()
Gets Z Step size in decimal micron.
Returns:
current Z step size

setXStepSize

public void setXStepSize(long v)
Sets X-Step size of stage in micron.
Parameters:
v - step size in micron

setYStepSize

public void setYStepSize(long v)
Set Y-Step size of stage in micron.
Parameters:
v - step size in micron

setXYStepSize

public java.lang.String setXYStepSize(long u,
                                      long v)
Set X and Y Step size of stage in micron.
Parameters:
u - X-Step size in micron
v - Y-Step size in micron
Returns:
stage response string for error control

setZStepSize

public java.lang.String setZStepSize(long v)
Set Z-Step size of stage in micron.
Parameters:
v - focus step size in micron
Returns:
stage response string for error control

setXYZStepSize

public java.lang.String setXYZStepSize(long u,
                                       long v,
                                       long w)
Set X, Y, Z Step size of stage in micron.
Parameters:
u - X-Step size in micron
v - Y-Step size in micron
w - Z-Step size in micron
Returns:
stage response string for error control

getBacklashStageStat

public boolean getBacklashStageStat()
Get Backlash stage X-Y status.
Returns:
X-Y Backlash status: false: Backlash disabled true: Backlash enabled

getBacklashFocusStat

public boolean getBacklashFocusStat()
Get Backlash focus status.
Returns:
Z-Backlash status: false: Z-Backlash disabled true: Z-Backlash enabled

enableStageBackLash

public java.lang.String enableStageBackLash(boolean b)
Enable or disable X,Y stage axis backlash
Parameters:
b - true=enable, false=disable
Returns:
stage response string for error control

enableZBackLash

public java.lang.String enableZBackLash(boolean b)
Enable or disable Z stage axis backlash
Parameters:
b - true=enable, false=disable
Returns:
stage response string for error control

moveStageTo

public void moveStageTo(long x,
                        long y,
                        long z)
Move Stage to Absolute position x,y,z
Parameters:
x - absolute X position in micron
y - absolute Y position in micron
z - absolute Z position in micron

moveZAxisTo

public void moveZAxisTo(long z)
Move Z to Absolute position z
Parameters:
z - absolute Z position in micron

moveStageTo

public java.lang.String moveStageTo(long x,
                                    long y)
Move stage to absolute position x,y
Parameters:
x - absolute X position in micron
y - absolute Y position in micron
Returns:
string stage response

moveXYStep

public java.lang.String moveXYStep(java.lang.String command)
Move stage in the selected direction by the size defined in the step dim:
Parameters:
command - movement direction: StageCommands.MOVE_DOWN: move the stage a step down StageCommands.MOVE_UP: move the stage a step up StageCommands.MOVE_RIGHT:move the stage a step right StageCommands.MOVE_LEFT: move the stage a step left
Returns:
string stage response

moveZStep

public java.lang.String moveZStep(java.lang.String command)
Move Z axis by one step:
Parameters:
command - movement direction: StageCommands.MOVE_Z_UP move z up by one step StageCommands.MOVE_Z_DOWN move z down by one step
Returns:
string stage response

setAbsPos

public java.lang.String setAbsPos(int x,
                                  int y,
                                  int z)
Set current stage position to absolute position x,y,z.
Parameters:
x - new absolute X position (in micron) value for current X-Stage position
y - new absolute Y position (in micron) value for current Y-Stage position
z - new absolute Z position (in micron) value for current Z-Stage position
Returns:
string stage response

run

public void run()
Launch searchSetLimits method. serchSetLimits() have to run in async mode to give to the user the possibility of process stopping.
Specified by:
run in interface java.lang.Runnable

setStageSpeed

public void setStageSpeed(int speed)
Deprecated. No enougth information on stage protocol manual

Set stage speed.
Parameters:
speed - speed

getXYSpeed

public int getXYSpeed()
Get stage speed range.
Returns:
x,y stage speed range

setXYSpeed

public java.lang.String setXYSpeed(int speed)
Set stage XY-axis speed range. set X-Y Stage speed range
Parameters:
speed - speed
Returns:
stage response string for error control

getXYAcc

public int getXYAcc()
Return Stage XY acceleration.
Returns:
X-Y acceleration

setXYAcc

public java.lang.String setXYAcc(int acc)
Set stage X,Y-axis acceleration.
Parameters:
acc - X-Y acceleration
Returns:
stage response string for error control

getZSpeed

public int getZSpeed()
Get z axis speed range.
Returns:
Z stage speed range

setZSpeed

public java.lang.String setZSpeed(int speed)
Set stage Z-axis speed range. set Z Stage speed range
Parameters:
speed - new speed
Returns:
stage response string for error control

getZAcc

public int getZAcc()
Return Z axis acceleration.
Returns:
Z acceleration

setZAcc

public java.lang.String setZAcc(int acc)
Set stage Z-axis acceleration.
Parameters:
acc - new Z acceleration
Returns:
stage response string for error control

stopStage

public java.lang.String stopStage()
Stop the stage if is moving. To work this methos needs that stage is in "compatibility mode"
Returns:
return command response if the operation had success null otherwise

getMode

public int getMode()
Send a request to stage controller questioning about its mode: usually COMPATIBILITY or STANDARD. May be this method could be VERY different if stage serial protocol is changed (i.e. when you would drive another stage)
Returns:
mode (integer value)

setMode

public java.lang.String setMode(int m)
Send to the stage the request to swap in mode m
Parameters:
m - mode
Returns:
stage response: null if m is different from allowed values

getStatus

public int getStatus()
Get status of the stage. Only available in compatibility mode. See prior documentation for more informations
Returns:
code value of stage state.

setDialogToHide

public void setDialogToHide(java.awt.Dialog d)
Set the dialog to hide at the end of seachLimits methods
Parameters:
d - the dialog
See Also:
searchSetLimits