Commit 5ba1e45e authored by Samuel Debionne's avatar Samuel Debionne
Browse files

Split rashpa wrapper in manager and receiver

parent 6df74901
Pipeline #25263 failed with stages
in 22 minutes and 12 seconds
// 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)
#pragma once
#if !defined(LIMA_CAMERAS_SMARTPIX_RASHPA_MANAGER_HPP)
#define LIMA_CAMERAS_SMARTPIX_RASHPA_MANAGER_HPP
#include <string>
#include <vector>
#include <libdeep.h>
#include <rashpaManager.h>
extern "C" {
#include <rashpaCore.h> //For RASHPA_LOG_ALL
}
namespace lima {
namespace smartpix {
class rashpa_manager
{
public:
static const size_t max_devices = 32;
rashpa_manager(std::string const& det_name)
{
rashpaSetLog(RASHPA_LOG_ALL, 2);
m_mgr = rashpaInitManager(det_name.c_str(), rashpa_evt_callback);
//Initialize modules
for (auto m : modules)
{
if (m.h_dev != BAD_HANDLE)
{
m.rashpa_name = DEEP_querry(&(manager.modules[mod].h_dev), "?RASHPA_NAME\n");
m.rashpa_pt = rashpaManagerCreateModule(m_mgr, m.rashpa_name);
}
else
{
m.rashpa_name = NULL;
m.rashpa_pt = NULL;
}
}
}
~rashpa_manager()
{
rashpaManagerFini(m_mgr);
//releaseMemory(rcv);
}
private:
rashpa_manager_t* m_mgr;
struct module_t
{
std::string devId;
deephandle_t h_dev;
rashpa_module_man_t* rashpa_pt;
};
struct receiver_t
{
int rank;
rashpa_receiver_man_t* rashpa_pt;
};
std::vector<module_t> modules;
std::vector<receiver_t> receivers;
static int rashpa_evt_callback(rashpa_event_t evt)
{
return 0;
}
};
}
} // namespace lima::smartpix
#endif //LIMA_CAMERAS_SMARTPIX_RASHPA_MANAGER_HPP
\ No newline at end of file
......@@ -6,16 +6,16 @@
#pragma once
#if !defined(LIMA_CAMERAS_SMARTPIX_RASHPA_HPP)
#define LIMA_CAMERAS_SMARTPIX_RASHPA_HPP
#if !defined(LIMA_CAMERAS_SMARTPIX_RASHPA_RECEIVER_HPP)
#define LIMA_CAMERAS_SMARTPIX_RASHPA_RECEIVER_HPP
#include <stdbool.h>
#include <stdint.h>
extern "C" {
#include <rashpaReceiver.h>
#include <rashpaCore.h> //For RASHPA_LOG_ALL
extern "C" {
#include <rashpaCore.h> //For RASHPA_LOG_ALL
}
namespace lima {
......@@ -24,11 +24,11 @@ namespace lima {
class rashpa_receiver
{
public:
rashpa_receiver(const char* name)
rashpa_receiver(std::string const& det_name)
{
rashpaSetLog(RASHPA_LOG_ALL, 2);
m_rcv = rashpaInitReceiver(name, rashpa_info_callback);
m_rcv = rashpaInitReceiver(det_name.c_str(), rashpa_info_callback);
//allocate_memory(rcv);
}
......@@ -102,4 +102,4 @@ private:
}
} // namespace lima::smartpix
#endif //LIMA_CAMERAS_SMARTPIX_RASHPA_HPP
\ No newline at end of file
#endif //LIMA_CAMERAS_SMARTPIX_RASHPA_RECEIVER_HPP
\ No newline at end of file
......@@ -21,6 +21,18 @@ target_link_libraries(smpx_wrapper
PRIVATE Smpx::Smpx
)
# C++ binding of the librashpa
add_library(rashpa_wrapper INTERFACE)
target_include_directories(rashpa_wrapper
INTERFACE "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../include>"
)
target_link_libraries(rashpa_wrapper
INTERFACE lima-core
INTERFACE Rashpa::Rashpa
)
file(GLOB_RECURSE header_files "../include/smartpix/*.hpp")
add_library(smartpix STATIC
......@@ -124,4 +136,4 @@ target_link_libraries(lima_smartpix_ct
install(
TARGETS lima_smartpix_ct
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
\ No newline at end of file
)
......@@ -18,7 +18,7 @@
#include <smartpix/acquisition.hpp>
#include <smartpix/smpx.hpp>
#include <smartpix/rashpa.hpp>
#include <smartpix/rashpa_receiver.hpp>
using namespace std::string_literals;
......
......@@ -14,6 +14,7 @@
#include <smartpix/control.hpp>
#include <smartpix/smpx.hpp>
#include <smartpix/rashpa_manager.hpp>
using namespace std::string_literals;
......
......@@ -22,4 +22,14 @@ target_link_libraries(test_smartpix_parsers
Boost::unit_test_framework
)
add_test(NAME test_smartpix_parsers COMMAND test_smartpix_parsers)
\ No newline at end of file
add_test(NAME test_smartpix_parsers COMMAND test_smartpix_parsers)
add_executable(test_rashpa
test_rashpa.cpp)
target_link_libraries(test_rashpa
smpx_wrapper
Boost::unit_test_framework
)
add_test(NAME test_rashpa COMMAND test_rashpa)
// 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)
#include <iostream>
#include <string>
#define BOOST_TEST_MODULE rashpa
#include <boost/test/unit_test.hpp>
#include <smartpix/rashpa_manager.hpp>
#include <smartpix/rashpa_receiver.hpp>
using namespace lima::smartpix;
BOOST_AUTO_TEST_CASE(test_rashpa_manager)
{
using namespace std::string_literals;
std::cout.rdbuf()->pubsetbuf(0, 0);
try
{
// Assuming ./controller -a cb184.01 -lALL
rashpa_manager rcv("cb184"s);
}
catch (std::exception & ex)
{
std::cerr << ex.what() << std::endl;
}
}
BOOST_AUTO_TEST_CASE(test_rashpa_receiver)
{
using namespace std::string_literals;
std::cout.rdbuf()->pubsetbuf(0, 0);
try
{
// Assuming ./controller -a cb184.01 -lALL
rashpa_receiver rcv("cb184"s);
}
catch (std::exception& ex)
{
std::cerr << ex.what() << std::endl;
}
}
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