Skip to content
Snippets Groups Projects
Commit 659021e5 authored by Roberto Borghes's avatar Roberto Borghes
Browse files

From CVS repository

parent 1074cc75
No related branches found
Tags 1.0.0
No related merge requests found
#!/usr/bin/env python
# -*- coding:utf-8 -*-
##############################################################################
## license :
##============================================================================
##
## File : PilatusXM.py
##
## Project : Interface class for the Pilatus detectors
##
## This file is part of Tango device class.
##
## Tango is free software: you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation, either version 3 of the License, or
## (at your option) any later version.
##
## Tango is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with Tango. If not, see <http://www.gnu.org/licenses/>.
##
##
## $Author : sci.comp$
##
## $Revision : $
##
## $Date : $
##
## $HeadUrl : $
##============================================================================
## This file is generated by POGO
## (Program Obviously used to Generate tango Object)
##
## (c) - Software Engineering Group - ESRF
##############################################################################
"""Pilatus detectors are a series pixel detecors build by DECTRIS
<br />
http://www.dectris.com.
<br />
All detectors of this series can talk to the outside world via a socket
connection. An ASCI protocol is used on this sockect connection to
communicate with the detector.
<p>
The server process which handles the socket on the detecor PC is
called camserver. Only one client can commumicate with camserver.
If the native client tvx is connected, the device server cannot connect until
tvx gets disconnected.
</p>"""
__all__ = ["PilatusXM", "PilatusXMClass", "main"]
__docformat__ = 'restructuredtext'
import PyTango
import sys
# Add additional import
#----- PROTECTED REGION ID(PilatusXM.additionnal_import) ENABLED START -----#
import socket
import traceback
import time
import os
END_MESSAGE = chr(0x18)
DBUG = False
class CommunicationClass():
def __init__(self, ipaddr_in):
self.ipaddr_in = ipaddr_in
self.socket = None
self._stop = False
self.connect()
def disconnect(self):
try:
if self.socket is not None:
self.socket.close()
except:
self.socket = None
def connect(self):
try:
if self.socket is not None:
self.socket.close()
except:
self.socket = None
self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.socket.settimeout(0.1)
port = 41234
host = self.ipaddr_in
try:
self.socket.connect((host,port))
except:
self.socket = None
def send_to_detector(self, msg, wait_reply = True):
# check state, Pilatus won't responde if it's RUNNING
# only STOP command can be sent in this case
self.socket.sendall(msg + END_MESSAGE)
t0 = time.time()
if DBUG:
print "Sent", msg
if not wait_reply:
return
if "CamSetup" in msg:
mandatory_code = "2 OK"
else:
mandatory_code = ""
try:
reply = self.get_detector_reply(timeout = 2, wait_string = mandatory_code)
except:
reply = ''
if reply is None:
self.disconnect()
return None
return reply.split(END_MESSAGE)[0]
def get_detector_reply(self, timeout = 2, wait_string = ''):
t0 = time.time()
reply = ''
while (END_MESSAGE not in reply) or (wait_string not in reply):
if (time.time() - t0) > timeout:
break
tmpreply = self.socket.recv(1024).strip()
reply += tmpreply
if DBUG:
print "Received", reply
if END_MESSAGE not in reply:
reply = None
return reply
class fakeAttr():
def __init__(self):
self.value = None
def set_value(self,value_in):
self.value = value_in
def get_write_value(self):
return value
#----- PROTECTED REGION END -----# // PilatusXM.additionnal_import
## Device States Description
## ON : The detecor is ready to take images.
## DISABLE : The device is disconnected from the camserver.
## RUNNING : An acquisition is running.
## FAULT : An error occured on the detector during an acquisition.
## Confirm with a Reset command or execute the next command.
class PilatusXM (PyTango.Device_4Impl):
#--------- Add you global variables here --------------------------
#----- PROTECTED REGION ID(PilatusXM.global_variables) ENABLED START -----#
#----- PROTECTED REGION END -----# // PilatusXM.global_variables
def __init__(self,cl, name):
PyTango.Device_4Impl.__init__(self,cl,name)
self.debug_stream("In __init__()")
PilatusXM.init_device(self)
#----- PROTECTED REGION ID(PilatusXM.__init__) ENABLED START -----#
#----- PROTECTED REGION END -----# // PilatusXM.__init__
def delete_device(self):
self.debug_stream("In delete_device()")
#----- PROTECTED REGION ID(PilatusXM.delete_device) ENABLED START -----#
#----- PROTECTED REGION END -----# // PilatusXM.delete_device
def init_device(self):
self.debug_stream("In init_device()")
self.get_device_properties(self.get_device_class())
self.attr_ExposureTime_read = 0.0
self.attr_ExposurePeriod_read = 0.0
self.attr_NbFrames_read = 0
self.attr_NbExposures_read = 0
self.attr_DelayTime_read = 0.0
self.attr_ShutterEnable_read = False
self.attr_TriggerMode_read = 0
self.attr_UseRamDisk_read = False
self.attr_FileDir_read = ''
self.attr_FilePrefix_read = ''
self.attr_FileStartNum_read = 0
self.attr_FilePostfix_read = ''
self.attr_LastImageTaken_read = ''
self.attr_Energy_read = 0
self.attr_Threshold_read = 0
self.attr_Gain_read = 0
self.attr_LastImagePath_read = ''
self.attr_MxSettings_read = ''
self.attr_GapFill_read = 0
self.attr_LdBadPixMap_read = ''
#----- PROTECTED REGION ID(PilatusXM.init_device) ENABLED START -----#
self.attr_FilePrefix_read = 'test'
self.attr_FilePostfix_read = '.tif'
self.attr_FileStartNum_read = 0
self.comm = CommunicationClass(self.ServerAddress)
self.set_state(PyTango.DevState.ON)
#----- PROTECTED REGION END -----# // PilatusXM.init_device
def always_executed_hook(self):
self.debug_stream("In always_excuted_hook()")
#----- PROTECTED REGION ID(PilatusXM.always_executed_hook) ENABLED START -----#
if self.get_state() == PyTango.DevState.RUNNING:
try:
det_msg = self.comm.get_detector_reply(timeout=0.1)
except:
# Pilatus does not reply when acquiring
# Let's stay RUNNING
return
cmd = "CamSetup"
reply = self.comm.send_to_detector(cmd)
if reply is None:
PyTango.Except.throw_exception("Communication error","Pilatus does not reply","always_executed_hook")
for token in reply.split("\n"):
if "Camera state:" in token:
if 'idle' in token:
self.set_state(PyTango.DevState.ON)
else:
self.set_state(PyTango.DevState.RUNNING)
elif "Last image: " in token:
self.attr_LastImageTaken_read = token.split("Last image: ")[-1]
self.attr_LastImagePath_read = os.path.dirname(self.attr_LastImageTaken_read)
#----- PROTECTED REGION END -----# // PilatusXM.always_executed_hook
#-----------------------------------------------------------------------------
# PilatusXM read/write attribute methods
#-----------------------------------------------------------------------------
def read_ExposureTime(self, attr):
self.debug_stream("In read_ExposureTime()")
#----- PROTECTED REGION ID(PilatusXM.ExposureTime_read) ENABLED START -----#
cmd = "exptime"
reply_cmd = "Exposure time set to: "
reply = self.comm.send_to_detector(cmd)
if reply is None:
PyTango.Except.throw_exception("Communication error","Pilatus does not reply","read_ExposureTime")
elif reply_cmd in reply:
self.attr_ExposureTime_read = float((reply.split(reply_cmd)[-1]).split(" ")[0])
else:
PyTango.Except.throw_exception("Communication error","Pilatus wrong reply","read_ExposureTime")
attr.set_value(self.attr_ExposureTime_read)
#----- PROTECTED REGION END -----# // PilatusXM.ExposureTime_read
def write_ExposureTime(self, attr):
self.debug_stream("In write_ExposureTime()")
data=attr.get_write_value()
#----- PROTECTED REGION ID(PilatusXM.ExposureTime_write) ENABLED START -----#
cmd = "exptime %g" % data
reply = self.comm.send_to_detector(cmd)
if reply is None:
PyTango.Except.throw_exception("Communication error","Pilatus does not reply","write_ExposureTime")
elif "ERR" in reply:
PyTango.Except.throw_exception("Command error","Pilatus reply: %s" % reply,"write_ExposureTime")
#----- PROTECTED REGION END -----# // PilatusXM.ExposureTime_write
def read_ExposurePeriod(self, attr):
self.debug_stream("In read_ExposurePeriod()")
#----- PROTECTED REGION ID(PilatusXM.ExposurePeriod_read) ENABLED START -----#
cmd = "expperiod"
reply_cmd = "Exposure period set to: "
reply = self.comm.send_to_detector(cmd)
if reply is None:
PyTango.Except.throw_exception("Communication error","Pilatus does not reply","read_ExposurePeriod")
elif reply_cmd in reply:
self.attr_ExposurePeriod_read = float((reply.split(reply_cmd)[-1]).split(" ")[0])
else:
PyTango.Except.throw_exception("Communication error","Pilatus wrong reply","read_ExposurePeriod")
attr.set_value(self.attr_ExposurePeriod_read)
#----- PROTECTED REGION END -----# // PilatusXM.ExposurePeriod_read
def write_ExposurePeriod(self, attr):
self.debug_stream("In write_ExposurePeriod()")
data=attr.get_write_value()
#----- PROTECTED REGION ID(PilatusXM.ExposurePeriod_write) ENABLED START -----#
cmd = "expperiod %g" % data
reply = self.comm.send_to_detector(cmd)
if reply is None:
PyTango.Except.throw_exception("Communication error","Pilatus does not reply","write_ExposurePeriod")
elif "ERR" in reply:
PyTango.Except.throw_exception("Command error","Pilatus reply: %s" % reply,"write_ExposurePeriod")
#----- PROTECTED REGION END -----# // PilatusXM.ExposurePeriod_write
def read_NbFrames(self, attr):
self.debug_stream("In read_NbFrames()")
#----- PROTECTED REGION ID(PilatusXM.NbFrames_read) ENABLED START -----#
cmd = "nimages"
reply_cmd = "N images set to: "
reply = self.comm.send_to_detector(cmd)
if reply is None:
PyTango.Except.throw_exception("Communication error","Pilatus does not reply","read_NbFrames")
elif reply_cmd in reply:
self.attr_NbFrames_read = int((reply.split(reply_cmd)[-1]).split(" ")[0])
else:
PyTango.Except.throw_exception("Communication error","Pilatus wrong reply","read_NbFrames")
attr.set_value(self.attr_NbFrames_read)
#----- PROTECTED REGION END -----# // PilatusXM.NbFrames_read
def write_NbFrames(self, attr):
self.debug_stream("In write_NbFrames()")
data=attr.get_write_value()
#----- PROTECTED REGION ID(PilatusXM.NbFrames_write) ENABLED START -----#
cmd = "nimages %d" % data
reply = self.comm.send_to_detector(cmd)
if reply is None:
PyTango.Except.throw_exception("Communication error","Pilatus does not reply","write_NbFrames")
elif "ERR" in reply:
PyTango.Except.throw_exception("Command error","Pilatus reply: %s" % reply,"write_NbFrames")
#----- PROTECTED REGION END -----# // PilatusXM.NbFrames_write
def read_NbExposures(self, attr):
self.debug_stream("In read_NbExposures()")
#----- PROTECTED REGION ID(PilatusXM.NbExposures_read) ENABLED START -----#
cmd = "nexpframe"
reply_cmd = "Exposures per frame set to: "
reply = self.comm.send_to_detector(cmd)
if reply is None:
PyTango.Except.throw_exception("Communication error","Pilatus does not reply","read_NbExposures")
elif reply_cmd in reply:
self.attr_NbExposures_read = int((reply.split(reply_cmd)[-1]).split(" ")[0])
else:
PyTango.Except.throw_exception("Communication error","Pilatus wrong reply","read_NbExposures")
attr.set_value(self.attr_NbExposures_read)
#----- PROTECTED REGION END -----# // PilatusXM.NbExposures_read
def write_NbExposures(self, attr):
self.debug_stream("In write_NbExposures()")
data=attr.get_write_value()
#----- PROTECTED REGION ID(PilatusXM.NbExposures_write) ENABLED START -----#
cmd = "nexpframe %d" % data
reply = self.comm.send_to_detector(cmd)
if reply is None:
PyTango.Except.throw_exception("Communication error","Pilatus does not reply","write_NbExposures")
elif "ERR" in reply:
PyTango.Except.throw_exception("Command error","Pilatus reply: %s" % reply,"write_NbExposures")
#----- PROTECTED REGION END -----# // PilatusXM.NbExposures_write
def read_DelayTime(self, attr):
self.debug_stream("In read_DelayTime()")
#----- PROTECTED REGION ID(PilatusXM.DelayTime_read) ENABLED START -----#
cmd = "delay"
reply_cmd = "Delay time set to: "
reply = self.comm.send_to_detector(cmd)
if reply is None:
PyTango.Except.throw_exception("Communication error","Pilatus does not reply","read_DelayTime")
elif reply_cmd in reply:
self.attr_DelayTime_read = float((reply.split(reply_cmd)[-1]).split(" ")[0])
else:
PyTango.Except.throw_exception("Communication error","Pilatus wrong reply","read_DelayTime")
attr.set_value(self.attr_DelayTime_read)
#----- PROTECTED REGION END -----# // PilatusXM.DelayTime_read
def write_DelayTime(self, attr):
self.debug_stream("In write_DelayTime()")
data=attr.get_write_value()
#----- PROTECTED REGION ID(PilatusXM.DelayTime_write) ENABLED START -----#
cmd = "delay %g" % data
reply = self.comm.send_to_detector(cmd)
if reply is None:
PyTango.Except.throw_exception("Communication error","Pilatus does not reply","write_DelayTime")
elif "ERR" in reply:
PyTango.Except.throw_exception("Command error","Pilatus reply: %s" % reply,"write_DelayTime")
#----- PROTECTED REGION END -----# // PilatusXM.DelayTime_write
def read_ShutterEnable(self, attr):
self.debug_stream("In read_ShutterEnable()")
#----- PROTECTED REGION ID(PilatusXM.ShutterEnable_read) ENABLED START -----#
attr.set_value(self.attr_ShutterEnable_read)
#----- PROTECTED REGION END -----# // PilatusXM.ShutterEnable_read
def write_ShutterEnable(self, attr):
self.debug_stream("In write_ShutterEnable()")
data=attr.get_write_value()
#----- PROTECTED REGION ID(PilatusXM.ShutterEnable_write) ENABLED START -----#
cmd = "ShutterEnable %g" % int(data)
reply = self.comm.send_to_detector(cmd)
if reply is None:
PyTango.Except.throw_exception("Communication error","Pilatus does not reply","write_ShutterEnable")
elif "ERR" in reply:
PyTango.Except.throw_exception("Command error","Pilatus reply: %s" % reply,"write_ShutterEnable")
self.attr_ShutterEnable_read = data
#----- PROTECTED REGION END -----# // PilatusXM.ShutterEnable_write
def read_TriggerMode(self, attr):
self.debug_stream("In read_TriggerMode()")
#----- PROTECTED REGION ID(PilatusXM.TriggerMode_read) ENABLED START -----#
attr.set_value(self.attr_TriggerMode_read)
#----- PROTECTED REGION END -----# // PilatusXM.TriggerMode_read
def write_TriggerMode(self, attr):
self.debug_stream("In write_TriggerMode()")
data=attr.get_write_value()
#----- PROTECTED REGION ID(PilatusXM.TriggerMode_write) ENABLED START -----#
self.attr_TriggerMode_read = data
#----- PROTECTED REGION END -----# // PilatusXM.TriggerMode_write
def read_UseRamDisk(self, attr):
self.debug_stream("In read_UseRamDisk()")
#----- PROTECTED REGION ID(PilatusXM.UseRamDisk_read) ENABLED START -----#
attr.set_value(self.attr_UseRamDisk_read)
#----- PROTECTED REGION END -----# // PilatusXM.UseRamDisk_read
def write_UseRamDisk(self, attr):
self.debug_stream("In write_UseRamDisk()")
data=attr.get_write_value()
#----- PROTECTED REGION ID(PilatusXM.UseRamDisk_write) ENABLED START -----#
#----- PROTECTED REGION END -----# // PilatusXM.UseRamDisk_write
def read_FileDir(self, attr):
self.debug_stream("In read_FileDir()")
#----- PROTECTED REGION ID(PilatusXM.FileDir_read) ENABLED START -----#
cmd = "imgpath"
reply_cmd = "OK "
reply = self.comm.send_to_detector(cmd)
if reply is None:
PyTango.Except.throw_exception("Communication error","Pilatus does not reply","read_FileDir")
elif reply_cmd in reply:
self.attr_FileDir_read = (reply.split(reply_cmd)[-1]).split(" ")[0]
else:
PyTango.Except.throw_exception("Communication error","Pilatus wrong reply","read_FileDir")
attr.set_value(self.attr_FileDir_read)
#----- PROTECTED REGION END -----# // PilatusXM.FileDir_read
def write_FileDir(self, attr):
self.debug_stream("In write_FileDir()")
data=attr.get_write_value()
#----- PROTECTED REGION ID(PilatusXM.FileDir_write) ENABLED START -----#
cmd = "imgpath %s" % (data)
reply = self.comm.send_to_detector(cmd)
if reply is None:
PyTango.Except.throw_exception("Communication error","Pilatus does not reply","write_FileDir")
elif "ERR" in reply:
PyTango.Except.throw_exception("Command error","Pilatus reply: %s" % reply,"write_FileDir")
#----- PROTECTED REGION END -----# // PilatusXM.FileDir_write
def read_FilePrefix(self, attr):
self.debug_stream("In read_FilePrefix()")
#----- PROTECTED REGION ID(PilatusXM.FilePrefix_read) ENABLED START -----#
attr.set_value(self.attr_FilePrefix_read)
#----- PROTECTED REGION END -----# // PilatusXM.FilePrefix_read
def write_FilePrefix(self, attr):
self.debug_stream("In write_FilePrefix()")
data=attr.get_write_value()
#----- PROTECTED REGION ID(PilatusXM.FilePrefix_write) ENABLED START -----#
self.attr_FilePrefix_read = data
if len(data) and not data.endswith("_"):
self.attr_FilePrefix_read += "_"
#----- PROTECTED REGION END -----# // PilatusXM.FilePrefix_write
def read_FileStartNum(self, attr):
self.debug_stream("In read_FileStartNum()")
#----- PROTECTED REGION ID(PilatusXM.FileStartNum_read) ENABLED START -----#
attr.set_value(self.attr_FileStartNum_read)
#----- PROTECTED REGION END -----# // PilatusXM.FileStartNum_read
def write_FileStartNum(self, attr):
self.debug_stream("In write_FileStartNum()")
data=attr.get_write_value()
#----- PROTECTED REGION ID(PilatusXM.FileStartNum_write) ENABLED START -----#
self.attr_FileStartNum_read = data
#----- PROTECTED REGION END -----# // PilatusXM.FileStartNum_write
def read_FilePostfix(self, attr):
self.debug_stream("In read_FilePostfix()")
#----- PROTECTED REGION ID(PilatusXM.FilePostfix_read) ENABLED START -----#
attr.set_value(self.attr_FilePostfix_read)
#----- PROTECTED REGION END -----# // PilatusXM.FilePostfix_read
def write_FilePostfix(self, attr):
self.debug_stream("In write_FilePostfix()")
data=attr.get_write_value()
#----- PROTECTED REGION ID(PilatusXM.FilePostfix_write) ENABLED START -----#
allowed_ext = ['tif','edf','img','cbf']
for item in allowed_ext:
if item in data:
self.attr_FilePostfix_read = ".%s" % item
return
PyTango.Except.throw_exception("Command error","Unknown Pilatus postfix (.tif, .edf, .img, .cbf)","write_FilePostfix")
#----- PROTECTED REGION END -----# // PilatusXM.FilePostfix_write
def read_LastImageTaken(self, attr):
self.debug_stream("In read_LastImageTaken()")
#----- PROTECTED REGION ID(PilatusXM.LastImageTaken_read) ENABLED START -----#
attr.set_value(self.attr_LastImageTaken_read)
#----- PROTECTED REGION END -----# // PilatusXM.LastImageTaken_read
def read_Energy(self, attr):
self.debug_stream("In read_Energy()")
#----- PROTECTED REGION ID(PilatusXM.Energy_read) ENABLED START -----#
attr.set_value(self.attr_Energy_read)
#----- PROTECTED REGION END -----# // PilatusXM.Energy_read
def write_Energy(self, attr):
self.debug_stream("In write_Energy()")
data=attr.get_write_value()
#----- PROTECTED REGION ID(PilatusXM.Energy_write) ENABLED START -----#
#----- PROTECTED REGION END -----# // PilatusXM.Energy_write
def read_Threshold(self, attr):
self.debug_stream("In read_Threshold()")
#----- PROTECTED REGION ID(PilatusXM.Threshold_read) ENABLED START -----#
cmd = "SetThreshold"
reply_cmd = "threshold: "
reply = self.comm.send_to_detector(cmd)
if reply is None:
PyTango.Except.throw_exception("Communication error","Pilatus does not reply","read_Threshold")
elif reply_cmd in reply:
self.attr_Threshold_read = int((reply.split(reply_cmd)[-1]).split(" ")[0])
elif "Threshold has not been set" in reply:
PyTango.Except.throw_exception("Pilatus error","Threshold has not been set","read_Threshold")
else:
PyTango.Except.throw_exception("Communication error","Pilatus wrong reply","read_Threshold")
attr.set_value(self.attr_Threshold_read)
#----- PROTECTED REGION END -----# // PilatusXM.Threshold_read
def write_Threshold(self, attr):
self.debug_stream("In write_Threshold()")
data=attr.get_write_value()
#----- PROTECTED REGION ID(PilatusXM.Threshold_write) ENABLED START -----#
#
# read the actual threshold and send command only if necessary
#
cmd = "SetThreshold"
reply_cmd = "threshold: "
reply = self.comm.send_to_detector(cmd)
if reply is None:
PyTango.Except.throw_exception("Communication error","Pilatus does not reply","write_Threshold")
elif reply_cmd in reply:
self.attr_Threshold_read = int((reply.split(reply_cmd)[-1]).split(" ")[0])
elif "Threshold has not been set" in reply:
self.attr_Threshold_read = None
else:
PyTango.Except.throw_exception("Communication error","Pilatus wrong reply","write_Threshold")
if self.attr_Threshold_read == data:
return
cmd = "SetThreshold %d" % data
reply = self.comm.send_to_detector(cmd)
if reply is None:
PyTango.Except.throw_exception("Communication error","Pilatus does not reply","write_Threshold")
elif "ERR" in reply:
PyTango.Except.throw_exception("Command error","Pilatus reply: %s" % reply,"write_Threshold")
#----- PROTECTED REGION END -----# // PilatusXM.Threshold_write
def read_Gain(self, attr):
self.debug_stream("In read_Gain()")
#----- PROTECTED REGION ID(PilatusXM.Gain_read) ENABLED START -----#
cmd = "SetThreshold"
reply_cmd = "Settings: "
reply = self.comm.send_to_detector(cmd)
if reply is None:
PyTango.Except.throw_exception("Communication error","Pilatus does not reply","read_Gain")
elif reply_cmd in reply:
gainstr = ((reply.split(reply_cmd)[-1]).split(";")[0])
if "mid gain" in gainstr:
self.attr_Gain_read = 1
elif "low gain" in gainstr:
self.attr_Gain_read = 0
elif "high gain" in gainstr:
self.attr_Gain_read = 2
elif "ultra high gain" in gainstr:
self.attr_Gain_read = 3
else:
PyTango.Except.throw_exception("Communication error","Pilatus wrong reply","read_Gain")
attr.set_value(self.attr_Gain_read)
#----- PROTECTED REGION END -----# // PilatusXM.Gain_read
def write_Gain(self, attr):
self.debug_stream("In write_Gain()")
data=attr.get_write_value()
#----- PROTECTED REGION ID(PilatusXM.Gain_write) ENABLED START -----#
gains = {0:"low6", 1:"midG", 2:"highG", 3:"uhighG"}
if data not in gains:
PyTango.Except.throw_exception("Command error","Invalid gain value!","write_Gain")
# read the actual gain and send command only if necessary
cmd = "SetThreshold"
reply_cmd = "Settings: "
reply = self.comm.send_to_detector(cmd)
if reply is None:
PyTango.Except.throw_exception("Communication error","Pilatus does not reply","write_Gain")
elif reply_cmd in reply:
gainstr = ((reply.split(reply_cmd)[-1]).split(";")[0])
if "mid gain" in gainstr:
self.attr_Gain_read = 1
elif "low gain" in gainstr:
self.attr_Gain_read = 0
elif "high gain" in gainstr:
self.attr_Gain_read = 2
elif "ultra high gain" in gainstr:
self.attr_Gain_read = 3
else:
PyTango.Except.throw_exception("Communication error","Pilatus wrong reply","write_Gain")
if self.attr_Gain_read == data:
return
cmd = "SetThreshold single %d" % gains[data]
reply = self.comm.send_to_detector(cmd)
if reply is None:
PyTango.Except.throw_exception("Communication error","Pilatus does not reply","write_Gain")
elif "ERR" in reply:
PyTango.Except.throw_exception("Command error","Pilatus reply: %s" % reply,"write_Gain")
#----- PROTECTED REGION END -----# // PilatusXM.Gain_write
def read_LastImagePath(self, attr):
self.debug_stream("In read_LastImagePath()")
#----- PROTECTED REGION ID(PilatusXM.LastImagePath_read) ENABLED START -----#
attr.set_value(self.attr_LastImagePath_read)
#----- PROTECTED REGION END -----# // PilatusXM.LastImagePath_read
def read_MxSettings(self, attr):
self.debug_stream("In read_MxSettings()")
#----- PROTECTED REGION ID(PilatusXM.MxSettings_read) ENABLED START -----#
cmd = "mxsettings"
reply_cmd = "OK "
reply = self.comm.send_to_detector(cmd)
if reply is None:
PyTango.Except.throw_exception("Communication error","Pilatus does not reply","read_MxSettings")
elif reply_cmd in reply:
self.attr_MxSettings_read = (reply.split(reply_cmd)[-1]).strip()
else:
PyTango.Except.throw_exception("Communication error","Pilatus wrong reply","read_MxSettings")
attr.set_value(self.attr_MxSettings_read)
#----- PROTECTED REGION END -----# // PilatusXM.MxSettings_read
def write_MxSettings(self, attr):
self.debug_stream("In write_MxSettings()")
data=attr.get_write_value()
#----- PROTECTED REGION ID(PilatusXM.MxSettings_write) ENABLED START -----#
cmd = "mxsettings %s" % (data)
reply = self.comm.send_to_detector(cmd)
if reply is None:
PyTango.Except.throw_exception("Communication error","Pilatus does not reply","write_MxSettings")
elif "ERR" in reply:
PyTango.Except.throw_exception("Command error","Pilatus reply: %s" % reply,"write_MxSettings")
#----- PROTECTED REGION END -----# // PilatusXM.MxSettings_write
def read_GapFill(self, attr):
self.debug_stream("In read_GapFill()")
#----- PROTECTED REGION ID(PilatusXM.GapFill_read) ENABLED START -----#
cmd = "gapfill"
reply_cmd = "Detector gap-fill is: "
reply = self.comm.send_to_detector(cmd)
if reply is None:
PyTango.Except.throw_exception("Communication error","Pilatus does not reply","read_GapFill")
elif reply_cmd in reply:
self.attr_GapFill_read = int((reply.split(reply_cmd)[-1]).strip())
else:
PyTango.Except.throw_exception("Communication error","Pilatus wrong reply","read_GapFill")
attr.set_value(self.attr_GapFill_read)
#----- PROTECTED REGION END -----# // PilatusXM.GapFill_read
def write_GapFill(self, attr):
self.debug_stream("In write_GapFill()")
data=attr.get_write_value()
#----- PROTECTED REGION ID(PilatusXM.GapFill_write) ENABLED START -----#
cmd = "gapfill %d" % (data)
reply = self.comm.send_to_detector(cmd)
if reply is None:
PyTango.Except.throw_exception("Communication error","Pilatus does not reply","write_GapFill")
elif "ERR" in reply:
PyTango.Except.throw_exception("Command error","Pilatus reply: %s" % reply,"write_GapFill")
#----- PROTECTED REGION END -----# // PilatusXM.GapFill_write
def read_LdBadPixMap(self, attr):
self.debug_stream("In read_LdBadPixMap()")
#----- PROTECTED REGION ID(PilatusXM.LdBadPixMap_read) ENABLED START -----#
cmd = "ldbadpixmap"
reply_cmd = "Bad pixels loaded from"
reply = self.comm.send_to_detector(cmd)
if reply is None:
PyTango.Except.throw_exception("Communication error","Pilatus does not reply","read_LdBadPixMap")
elif reply_cmd in reply:
self.attr_LdBadPixMap_read = ((reply.split(reply_cmd)[-1]).strip())
else:
PyTango.Except.throw_exception("Communication error","Pilatus wrong reply","read_LdBadPixMap")
attr.set_value(self.attr_LdBadPixMap_read)
#----- PROTECTED REGION END -----# // PilatusXM.LdBadPixMap_read
def write_LdBadPixMap(self, attr):
self.debug_stream("In write_LdBadPixMap()")
data=attr.get_write_value()
#----- PROTECTED REGION ID(PilatusXM.LdBadPixMap_write) ENABLED START -----#
cmd = "ldbadpixmap %s" % (data)
reply = self.comm.send_to_detector(cmd)
if reply is None:
PyTango.Except.throw_exception("Communication error","Pilatus does not reply","write_LdBadPixMap")
elif "ERR" in reply:
PyTango.Except.throw_exception("Command error","Pilatus reply: %s" % reply,"write_LdBadPixMap")
#----- PROTECTED REGION END -----# // PilatusXM.LdBadPixMap_write
#----- PROTECTED REGION ID(PilatusXM.initialize_dynamic_attributes) ENABLED START -----#
#----- PROTECTED REGION END -----# // PilatusXM.initialize_dynamic_attributes
def read_attr_hardware(self, data):
self.debug_stream("In read_attr_hardware()")
#----- PROTECTED REGION ID(PilatusXM.read_attr_hardware) ENABLED START -----#
#----- PROTECTED REGION END -----# // PilatusXM.read_attr_hardware
#-----------------------------------------------------------------------------
# PilatusXM command methods
#-----------------------------------------------------------------------------
def StartStandardAcq(self):
""" Start an acquisition with the propositioned parameters
:param :
:type: PyTango.DevVoid
:return:
:rtype: PyTango.DevVoid """
self.debug_stream("In StartStandardAcq()")
#----- PROTECTED REGION ID(PilatusXM.StartStandardAcq) ENABLED START -----#
expPeriodAttr = fakeAttr()
self.read_ExposurePeriod(expPeriodAttr)
expTimeAttr = fakeAttr()
self.read_ExposureTime(expTimeAttr)
if (expPeriodAttr.value < (expTimeAttr.value + 0.003) ):
expPeriodAttr.set_value(expTimeAttr.value + 0.003)
self.write_ExposurePeriod(expPeriodAttr)
fullname = "%s%05d%s" % (self.attr_FilePrefix_read,self.attr_FileStartNum_read,self.attr_FilePostfix_read)
trgModes = {0:"exposure", 1:"extenable",2:"exttrigger",3:"extmtrigger"}
#
self.attr_LastImageTaken_read = ''
self.attr_LastImagePath_read = ''
cmd = trgModes[self.attr_TriggerMode_read] +" "+fullname
reply = self.comm.send_to_detector(cmd)
if reply is None:
PyTango.Except.throw_exception("Communication error","Pilatus does not reply","StartStandardAcq")
elif "ERR" in reply:
PyTango.Except.throw_exception("Command error","Pilatus reply: %s" % reply,"StartStandardAcq")
elif "15 OK Starting" in reply:
self.set_state(PyTango.DevState.RUNNING)
#----- PROTECTED REGION END -----# // PilatusXM.StartStandardAcq
def is_StartStandardAcq_allowed(self):
self.debug_stream("In is_StartStandardAcq_allowed()")
state_ok = not(self.get_state() in [PyTango.DevState.DISABLE,
PyTango.DevState.RUNNING,
PyTango.DevState.FAULT])
#----- PROTECTED REGION ID(PilatusXM.is_StartStandardAcq_allowed) ENABLED START -----#
#----- PROTECTED REGION END -----# // PilatusXM.is_StartStandardAcq_allowed
return state_ok
def StopAcq(self):
""" Stop the acquisition. This works only for multi images acquisitions.
A single image acquisition will always finish.
:param :
:type: PyTango.DevVoid
:return:
:rtype: PyTango.DevVoid """
self.debug_stream("In StopAcq()")
#----- PROTECTED REGION ID(PilatusXM.StopAcq) ENABLED START -----#
cmd = "camcmd k"
reply = self.comm.send_to_detector(cmd, wait_reply = False)
#----- PROTECTED REGION END -----# // PilatusXM.StopAcq
def is_StopAcq_allowed(self):
self.debug_stream("In is_StopAcq_allowed()")
state_ok = not(self.get_state() in [PyTango.DevState.DISABLE,
PyTango.DevState.FAULT])
#----- PROTECTED REGION ID(PilatusXM.is_StopAcq_allowed) ENABLED START -----#
#----- PROTECTED REGION END -----# // PilatusXM.is_StopAcq_allowed
return state_ok
def Reset(self):
""" Reset a state
:param :
:type: PyTango.DevVoid
:return:
:rtype: PyTango.DevVoid """
self.debug_stream("In Reset()")
#----- PROTECTED REGION ID(PilatusXM.Reset) ENABLED START -----#
self.StopAcq()
#----- PROTECTED REGION END -----# // PilatusXM.Reset
class PilatusXMClass(PyTango.DeviceClass):
#--------- Add you global class variables here --------------------------
#----- PROTECTED REGION ID(PilatusXM.global_class_variables) ENABLED START -----#
#----- PROTECTED REGION END -----# // PilatusXM.global_class_variables
def dyn_attr(self, dev_list):
"""Invoked to create dynamic attributes for the given devices.
Default implementation calls
:meth:`PilatusXM.initialize_dynamic_attributes` for each device
:param dev_list: list of devices
:type dev_list: :class:`PyTango.DeviceImpl`"""
for dev in dev_list:
try:
dev.initialize_dynamic_attributes()
except:
import traceback
dev.warn_stream("Failed to initialize dynamic attributes")
dev.debug_stream("Details: " + traceback.format_exc())
#----- PROTECTED REGION ID(PilatusXM.dyn_attr) ENABLED START -----#
#----- PROTECTED REGION END -----# // PilatusXM.dyn_attr
# Class Properties
class_property_list = {
}
# Device Properties
device_property_list = {
'ServerAddress':
[PyTango.DevString,
"The IP address of the PilatusXM camserver.",
[] ],
}
# Command definitions
cmd_list = {
'StartStandardAcq':
[[PyTango.DevVoid, "none"],
[PyTango.DevVoid, "none"]],
'StopAcq':
[[PyTango.DevVoid, "none"],
[PyTango.DevVoid, "none"]],
'Reset':
[[PyTango.DevVoid, "none"],
[PyTango.DevVoid, "none"]],
}
# Attribute definitions
attr_list = {
'ExposureTime':
[[PyTango.DevDouble,
PyTango.SCALAR,
PyTango.READ_WRITE],
{
'label': "Exposure Time",
'unit': "s",
'format': "%10.8f",
'min value': "0",
'description': "The exposure time for the detector.\nIn the External Enable mode this value is not used by camserver.",
'Memorized':"true"
} ],
'ExposurePeriod':
[[PyTango.DevDouble,
PyTango.SCALAR,
PyTango.READ_WRITE],
{
'label': "Exposure Period",
'unit': "s",
'format': "%10.8f",
'min value': "0",
'description': "Controls the exposure period between to images in seconds. \nIt applies only in Internal or External Trigger modes when NbFrames > 1.",
'Memorized':"true"
} ],
'NbFrames':
[[PyTango.DevLong,
PyTango.SCALAR,
PyTango.READ_WRITE],
{
'label': "Number of Frames",
'unit': " ",
'format': "%6d",
'min value': "1",
'description': "The number of images to acquire when starting the detector",
'Memorized':"true"
} ],
'NbExposures':
[[PyTango.DevLong,
PyTango.SCALAR,
PyTango.READ_WRITE],
{
'label': "Number of Exposures",
'unit': " ",
'format': "%6d",
'min value': "1",
'description': "The number of exposures per images.\nIt applies only in External Enable mode.",
'Memorized':"true"
} ],
'DelayTime':
[[PyTango.DevDouble,
PyTango.SCALAR,
PyTango.READ_WRITE],
{
'label': "Delay Time",
'unit': "s",
'format': "%6.4f",
'min value': "0",
'description': "Delay in seconds between the external trigger and the start of image acquisition. \nIt only applies in External Trigger mode",
'Memorized':"true"
} ],
'ShutterEnable':
[[PyTango.DevBoolean,
PyTango.SCALAR,
PyTango.READ_WRITE],
{
'label': "Enable Shutter Control",
'description': "Enable the shutter control by the detector.",
'Memorized':"true"
} ],
'TriggerMode':
[[PyTango.DevShort,
PyTango.SCALAR,
PyTango.READ_WRITE],
{
'label': "Trigger Mode",
'format': "%1d",
'max value': "3",
'min value': "0",
'description': "The possible trigger modes for the Pilatus detector are:\n<p>\n 0 = Internal (external signal not used)\n<br />\n 1 = External Enable (count while external trigger line is high, readout on high to low transition)\n <br /> \n 2 = External Trigger (begin acquisition sequence on high to low transition of external trigger line)\n <br /> \n 3 = Multiple External Trigger (high to low transition on external signal triggers a single acquisition for the programmed exposure time)\n</p><p>\nThe 4 modes correspond directly to the camserver \ncommands Exposure, ExtEnable, ExtTrigger, and ExtMTrigger respectively.\n</p></Font>",
'Memorized':"true"
} ],
'UseRamDisk':
[[PyTango.DevBoolean,
PyTango.SCALAR,
PyTango.READ_WRITE],
{
'label': "Use RAM Disk",
'description': "When true, will force image file to be written to /ramdisk.\nTherefore, attribute FileDir will be ignored.",
'Memorized':"true"
} ],
'FileDir':
[[PyTango.DevString,
PyTango.SCALAR,
PyTango.READ_WRITE],
{
'label': "Image File Path",
'unit': " ",
'description': "Path to the dector image files.",
'Memorized':"true"
} ],
'FilePrefix':
[[PyTango.DevString,
PyTango.SCALAR,
PyTango.READ_WRITE],
{
'label': "Image File Prefix",
'unit': " ",
'description': "The prefix of the image files to be created.\nThe full image file name will be composed as\n<br />\n<b>prefix_number.postfix </b>\n<br />\nwhen acquiring images.",
'Memorized':"true"
} ],
'FileStartNum':
[[PyTango.DevLong,
PyTango.SCALAR,
PyTango.READ_WRITE],
{
'label': "Image File Number",
'unit': " ",
'format': "%5d",
'description': "The file number used when taking an image.\n<br />\nWhen taking more than one frame, the detector creates\nthe file numbers automatically from this number onwards.\n<p>\nWhen saving multiple images (NImages>1) camserver has its own rules for \ncreating the names of the individual files.\nThe following examples shows the interpretation of the basename.\n</p><p>\nBasename - Files produced\n<br />\ntest6.tif - test6_00000.tif, test6_00001.tif, ...\n<br />\ntest6_.tif - test6_00000.tif, test6_00001.tif, ...\n<br />\ntest6_00008.tif - test6_00008.tif, test6_00009.tif, ...\n<br />\ntest6_2_00035.tif - test6_2_00035.tif, test6_2_00036.tif, ...\n</p>\nThe numbers following the last '_' are taken as a format template, \nand as a start value. \nThe format is also constrained by the requested number of images.",
'Memorized':"true"
} ],
'FilePostfix':
[[PyTango.DevString,
PyTango.SCALAR,
PyTango.READ_WRITE],
{
'label': "Image File Postfix",
'unit': " ",
'description': "The Pilatus detector allows the following postfix:\n<br />\n<b>.tif, .edf, .img, .cbf</b>\n<br />\nThe postfix determines the image format for the saved\nimage files.\n<p>\nThe camserver uses the file extension to determine what format to save \nthe files in.\n</p>",
'Memorized':"true"
} ],
'LastImageTaken':
[[PyTango.DevString,
PyTango.SCALAR,
PyTango.READ],
{
'label': "Last Image File Name",
'unit': " ",
'description': "The name of the last image file written.",
} ],
'Energy':
[[PyTango.DevLong,
PyTango.SCALAR,
PyTango.READ_WRITE],
{
'label': "Photon Energy",
'unit': "eV",
'format': "%5d",
'description': "Simplified method to set gain and threshold for the\ndetector.\nThe threshold will be set to half the photon energy.\nThe detecor loads the corresponding trim files\nwhen changing the energy.\nModifying the detector setting will take several\nseconds.",
'Memorized':"true_without_hard_applied"
} ],
'Threshold':
[[PyTango.DevLong,
PyTango.SCALAR,
PyTango.READ_WRITE],
{
'label': "Threshold Energy",
'unit': "eV",
'format': "%5d",
'max value': "14337",
'min value': "2113",
'description': "The threshold energy for the detector.\nThe detecor loads the corresponding trim files\nwhen changing the energy threshold.\nThe threshold energy will always be set together with the gain.\nModifying the detector setting will take several\nseconds.",
'Memorized':"true_without_hard_applied"
} ],
'Gain':
[[PyTango.DevShort,
PyTango.SCALAR,
PyTango.READ_WRITE],
{
'label': "Gain (Energy Range)",
'unit': " ",
'format': "%1d",
'max value': "3",
'min value': "0",
'description': "The gain controls the value of Vrf, which determines the shaping time and gain of\nthe input amplifiers.\nThe allowed gain values for the Pilatus detector are:\n\n 0 = lowG = Fastest shaping time (~125ns) and lowest gain.\n\n 1 = midG = Medium shaping time (~200ns) and medium gain.\n \n 2 = highG = Slow shaping time (~400ns) and high gain.\n \n 3 = uhighG = Slowest peaking time and highest gain.\nThe gain will always be set together with the threshold energy.\nModifying the detector setting will take several\nseconds.",
'Memorized':"true_without_hard_applied"
} ],
'LastImagePath':
[[PyTango.DevString,
PyTango.SCALAR,
PyTango.READ],
{
'label': "Last Image Path",
'description': "The last path where an image was written.",
} ],
'MxSettings':
[[PyTango.DevString,
PyTango.SCALAR,
PyTango.READ_WRITE],
{
'description': "Set crystallographic parameters in the image header.\nPossible parameter names are: Wavelength, Energy_range, Detector_distance, ...\n(see Pilatus manual for a complete list).",
} ],
'GapFill':
[[PyTango.DevShort,
PyTango.SCALAR,
PyTango.READ_WRITE]],
'LdBadPixMap':
[[PyTango.DevString,
PyTango.SCALAR,
PyTango.READ_WRITE]],
}
def main():
try:
py = PyTango.Util(sys.argv)
py.add_class(PilatusXMClass,PilatusXM,'PilatusXM')
U = PyTango.Util.instance()
U.server_init()
U.server_run()
except PyTango.DevFailed,e:
print '-------> Received a DevFailed exception:',e
except Exception,e:
print '-------> An unforeseen exception occured....',e
if __name__ == '__main__':
main()
<?xml version="1.0" encoding="ASCII"?>
<pogoDsl:PogoSystem xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:pogoDsl="http://www.esrf.fr/tango/pogo/PogoDsl">
<classes name="PilatusXM" pogoRevision="8.1">
<description description="Pilatus detectors are a series pixel detecors build by DECTRIS&#xA;&lt;br />&#xA;http://www.dectris.com.&#xA;&lt;br />&#xA;All detectors of this series can talk to the outside world via a socket&#xA;connection. An ASCI protocol is used on this sockect connection to&#xA;communicate with the detector.&#xA;&lt;p>&#xA;The server process which handles the socket on the detecor PC is&#xA;called camserver. Only one client can commumicate with camserver.&#xA;If the native client tvx is connected, the device server cannot connect until&#xA;tvx gets disconnected.&#xA;&lt;/p>" title="Interface class for the Pilatus detectors" sourcePath="/home/rob/lavoro/XPRESS-XRD2/Tango_servers/PilatusXM" language="Python" filestogenerate="XMI file,Code files" license="GPL" hasMandatoryProperty="true" hasConcreteProperty="true" hasAbstractCommand="false" hasAbstractAttribute="false">
<inheritances classname="Device_4Impl" sourcePath=""/>
<identification contact="at elettra.eu - sci.comp" author="sci.comp" emailDomain="elettra.eu" classFamily="Instrumentation" siteSpecific="" platform="Unix Like" bus="Ethernet" manufacturer="Dectris" reference=""/>
</description>
<deviceProperties name="ServerAddress" mandatory="true" description="The IP address of the PilatusXM camserver.">
<type xsi:type="pogoDsl:StringType"/>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
</deviceProperties>
<commands name="State" description="This command gets the device state (stored in its &lt;i>device_state&lt;/i> data member) and returns it to the caller." execMethod="dev_state" displayLevel="OPERATOR" polledPeriod="0">
<argin description="none.">
<type xsi:type="pogoDsl:VoidType"/>
</argin>
<argout description="State Code">
<type xsi:type="pogoDsl:StateType"/>
</argout>
<status abstract="true" inherited="true" concrete="true" concreteHere="false"/>
</commands>
<commands name="Status" description="This command gets the device status (stored in its &lt;i>device_status&lt;/i> data member) and returns it to the caller." execMethod="dev_status" displayLevel="OPERATOR" polledPeriod="0">
<argin description="none.">
<type xsi:type="pogoDsl:VoidType"/>
</argin>
<argout description="Status description">
<type xsi:type="pogoDsl:ConstStringType"/>
</argout>
<status abstract="true" inherited="true" concrete="true" concreteHere="true"/>
</commands>
<commands name="StartStandardAcq" description="Start an acquisition with the propositioned parameters" execMethod="start_standard_acq" displayLevel="OPERATOR" polledPeriod="0">
<argin description="">
<type xsi:type="pogoDsl:VoidType"/>
</argin>
<argout description="">
<type xsi:type="pogoDsl:VoidType"/>
</argout>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
<excludedStates>DISABLE</excludedStates>
<excludedStates>RUNNING</excludedStates>
<excludedStates>FAULT</excludedStates>
</commands>
<commands name="StopAcq" description="Stop the acquisition. This works only for multi images acquisitions.&#xA;A single image acquisition will always finish." execMethod="stop_acq" displayLevel="OPERATOR" polledPeriod="0">
<argin description="">
<type xsi:type="pogoDsl:VoidType"/>
</argin>
<argout description="">
<type xsi:type="pogoDsl:VoidType"/>
</argout>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
<excludedStates>DISABLE</excludedStates>
<excludedStates>FAULT</excludedStates>
</commands>
<commands name="Reset" description="Reset a state" execMethod="reset" displayLevel="OPERATOR" polledPeriod="0">
<argin description="">
<type xsi:type="pogoDsl:VoidType"/>
</argin>
<argout description="">
<type xsi:type="pogoDsl:VoidType"/>
</argout>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
</commands>
<attributes name="ExposureTime" attType="Scalar" rwType="READ_WRITE" displayLevel="OPERATOR" polledPeriod="0" maxX="0" maxY="0" memorized="true" memorizedAtInit="true">
<dataType xsi:type="pogoDsl:DoubleType"/>
<changeEvent fire="false" libCheckCriteria="false"/>
<archiveEvent fire="false" libCheckCriteria="false"/>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
<properties description="The exposure time for the detector.\nIn the External Enable mode this value is not used by camserver." label="Exposure Time" unit="s" standardUnit="" displayUnit="" format="%10.8f" maxValue="" minValue="0" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/>
<writeExcludedStates>DISABLE</writeExcludedStates>
<writeExcludedStates>RUNNING</writeExcludedStates>
</attributes>
<attributes name="ExposurePeriod" attType="Scalar" rwType="READ_WRITE" displayLevel="OPERATOR" polledPeriod="0" maxX="0" maxY="0" memorized="true" memorizedAtInit="true">
<dataType xsi:type="pogoDsl:DoubleType"/>
<changeEvent fire="false" libCheckCriteria="false"/>
<archiveEvent fire="false" libCheckCriteria="false"/>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
<properties description="Controls the exposure period between to images in seconds. \nIt applies only in Internal or External Trigger modes when NbFrames > 1." label="Exposure Period" unit="s" standardUnit="" displayUnit="" format="%10.8f" maxValue="" minValue="0" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/>
<writeExcludedStates>DISABLE</writeExcludedStates>
<writeExcludedStates>RUNNING</writeExcludedStates>
</attributes>
<attributes name="NbFrames" attType="Scalar" rwType="READ_WRITE" displayLevel="OPERATOR" polledPeriod="0" maxX="0" maxY="0" memorized="true" memorizedAtInit="true">
<dataType xsi:type="pogoDsl:IntType"/>
<changeEvent fire="false" libCheckCriteria="false"/>
<archiveEvent fire="false" libCheckCriteria="false"/>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
<properties description="The number of images to acquire when starting the detector" label="Number of Frames" unit=" " standardUnit="" displayUnit="" format="%6d" maxValue="" minValue="1" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/>
<writeExcludedStates>DISABLE</writeExcludedStates>
<writeExcludedStates>RUNNING</writeExcludedStates>
<writeExcludedStates>FAULT</writeExcludedStates>
</attributes>
<attributes name="NbExposures" attType="Scalar" rwType="READ_WRITE" displayLevel="OPERATOR" polledPeriod="0" maxX="0" maxY="0" memorized="true" memorizedAtInit="true">
<dataType xsi:type="pogoDsl:IntType"/>
<changeEvent fire="false" libCheckCriteria="false"/>
<archiveEvent fire="false" libCheckCriteria="false"/>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
<properties description="The number of exposures per images.\nIt applies only in External Enable mode." label="Number of Exposures" unit=" " standardUnit="" displayUnit="" format="%6d" maxValue="" minValue="1" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/>
<writeExcludedStates>DISABLE</writeExcludedStates>
<writeExcludedStates>RUNNING</writeExcludedStates>
<writeExcludedStates>FAULT</writeExcludedStates>
</attributes>
<attributes name="DelayTime" attType="Scalar" rwType="READ_WRITE" displayLevel="OPERATOR" polledPeriod="0" maxX="0" maxY="0" memorized="true" memorizedAtInit="true">
<dataType xsi:type="pogoDsl:DoubleType"/>
<changeEvent fire="false" libCheckCriteria="false"/>
<archiveEvent fire="false" libCheckCriteria="false"/>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
<properties description="Delay in seconds between the external trigger and the start of image acquisition. \nIt only applies in External Trigger mode" label="Delay Time" unit="s" standardUnit="" displayUnit="" format="%6.4f" maxValue="" minValue="0" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/>
<writeExcludedStates>DISABLE</writeExcludedStates>
<writeExcludedStates>RUNNING</writeExcludedStates>
<writeExcludedStates>FAULT</writeExcludedStates>
</attributes>
<attributes name="ShutterEnable" attType="Scalar" rwType="READ_WRITE" displayLevel="OPERATOR" polledPeriod="0" maxX="0" maxY="0" memorized="true" memorizedAtInit="true" allocReadMember="false" isDynamic="false">
<dataType xsi:type="pogoDsl:BooleanType"/>
<changeEvent fire="false" libCheckCriteria="false"/>
<archiveEvent fire="false" libCheckCriteria="false"/>
<dataReadyEvent fire="false" libCheckCriteria="true"/>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
<properties description="Enable the shutter control by the detector." label="Enable Shutter Control" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/>
<writeExcludedStates>DISABLE</writeExcludedStates>
<writeExcludedStates>RUNNING</writeExcludedStates>
<writeExcludedStates>FAULT</writeExcludedStates>
</attributes>
<attributes name="TriggerMode" attType="Scalar" rwType="READ_WRITE" displayLevel="OPERATOR" polledPeriod="0" maxX="0" maxY="0" memorized="true" memorizedAtInit="true" allocReadMember="false" isDynamic="false">
<dataType xsi:type="pogoDsl:ShortType"/>
<changeEvent fire="false" libCheckCriteria="false"/>
<archiveEvent fire="false" libCheckCriteria="false"/>
<dataReadyEvent fire="false" libCheckCriteria="true"/>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
<properties description="The possible trigger modes for the Pilatus detector are:&#xA;&lt;p>&#xA; 0 = Internal (external signal not used)&#xA;&lt;br />&#xA; 1 = External Enable (count while external trigger line is high, readout on high to low transition)&#xA; &lt;br /> &#xA; 2 = External Trigger (begin acquisition sequence on high to low transition of external trigger line)&#xA; &lt;br /> &#xA; 3 = Multiple External Trigger (high to low transition on external signal triggers a single acquisition for the programmed exposure time)&#xA;&lt;/p>&lt;p>&#xA;The 4 modes correspond directly to the camserver &#xA;commands Exposure, ExtEnable, ExtTrigger, and ExtMTrigger respectively.&#xA;&lt;/p>&lt;/Font>" label="Trigger Mode" unit="" standardUnit="" displayUnit="" format="%1d" maxValue="3" minValue="0" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/>
<writeExcludedStates>DISABLE</writeExcludedStates>
<writeExcludedStates>RUNNING</writeExcludedStates>
<writeExcludedStates>FAULT</writeExcludedStates>
</attributes>
<attributes name="UseRamDisk" attType="Scalar" rwType="READ_WRITE" displayLevel="OPERATOR" polledPeriod="0" maxX="0" maxY="0" memorized="true" memorizedAtInit="true">
<dataType xsi:type="pogoDsl:BooleanType"/>
<changeEvent fire="false" libCheckCriteria="false"/>
<archiveEvent fire="false" libCheckCriteria="false"/>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
<properties description="When true, will force image file to be written to /ramdisk.\nTherefore, attribute FileDir will be ignored." label="Use RAM Disk" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/>
</attributes>
<attributes name="FileDir" attType="Scalar" rwType="READ_WRITE" displayLevel="OPERATOR" polledPeriod="0" maxX="0" maxY="0" memorized="true" memorizedAtInit="true">
<dataType xsi:type="pogoDsl:StringType"/>
<changeEvent fire="false" libCheckCriteria="false"/>
<archiveEvent fire="false" libCheckCriteria="false"/>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
<properties description="Path to the dector image files." label="Image File Path" unit=" " standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/>
<writeExcludedStates>DISABLE</writeExcludedStates>
<writeExcludedStates>RUNNING</writeExcludedStates>
<writeExcludedStates>FAULT</writeExcludedStates>
</attributes>
<attributes name="FilePrefix" attType="Scalar" rwType="READ_WRITE" displayLevel="OPERATOR" polledPeriod="0" maxX="0" maxY="0" memorized="true" memorizedAtInit="true">
<dataType xsi:type="pogoDsl:StringType"/>
<changeEvent fire="false" libCheckCriteria="false"/>
<archiveEvent fire="false" libCheckCriteria="false"/>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
<properties description="The prefix of the image files to be created.\nThe full image file name will be composed as\n&lt;br />\n&lt;b>prefix_number.postfix &lt;/b>\n&lt;br />\nwhen acquiring images." label="Image File Prefix" unit=" " standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/>
<writeExcludedStates>DISABLE</writeExcludedStates>
<writeExcludedStates>RUNNING</writeExcludedStates>
<writeExcludedStates>FAULT</writeExcludedStates>
</attributes>
<attributes name="FileStartNum" attType="Scalar" rwType="READ_WRITE" displayLevel="OPERATOR" polledPeriod="0" maxX="0" maxY="0" memorized="true" memorizedAtInit="true">
<dataType xsi:type="pogoDsl:IntType"/>
<changeEvent fire="false" libCheckCriteria="false"/>
<archiveEvent fire="false" libCheckCriteria="false"/>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
<properties description="The file number used when taking an image.\n&lt;br />\nWhen taking more than one frame, the detector creates\nthe file numbers automatically from this number onwards.\n&lt;p>\nWhen saving multiple images (NImages>1) camserver has its own rules for \ncreating the names of the individual files.\nThe following examples shows the interpretation of the basename.\n&lt;/p>&lt;p>\nBasename - Files produced\n&lt;br />\ntest6.tif - test6_00000.tif, test6_00001.tif, ...\n&lt;br />\ntest6_.tif - test6_00000.tif, test6_00001.tif, ...\n&lt;br />\ntest6_00008.tif - test6_00008.tif, test6_00009.tif, ...\n&lt;br />\ntest6_2_00035.tif - test6_2_00035.tif, test6_2_00036.tif, ...\n&lt;/p>\nThe numbers following the last '_' are taken as a format template, \nand as a start value. \nThe format is also constrained by the requested number of images." label="Image File Number" unit=" " standardUnit="" displayUnit="" format="%5d" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/>
<writeExcludedStates>RUNNING</writeExcludedStates>
</attributes>
<attributes name="FilePostfix" attType="Scalar" rwType="READ_WRITE" displayLevel="OPERATOR" polledPeriod="0" maxX="0" maxY="0" memorized="true" memorizedAtInit="true">
<dataType xsi:type="pogoDsl:StringType"/>
<changeEvent fire="false" libCheckCriteria="false"/>
<archiveEvent fire="false" libCheckCriteria="false"/>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
<properties description="The Pilatus detector allows the following postfix:\n&lt;br />\n&lt;b>.tif, .edf, .img, .cbf&lt;/b>\n&lt;br />\nThe postfix determines the image format for the saved\nimage files.\n&lt;p>\nThe camserver uses the file extension to determine what format to save \nthe files in.\n&lt;/p>" label="Image File Postfix" unit=" " standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/>
<writeExcludedStates>DISABLE</writeExcludedStates>
<writeExcludedStates>RUNNING</writeExcludedStates>
<writeExcludedStates>FAULT</writeExcludedStates>
</attributes>
<attributes name="LastImageTaken" attType="Scalar" rwType="READ" displayLevel="OPERATOR" polledPeriod="0" maxX="0" maxY="0">
<dataType xsi:type="pogoDsl:StringType"/>
<changeEvent fire="false" libCheckCriteria="false"/>
<archiveEvent fire="false" libCheckCriteria="false"/>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
<properties description="The name of the last image file written." label="Last Image File Name" unit=" " standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/>
</attributes>
<attributes name="Energy" attType="Scalar" rwType="READ_WRITE" displayLevel="OPERATOR" polledPeriod="0" maxX="0" maxY="0" memorized="true">
<dataType xsi:type="pogoDsl:IntType"/>
<changeEvent fire="false" libCheckCriteria="false"/>
<archiveEvent fire="false" libCheckCriteria="false"/>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
<properties description="Simplified method to set gain and threshold for the\ndetector.\nThe threshold will be set to half the photon energy.\nThe detecor loads the corresponding trim files\nwhen changing the energy.\nModifying the detector setting will take several\nseconds." label="Photon Energy" unit="eV" standardUnit="" displayUnit="" format="%5d" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/>
<writeExcludedStates>DISABLE</writeExcludedStates>
<writeExcludedStates>RUNNING</writeExcludedStates>
<writeExcludedStates>FAULT</writeExcludedStates>
</attributes>
<attributes name="Threshold" attType="Scalar" rwType="READ_WRITE" displayLevel="OPERATOR" polledPeriod="0" maxX="0" maxY="0" memorized="true">
<dataType xsi:type="pogoDsl:IntType"/>
<changeEvent fire="false" libCheckCriteria="false"/>
<archiveEvent fire="false" libCheckCriteria="false"/>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
<properties description="The threshold energy for the detector.\nThe detecor loads the corresponding trim files\nwhen changing the energy threshold.\nThe threshold energy will always be set together with the gain.\nModifying the detector setting will take several\nseconds." label="Threshold Energy" unit="eV" standardUnit="" displayUnit="" format="%5d" maxValue="14337" minValue="2113" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/>
<writeExcludedStates>DISABLE</writeExcludedStates>
<writeExcludedStates>RUNNING</writeExcludedStates>
<writeExcludedStates>FAULT</writeExcludedStates>
</attributes>
<attributes name="Gain" attType="Scalar" rwType="READ_WRITE" displayLevel="OPERATOR" polledPeriod="0" maxX="0" maxY="0" memorized="true">
<dataType xsi:type="pogoDsl:ShortType"/>
<changeEvent fire="false" libCheckCriteria="false"/>
<archiveEvent fire="false" libCheckCriteria="false"/>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
<properties description="The gain controls the value of Vrf, which determines the shaping time and gain of\nthe input amplifiers.\nThe allowed gain values for the Pilatus detector are:\n\n 0 = lowG = Fastest shaping time (~125ns) and lowest gain.\n\n 1 = midG = Medium shaping time (~200ns) and medium gain.\n \n 2 = highG = Slow shaping time (~400ns) and high gain.\n \n 3 = uhighG = Slowest peaking time and highest gain.\nThe gain will always be set together with the threshold energy.\nModifying the detector setting will take several\nseconds." label="Gain (Energy Range)" unit=" " standardUnit="" displayUnit="" format="%1d" maxValue="3" minValue="0" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/>
<writeExcludedStates>DISABLE</writeExcludedStates>
<writeExcludedStates>RUNNING</writeExcludedStates>
<writeExcludedStates>FAULT</writeExcludedStates>
</attributes>
<attributes name="LastImagePath" attType="Scalar" rwType="READ" displayLevel="OPERATOR" polledPeriod="0" maxX="0" maxY="0" allocReadMember="false" isDynamic="false">
<dataType xsi:type="pogoDsl:StringType"/>
<changeEvent fire="false" libCheckCriteria="false"/>
<archiveEvent fire="false" libCheckCriteria="false"/>
<dataReadyEvent fire="false" libCheckCriteria="true"/>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
<properties description="The last path where an image was written." label="Last Image Path" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/>
</attributes>
<attributes name="MxSettings" attType="Scalar" rwType="READ_WRITE" displayLevel="OPERATOR" polledPeriod="0" maxX="" maxY="" allocReadMember="true" isDynamic="false">
<dataType xsi:type="pogoDsl:StringType"/>
<changeEvent fire="false" libCheckCriteria="false"/>
<archiveEvent fire="false" libCheckCriteria="false"/>
<dataReadyEvent fire="false" libCheckCriteria="true"/>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
<properties description="Set crystallographic parameters in the image header.&#xA;Possible parameter names are: Wavelength, Energy_range, Detector_distance, ...&#xA;(see Pilatus manual for a complete list)." label="" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/>
</attributes>
<attributes name="GapFill" attType="Scalar" rwType="READ_WRITE" displayLevel="OPERATOR" polledPeriod="0" maxX="" maxY="" allocReadMember="true" isDynamic="false">
<dataType xsi:type="pogoDsl:ShortType"/>
<changeEvent fire="false" libCheckCriteria="false"/>
<archiveEvent fire="false" libCheckCriteria="false"/>
<dataReadyEvent fire="false" libCheckCriteria="true"/>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
<properties description="" label="" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/>
</attributes>
<attributes name="LdBadPixMap" attType="Scalar" rwType="READ_WRITE" displayLevel="OPERATOR" polledPeriod="0" maxX="" maxY="" allocReadMember="true" isDynamic="false">
<dataType xsi:type="pogoDsl:StringType"/>
<changeEvent fire="false" libCheckCriteria="false"/>
<archiveEvent fire="false" libCheckCriteria="false"/>
<dataReadyEvent fire="false" libCheckCriteria="true"/>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
<properties description="" label="" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/>
</attributes>
<states name="ON" description="The detecor is ready to take images.">
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
</states>
<states name="DISABLE" description="The device is disconnected from the camserver.">
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
</states>
<states name="RUNNING" description="An acquisition is running.">
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
</states>
<states name="FAULT" description="An error occured on the detector during an acquisition.">
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
</states>
<preferences docHome="./doc_html" makefileHome="/usr/share/pogo/preferences"/>
</classes>
</pogoDsl:PogoSystem>
Camserver is a completely freestanding program that controls an x-ray camera and provides a simple user interface for "atomic" (single function) commands. It is intended to provide a spartan, but fully functional, low level interface to camera hardware.
Camserver takes a single command-line argument, the path to the resource file. Camserver will also use the same path to open its debugging file, 'camdbg.out', if debugging is enabled.
A major function is to accept socket connections from a high level controller (e.g., tvx), which can provide high level services to this or other cameras. The interface is a simple text-based message passing system. Images - the ultimate product of a working area x-ray detector - do not pass thru the interface, but are written to a configurable location (e.g., an nfs mount) where either program can access them.
Because of the socket connection protocol, the camera hardware and server can reside on a different machine form the high level controller.
Camserver implements a token mechanism (controllingProcess) to prevent more than one outside process from having control over the hardware. The camserver window has full control at all times.
Commands in camserver that are also present in the tvx main window must have different names to prevent collisions between the enum's in camclient.c and in tvx.c. I have chosen to distinguish them by upper-casing the last letter (e.g., Run in tvx.c, RuN in camserver.c), and re-lower the case of the last letter in menu_print to make it look better. This is generally poor prctice in C, but since these commands have the same function in the two places, I see no harm. Alternatives would be leading or trailing underscores, all upper-case in one window, or slightly respelling commands.
To permit all processes to enquire as to the state of the camera system, I implemented a /proc-like file system which at all times has the camera status, and which can be queried by any process (just 'cat' from the command line will work, too). Alternatives would have been: use of threads (__clone) rather than fork, so that all child processes share memory; use of shared memory (shmop, etc.); or use of pipes. Of course, programmers must see to it that these values are always updated.
--- Organization:
cam_config.h - locations of configuration files & names of configurable vars
camrc - camera resource file read at startup
~/.camrc - your customized copy of camrc, read after the system file.
These can be used to configure the camera status reporting system and
the location of the camera definition.
./camrc - project-specific camera resource file in your project directory
This is read after ~/.camrc, and overwrites previous global settings
These various "camrc" files are read and interpreted by code in
./camserver/util/cam_config.c, which may be extended with new items as
needed.
camera.def - the camera hardware definition
The camera definition file is specified in the 'camrc' file and is read and
interpreted by code in, e.g., ./camserver/sls42/util/cam_tbl.c, that is, in
the camera-specific directory. As above, this may be extended with new
items as needed. New camera definition files can be reread/replaced
from the command line during camera operation.
cam_config.c - the configuration reader (see above)
camserver.c - main program
camserver.h - declarations for the server. Needed also by the client (tvx)
sls42cam.pkg - a package of commands specific to one equipment.
The reading of, e.g., sls_05_16_1.def is compiled into the sls42
directory tree.
--- Paths:
camstat_path - path to the /proc-like filesystem that tracks camera status
cam_data_path - default path for camera data
cam_image_path - place to put images for stand-alone operation
Note that the image path is normally provided by the client in the
'exposure' command.
--- Files:
cam_definition_file - hardware-specific configuration of camera containing
values of camera variables, e.g. width, height, bits-per-pixel
cam_startup_file - camera-specific commands to executed at startup. Note that
this function could equally well be accomplished in the tvx startup file.
--- Initialization:
Each camera type should be configured in its own directory, following the model of the sls42 directory. The concept is (though it may fail in practice) that camserver, and its 'utils' are fairly generic, and that the personality of particular camera is brought about by the association with a camera-specific directory. This is all controlled by reasonably straight-forward changes in ./camserver/Makefile (and only there). Of course, you have to write the camera code for your camera.
Summary - (sls42 setup)
1. camserver calls cam_config_initialize(path) in util/cam_config.c
which calls camera_read_setup(filename) in sls42/util/interface.c
which calls read_camera_setup(filename) in sls42/util/interface.c
which calls read_detector_info(filename) in sls42/progi2c/signals.c
2. camserver calls camera_initialize(void) in sls42/util/interface.c
which currently is a no-op
3. camserver command 'read_setup filename' calls camera_read_setup (filename)
which repeats the steps above.
In more detail -
camserver.c invokes cam_config_initialize (in cam_config.c) supplying the path to the resource file (camrc) supplied in the invocation line.
cam_config_initialize reads (1) the system config file (/usr/local/etc/camrc); (2) the local config file (./camrc); and then (3) the user config file ($HOME/.camrc). These overwrite previous data in that order. Thus, the user can have differing configurations in each of several experiment-related directories, or simply a single configuration in his personal .camrc. It is probably a bad idea to rely on the system default - it will normally point to /tmp, which is guaranteed writable by everyone, but wherein data is insecure.
If a 'camera_definition_file' is specified in the config file, read_camera_setup (in hardware-specific directory sls42/util/cam_tbl.c) is invoked to read camera-specific parameters. This action may be repeated from the command line by the Read_setup command. The camera table contains operational parameters for the camera such as image height, width, bpp, bin-factor, etc. This may be extended to include parameters specific for one kind of hardware, or those variables may be read separately in an application specific package (see next).
camserver.c then invokes read_detector_info (in signals.c, an application specific package). This reads the camera hardware definition from a file in the cam_data_path directory (default is ./cam_data; the file is specified in 'pix_detector.h' ).
camserver.c finally reads and executes the cam_startup_file specified in the resource file, if any.
--- To implement a new camera:
Camserver is now organized to make configuring for a new camera fairly easy. The concept is that camserver and its associated utilities are fairly generic, and the real personality of a detector is carried in a subdirectory devoted to the camera. Camserver isssues calls to, e.g., camera_start(), which is defined in interface.c, in the util directory of the specific camera. The avoids most of the messy conditional compilation that could arise.
The steps to create a new camera are:
(1) create a new directory for the camera by copying demo_cam in its entirety:
cd ./tvx/camera/camserver
cp -a demo_cam new_cam
(2) in ./new_cam, change the name of the package to "new_cam.pkg"
(3) in ./camserver/Makefile, add CAMERA = NEW_CAM, and comment out all cameras
(4) in ./camserver/Makefile, add an 'ifeq' case for NEW_CAM, and list your
directories (just follow the existing cases)
(5) in ./camserver/Makefile, add your new directory to the list CAMDIRS
(6) in ./camserver/util/Makefile, add CAMERA = NEW_CAM
(7) change ./camserver/util/cam_config.c to suit your needs
(8) change ./camserver/new_cam/util/inteface.c to suit your needs
(9) edit ./camserver/camrc to point to your configuration data
(10) issue 'make' in the ./camserver directory
That should do it. Of course now you must build all your hardware specific code.
Step (5) is so that 'make distclean' can clean up non-selected directories.
Step (6) isn't strictly necessary if you do all your 'make's from the ./camserver directory, as the defines will propagate into the subsidiary directories. But, just to be safe, it is better to do it.
To use 'make' in the individual directories (convenient for debugging), it is necessary to use the same order as in the Makefile in ./camserver, namely:
./camserver/misc
./camserver/util
./camserver/new_camera/util
./camserver/new_camera/(other directories)
if you use 'make distclean' in any directory, it erases the library, so you must repeat these steps.
----- DEBUGGING:
Many errors may be displayed until the configuration is correct, and these will scroll out of the window, or worse exit, before you can read them. To debug the startup, cd to the camserver directory, and in a large window invoke the camserver directly (not from 'runtvx') giving as argument the (optional) path to the resource file (camrc) you are using; e.g.:
cd ./tvx/camera/camserver
./camserver /home/efe/testtvx
My directory testtvx has a 'camrc' file in it (also a 'tvxrc' file).
Or, look at camdbg.out where initialization steps and errors are displayed clearly.
----- COMMANDS:
These are the commands in the base module, without camera-specific packages.
Please do not change the format below, as it is used by the on-line help.
~keystart=CamCmd
CamCmd - a general client entry to interpreter - used in tvx to send
commands to camserver (that camserver understands) without programming tvx.
This instruction is not needed if you are writing your own client.
Socket connection return code: 1
Socket connection return text: none
~keyend
~keystart=CamSetup
CamSetup - report cmaera setup
Socket connection return code: 2
Socket connection return text: camera setup
~keyend
~keystart=CamWait
CamWait - wait for an exposure to end, or program a wait state
Socket connection return code: 15
Socket connection return text: none
~keyend
~keystart=DataPath
DataPath - set or show cam_data_path. Usage:
datapath path_to_directory
1) path_to_directory should already exist & have write permission
2) path should be either a full path, or begin with '~'.
3) normally should point to the cam_data directory
This is the path to camera setup data (not the image path) and
generally should not be changed.
Socket connection return code: 15
Socket connection return text: full data path
~keyend
~keystart=Df
Df - show the number of 1024 KB blocks available on ImgPath
Socket connection return code: 5
Socket connection return text: number of 1K blocks available
~keyend
~keystart=ExpEnd
ExpEnd - end an exposure
Socket connection return code: 6
Socket connection return text: full path name of last image
~keyend
~keystart=Exposure
Exposure - make an exposure
Usage: exposure [filename]
ExpTime and ShutterEnable should be preset. The image is written to the
specified filename relative to ImgPath, or to an absolute path if given.
The format of the image is derived from the filename extension if given
(tif, cbf or edf); otherwise a raw iamge is written.
If a camera-specific exposure series is set up, an image number is inserted
before the extension.
If the camserver shutter control is being used, this command starts either
a background or an exposure depending on the shutter state.
Do 'help ExposureNaming' to see the exposure file naming convention
Socket connection return code:
15 at the start of the exposure or exposure series
7 after completion.
Socket connection return text:
at start: starting xxx second background <date & time> -or-
starting xxx second exposure <date & time>
at end: full path name of last image
~keyend
~keystart=ExpTime
ExpTime - query or set the exposure time.
Socket connection return code: 15
Socket connection return text: Exposure time set to: xxx sec.
~keyend
~keystart=HeaderString
HeaderString - give a string to be included in the image header
Usage: HeaderString text
1) The maximum length is 68 characters, no formatting permitted
2) Enclose the text in quotes to transmit non-alpha characters
Socket connection return code: 15
Socket connection return text: none
~keyend
~keystart=ImgPath
ImgPath - query or change cam_image_path. Usage:
imgpath [path_to_directory]
1) if path_to_directory does not exist, it will be created if
it is possible to do so with write permission
2) path may be a full path, or begin with '~'.
3) A path relative to the current path is accepted; '..' is accepted
4) E.g., if 'imgpath test' is given, and the current directory is
name 'test', a new directroy is NOT created. If such a new
directory is desired, it may be specified by 'test/test'.
5) E.g., if 'imgpath test1/test2' is given, and the current path
is '.../test1/test2', a new directroy is NOT created.
Socket connection return code: 10
Socket connection return text: the path
~keyend
~keystart=LdCmndFile
LdCmndFile - load a file of camera commands and execute them
Socket connection return code: 11
Socket connection return text: none
~keyend
~keystart=Read_setup
Read_setup - (re)read a hardware-specific camera setup from a file,
e.g. camera.def
Usage: read_setup pathname
Socket connection return code: 12
Socket connection return text: the setup
~keyend
~keystart=K
K - stop an exposure in progress
Socket connection return code:
13 if an exposure is in progress
15 if no exposure in progress
Socket connection return text:
image name if there was an exposure in progress
none if no exposure in progress
~keyend
~keystart=ResetCam
ResetCam - synonym for 'K'
~keyend
~keystart=Send
Send - send a message to the client (tvx)
Socket connection return code: 15
Socket connection return text: message text
~keyend
~keystart=ShowPID
ShowPID - show the PID of the process receiving the command
Socket connection return code: 16
Socket connection return text: the pid
~keyend
~keystart=ShutterEnable
ShutterEnable - enable/disable shutter control
Socket connection return code: 15
Socket connection return text: none
~keyend
~keystart=Telemetry
Telemetry - report camera telemetry
Socket connection return code: 18
Socket connection return text: telemetry text
~keyend
~keystart=Exit
Exit - exit the program
Socket connection return code: N/A
Socket connection return text: none
~keyend
~keystart=Quit
Quit - synonym for 'exit'
~keyend
~keystart=Menu
Menu - type the menu of all commands, including camera specific commands
Socket connection return code: none
Socket connection return text: none (prints only to the camserver window)
~keyend
~keystart=Status
Status - return the camera status word as text
Socket connection return code: 22
Socket connection return text: status word
~keyend
~keystart=CamStatus
CamStatus - synonym for Status, q.v.
~keyend
~keystart=Version
Version - print the version (code release)
Socket connection return code: 24
Socket connection return text: version
~keyend
~keystart=CamNoop
CamNoop - echo the argument to this command
Socket connection return code: none
Socket connection return text: none (prints only to the camserver window)
~keyend
~keystart=DbglvL
Dbglvl - print or set the debugging level
Socket connection return code: none
Socket connection return text: none (prints only to the camserver window)
~keyend
~keystart=EndOfHelpText **** THIS INDICATES THE END OF THE HELP FILE TEXT.
TEXT AFTER THIS WILL NOT BE READ! ****
ExtMTrigger - make exposures using multiple external triggers. Usage:
extmtrigger file_base_name
1) Set NImages, ExpTime in advance.
2) Set delay in advance; default is 0
3) The time between triggers must be < 15 sec.
4) Images are trigged by the external trigger, but use the internal
timer for the exposure time.
Do 'help ExpNaming' to see the exposure file naming convention
DiscardMultiIm - discard multiple images
Usage:
discardmultiim [n]
where n=0 to turn off this feature, or n!=0 to turn on
1) if n is omitted, the current state is printed
2) n may also be the word 'yes' or 'no' or 'y' or 'n
DacOffset - query or set the state of dac offset compensation
Usage:
dacoffset [n]
where n=0 to turn off this feature, or n!=0 to turn on
1) if n is omitted, the current state is printed
2) n can be 0 or !0 or 'on' or 'off'
3) the default state is off; turn on for trim calculations
MXsettings - query or set crystallography parameters
Usage:
mxsettings [parm_name [value] [parm_name value] ...]
Parameter names:
Wavelength
Threshold_setting
Detector_distance
Detector_Voffset
Beam_xy
Flux
Filter_transmission
Start_angle
Angle_increment
Detector_2theta
Kappa
Phi
Chi
N_oscillations
1) The parameter 'beam xy' accepts 2 values.
2) These paramters are included in CBF and TIFF image headers as comments.
3) More than 1 parameter may be specified in each command and they
can be in any order.
4) With no parameters, prints the entire current list
5) With a parameter name only, print just that parameter's value
6) All parameters may be abbreviated with the shortest unambiguous string
7) In an automatic sequence, Start_angle is automatically incremented by
Angle_increment after each recorded image.
CalibFile - show or change the detector calibration file
Usage:
calibfile [path]
1) if path not given, the current calibration file is printed
2) if path is given, it will be interpreted relative to the current
cam_data_path, unless an absolute path is given.
SetThreshold - set gain (energy range) and threshold energy
Usage:
setthreshold [[gain] threshold]
1) if parameters are omitted, the current settings are shown
2) gain is 'uhighG', 'highG', 'midG' (standard) or 'lowG'
3) if gain is omitted, the previous setting is retained
4) threshold is in eV
5) this command builds a script in "/tmp/setthreshold.dat" and
then loads it. The data for building the script are read, e.g.,
from p2_1mod/config/cam_data/m169_calibration.def.
SetAckInt - set the interval for acknowledgements over the socket
Usage:
setackint [N]
1) if N is omitted, the current value is shown
2) N=0 (default) - only the last exposure of a series is acknowledged.
The initiating command is always acknowledged, so for 1 or more
images, there is an acknowldgement before the start and at the end
of a series.
3) N=n - acknowledge every nth image. There are some restrictions at
high frame rate: n cannot be too low.
DMA_hold - set or query the dma holdoff time: the time until DMA is enabled
Usage:
dma_hold [time]
1) If a time (in seconds) is not given, print the current setting
2) enter "dma_hold 0" to turn off the facility
3) This is useable only in the ExtEnable, ExtTrigger, and ExtMTrigger
modes.
4) The minimum useable holdoff is 5 sec.
5) Be very careful - wrong values will cause data loss
LdBadPixMap - load a mask image giving bad pixels to be flagged
Usage:
ldbadpixmap [filename]
1) if filename is not given, the current setting is shown
2) if filename is '0' or "off", the pixel flagging function is turned off
3) filename must be a full pathname
4) the maximum number of bad pixels and the flag value are in detsys.h
LdFlatField - load or query flat-field correction file
Usage:
ldflatfield [filename]
1) if filename is not given, the current setting is shown
2) if filename is '0' or "off", the flat field function is turned off
3) filename must be a full pathname
4) filename must be a 32-bit floating-point image
5) the image is pixel-wise multiplied by the correction file
GapFill - query or set the value to be used in pixels between modules
Usage:
gapfill [n]
where n is 0 or -1.
1) if n is omitted, the current value is printed
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment