Commit ae267a47 authored by Alejandro Homs Puron's avatar Alejandro Homs Puron Committed by Generic Bliss account for Control Software
Browse files

[PSI] Add gain_mode control

parent 5f3e8b08
......@@ -18,6 +18,8 @@ namespace detectors::psi::hw
{
BOOST_DESCRIBE_ENUM(assembly_mode_enum, raw, assembled_no_gap, assembled_with_gap)
BOOST_DESCRIBE_ENUM(gain_mode_enum, dynamic, force_switch_g1, force_switch_g2, fix_g1, fix_g2, fix_g0)
using boost::describe::operator<<;
using boost::describe::operator>>;
......
......@@ -18,5 +18,16 @@ namespace detectors::psi::hw
assembled_with_gap
};
/// Detector gain mode
enum class gain_mode_enum : int
{
dynamic,
force_switch_g1,
force_switch_g2,
fix_g1,
fix_g2,
fix_g0
};
} // namespace detectors::psi::hw
} // namespace lima
......@@ -26,13 +26,18 @@ namespace detectors::psi::hw
(doc, "The PSI plugin configuration file in JSON format"))
// clang-format on
BOOST_DESCRIBE_STRUCT(detector_params, (), (bit_depth, packet_fifo_depth, assembly_mode))
BOOST_DESCRIBE_STRUCT(detector_params, (), (bit_depth, gain_mode, packet_fifo_depth, assembly_mode))
// clang-format off
BOOST_ANNOTATE_MEMBER(detector_params, bit_depth,
(desc, "detector bit depth"),
(doc, "The detector bit depth (depends on detector model) [4, 8, 16, 32]"))
BOOST_ANNOTATE_MEMBER(detector_params, gain_mode,
(desc, "detector gain mode"),
(doc, "The detector gain-mode (depends on detector model) "
"[dynamic, force_switch_g1, force_switch_g2, fix_g1, fix_g2, fix_g0]"))
BOOST_ANNOTATE_MEMBER(detector_params, packet_fifo_depth,
(desc, "detector packet fifo size in frames"),
(doc, "The size of each receiver listener packet fifo"))
......
......@@ -25,7 +25,8 @@ namespace detectors::psi::hw
/// Acquisition parameters specific to the camera
struct detector_params
{
short bit_depth;
short bit_depth{16};
gain_mode_enum gain_mode{gain_mode_enum::dynamic};
int packet_fifo_depth{2500};
assembly_mode_enum assembly_mode{assembly_mode_enum::assembled_with_gap};
};
......
......@@ -18,6 +18,8 @@
#include <lima/detectors/psi/hw/control.hpp>
#include <lima/detectors/psi/utils.hpp>
#include <lima/detectors/psi/hw/params.describe.hpp>
using namespace std::string_literals;
namespace gil = boost::gil;
......@@ -93,6 +95,7 @@ class control::impl
void remove_shared_mem();
void load_sdk_config_params(const sdk_config_params& params);
void check_rr_recv_frame_match();
void set_gain_mode(gain_mode_enum gain_mode);
};
control::impl::impl(control& ct, const control::init_params_t& init_params) : m_ct(ct), m_init_params(init_params)
......@@ -218,6 +221,37 @@ void control::impl::check_rr_recv_frame_match()
}
}
void control::impl::set_gain_mode(gain_mode_enum gain_mode)
{
LIMA_LOG(trace, det) << "Setting gain mode: " << gain_mode;
slsDetectorDefs::gainMode sdk_gain_mode;
switch (gain_mode) {
case gain_mode_enum::dynamic:
sdk_gain_mode = slsDetectorDefs::DYNAMIC;
break;
case gain_mode_enum::force_switch_g1:
sdk_gain_mode = slsDetectorDefs::FORCE_SWITCH_G1;
break;
case gain_mode_enum::force_switch_g2:
sdk_gain_mode = slsDetectorDefs::FORCE_SWITCH_G2;
break;
case gain_mode_enum::fix_g1:
sdk_gain_mode = slsDetectorDefs::FIX_G1;
break;
case gain_mode_enum::fix_g2:
sdk_gain_mode = slsDetectorDefs::FIX_G2;
break;
case gain_mode_enum::fix_g0:
sdk_gain_mode = slsDetectorDefs::FIX_G0;
break;
default:
std::ostringstream os;
os << gain_mode;
throw lima::invalid_argument("Unknown gain mode: " + os.str());
}
m_det->setGainMode(sdk_gain_mode);
}
void control::impl::hw_prepare(acq_params_t const& acq_params)
{
using namespace sls::FrameAssembler;
......@@ -236,6 +270,9 @@ void control::impl::hw_prepare(acq_params_t const& acq_params)
m_det->setNumberOfTriggers(cam_triggers);
// Set detector parameters
set_gain_mode(acq_params.det.gain_mode);
// Set Fifo depth
m_det->setRxFifoDepth(acq_params.det.packet_fifo_depth);
// Disable SDK file writing
......
Supports Markdown
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