Commit bd65ff4e authored by Laurent Claustre's avatar Laurent Claustre
Browse files

Merge branch '7-add-energy-threshold-diff-mode' into 'master'

Resolve "add energy threshold diff mode"

Closes #7

See merge request !13
parents 56e707dd f776ee2a
Pipeline #41635 passed with stages
in 12 minutes and 47 seconds
......@@ -5,7 +5,6 @@ c_compiler:
cxx_compiler:
- vs2017 # [win]
python:
- 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.
......
......@@ -107,6 +107,7 @@ Optional capabilities
* **LZ4 Compression**
* **Virtual pixel correction**
* **Pixelmask**
* **Retrigger**
Configuration
-------------
......@@ -155,9 +156,9 @@ This is a python code of a simple acquisition:
print (cam.getHumidity())
# set energy threshold in KeV
cam.seThresholdEnery(16.0)
cam.setPhotonEnergy(16.0)
# set energy threshold in eV
cam.seThresholdEnery(16000)
cam.setPhotonEnergy(16000)
# setting new file parameters and autosaving mode
saving=ct.saving()
......@@ -176,7 +177,7 @@ This is a python code of a simple acquisition:
# now ask for 10 msec exposure and 10 frames
acq.setAcqExpoTime(0.01)
acq.setNbImages(10)
acq.setAcqNbFrames(10)
ct.prepareAcq()
ct.startAcq()
......
......@@ -21,6 +21,7 @@ Attributes
========================= ======= ======================= ======================================================================
Attribute name RW Type Description
========================= ======= ======================= ======================================================================
api_version ro DevString The detected API version, e.g '1.8.0'
auto_summation rw DevString If enable image depth is bpp32 and, if not image depth is bpp16 **(\*)**
cam_status ro DevString The internal camera status
compression_type rw DevString For data stream, supported compression are:
......@@ -28,16 +29,24 @@ compression_type rw DevString For data stream, suppo
- LZ4
- BSLZ4
countrate_correction rw DevString Enable or disable the countrate correction **(\*)**
detector_ip ro DevString The IP address of the detector DCU, useful to run curl commands
efficency_correction rw DevString Enable the efficienty correction
flatfield_correction rw DevString Enable or disable the internal (vs. lima) flatfield correction **(\*)**
humidity ro DevFloat Return the humidity percentage
pixel_mask rw DevString Enable or disable the pixel mask correction **(\*)**
photon_energy rw DevFloat The photon energy,it should be set to the incoming beam energy. Actually it’s an helper which set the threshold
photon_energy rw DevFloat The photon energy,it should be set to the incoming beam energy. Actually
it’s an helper which set the threshold
plugin_status ro DevString The camera plugin status
retrigger rw DevString Enable or disable the retrigger mode **(\*)**
serie_id ro DevLong The current acquisition serie identifier
stream_last_info ro DevString Information on data stream, encoding, frame_dim and packed_size
stream_stats ro DevDouble ave_size, ave_time, ave_speed
threshold_energy rw DevFloat The threshold energy, it will set the camera detection threshold. This should be set between 50 to 60 % of the incoming beam energy.
threshold_energy rw DevFloat The threshold energy (eV), it will set the camera detection threshold.
This should be set between 50 to 60 % of the incoming beam energy.
threshold_energy2 rw DevFloat The 2nd threshold energy (eV), useful only if you need to activate the
threshold differential mode
threshold_diff_mode rw DevString Enable or disable the threshold diff mode, can be use to mask gamma
x-rays (i.e cosmics) **(\*)**
temperature ro DevFloat The sensor temperature
virtual_pixel_correction rw DevString Enable or disable the virtual-pixel correction **(\*)**
========================= ======= ======================= ======================================================================
......@@ -58,6 +67,7 @@ latchStreamStatistics DevBoolean DevVarDoubleArray: If True, reset t
- ave_size,
- ave_time,
- ave_speed
resetHighVoltage DevVoid DevVoid For CdTe sensors only, switch off/on the high-voltage
Init DevVoid DevVoid Do not use
State DevVoid DevLong Return the device state
Status DevVoid DevString Return the device state as a string
......
......@@ -119,12 +119,11 @@ class LIBEIGER Camera : public HwMaxImageSizeCallbackGen, public EventCallbackGe
// -- Eiger specific
void getApiGeneration(ApiGeneration&);
void getApiVersion(std::string&);
void getTemperature(double&);
void getHumidity(double&);
void getHighVoltageState(std::string&);
void getHighVoltageMeasured(double&);
void getHighVoltageTarget(double&);
void resetHighVoltage();
void setCountrateCorrection(bool);
......@@ -141,6 +140,10 @@ class LIBEIGER Camera : public HwMaxImageSizeCallbackGen, public EventCallbackGe
void getPixelMask(bool&);
void setThresholdEnergy(double);
void getThresholdEnergy(double&);
void setThresholdEnergy2(double);
void getThresholdEnergy2(double&);
void setThresholdDiffMode(bool);
void getThresholdDiffMode(bool&);
void setVirtualPixelCorrection(bool);
void getVirtualPixelCorrection(bool&);
void setPhotonEnergy(double);
......@@ -237,6 +240,7 @@ class LIBEIGER Camera : public HwMaxImageSizeCallbackGen, public EventCallbackGe
//- camera stuff
ApiGeneration m_api;
std::string m_api_version;
std::string m_detector_model;
std::string m_detector_type;
unsigned int m_maxImageWidth, m_maxImageHeight;
......
......@@ -141,8 +141,6 @@ namespace eigerapi
enum PARAM_NAME {TEMP,
HUMIDITY,
HVSTATE,
HVMEASURED,
HVTARGET,
DETECTOR_STATUS,
PIXELDEPTH,
X_PIXEL_SIZE,
......@@ -163,6 +161,9 @@ namespace eigerapi
RETRIGGER,
PIXEL_MASK,
THRESHOLD_ENERGY,
THRESHOLD_ENERGY2,
THRESHOLD_MODE2,
THRESHOLD_DIFF_MODE,
VIRTUAL_PIXEL_CORRECTION,
PHOTON_ENERGY,
NIMAGES,
......
......@@ -272,7 +272,7 @@ void CurlLoop::quit()
Lock alock(&m_lock);
m_quit = true;
write(m_pipes[1],"|",1);
ssize_t w = write(m_pipes[1],"|",1);
pthread_cond_broadcast(&m_cond);
alock.unLock();
......
......@@ -40,8 +40,6 @@ typedef Requests::CurlReq CurlReq;
static const char* CSTR_EIGERCONFIG = "config";
static const char* CSTR_EIGERSTATUS = "status";
static const char* CSTR_EIGERSTATUS_BOARD = "status/board_000";
static const char* CSTR_EIGERSTATUS_HV = "status/high_voltage";
static const char* CSTR_EIGERCOMMAND = "command";
static const char* CSTR_EIGERFILES = "files";
static const char* CSTR_SUBSYSTEMFILEWRITER = "filewriter";
......@@ -105,11 +103,9 @@ struct ParamIndex
ParamIndex ParamDescription[] = {
// Detector Read only values
{Requests::TEMP, {"th0_temp",CSTR_SUBSYSTEMDETECTOR,CSTR_EIGERSTATUS_BOARD}},
{Requests::HUMIDITY, {"th0_humidity",CSTR_SUBSYSTEMDETECTOR,CSTR_EIGERSTATUS_BOARD}},
{Requests::HVSTATE, {"state",CSTR_SUBSYSTEMDETECTOR,CSTR_EIGERSTATUS_HV}},
{Requests::HVMEASURED, {"measured",CSTR_SUBSYSTEMDETECTOR,CSTR_EIGERSTATUS_HV}},
{Requests::HVTARGET, {"target",CSTR_SUBSYSTEMDETECTOR,CSTR_EIGERSTATUS_HV}},
{Requests::TEMP, {"temperature",CSTR_SUBSYSTEMDETECTOR,CSTR_EIGERSTATUS}},
{Requests::HUMIDITY, {"humidity",CSTR_SUBSYSTEMDETECTOR,CSTR_EIGERSTATUS}},
{Requests::HVSTATE, {"high_voltage/state",CSTR_SUBSYSTEMDETECTOR,CSTR_EIGERSTATUS}},
{Requests::DETECTOR_STATUS, {"state",CSTR_SUBSYSTEMDETECTOR,CSTR_EIGERSTATUS}},
{Requests::PIXELDEPTH, {"bit_depth_readout"}},
{Requests::X_PIXEL_SIZE, {"x_pixel_size"}},
......@@ -131,6 +127,9 @@ ParamIndex ParamDescription[] = {
{Requests::EFFICIENCY_CORRECTION, {"efficiency_correction_applied"}},
{Requests::PIXEL_MASK, {"pixel_mask_applied"}},
{Requests::THRESHOLD_ENERGY, {"threshold_energy"}},
{Requests::THRESHOLD_ENERGY2, {"threshold/2/energy"}},
{Requests::THRESHOLD_MODE2, {"threshold/2/mode"}},
{Requests::THRESHOLD_DIFF_MODE, {"threshold/difference/mode"}},
{Requests::VIRTUAL_PIXEL_CORRECTION, {"virtual_pixel_correction_applied"}},
{Requests::PHOTON_ENERGY, {"photon_energy"}},
{Requests::NIMAGES, {"nimages"}},
......@@ -425,10 +424,13 @@ size_t Requests::Command::_write_callback(char *ptr,size_t size,
int Requests::Command::get_serie_id()
{
Json::Value root;
Json::Reader reader;
if(!reader.parse(m_data,root))
THROW_EIGER_EXCEPTION(eigerapi::JSON_PARSE_FAILED,"");
Json::Value root;
Json::CharReaderBuilder rbuilder;
std::unique_ptr<Json::CharReader> const reader(rbuilder.newCharReader());
std::string errs;
if (!reader->parse(m_data, m_data+strlen(m_data), &root, &errs))
THROW_EIGER_EXCEPTION(eigerapi::JSON_PARSE_FAILED, errs.c_str());
int seq_id = root.get("sequence id", -1).asInt();
return seq_id;
......@@ -473,10 +475,13 @@ Requests::Param::Value Requests::Param::_get(double timeout,bool lock,
//- Json decoding to return the wanted data
Json::Value root;
Json::Reader reader;
Json::CharReaderBuilder rbuilder;
std::unique_ptr<Json::CharReader> const reader(rbuilder.newCharReader());
std::string errs;
if (!reader->parse(m_data_buffer, m_data_buffer+m_data_size, &root, &errs))
THROW_EIGER_EXCEPTION(eigerapi::JSON_PARSE_FAILED, errs.c_str());
if (!reader.parse(m_data_buffer, root))
THROW_EIGER_EXCEPTION(eigerapi::JSON_PARSE_FAILED,"");
Value value;
std::string json_type;
bool is_list = root.isArray() || root.get(param_name, "no_value").isArray();
......@@ -562,8 +567,9 @@ void Requests::Param::_fill_set_request(const T& value)
{
Json::Value root;
root["value"] = value;
Json::FastWriter writer;
std::string json_struct = writer.write(root);
Json::StreamWriterBuilder wbuilder;
std::string json_struct = Json::writeString(wbuilder, root);
m_headers = curl_slist_append(m_headers, "Accept: application/json");
m_headers = curl_slist_append(m_headers, "Content-Type: application/json;charset=utf-8");
......
......@@ -78,12 +78,11 @@ namespace Eiger
// -- Eiger specific
void getApiGeneration(ApiGeneration& /Out/);
void getApiVersion(std::string& /Out/);
void getTemperature(double& /Out/);
void getHumidity(double& /Out/);
void getHighVoltageState(std::string& /Out/);
void getHighVoltageMeasured(double& /Out/);
void getHighVoltageTarget(double& /Out/);
void resetHighVoltage();
void setCountrateCorrection(const bool);
......@@ -100,6 +99,10 @@ namespace Eiger
void getPixelMask(bool& /Out/);
void setThresholdEnergy(const double);
void getThresholdEnergy(double& /Out/);
void setThresholdEnergy2(const double);
void getThresholdEnergy2(double& /Out/);
void setThresholdDiffMode(const bool);
void getThresholdDiffMode(bool& /Out/);
void setVirtualPixelCorrection(const bool);
void getVirtualPixelCorrection(bool& /Out/);
void setPhotonEnergy(const double);
......
......@@ -140,14 +140,14 @@ Camera::Camera(const std::string& host, int http_port, int stream_port) ///< [in
m_requests = new Requests(http_address);
// Detect EigerAPI version
std::string api_version = m_requests->get_api_version();
DEB_TRACE() << DEB_VAR1(api_version);
if (api_version == "1.6.0")
m_api_version = m_requests->get_api_version();
DEB_TRACE() << DEB_VAR1(m_api_version);
if (m_api_version == "1.6.0")
m_api = Eiger1;
else if (api_version == "1.8.0")
else if (m_api_version == "1.8.0")
m_api = Eiger2;
else
THROW_HW_ERROR(Error) << "Unknown " << DEB_VAR1(api_version);
THROW_HW_ERROR(Error) << "Unknown " << DEB_VAR1(m_api_version);
DEB_TRACE() << DEB_VAR1(m_api);
// Init EigerAPI
......@@ -812,7 +812,7 @@ bool Camera::allFramesAcquired()
//-----------------------------------------------------------------------------
/// Returns the API generation of the detector
/*!
@return temperature value
@return API generation (eiger1, eiger2)
*/
//-----------------------------------------------------------------------------
void Camera::getApiGeneration(ApiGeneration& api)
......@@ -822,6 +822,18 @@ void Camera::getApiGeneration(ApiGeneration& api)
DEB_RETURN() << DEB_VAR1(api);
}
//-----------------------------------------------------------------------------
/// Returns the API version of the detector
/*!
@return api version string (1.6.0/1.8.0)
*/
//-----------------------------------------------------------------------------
void Camera::getApiVersion(std::string& api)
{
DEB_MEMBER_FUNCT();
api = m_api_version;
DEB_RETURN() << DEB_VAR1(api);
}
//-----------------------------------------------------------------------------
/// Returns the temperature of the detector
/*!
......@@ -868,17 +880,6 @@ void Camera::resetHighVoltage()
DEB_TRACE() << "reset HighVoltage";
}
void Camera::getHighVoltageMeasured(double &hvmeas)
{
DEB_MEMBER_FUNCT();
getParam(Requests::HVMEASURED, hvmeas);
}
void Camera::getHighVoltageTarget(double &hvtarget)
{
DEB_MEMBER_FUNCT();
getParam(Requests::HVTARGET, hvtarget);
}
//-----------------------------------------------------------------------------
/// Count rate correction setter
//-----------------------------------------------------------------------------
......@@ -1012,7 +1013,7 @@ void Camera::getEfficiencyCorrection(bool& value) ///< [out] true:enabled, fals
//-----------------------------------------------------------------------------
/// ThresholdEnergy setter
//-----------------------------------------------------------------------------
void Camera::setThresholdEnergy(double value) ///< [in] true:enabled, false:disabled
void Camera::setThresholdEnergy(double value)
{
DEB_MEMBER_FUNCT();
setParam(Requests::THRESHOLD_ENERGY,value);
......@@ -1022,13 +1023,68 @@ void Camera::setThresholdEnergy(double value) ///< [in] true:enabled, false:disa
//-----------------------------------------------------------------------------
/// ThresholdEnergy getter
//-----------------------------------------------------------------------------
void Camera::getThresholdEnergy(double& value) ///< [out] true:enabled, false:disabled
void Camera::getThresholdEnergy(double& value)
{
DEB_MEMBER_FUNCT();
getParam(Requests::THRESHOLD_ENERGY,value);
}
//-----------------------------------------------------------------------------
/// ThresholdEnergy2 setter
//-----------------------------------------------------------------------------
void Camera::setThresholdEnergy2(double value)
{
DEB_MEMBER_FUNCT();
setParam(Requests::THRESHOLD_ENERGY2,value);
}
//-----------------------------------------------------------------------------
/// ThresholdEnergy getter
//-----------------------------------------------------------------------------
void Camera::getThresholdEnergy2(double& value)
{
DEB_MEMBER_FUNCT();
getParam(Requests::THRESHOLD_ENERGY2,value);
}
//-----------------------------------------------------------------------------
/// ThresholdEnergy2 setter
//-----------------------------------------------------------------------------
void Camera::setThresholdDiffMode(bool value)
{
DEB_MEMBER_FUNCT();
if (value) {
setParam(Requests::THRESHOLD_MODE2,"enabled");
setParam(Requests::THRESHOLD_DIFF_MODE,"enabled");
} else {
setParam(Requests::THRESHOLD_DIFF_MODE,"disabled");
setParam(Requests::THRESHOLD_MODE2,"disabled");
}
}
//-----------------------------------------------------------------------------
/// ThresholdEnergy2 setter
//-----------------------------------------------------------------------------
void Camera::getThresholdDiffMode(bool& value)
{
DEB_MEMBER_FUNCT();
std::string mode_str;
getParam(Requests::THRESHOLD_DIFF_MODE,mode_str);
if (mode_str == "enabled") {
value = true;
} else {
value = false;
}
}
//-----------------------------------------------------------------------------
/// VirtualPixelCorrection setter
//-----------------------------------------------------------------------------
......
......@@ -33,7 +33,7 @@
#include "lima/Exceptions.h"
#include "EigerStream.h"
#define _BSD_SOURCE
//#define _BSD_SOURCE
#include <endian.h>
using namespace lima;
......@@ -170,9 +170,11 @@ inline Json::Value Stream::_ZmqThread::_get_json_header(MessagePtr &msg)
const char* begin = (const char*)data;
const char* end = begin + data_size;
Json::Value header;
Json::Reader reader;
if (!reader.parse(begin,end,header))
THROW_HW_ERROR(Error) << "Error parsing header: " << std::string(begin, end);
Json::CharReaderBuilder rbuilder;
std::unique_ptr<Json::CharReader> const reader(rbuilder.newCharReader());
std::string errs;
if (!reader->parse(begin, end, &header, &errs))
THROW_HW_ERROR(Error) << "Error parsing header: " << errs;
return header;
}
......
......@@ -85,6 +85,8 @@ class Eiger(PyTango.Device_4Impl):
'OFF':False}
self.__PixelMask = {'ON':True,
'OFF':False}
self.__ThresholdDiffMode = {'ON':True,
'OFF':False}
self.__CompressionType = {'NONE': EigerAcq.Camera.NoCompression,
'LZ4': EigerAcq.Camera.LZ4,
'BSLZ4': EigerAcq.Camera.BSLZ4}
......@@ -152,6 +154,14 @@ class Eiger(PyTango.Device_4Impl):
stream_stats_arr = self.latchStreamStatistics(False)
attr.set_value(stream_stats_arr)
@Core.DEB_MEMBER_FUNCT
def read_detector_ip(self, attr):
ip_addr = self.detector_ip_address
ip_addr = ip_addr.replace("100ge1", "")
ip_addr = ip_addr.replace("10ge1", "")
ip_addr = ip_addr.replace("ge1", "")
attr.set_value(ip_addr)
#==================================================================
#
# Eiger command methods
......@@ -242,6 +252,14 @@ class EigerClass(PyTango.DeviceClass):
[[PyTango.DevString,
PyTango.SCALAR,
PyTango.READ]],
'api_version':
[[PyTango.DevString,
PyTango.SCALAR,
PyTango.READ]],
'detector_ip':
[[PyTango.DevString,
PyTango.SCALAR,
PyTango.READ]],
'temperature':
[[PyTango.DevFloat,
PyTango.SCALAR,
......@@ -254,14 +272,6 @@ class EigerClass(PyTango.DeviceClass):
[[PyTango.DevString,
PyTango.SCALAR,
PyTango.READ]],
'high_voltage_measured':
[[PyTango.DevFloat,
PyTango.SCALAR,
PyTango.READ]],
'high_voltage_target':
[[PyTango.DevFloat,
PyTango.SCALAR,
PyTango.READ]],
'countrate_correction':
[[PyTango.DevString,
PyTango.SCALAR,
......@@ -298,6 +308,14 @@ class EigerClass(PyTango.DeviceClass):
[[PyTango.DevFloat,
PyTango.SCALAR,
PyTango.READ_WRITE]],
'threshold_energy2':
[[PyTango.DevFloat,
PyTango.SCALAR,
PyTango.READ_WRITE]],
'threshold_diff_mode':
[[PyTango.DevString,
PyTango.SCALAR,
PyTango.READ_WRITE]],
'photon_energy':
[[PyTango.DevFloat,
PyTango.SCALAR,
......
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