Commit 703b25ba authored by Sebastien Petitdemange's avatar Sebastien Petitdemange
Browse files

Manage the new Pilatus3 setthreshold command

parent 960b7296
......@@ -93,8 +93,9 @@ public:
int threshold() const;
Gain gain() const;
void setThresholdGain(int threshold,Gain gain = DEFAULT_GAIN);
void setThresholdGain(int threshold,Gain gain = DEFAULT_GAIN); // backward compatibility
void setThreshold(int threshold,int energy = -1);
double exposure() const;
void setExposure(double expo);
......@@ -141,7 +142,8 @@ private:
void _initVariable();
void _resync();
void _reinit();
void _pilatus3model(); ///< set pilatus3 threshold extention
std::map<std::string,Gain> GAIN_SERVER_RESPONSE;
std::map<Gain,std::string> GAIN_VALUE2SERVER;
......@@ -173,6 +175,7 @@ private:
std::string m_file_pattern;
int m_nb_acquired_images;
bool m_has_cmd_setenergy;
bool m_pilatus3_threshold_mode;
};
}
}
......
......@@ -74,9 +74,11 @@ public:
}
;
double getMinLatTime() const {return 3e-3;}
double getMinLatTime() const;
bool isPilatus3() const {return m_is_pilatus3;}
private:
Info m_info;
bool m_is_pilatus3;
};
/*******************************************************************
* \class SyncCtrlObj
......@@ -140,7 +142,8 @@ public:
void setEnergy(double energy);
double getEnergy(void);
void setThresholdGain(int threshold, Camera::Gain gain);
void setThresholdGain(int threshold, Camera::Gain gain); // backward compatibility
void setThreshold(int threshold,int energy = -1);
int getThreshold(void);
Camera::Gain getGain(void);
void sendAnyCommand(const std::string& str);
......
......@@ -64,6 +64,7 @@ namespace Pilatus
Pilatus::Camera::Gain gain() const;
void setThresholdGain(int threshold,
Pilatus::Camera::Gain gain = DEFAULT_GAIN);
void setThreshold(int threshold,int energy = -1);
double exposure() const;
void setExposure(double expo);
......
......@@ -83,6 +83,7 @@ namespace Pilatus
void setEnergy(double energy);
double getEnergy();
void setThresholdGain(int threshold, Pilatus::Camera::Gain gain);
void setThreshold(int threshold,int energy = -1);
int getThreshold();
Pilatus::Camera::Gain getGain();
void sendAnyCommand(const std::string& str);
......
......@@ -107,7 +107,9 @@ Camera::Camera(const char *host,int port)
m_stop(false),
m_thread_id(0),
m_state(DISCONNECTED),
m_nb_acquired_images(0)
m_nb_acquired_images(0),
m_has_cmd_setenergy(true),
m_pilatus3_threshold_mode(false)
{
DEB_CONSTRUCTOR();
m_server_ip = host;
......@@ -291,7 +293,13 @@ void Camera::_reinit()
_resync();
send("nimages");
}
//-----------------------------------------------------
//
//-----------------------------------------------------
void Camera::_pilatus3model()
{
m_pilatus3_threshold_mode = true;
}
//-----------------------------------------------------
//
//-----------------------------------------------------
......@@ -760,7 +768,34 @@ void Camera::setThresholdGain(int value,Camera::Gain gain)
if (m_gap_fill)
send("gapfill -1");
}
//-----------------------------------------------------
//
//-----------------------------------------------------
void Camera::setThreshold(int threshold,int energy)
{
DEB_MEMBER_FUNCT();
if(!m_pilatus3_threshold_mode)
THROW_HW_ERROR(NotSupported) << "Could not use pilatus threshold flavor";
AutoMutex aLock(m_cond.mutex());
RECONNECT_WAIT_UNTIL(Camera::STANDBY,
"Could not set threshold,server is not idle");
m_state = Camera::SETTING_THRESHOLD;
if(energy < 0)
{
char buffer[128];
snprintf(buffer,sizeof(buffer),"setthreshold %d",threshold);
send(buffer);
}
else
{
char buffer[128];
snprintf(buffer,sizeof(buffer),"setthreshold energy %d %d",energy,threshold);
send(buffer);
}
}
//-----------------------------------------------------
//
//-----------------------------------------------------
......
......@@ -37,6 +37,7 @@ 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_%.5d.edf";
......@@ -81,6 +82,8 @@ DetInfoCtrlObj::DetInfoCtrlObj(const DetInfoCtrlObj::Info* info)
char *aEndPt = strrchr(aBeginPt,(unsigned int)'"');
*aEndPt = '\0'; // remove last "
m_info.m_det_model = aBeginPt;
//Check if pilatus2 or 3
m_is_pilatus3 = !strncmp(aBeginPt,CAMERA_PILATUS3_TOKEN,sizeof(CAMERA_PILATUS3_TOKEN) - 1);
}
else if(!strncmp(aReadBuffer,
CAMERA_HIGH_TOKEN,sizeof(CAMERA_HIGH_TOKEN) - 1))
......@@ -193,8 +196,13 @@ void DetInfoCtrlObj::getDetectorModel(std::string& model)
DEB_MEMBER_FUNCT();
model = m_info.m_det_model;
}
//-----------------------------------------------------
//
//-----------------------------------------------------
double DetInfoCtrlObj::getMinLatTime() const
{
return m_is_pilatus3 ? 900e-6 : 3e-3;
}
/*******************************************************************
* \brief SyncCtrlObj constructor
......@@ -476,6 +484,9 @@ Interface::Interface(Camera& cam,const DetInfoCtrlObj::Info* info)
m_cap_list.push_back(HwCap(saving));
m_buffer.getDirectoryEvent().watch_moved_to();
//Activate new pilatus3 threshold method
if(m_det_info.isPilatus3()) cam._pilatus3model();
}
//-----------------------------------------------------
......@@ -622,7 +633,13 @@ void Interface::setThresholdGain(int threshold, Camera::Gain gain)
{
m_cam.setThresholdGain(threshold, gain);
}
//-----------------------------------------------------
//
//-----------------------------------------------------
void Interface::setThreshold(int threshold,int energy)
{
m_cam.setThreshold(threshold,energy);
}
//-----------------------------------------------------
//
//-----------------------------------------------------
......
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