Commit e52b1cf9 authored by Samuel Debionne's avatar Samuel Debionne
Browse files

Merge branch '5-add-properties-to-run-server-on-a-extra-computer' into 'master'

Resolve "add properties to run server on a different computer"

Closes #5

See merge request !9
parents 63ba478a de9c2f0f
Pipeline #28958 passed with stages
in 4 minutes and 8 seconds
......@@ -5,8 +5,6 @@ c_compiler:
cxx_compiler:
- vs2017 # [win]
python:
- 2.7 # [linux]
- 3.6
- 3.7
# This differs from target_platform in that it determines what subdir the compiler
# will target, not what subdir the compiler package will be itself.
......
......@@ -18,7 +18,6 @@ build:
requirements:
host:
- python {{ python }}
- numpy
- sip 4.19.8 # For compatibility with pyqt 5.9.2
- lima-core
- cbflib
......
......@@ -13,7 +13,14 @@ This camera device has no property.
=============== =============== =============== ==============================================================
Property name Mandatory Default value Description
=============== =============== =============== ==============================================================
TmpfsSize No 0 OBSOLETE
host_name No localhost Pilatus computer hostname
host_port No 41234 Pilatus camserver port number
config_file No /home/det/ Configuration file path, read to get pilatus version (2 or 3)
p2_det/config/ and the camera size (height and width)
cam_data/
camera.def
tmpfs_path No /lima_data Path to the temporary file-system where camserver will store
the images
=============== =============== =============== ==============================================================
Attributes
......@@ -26,7 +33,8 @@ fill_mode rw DevString The gap fill mode (**ON,OFF**)
threshold rw DevLong The threshold level of detector in eV
energy_threshold rw DevFloat The energy threshold in keV (set the gain and the threshold)
trigger_delay rw DevDouble The start exposure delay after the hard trigger
nb_exposure_per_frame rw DevLong The number of exposure/frame to set an accumulation of frames Very useful to not saturate the pixel counters.
nb_exposure_per_frame rw DevLong The number of exposure/frame to set an accumulation of
frames
======================= ======= ======================= ============================================================
Commands
......
......@@ -74,8 +74,11 @@ public:
EXTERNAL_GATE
};
Camera(const char *host = "localhost",int port = 41234);
~Camera();
Camera(const std::string& host_name = "localhost",
int host_port = 41234,
const std::string& config_file = "/home/det/p2_det/config/cam_data/camera.def",
const std::string& tmpfs_path = "/lima_data");
~Camera();
void connect(const char* host,int port);
......@@ -136,6 +139,9 @@ public:
bool hasHighVoltageReset();
void resetHighVoltage(unsigned int sleeptime = 1);
const char* configFile() const {return m_config_file.c_str();};
const char* tmpFsPath() const {return m_tmpfs_path.c_str();};
private:
static constexpr double TIME_OUT = 10.;
enum HIGH_VOLTAGE { NOT_INITIALIZED,
......@@ -162,7 +168,9 @@ private:
//socket/synchronization with pilatus variables
std::string m_server_ip;
int m_server_port;
int m_server_port;
std::string m_config_file;
std::string m_tmpfs_path;
int m_socket;
bool m_stop;
pthread_t m_thread_id;
......
......@@ -51,7 +51,7 @@ public:
Size m_det_size;
std::string m_det_model;
};
DetInfoCtrlObj(const Info* = NULL);
DetInfoCtrlObj(Camera& cam, const Info* = NULL);
virtual ~DetInfoCtrlObj();
virtual void getMaxImageSize(Size& max_image_size);
......@@ -84,6 +84,7 @@ private:
Info m_info;
bool m_is_pilatus2;
bool m_is_pilatus3;
Camera& m_cam;
};
/*******************************************************************
......@@ -208,6 +209,7 @@ private:
RoiCtrlObj m_roi;
SyncCtrlObj m_sync;
SavingCtrlObj m_saving;
int m_image_number;
};
} // namespace Pilatus
......
......@@ -43,7 +43,7 @@ namespace Pilatus
EXTERNAL_GATE
};
Camera(const char *host = "localhost",int port = 41234);
Camera(const std::string& host_name = "localhost",int host_port = 41234, const std::string& config_file = "/home/det/p2_det/config/cam_data/camera.def", const std::string& tmpfs_path = "/lima_data") /KeywordArgs="Optional"/;
~Camera();
void connect(const char* host,int port);
......
......@@ -12,7 +12,7 @@ namespace Pilatus
Size m_det_size;
std::string m_det_model;
};
DetInfoCtrlObj(const Pilatus::DetInfoCtrlObj::Info* = NULL);
DetInfoCtrlObj(Pilatus::Camera& cam, const Pilatus::DetInfoCtrlObj::Info* = NULL);
virtual ~DetInfoCtrlObj();
virtual void getMaxImageSize(Size& max_image_size /Out/);
......
......@@ -104,7 +104,10 @@ inline void _split(const std::string inString,
//-----------------------------------------------------
//
//-----------------------------------------------------
Camera::Camera(const char *host,int port)
Camera::Camera(const std::string& host_name,
int host_port,
const std::string& config_file,
const std::string& tmpfs_path)
: m_socket(-1),
m_stop(false),
m_thread_id(0),
......@@ -117,11 +120,15 @@ Camera::Camera(const char *host,int port)
m_major_version(-1),
m_minor_version(-1),
m_patch_version(-1),
m_cmd_high_voltage_reset(NOT_INITIALIZED)
m_cmd_high_voltage_reset(NOT_INITIALIZED),
m_server_ip(host_name),
m_server_port(host_port),
m_config_file(config_file),
m_tmpfs_path(tmpfs_path)
{
DEB_CONSTRUCTOR();
m_server_ip = host;
m_server_port = port;
_initVariable();
if(pipe(m_pipes))
......@@ -131,7 +138,7 @@ Camera::Camera(const char *host,int port)
try
{
connect(host,port);
connect(host_name.c_str(),host_port);
}
catch(Exception &e) // Not an error in that case
{
......
......@@ -34,15 +34,11 @@
using namespace lima;
using namespace lima::Pilatus;
static const char* CAMERA_INFO_FILE = "p2_det/config/cam_data/camera.def";
static const char* CAMERA_DEFAULT_USER= "det";
static const char CAMERA_NAME_TOKEN[] = "camera_name";
static const char CAMERA_WIDE_TOKEN[] = "camera_wide";
static const char CAMERA_HIGH_TOKEN[] = "camera_high";
static const char CAMERA_PILATUS3_TOKEN[] = "PILATUS3";
static const char WATCH_PATH[] = "/lima_data";
static const char FILE_PATTERN[] = "tmp_img_%.7d.edf";
static const int DECTRIS_EDF_OFFSET = 1024;
......@@ -56,7 +52,8 @@ static const float P3_6M_MAX_FREQUENCY[3] = {100, 200, 500}; //full, c18, c2
* \brief DetInfoCtrlObj constructor
* \param info if info is NULL look for ~det/p2_det/config/cam_data/camera.def file
*******************************************************************/
DetInfoCtrlObj::DetInfoCtrlObj(const DetInfoCtrlObj::Info* info)
DetInfoCtrlObj::DetInfoCtrlObj(Camera& cam,const DetInfoCtrlObj::Info* info):
m_cam(cam)
{
DEB_CONSTRUCTOR();
if(info)
......@@ -66,19 +63,13 @@ DetInfoCtrlObj::DetInfoCtrlObj(const DetInfoCtrlObj::Info* info)
char aBuffer[2048];
struct passwd aPwd;
struct passwd *aResultPwd;
if(getpwnam_r(CAMERA_DEFAULT_USER,&aPwd,
aBuffer,sizeof(aBuffer),
&aResultPwd))
THROW_HW_ERROR(Error) << "Can't get information of user : "
<< CAMERA_DEFAULT_USER;
const char *config_file = m_cam.configFile();
char aConfigFullPath[1024];
snprintf(aConfigFullPath,sizeof(aConfigFullPath),
"%s/%s",aPwd.pw_dir,CAMERA_INFO_FILE);
FILE* aConfFile = fopen(aConfigFullPath,"r");
FILE* aConfFile = fopen(config_file,"r");
if(!aConfFile)
THROW_HW_ERROR(Error) << "Can't open config file :"
<< aConfigFullPath;
<< config_file;
char aReadBuffer[1024];
int aWidth = -1,aHeight = -1;
while(fgets(aReadBuffer,sizeof(aReadBuffer),aConfFile))
......@@ -697,9 +688,11 @@ public:
m_interface.m_cam.errorStopAcquisition();
aReturnFlag = false;
}
else
aReturnFlag = int(m_image_events.size()) != m_interface.m_cam.nbImagesInSequence();
else {
int nb_frames;
m_interface.m_sync.getNbHwFrames(nb_frames);
aReturnFlag = int(m_image_events.size()) != nb_frames;
}
return aReturnFlag;
}
virtual void getFrameDim(FrameDim& frame_dim)
......@@ -731,13 +724,12 @@ private:
Interface::Interface(Camera& cam,const DetInfoCtrlObj::Info* info)
: m_cam(cam),
m_det_info(info),
m_det_info(cam, info),
m_buffer_cbk(new Interface::_BufferCallback(*this)),
m_buffer(WATCH_PATH,FILE_PATTERN,
*m_buffer_cbk),
m_roi(cam,m_det_info),
m_sync(cam,m_det_info,m_roi),
m_saving(cam)
m_roi(cam, m_det_info),
m_sync(cam,m_det_info, m_roi),
m_saving(cam),
m_buffer(cam.tmpFsPath(), FILE_PATTERN, *m_buffer_cbk)
{
DEB_CONSTRUCTOR();
......@@ -818,6 +810,8 @@ void Interface::prepareAcq()
else
m_buffer.prepare();
m_sync.prepareAcq();
// counter only use for IntTrigMult to increase the file number
m_image_number = 0;
}
......@@ -828,12 +822,17 @@ void Interface::startAcq()
{
DEB_MEMBER_FUNCT();
if(m_saving.isActive())
m_saving.start();
else
m_buffer.start();
m_cam.startAcquisition();
// multi start calls if trigger mode is IntTrigMult
if (m_image_number == 0) {
if(m_saving.isActive())
m_saving.start();
else
m_buffer.start();
}
// in case of IntTrigMult trigger mode an image number
// is passed to the start to increase the file number
m_cam.startAcquisition(m_image_number);
m_image_number++;
}
//-----------------------------------------------------
......@@ -869,8 +868,9 @@ void Interface::getStatus(StatusType& status)
m_sync.getNbHwFrames(nbFrames);
if(m_buffer.isStopped())
status.acq = AcqReady;
else
else {
status.acq = getNbHwAcquiredFrames() >= nbFrames ? AcqReady : AcqRunning;
}
}
else
status.acq = AcqReady;
......
......@@ -112,10 +112,6 @@ class Pilatus(PyTango.Device_4Impl):
self.set_state(PyTango.DevState.ON)
self.get_device_properties(self.get_device_class())
if self.TmpfsSize:
buffer = _PilatusInterface.buffer()
buffer.setTmpfsSize(self.TmpfsSize * 1024 * 1024)
#------------------------------------------------------------------
# getAttrStringValueList command:
#
......@@ -296,9 +292,21 @@ class PilatusClass(PyTango.DeviceClass):
# Device Properties
device_property_list = {
'TmpfsSize' :
'host_port' :
[PyTango.DevInt,
"Size of communication temp. filesystem (in MB)",0],
"detector computer host name",4123],
'host_name' :
[PyTango.DevString,
"detector computer host name","localhost"],
'config_file' :
[PyTango.DevString,
"detector config path to get frame dimensions","/home/det/p2_det/config/cam_data/camera.def"],
'tmpfs_path' :
[PyTango.DevString,
"temporary file-system path to let camserver stores images","/lima_data"],
}
# Command definitions
......@@ -371,7 +379,14 @@ def get_control(**keys) :
global _PilatusCamera
global _CtControl
if _PilatusInterface is None:
_PilatusCamera = PilatusAcq.Camera()
host_name = keys.pop('host_name', 'localhost')
host_port = keys.pop('host_port', 41234)
config_file = keys.pop('config_file', '/home/det/p2_det/config/cam_data/camera_def')
tmpfs_path = keys.pop('tmpfs_path', '/lima_data')
_PilatusCamera = PilatusAcq.Camera(host_name = host_name,
host_port = host_port,
config_file = config_file,
tmpfs_path = tmpfs_path)
_PilatusInterface = PilatusAcq.Interface(_PilatusCamera)
_CtControl = Core.CtControl(_PilatusInterface)
return _CtControl
......
Markdown is supported
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