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

[PSI] Adapt to latest core

parent cdaa5d96
......@@ -6,7 +6,7 @@
{% endif %}
package:
name: lima2-tango-servers
name: lima2-psi
version: {{ version }}
source:
......
// Copyright (C) 2020 Alejandro Homs Puron, ESRF.
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#pragma once
#include <lima/detectors/psi.hpp>
#include <lima/detectors/psi/hw/params.describe.hpp>
......@@ -6,11 +6,8 @@
#pragma once
#if !defined(LIMA_DETECTORS_PSI_DETECTOR_HPP)
#define LIMA_DETECTORS_PSI_DETECTOR_HPP
#include <psi/controller.hpp>
#include <psi/receiver.hpp>
#include <lima/detectors/psi/controller.hpp>
#include <lima/detectors/psi/receiver.hpp>
#include <psi_hw_export.h>
#if defined(LIMA_HAS_PROPAGATE_CONST)
......@@ -19,19 +16,16 @@
namespace lima
{
namespace psi
namespace detectors::psi
{
struct PSI_HW_EXPORT detector
{
using controller_t = controller;
template <typename Processing>
using receiver_t = receiver<Processing>;
using receiver_t = receiver;
/// Name of the camera
static constexpr const char* const name = "psi";
};
} // namespace psi
} // namespace detectors::psi
} // namespace lima
#endif //!defined(LIMA_DETECTORS_PSI_DETECTOR_HPP)
......@@ -6,37 +6,28 @@
#pragma once
#if !defined(LIMA_DETECTORS_PSI_CONTROLLER_HPP)
#define LIMA_DETECTORS_PSI_CONTROLLER_HPP
#include <functional>
#include <memory>
#include <string>
#include <type_traits>
#include <vector>
#if defined(LIMA_HAS_PROPAGATE_CONST)
#include <experimental/propagate_const>
#endif
#include <lima/core/enums.hpp>
#include <lima/core/uuid.hpp>
#include <lima/hw/info.hpp>
#include <lima/utils/channel.hpp>
#include <psi/hw/config.hpp>
#include <lima/detectors/psi/hw/config.hpp>
#include <psi_hw_export.h>
namespace lima
{
namespace psi
namespace detectors::psi
{
class PSI_HW_EXPORT controller
{
public:
using init_params_t = typename hw::config::init_params_t;
using acq_params_t = typename hw::config::acq_params_t;
using acquisition_uid_t = uuid;
/// Construct the controller and broadcast the camera init parameters
controller(init_params_t const& init_params, bool attach_debugger = false);
......@@ -50,7 +41,7 @@ namespace psi
int world_rank() const;
/// Prepare acquisition and processing pipeline
void prepare_acq(acquisition_uid_t const& uuid, acq_params_t const& acq_params);
void prepare_acq(acq_params_t const& acq_params);
/// Start acquisition
void start_acq();
......@@ -91,7 +82,5 @@ namespace psi
#endif
};
} // namespace psi
} // namespace detectors::psi
} //namespace lima
#endif //!defined(LIMA_DETECTORS_PSI_CONTROLLER_HPP)
......@@ -6,14 +6,9 @@
#pragma once
#if !defined(LIMA_DETECTORS_PSI_HW_ACQUISITION_HPP)
#define LIMA_DETECTORS_PSI_HW_ACQUISITION_HPP
#include <string>
#include <lima/hw/acquisition.hpp>
#include <psi/hw/config.hpp>
#include <lima/detectors/psi/hw/config.hpp>
#include <psi_hw_export.h>
#if defined(LIMA_HAS_PROPAGATE_CONST)
......@@ -22,7 +17,7 @@
namespace lima
{
namespace psi::hw
namespace detectors::psi::hw
{
// Acquisition part of the camera
class PSI_HW_EXPORT acquisition : public lima::hw::acquisition<acquisition, config>
......@@ -36,9 +31,6 @@ namespace psi::hw
acquisition(const init_params_t& init_params);
~acquisition(); // defined in the implementation file, where impl is a complete type
/// Camera specific function
std::string detector_type();
private:
/// Prepare the acquisition (e.g. allocate buffers)
acq_info_t hw_prepare(acq_params_t const& acq_params);
......@@ -49,12 +41,6 @@ namespace psi::hw
/// Stop acquisition loop
void hw_stop();
/// Returns the number of frames already acquired
int hw_nb_frames_acquired() const;
/// Returns the number of frames already transfered
int hw_nb_frames_xfered() const;
/// Get frame
data_t hw_get_frame();
......@@ -72,7 +58,5 @@ namespace psi::hw
#endif
};
} // namespace psi::hw
} // namespace detectors::psi::hw
} // namespace lima
#endif //!defined(LIMA_DETECTORS_PSI_HW_ACQUISITION_HPP)
......@@ -6,24 +6,17 @@
#pragma once
#if !defined(LIMA_DETECTORS_PSI_HW_CONFIG_HPP)
#define LIMA_DETECTORS_PSI_HW_CONFIG_HPP
#include <lima/core/frame.hpp>
#include <string>
#include <filesystem>
#include <lima/hw/acq_info.hpp>
#include <lima/hw/params.hpp>
#include <lima/core/frame_info.hpp>
#include <lima/core/uuid.hpp>
#include <lima/hw/config.hpp>
#include <lima/logging.hpp>
#include <psi/typedefs.hpp>
#include <psi/hw/params.hpp>
#include <lima/detectors/psi/typedefs.hpp>
#include <lima/detectors/psi/hw/params.hpp>
namespace lima
{
namespace psi::hw
namespace detectors::psi::hw
{
/// Configuration of the camera plugin
struct config
......@@ -33,21 +26,17 @@ namespace psi::hw
{
};
using acquisition_uid_t = uuid;
/// Initialization parameters specific to the camera
using init_params_t = init_params;
/// Acquisition parameters
using acq_params_t = acquisition_params;
using acq_params_t = acq_params;
/// Acquisition information passed to processing
using acq_info_t = lima::psi::acq_info;
using acq_info_t = lima::hw::acq_info;
/// Output data type of the acquisition
using data_t = lima::psi::frame_data;
using data_t = std::any;
};
} // namespace psi::hw
} // namespace detectors::psi::hw
} // namespace lima
#endif //!defined(LIMA_DETECTORS_PSI_HW_CONFIG_HPP)
......@@ -6,15 +6,12 @@
#pragma once
#if !defined(LIMA_DETECTORS_PSI_HW_CONTROL_HPP)
#define LIMA_DETECTORS_PSI_HW_CONTROL_HPP
#include <string>
#include <lima/hw/control.hpp>
#include <lima/hw/info.hpp>
#include <psi/hw/config.hpp>
#include <lima/detectors/psi/hw/config.hpp>
#include <psi_hw_export.h>
#if defined(LIMA_HAS_PROPAGATE_CONST)
......@@ -23,7 +20,7 @@
namespace lima
{
namespace psi::hw
namespace detectors::psi::hw
{
class PSI_HW_EXPORT control : public lima::hw::control<control, config>
{
......@@ -36,9 +33,6 @@ namespace psi::hw
control(const init_params_t& init_params = init_params_t());
~control(); // defined in the implementation file, where impl is a complete type
/// My camera specific command
std::string detector_type();
private:
/// Prepare acquisition
void hw_prepare(acq_params_t const& acq_params);
......@@ -64,6 +58,12 @@ namespace psi::hw
/// Returns information about the hardware capabilities
lima::hw::info hw_info() const;
/// Returns the number of frames already acquired
int hw_nb_frames_acquired() const;
/// Camera specific commands
std::string detector_type();
class impl; // forward declaration of the implementation class
// One implementation example: see below for other design options and trade-offs
#if defined(LIMA_HAS_PROPAGATE_CONST)
......@@ -77,7 +77,5 @@ namespace psi::hw
m_pimpl; // to the forward-declared implementation class
#endif
};
} // namespace psi::hw
} // namespace detectors::psi::hw
} // namespace lima
#endif //!defined(LIMA_DETECTORS_PSI_HW_CONTROL_HPP)
// Copyright (C) 2018 Alejandro Homs, ESRF.
// Copyright (C) 2020 Alejandro Homs Puron, ESRF.
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
......@@ -6,26 +6,20 @@
#pragma once
#if !defined(LIMA_DETECTORS_PSI_PROCESSING_GRAPH_ID29_HPP)
#define LIMA_DETECTORS_PSI_PROCESSING_GRAPH_ID29_HPP
#include <boost/describe.hpp>
#include <psi/processing/graph/id29/processing.hpp>
#include <boost/describe/io_enums.hpp>
#include <lima/detectors/psi/hw/enums.hpp>
namespace lima
{
namespace psi::processing
namespace detectors::psi::hw
{
namespace id29
{
struct graph
{
/// Name of the processing
static constexpr const char* const name = "id29";
using processing_t = processing;
};
} // namespace id29
} // namespace psi::processing
} // namespace lima
BOOST_DESCRIBE_ENUM(assembly_mode_enum, raw, assembled_no_gap, assembled_with_gap)
#endif //!defined(LIMA_DETECTORS_PSI_PROCESSING_GRAPH_ID29_HPP)
using boost::describe::operator<<;
using boost::describe::operator>>;
} // namespace detectors::psi::hw
} // namespace lima
// Copyright (C) 2018 Samuel Debionne, ESRF.
// Copyright (C) 2020 Alejandro Homs Puron, ESRF.
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
......@@ -6,24 +6,17 @@
#pragma once
#if !defined(LIMA_DETECTORS_PSI_HW_INTERFACE_HPP)
#define LIMA_DETECTORS_PSI_HW_INTERFACE_HPP
#include <psi/hw/config.hpp>
#include <psi/hw/acquisition.hpp>
#include <psi/hw/control.hpp>
#include <psi_hw_export.h>
namespace lima
{
namespace psi::hw
namespace detectors::psi::hw
{
struct PSI_HW_EXPORT interface : config
/// Frame (reconstruction) assembly mode
enum class assembly_mode_enum : int
{
using control_t = control;
using acquisition_t = acquisition;
raw,
assembled_no_gap,
assembled_with_gap
};
} // namespace psi::hw
} // namespace lima
#endif //!defined(LIMA_DETECTORS_PSI_HW_INTERFACE_HPP)
} // namespace detectors::psi::hw
} // namespace lima
......@@ -6,19 +6,17 @@
#pragma once
#if !defined(LIMA_DETECTORS_PSI_HW_PARAMS_DESCRIBE_HPP)
#define LIMA_DETECTORS_PSI_HW_PARAMS_DESCRIBE_HPP
#include <boost/describe/annotations.hpp>
#include <boost/describe/io_structs.hpp>
#include <lima/hw/params.describe.hpp>
#include <psi/hw/params.hpp>
#include <lima/detectors/psi/hw/enums.describe.hpp>
#include <lima/detectors/psi/hw/params.hpp>
namespace lima
{
namespace psi::hw
namespace detectors::psi::hw
{
BOOST_DESCRIBE_STRUCT(init_params, (), (config_file))
......@@ -28,7 +26,7 @@ namespace psi::hw
(doc, "The PSI plugin configuration file in JSON format"))
// clang-format on
BOOST_DESCRIBE_STRUCT(detector_params, (), (bit_depth, packet_fifo_depth))
BOOST_DESCRIBE_STRUCT(detector_params, (), (bit_depth, packet_fifo_depth, assembly_mode))
// clang-format off
BOOST_ANNOTATE_MEMBER(detector_params, bit_depth,
......@@ -38,43 +36,21 @@ namespace psi::hw
BOOST_ANNOTATE_MEMBER(detector_params, packet_fifo_depth,
(desc, "detector packet fifo size in frames"),
(doc, "The size of each receiver listener packet fifo"))
BOOST_ANNOTATE_MEMBER(detector_params, assembly_mode,
(desc, "frame assembly mode"),
(doc, "The frame (reconstruction) assembly mode: raw, assembled_no_gap, assembled_with_gap"))
// clang-format on
BOOST_DESCRIBE_STRUCT(acquisition_params, (), (acq, img, shut, accu, vid, xfer, det))
BOOST_DESCRIBE_STRUCT(acq_params, (lima::hw::acq_params), (det))
// clang-format off
BOOST_ANNOTATE_MEMBER(acquisition_params, acq,
(desc, "acquisition"),
(doc, "The HW acquisition parameters of the detector"))
BOOST_ANNOTATE_MEMBER(acquisition_params, img,
(desc, "image"),
(doc, "The HW image parameters of the detector (ROI, Flip, Binning)"))
BOOST_ANNOTATE_MEMBER(acquisition_params, shut,
(desc, "shutter"),
(doc, "The HW shutter parameters of the detector"))
BOOST_ANNOTATE_MEMBER(acquisition_params, accu,
(desc, "accumulation"),
(doc, "The HW accumulation parameters of the detector"))
BOOST_ANNOTATE_MEMBER(acquisition_params, vid,
(desc, "video"),
(doc, "The HW vid parameters of the detector"))
BOOST_ANNOTATE_MEMBER(acquisition_params, xfer,
(desc, "transfer"),
(doc, "The HW transfer parameters of the detector"))
BOOST_ANNOTATE_MEMBER(acquisition_params, det,
BOOST_ANNOTATE_MEMBER(acq_params, det,
(desc, "detector"),
(doc, "The HW specific parameters of the detector"))
// clang-format on
using boost::describe::operator<<;
} // namespace psi::hw
} // namespace detectors::psi::hw
} // namespace lima
#endif //!defined(LIMA_DETECTORS_PSI_HW_PARAMS_DESCRIBE_HPP)
......@@ -6,17 +6,15 @@
#pragma once
#if !defined(LIMA_DETECTORS_PSI_HW_PARAMS_HPP)
#define LIMA_DETECTORS_PSI_HW_PARAMS_HPP
#include <array>
#include <filesystem>
#include <lima/core/enums.hpp>
#include <lima/core/rectangle.hpp>
#include <lima/detectors/psi/hw/enums.hpp>
namespace lima
{
namespace psi::hw
namespace detectors::psi::hw
{
/// Initialization parameters specific to the camera
struct init_params
......@@ -29,20 +27,13 @@ namespace psi::hw
{
short bit_depth;
int packet_fifo_depth{2500};
assembly_mode_enum assembly_mode{assembly_mode_enum::assembled_with_gap};
};
struct acquisition_params
struct acq_params : lima::hw::acq_params
{
lima::hw::acquisition_params acq; //!< Acquisition parameters
lima::hw::image_params img; //!< Image parameters
lima::hw::shutter_params shut; //!< Shutter parameters
lima::hw::accumulation_params accu; //!< Accumulation parameters
lima::hw::video_params vid; //!< Video parameters
lima::hw::xfer_params xfer; //!< Transfer parameters
detector_params det; //!< Detector parameters
detector_params det; //!< Detector parameters
};
} // namespace psi::hw
} // namespace detectors::psi::hw
} // namespace lima
#endif //!defined(LIMA_DETECTORS_PSI_HW_PARAMS_HPP)
......@@ -6,38 +6,28 @@
#pragma once
#if !defined(LIMA_DETECTORS_PSI_RECEIVER_HPP)
#define LIMA_DETECTORS_PSI_RECEIVER_HPP
#include <functional>
#include <type_traits>
#include <memory>
#if defined(LIMA_HAS_PROPAGATE_CONST)
#include <experimental/propagate_const>
#endif
#include <psi/hw/config.hpp>
#include <lima/detectors/psi/hw/config.hpp>
#include <psi_hw_export.h>
namespace lima
{
namespace psi
namespace detectors::psi
{
template <typename Processing>
class PSI_HW_EXPORT receiver
{
static_assert(std::is_same_v<hw::config::data_t, typename Processing::data_t>,
"Detector and processing frame types do not match");
public:
using init_params_t = typename hw::config::init_params_t;
using acq_params_t = typename hw::config::acq_params_t;
using proc_params_t = typename Processing::proc_params_t;
using acquisition_uid_t = uuid;
using proc_states_t = typename Processing::proc_states_t;
using data_t = typename Processing::data_t;
using acq_info_t = typename hw::config::acq_info_t;
using data_t = typename hw::config::data_t;
receiver();
~receiver(); // defined in the implementation file, where impl is a complete type
......@@ -53,7 +43,7 @@ namespace psi
int recv_rank() const;
/// Prepare acquisition and processing pipeline
void prepare_acq(acquisition_uid_t uuid, acq_params_t const& acq_params, proc_params_t const& proc_params);
acq_info_t prepare_acq(acq_params_t const& acq_params);
/// Start acquisition
void start_acq();
......@@ -62,19 +52,13 @@ namespace psi
void stop_acq();
/// Returns the number of frames transfered
int nb_frames_xfered() const;
/// List all the processings
std::vector<acquisition_uid_t> list_proc() const;
int nb_frames_xferred() const;
/// Abort processing
void abort_proc(acquisition_uid_t const& uid);
/// Register a callack for on acquisition start event
void register_on_start(std::function<void()> cbk);
/// Erase processing from processing list
void erase_proc(acquisition_uid_t const& uid);
/// Get processing states
proc_states_t get_states(lima::uuid const& uid) const;
/// Register a callack for on frame ready event
void register_on_frame_ready(std::function<void(data_t)> cbk);
/// Set a callack for on end of acquisition event
void register_on_end_acq(std::function<void(int)> cbk);
......@@ -94,7 +78,5 @@ namespace psi
#endif
};
} // namespace psi
} // namespace detectors::psi
} //namespace lima
#endif //!defined(LIMA_DETECTORS_PSI_RECEIVER_HPP)
......@@ -6,9 +6,6 @@
#pragma once
#if !defined(LIMA_DETECTORS_PSI_TYPEDEFS_HPP)
#define LIMA_DETECTORS_PSI_TYPEDEFS_HPP
#include <any>
#include <lima/core/frame.hpp>
......@@ -17,7 +14,7 @@
namespace lima
{
namespace psi
namespace detectors::psi
{
using acq_info = std::any;
......@@ -27,7 +24,5 @@ namespace psi
lima::frame::metadata_t metadata;
};
} // namespace psi
} // namespace detectors::psi
} // namespace lima
#endif //!defined(LIMA_DETECTORS_PSI_TYPEDEFS_HPP)