Table of Contents

Class: basicCCDCommand hwdriver/ccddrv.py

High-level Kappa-CCD PC driver

Base Classes   
anyhw.Driver
anyhw.SquareDetector
Methods   
Abort
ActiveCommand
BeamstopPosition
CheckScan
Cryo
Cryo600
Cryo700
Disconnect
GetAllowedCurrent
GetAllowedVoltage
GetCryo
GetGenerator
GetMastership
GetOmegaRange
GetOmegaRanges
GetPosition
GonZero
MakeScan
MicroscopeImage
MinimizeDx
PassiveCommand
PopupCommunications
PosHardAllowed
PosSoftAllowed
RawCommand
RouteAllowed
SetFilename
SetGenerator
SetIdleTask
SetImageSink
SetPosition
SetShutter
SetVideo
__init__
__repr__
handleexternalimage
  Abort 
Abort ( self )

Try to break running command on CCD controller

  ActiveCommand 
ActiveCommand (
        self,
        line,
        outsink=None,
        )

Send a command that actually moves or measures.

  BeamstopPosition 
BeamstopPosition ( self )

Return the beamstop DX.

The beamstop dx is the lowest value of dx that can be reached at theta=0 without the detector touching the beam stop.

  CheckScan 
CheckScan (
        self,
        numframes,
        phistep=0.0,
        dxstep=0.0,
        omegastep=0.0,
        kappastep=0.0,
        thetastep=0.0,
        )

Verify that a scan can be performed.

Parameters identical to MakeScan

  Cryo 
Cryo (
        self,
        speed=120,
        goal=298,
        wait=1,
        shutdown=0,
        autocryomove=0,
        outsink=None,
        )

Start a command on the cryostat.

optional parameters:

speed

the ramp speed in K/minute. The model 600 supports speeds up to 360K/minute. If higher speeds are requested, the 600 will do 360K/minute, while the model 700 will use a "COOL" command instead to go as fast as possible.

goal

the target temperature (K).

wait

if set to 1, the function will return when the final temperature is reached. If set to 0, it will return immediately.

shutdown

if set to 1, the cryostream will be shut down when the target temperature (normally 298) has been reached. A model 600 will then lose contact completely and it will no longer be able to turn it on.

autocryomove

if set to 1, the cryo movement option will be toggled automatically according to the target temperature.

Return value: 1 if the operation could be started, 0 if not.

  Cryo600 
Cryo600 (
        self,
        cr,
        speed,
        goal,
        wait,
        shutdown,
        autocryomove,
        )

Internal implementation of the Cryo() method for the model 600

  Cryo700 
Cryo700 (
        self,
        cr,
        speed,
        goal,
        wait,
        shutdown,
        autocryomove,
        )

Internal implementation of the Cryo() method for the model 700

  Disconnect 
Disconnect ( self )

Break the connection with the hardware.

After this no more commands can be sent, which makes the object as good as dead.

  GetAllowedCurrent 
GetAllowedCurrent ( self,  kv )

Give the range of allowed ma settings for a given kv.

If the Server does not support the retrieval of limits, a guess is made.

parameters:

kv

high voltage that you are planning to use.

Return value: a 2-tuple of the lowest and highest allowed mA settings at the requested kV setting.

Exceptions   
generatorerror( "Generator can not handle requested kV" )
generatorerror( "Generator communication problem in CheckGen" )
  GetAllowedVoltage 
GetAllowedVoltage ( self,  ma )

Give the range of allowed kv settings for a given ma.

If the Server does not support the retrieval of limits, a guess is made.

parameters:

ma

tube current that you are planning to use.

Return value: a 2-tuple of the lowest and highest allowed kV settings at the requested mA setting.

Exceptions   
generatorerror( "Generator can not handle requested mA" )
generatorerror( "Generator communication problem in CheckGen" )
  GetCryo 
GetCryo ( self )

Retrieve the status of the crystal cryostat.

The return value is a projtls.Record that always contains the "status" field. status==0 means there is no cryo device, or the one that is there is not connected or switched off. status==1 means that the cryo device can be queried, but no commands to set anything will be accepted. status==2 means that the cryo device is working on a previous command, but may be sent a new command. status==3 means that the cryo device is ready and listening.

Other attributes of the returned Record() are all optional, and the caller should check for their presence before using any of them:

movement

whether the goniostat has instructions to regularly move the crystal while there are no measurements going on. This is normally done at low temperature to avoid freezing of the goniometer head, the phi motor and icing of the crystal.

type

either 600 for a Model 600 or 700 for a model 700 cryostat from Oxford Cryosystems.

temperature

The current temperature at the crystal.

settemperature

The temperature the crystal is programmed to have at this moment.

finaltemperature

The end-point temperature of the current ramp operation.

ramprate

The speed at which temperature is being changed in K/minute.

operation

A string describing the currently active operation

minutes

The number of minutes until completion of the current operation.

Exceptions   
mastershiperror( "Need mastership to query cryostat" )
  GetGenerator 
GetGenerator ( self,  update=0 )

Ask interface for current generator settings.

optional parameters:

update

if set to 1, make sure that the data are current and not obtained from a cache.

return value: a projtls.Record(), with at present possibly two attributes: "x.ma" for the current, and "x.kv" for the voltage. If the generator is not remote addressable, these attributes are not present [test with hasattr(x,'ma')]

Exceptions   
generatorerror( "Cannot read generator" )
  GetMastership 
GetMastership ( self )

Try to get mastership over the CCD

No return value.

  GetOmegaRange 
GetOmegaRange ( self,  p )

Ask the ccd driver PC what omega range can be reached from p.

parameters:

p

position for which omega ranges are requested.

return value: None if the position can not be reached, or a 2-tuple (omegamin, omegamax) of possible values for omega.

  GetOmegaRanges 
GetOmegaRanges ( self,  p )

Ask the ccd driver PC what omega ranges can be reached.

parameters:

p

position for which omega ranges are requested. The omega of this position is not used for the demand.

return value: a list of 2-tuples (omegamin, omegamax) of possible ranges for omega. If the dx/theta/kappa combination is completely impossible the list will be empty. Currently it can contain up to 4 different ranges.

Exceptions   
error( "Incomplete position to GetOmegaRange" )
rangeerror( "Error message in range-question to server. Do you have mastership?" )
  GetPosition 
GetPosition ( self )

Ask interface for the current goniostat position

return value: Position() object encoding the current position of the goniostat.

Exceptions   
mastershiperror( "Need mastership for GetPosition" )
  GonZero 
GonZero ( self )

Take proper action to handle a lost position on the goniostat.

Depending on the gonzeroaction configuration variable, the goniostat is reset automatically or after asking a question, or an exception is raised.

Exceptions   
poslost( "Position lost" )
  MakeScan 
MakeScan (
        self,
        frametime,
        numframes=1,
        phistep=0.0,
        dxstep=0.0,
        omegastep=0.0,
        kappastep=0.0,
        thetastep=0.0,
        repeats=1,
        shutter=1,
        outsink=None,
        )

Perform a scan.

This will make measurements starting from the current goniostat position, stepping each motor by the given amount for the specified number of frames.

This routine will properly handle a lost goniometer position.

parameters:

frametime

the exposure time (in seconds) to be used for each frame.

optional parameters:

numframes

the number of images that should be made.

phistep

the phi movement (radians) during 1 image.

dxstep

the dx movement (radians) during 1 image.

omegastep

the omega movement (radians) during 1 image.

kappastep

the kappa movement (radians) during 1 image.

thetastep

the theta movement (radians) during 1 image.

repeats

the number of times each frame should be repeated to make an image. Normally 1 for double measurements.

shutter

shutter status during the measurements. 0=closed, 1=open.

outsink

a file-like object where a copy of the communications can be sent.

  MicroscopeImage 
MicroscopeImage ( self )

Get an image from the microscope pointing at the crystal.

If the hardware is completely free, this will first set the video microscope to a large size.

It will contact the microscope, and return a PIL image object containing the image.

If the operation fails for some reason (this may happen because someone else has a connection to the miscroscope, or because the microscope is not remote addressable) None is returned.

  MinimizeDx 
MinimizeDx (
        self,
        p,
        margin=0.1,
        )

Calculate the minimum dx for which p.With(dx=dx) is no collision.

Uses binary search to locate the minimum allowed dx for the specified precision.

parameters:

p

the desired position.

margin

the accuracy with which the minimal dx should be determined.

Return value: A new, adapted, Position() object.

  PassiveCommand 
PassiveCommand (
        self,
        line,
        outsink=None,
        )

Send a command that does not actively move anything.

  PopupCommunications 
PopupCommunications ( self )

Pop up a communication window (if supported).

If the text-output object has a "Show" method, call it (possibly popping up a window on the display, see Progress class....

No return value.

  PosHardAllowed 
PosHardAllowed ( self,  p )

Check whether a position can be reached on the goniostat.

This checks for collisions and obscuration. Since this involves communication to the server, it may take quite some time to complete.

parameter:

p

position

return value: false if there would be a collision or obscuration; true if the position is OK

Exceptions   
error( "Don't understand result of checkpos" )
error( "Goniometer busy" )
  PosSoftAllowed 
PosSoftAllowed ( self,  p )

Check whether a position is in principle allowed.

This does not check for collisions and obscuration (only bound checks for angles and distances). It is a quick pre check that is meant for internal use.

parameter:

p

position

return value: false if at least one of the parameters is out of bounds. true if all of the specified parameters are OK

  RawCommand 
RawCommand ( self,  line )

Send a single raw command encoded in the string line.

This will not do any interpretation of the resulting communication lines. If the command is a SCAN, the imagesink will be sent a FinalEnd when the command is finished.

This should normally not be used, except to handle input from the user into a GUI window

  RouteAllowed 
RouteAllowed (
        self,
        p1,
        p2,
        )

Check whether a scan from p1 to p2 is possible.

This checks the complete route from position p1 to position p2 for collisions and obscurations. This may take some time, since it involves communications to the server, and a lot of computations on the server computer.

Exceptions   
error( "Don't understand result of checkpos" )
  SetFilename 
SetFilename ( self,  filename )

Set filename for the first image in the next scan.

The extension .kcd will be added if no extension is specified.

parameter:

filename

filename

  SetGenerator 
SetGenerator (
        self,
        kv=None,
        ma=None,
        bias=None,
        outsink=None,
        )

Set generator settings.

Set the given kv and ma settings on the generator. If kv=0 and ma=0, switch off generator.

This will only work if the generator can be remotely controlled.

If the generator settings after this command do not correspond to the given settings, a generatorerror exception is raised.

optional parameters:

kv

high voltage (kV) to generate

ma

desired current (mA)

bias

desired bias voltage for RAG (units)

outsink

where textual output is to be sent immediately

No return value.

Exceptions   
generatorerror( "Generator cannot be properly set" )
  SetIdleTask 
SetIdleTask ( self,  idletask )

Tell the hardware object what to do when waiting for the connection to send data.

parameter:

idletask

callable function that will be executed while waiting. Should not take a long time to complete!

No return value.

  SetImageSink 
SetImageSink ( self,  imagesink )

Change the disposition of images coming from the hardware

  SetPosition 
SetPosition (
        self,
        p=None,
        outsink=None,
        )

Ask interface to set current goniometer position

optional parameters:

p

Position() object encoding the position to go to.

outsink

pseudofile where communications should be sent

This routine will properly handle a lost goniostat position.

  SetShutter 
SetShutter ( self,  shutter=0 )

  SetVideo 
SetVideo ( self,  size=None )

  __init__ 
__init__ (
        self,
        host,
        txtout=None,
        idletask=None,
        )

Constructor.

parameters:

host

hostname of PC controlling the Kappa-CCD

optional parameters:

txtout

file-like object that will receive a copy of the communications between us and the server.

Exceptions   
error( "Server closed connection" )
mastershiperror( "Mastership over system required to make connection" )
  __repr__ 
__repr__ ( self )

One-line object identification

  handleexternalimage 
handleexternalimage (
        self,
        filename,
        saveid,
        )


Table of Contents

This document was automatically generated on Fri Jul 3 09:28:36 2009 by HappyDoc version WORKING