Commit 43f7dad2 authored by bliss administrator's avatar bliss administrator
Browse files

Camera and Interface manage now optional parameters to set host_name,...

Camera and Interface manage now optional parameters to set host_name, host_port, config_file and tmpfs_path
parent 63ba478a
......@@ -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;
};
/*******************************************************************
......
......@@ -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))
......@@ -731,13 +722,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();
......
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