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

Merge branch '123-formalize-acq_info-with-assembly-info' into psi-opencl-processing

parents 3e064f4b 6fa5fe08
......@@ -129,7 +129,9 @@ find_package(TBB REQUIRED COMPONENTS tbb)
find_package(fmt REQUIRED)
#CLI
find_package(cli REQUIRED)
if(LIMA_ENABLE_CLI)
find_package(cli REQUIRED)
endif(LIMA_ENABLE_CLI)
if(LIMA_USE_PCH)
add_compile_definitions(LIMA_USE_PCH)
......@@ -156,17 +158,15 @@ if(LIMA_ENABLE_BLOSC2)
find_package(Blosc2 REQUIRED)
endif()
#file(GLOB_RECURSE lima_header_files "lima/*.hpp")
# Add third parties
add_subdirectory(third_party)
# Add sources
add_subdirectory(src)
# Add detectors
add_subdirectory(detectors)
# Add processing pipelines
add_subdirectory(processings)
# Tests
if(LIMA_ENABLE_TESTS)
enable_testing()
......
......@@ -9,7 +9,7 @@ add_executable(bench_buffer_allocation
)
target_link_libraries(bench_buffer_allocation
lima-core
lima_core
benchmark::benchmark
)
......@@ -21,7 +21,7 @@ add_executable(bench_buffer_pool
)
target_link_libraries(bench_buffer_pool
lima-core
lima_core
benchmark::benchmark
)
......
......@@ -9,6 +9,6 @@ add_executable(bench_io_hdf5
)
target_link_libraries(bench_io_hdf5
lima-core
lima_core
benchmark::benchmark
)
......@@ -105,7 +105,9 @@ static void graph_io_hdf5_raw(benchmark::State& state)
const int nb_frames = 10000;
auto src = input_node(g, nb_frames);
lima::io::h5::writer writer("test_raw.h5", nb_frames, 1, dimensions_t{512, 512}, lima::pixel_enum::gray8);
lima::io::h5::saving_params params;
params.nb_frames_per_file = nb_frames;
lima::io::h5::writer writer("test_writer_raw.h5", params, dimensions_t{512, 512}, lima::pixel_enum::gray8);
flow::function_node<frame_t> write_view(
g, flow::serial, [&writer](frame_t in) { writer.write_view(lima::view(in), in.metadata.idx); });
......@@ -157,8 +159,10 @@ static void graph_io_hdf5_chunk_raw(benchmark::State& state)
}
});
lima::io::h5::writer writer("test_raw.h5", nb_frames, nb_frames_per_chunk, dimensions_t{512, 512},
lima::pixel_enum::gray8);
lima::io::h5::saving_params params;
params.nb_frames_per_file = nb_frames;
params.nb_frames_per_chunk = nb_frames_per_chunk;
lima::io::h5::writer writer("test_writer_raw.h5", params, dimensions_t{512, 512}, lima::pixel_enum::gray8);
flow::function_node<chunk_ptr_t> write_chunk(
g, flow::serial, [&writer](chunk_ptr_t in) { writer.write_chunk(in->data.data(), in->data.size(), in->id); });
......@@ -210,8 +214,10 @@ static void graph_io_hdf5_comp(benchmark::State& state)
return res;
});
lima::io::h5::writer writer("test_comp.h5", nb_frames, 1, dimensions_t{512, 512}, lima::pixel_enum::gray8,
lima::io::h5::compression_enum::bshuf_lz4);
lima::io::h5::saving_params params;
params.nb_frames_per_file = nb_frames;
params.compression = lima::io::h5::compression_enum::bshuf_lz4;
lima::io::h5::writer writer("test_writer_raw.h5", params, dimensions_t{512, 512}, lima::pixel_enum::gray8);
flow::function_node<chunk_ptr_t> write_chunk(
g, flow::serial, [&writer](chunk_ptr_t in) { writer.write_chunk(in->data.data(), in->data.size(), in->id); });
......@@ -290,8 +296,11 @@ static void graph_io_hdf5_chunk_comp(benchmark::State& state)
return res;
});
lima::io::h5::writer writer("test_chunk_comp.h5", nb_frames, nb_frames_per_chunk, dimensions_t{512, 512},
lima::pixel_enum::gray8, lima::io::h5::compression_enum::bshuf_lz4);
lima::io::h5::saving_params params;
params.nb_frames_per_file = nb_frames;
params.nb_frames_per_chunk = nb_frames_per_chunk;
params.compression = lima::io::h5::compression_enum::bshuf_lz4;
lima::io::h5::writer writer("test_writer_raw.h5", params, dimensions_t{512, 512}, lima::pixel_enum::gray8);
flow::function_node<chunk_ptr_t> write_chunk(g, flow::serial, [&writer, &nb_frames_per_chunk](chunk_ptr_t in) {
writer.write_chunk(in->data.data(), in->data.size(), in->id);
......
......@@ -9,7 +9,7 @@ add_executable(bench_binning
)
target_link_libraries(bench_binning
lima-core
lima_core
benchmark::benchmark
TIFF::TIFF
)
......@@ -19,7 +19,7 @@ add_executable(bench_exp4bit
)
target_link_libraries(bench_exp4bit
lima-core
lima_core
benchmark::benchmark
)
......@@ -28,7 +28,7 @@ add_executable(bench_sparse
)
target_link_libraries(bench_sparse
lima-core
lima_core
benchmark::benchmark
)
......@@ -37,7 +37,7 @@ add_executable(bench_gather
)
target_link_libraries(bench_gather
lima-core
lima_core
benchmark::benchmark
)
......@@ -46,7 +46,7 @@ add_executable(bench_rotation
)
target_link_libraries(bench_rotation
lima-core
lima_core
benchmark::benchmark
)
......@@ -55,7 +55,7 @@ add_executable(bench_flip
)
target_link_libraries(bench_flip
lima-core
lima_core
benchmark::benchmark
)
......@@ -64,7 +64,7 @@ add_executable(bench_counters
)
target_link_libraries(bench_counters
lima-core
lima_core
benchmark::benchmark
)
......
#!/bin/bash
cmake -Bbuild -H. -G "Ninja" -DCMAKE_INSTALL_PREFIX=$PREFIX -DCMAKE_FIND_ROOT_PATH=$PREFIX -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY -DLIMA_ENABLE_TESTS=ON -DLIMA_ENABLE_TEST_HEADERS=ON -DLIMA_ENABLE_BENCHMARKS=ON -DLIMA_ENABLE_MPI=ON -DLIMA_ENABLE_PYTHON=ON -DLIMA_ENABLE_TIFF=ON -DLIMA_ENABLE_HDF5=ON -DLIMA_ENABLE_NUMA=ON -DLIMA_ENABLE_BSHUF_LZ4=ON -DLIMA_ENABLE_ZLIB=ON -DLIMA_CAMERA_PSI=ON
cmake -Bbuild -H. -G "Ninja" -DCMAKE_INSTALL_PREFIX=$PREFIX -DCMAKE_FIND_ROOT_PATH=$PREFIX -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY -DLIMA_ENABLE_TESTS=ON -DLIMA_ENABLE_TEST_HEADERS=ON -DLIMA_ENABLE_BENCHMARKS=ON -DLIMA_ENABLE_MPI=ON -DLIMA_ENABLE_PYTHON=ON -DLIMA_ENABLE_TIFF=ON -DLIMA_ENABLE_HDF5=ON -DLIMA_ENABLE_NUMA=ON -DLIMA_ENABLE_BSHUF_LZ4=ON -DLIMA_ENABLE_ZLIB=ON -DLIMA_ENABLE_OPENCL=ON -DLIMA_CAMERA_PSI=ON
cmake --build build --target install
......@@ -41,6 +41,8 @@ requirements:
- cpptango
- omniorb
- cppzmq
# GPU
- pocl-cuda
build:
- git
- cmake >=3.16
......
# Copyright (C) 2018 Samuel Debionne, 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)
if(LIMA_USE_LEGACY)
project(legacy)
# Library definition
add_library(legacy SHARED
src/SimulatorFrameBuilder.cpp
src/SimulatorFrameLoader.cpp
src/SimulatorFramePrefetcher.cpp
src/SimulatorCamera.cpp
src/SimulatorInterface.cpp
src/SimulatorSyncCtrlObj.cpp
src/SimulatorDetInfoCtrlObj.cpp
src/SimulatorShutterCtrlObj.cpp
src/SimulatorBinCtrlObj.cpp
)
# Generate export macros
generate_export_header(legacy)
target_include_directories(legacy
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include
)
target_link_libraries(legacy
lima-core
lima-legacy
)
endif(LIMA_USE_LEGACY)
//###########################################################################
// This file is part of LImA, a Library for Image Acquisition
//
// Copyright (C) : 2009-2011
// European Synchrotron Radiation Facility
// BP 220, Grenoble 38043
// FRANCE
//
// This is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3 of the License, or
// (at your option) any later version.
//
// This software is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, see <http://www.gnu.org/licenses/>.
//###########################################################################
#pragma once
#if !defined(SIMULATOR_BINCTRLOBJ_H)
#define SIMULATOR_BINCTRLOBJ_H
#include <lima/HwInterface.h>
#include <simulator_export.h>
namespace lima {
// Forward definitions
class HwInterface;
namespace Simulator {
class Camera;
/// Control object providing simulator binning interface
class SIMULATOR_EXPORT BinCtrlObj : public HwBinCtrlObj {
public:
BinCtrlObj(Camera &simu) : m_simu(simu) {}
virtual void setBin(const Bin &bin);
virtual void getBin(Bin &bin);
virtual void checkBin(Bin &bin);
private:
Camera &m_simu;
};
} // namespace Simulator
} // namespace lima
#endif // !defined(SIMULATOR_BINCTRLOBJ_H)
//###########################################################################
// This file is part of LImA, a Library for Image Acquisition
//
// Copyright (C) : 2009-2011
// European Synchrotron Radiation Facility
// BP 220, Grenoble 38043
// FRANCE
//
// This is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3 of the License, or
// (at your option) any later version.
//
// This software is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, see <http://www.gnu.org/licenses/>.
//###########################################################################
#pragma once
#if !defined(SIMULATOR_CAMERA_H)
#define SIMULATOR_CAMERA_H
#include <ostream>
#include <lima/HwInterface.h>
#include <lima/HwBufferMgr.h>
#include <lima/ThreadUtils.h>
#include <lima/SizeUtils.h>
#include <simulator_export.h>
namespace lima {
namespace Simulator {
// Forward definitions
struct FrameGetter;
class FrameBuilder;
class FrameLoader;
template <typename FrameGetter>
class FramePrefetcher;
class SIMULATOR_EXPORT Camera {
DEB_CLASS_NAMESPC(DebModCamera, "Camera", "Simulator");
public:
enum Mode {
MODE_GENERATOR, //<! Generate frames using a super smart multi-gaussian algorithm in realtime (default)
MODE_GENERATOR_PREFETCH, //<! Prebuild frames using a super smart multi-gaussian algorithm
MODE_LOADER, //<! Load frames from files in realtime
MODE_LOADER_PREFETCH, //<! Preload frames from files
};
enum SimuShutterMode { FRAME, MANUAL };
static const char *DetectorModel[4];
Camera(const Mode &mode = Mode::MODE_GENERATOR);
~Camera();
HwBufferCtrlObj *getBufferCtrlObj() { return &m_buffer_ctrl_obj; }
FrameGetter *getFrameGetter() { return m_frame_getter; }
FrameBuilder *getFrameBuilder();
FramePrefetcher<FrameBuilder> *getFrameBuilderPrefetched();
FrameLoader *getFrameLoader();
FramePrefetcher<FrameLoader> *getFrameLoaderPrefetched();
/// Returns the detectof model (according to the current mode)
void getDetectorModel(std::string &det_model) const;
void prepareAcq();
void startAcq();
void stopAcq();
void setMode(const Mode &mode);
void getMode(Mode &mode) const { mode = m_mode; }
void setNbFrames(int nb_frames);
void getNbFrames(int &nb_frames);
void setExpTime(double exp_time);
void getExpTime(double &exp_time);
void setLatTime(double lat_time);
void getLatTime(double &lat_time);
void setTrigMode(TrigMode trig_mode) { m_trig_mode = trig_mode; };
void getTrigMode(TrigMode &trig_mode) { trig_mode = m_trig_mode; };
void setFrameDim(const FrameDim &frame_dim);
void getFrameDim(FrameDim &frame_dim);
void getMaxImageSize(Size &max_image_size) const;
HwInterface::StatusType::Basic getStatus();
int getNbAcquiredFrames();
void reset();
private:
class SimuThread : public CmdThread {
DEB_CLASS_NAMESPC(DebModCamera, "Camera", "SimuThread");
public:
enum { // Status
Ready = MaxThreadStatus,
Prepare,
Exposure,
Readout,
Latency,
};
enum { // Cmd
PrepareAcq = MaxThreadCmd,
StartAcq,
StopAcq,
};
SimuThread(Camera &simu);
~SimuThread();
virtual void start();
int m_acq_frame_nb;
protected:
virtual void init();
virtual void execCmd(int cmd);
private:
void execPrepareAcq();
void execStartAcq();
Camera *m_simu;
};
friend class SimuThread;
void setDefaultProperties();
void constructFrameGetter();
double m_exp_time;
double m_lat_time;
int m_nb_frames;
TrigMode m_trig_mode;
SoftBufferCtrlObj m_buffer_ctrl_obj;
SimuThread m_thread;
Mode m_mode; //<! The current mode of the simulateur
FrameGetter *m_frame_getter; //<! The current frame getter (according to the mode)
// unsigned int m_nb_prebuilt_frames; //<! In MODE_GENERATOR_PREBUILT mode, the number of frame to prebuilt
// std::string m_file_pattern; //<! In MODE_LOADER mode, the file pattern use to load the frames
// bool m_mis_cb_act; //<! Used by setMaxImageSizeCallbackActive
};
SIMULATOR_EXPORT std::ostream &operator<<(std::ostream &os, Camera &simu);
} // namespace Simulator
} // namespace lima
#endif // !defined(SIMULATOR_CAMERA_H)
//###########################################################################
// This file is part of LImA, a Library for Image Acquisition
//
// Copyright (C) : 2009-2011
// European Synchrotron Radiation Facility
// BP 220, Grenoble 38043
// FRANCE
//
// This is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3 of the License, or
// (at your option) any later version.
//
// This software is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, see <http://www.gnu.org/licenses/>.
//###########################################################################
#pragma once
#if !defined(SIMULATOR_DETINFOCTRLOBJ_H)
#define SIMULATOR_DETINFOCTRLOBJ_H
#include <simulator_export.h>
#include "SimulatorCamera.h"
namespace lima {
namespace Simulator {
/// Control object providing simulator detector info interface
class SIMULATOR_EXPORT DetInfoCtrlObj : public HwDetInfoCtrlObj {
public:
DetInfoCtrlObj(Camera &simu) : m_simu(simu) {}
virtual void getMaxImageSize(Size &max_image_size);
virtual void getDetectorImageSize(Size &det_image_size);
virtual void getDefImageType(ImageType &def_image_type);
virtual void getCurrImageType(ImageType &curr_image_type);
virtual void setCurrImageType(ImageType curr_image_type);
virtual void getPixelSize(double &x_size, double &y_size);
virtual void getDetectorType(std::string &det_type);
virtual void getDetectorModel(std::string &det_model);
virtual void registerMaxImageSizeCallback(HwMaxImageSizeCallback &cb);
virtual void unregisterMaxImageSizeCallback(HwMaxImageSizeCallback &cb);
private:
Camera &m_simu;
};
} // namespace Simulator
} // namespace lima
#endif //! defined(SIMULATOR_DETINFOCTRLOBJ_H)
//###########################################################################
// This file is part of LImA, a Library for Image Acquisition
//
// Copyright (C) : 2009-2011
// European Synchrotron Radiation Facility
// BP 220, Grenoble 38043
// FRANCE
//
// This is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3 of the License, or
// (at your option) any later version.
//
// This software is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, see <http://www.gnu.org/licenses/>.
//###########################################################################
#pragma once
#if !defined(SIMULATOR_FRAMEBUILDER_H)
#define SIMULATOR_FRAMEBUILDER_H
#include <vector>
#include <lima/SizeUtils.h>
#include <lima/Exceptions.h>
#include <simulator_export.h>
#include "simulator/SimulatorFrameGetter.h"
namespace lima {
namespace Simulator {
struct SIMULATOR_EXPORT GaussPeak {
double x0, y0; //<! The center of the peak
double fwhm; //<! Full Width at Half Maximum
double max; //<! The maximum value
GaussPeak() : x0(0), y0(0), fwhm(0), max(0) {}
GaussPeak(const GaussPeak &o) : x0(o.x0), y0(o.y0), fwhm(o.fwhm), max(o.max) {}
GaussPeak(double x, double y, double w, double m) : x0(x), y0(y), fwhm(w), max(m) {}
};
/// This class configures and generates frames for the Simulator
class SIMULATOR_EXPORT FrameBuilder : public FrameGetter {
DEB_CLASS_NAMESPC(DebModCamera, "FrameBuilder", "Simulator");
public:
static const bool is_thread_safe = true;
static const int max_dim = 1024;
enum FillType {
Gauss,
Diffraction,
};
enum RotationAxis {
Static,
RotationX,
RotationY,
};
typedef std::vector<struct GaussPeak> PeakList;
FrameBuilder();
FrameBuilder(FrameDim &frame_dim, Bin &bin, Roi &roi, const PeakList &peaks, double grow_factor);
~FrameBuilder();
Camera::Mode getMode() const { return Camera::MODE_GENERATOR; }
void getFrameDim(FrameDim &dim) const;
void setFrameDim(const FrameDim &dim);
void getBin(Bin &bin) const;
void setBin(const Bin &bin);
void checkBin(Bin &bin) const;
void getRoi(Roi &roi) const;
void setRoi(const Roi &roi);
void checkRoi(Roi &roi) const;
void getPeaks(PeakList &peaks) const;