Skip to content
Snippets Groups Projects
Commit 4ae2af34 authored by Ewan Barr's avatar Ewan Barr
Browse files

compiling build with psrdada linking

parent e7f93dc5
Branches
Tags
No related merge requests found
...@@ -30,3 +30,10 @@ ...@@ -30,3 +30,10 @@
*.exe *.exe
*.out *.out
*.app *.app
# Directories
build/
# Editor files
*~
*\#
\ No newline at end of file
include(compiler_settings) include(compiler_settings)
include(cmake/boost.cmake) include(cmake/boost.cmake)
#include(cmake/psrdada.cmake) include(cmake/psrdada.cmake)
include_directories(SYSTEM ${Boost_INCLUDE_DIR} )#${PSRDADA_INCLUDE_DIR}) include_directories(SYSTEM ${Boost_INCLUDE_DIR} ${PSRDADA_INCLUDE_DIR})
set(DEPENDENCY_LIBRARIES set(DEPENDENCY_LIBRARIES
${Boost_LIBRARIES} ${Boost_LIBRARIES}
# ${PSRDADA_LIBRARIES} ${PSRDADA_LIBRARIES}
) )
\ No newline at end of file
IF (PSRDADA_INCLUDE_DIR)
SET(PSRDADA_INC_DIR ${PSRDADA_INCLUDE_DIR})
UNSET(PSRDADA_INCLUDE_DIR)
ENDIF (PSRDADA_INCLUDE_DIR)
FIND_PATH(PSRDADA_INCLUDE_DIR dada_def.h
PATHS ${PSRDADA_INC_DIR}
${PSRDADA_INSTALL_DIR}/include
/usr/local/include
/usr/include )
message("Found ${PSRDADA_INCLUDE_DIR} : ${PSRDADA_INSTALL_DIR}")
SET(PSRDADA_NAMES psrdada)
FOREACH( lib ${PSRDADA_NAMES} )
FIND_LIBRARY(PSRDADA_LIBRARY_${lib}
NAMES ${lib}
PATHS ${PSRDADA_LIBRARY_DIR} ${PSRDADA_INSTALL_DIR} ${PSRDADA_INSTALL_DIR}/lib /usr/local/lib /usr/lib
)
LIST(APPEND PSRDADA_LIBRARIES ${PSRDADA_LIBRARY_${lib}})
ENDFOREACH(lib)
# handle the QUIETLY and REQUIRED arguments and set PSRDADA_FOUND to TRUE if.
# all listed variables are TRUE
include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(PSRDADA DEFAULT_MSG PSRDADA_LIBRARIES PSRDADA_INCLUDE_DIR)
IF(NOT PSRDADA_FOUND)
SET( PSRDADA_LIBRARIES )
SET( PSRDADA_TEST_LIBRARIES )
ELSE(NOT PSRDADA_FOUND)
# -- add dependecies
LIST(APPEND PSRDADA_LIBRARIES ${CUDA_curand_LIBRARY})
ENDIF(NOT PSRDADA_FOUND)
LIST(APPEND PSRDADA_INCLUDE_DIR "${PSRDADA_INCLUDE_DIR}")
MARK_AS_ADVANCED(PSRDADA_LIBRARIES PSRDADA_TEST_LIBRARIES PSRDADA_INCLUDE_DIR)
\ No newline at end of file
...@@ -5,15 +5,15 @@ include_directories(..) ...@@ -5,15 +5,15 @@ include_directories(..)
include_directories(${PROJECT_BINARY_DIR}) include_directories(${PROJECT_BINARY_DIR})
set(psrdada_cpp_src set(psrdada_cpp_src
#src/multilog.cpp src/multilog.cpp
#src/raw_bytes.cpp src/raw_bytes.cpp
#src/dada_client_base.cpp src/dada_client_base.cpp
#src/dada_write_client.cpp src/dada_write_client.cpp
#src/dada_read_client.cpp src/dada_read_client.cpp
) )
# -- the main library target # -- the main library target
#add_library(${CMAKE_PROJECT_NAME} ${psrdada_cpp_src}) add_library(${CMAKE_PROJECT_NAME} ${psrdada_cpp_src})
add_executable(junkdb examples/junkdb.cpp) add_executable(junkdb examples/junkdb.cpp)
target_link_libraries (junkdb ${PSRDADA_CPP_LIBRARIES}) target_link_libraries (junkdb ${PSRDADA_CPP_LIBRARIES})
install (TARGETS junkdb DESTINATION bin) install (TARGETS junkdb DESTINATION bin)
......
#ifndef PSRDADA_CPP_COMMON_HPP
#define PSRDADA_CPP_COMMON_HPP
#include <cstddef>
#include <stdexcept>
#include <memory>
#include <string>
#endif //PSRDADA_CPP_COMMON_HPP
\ No newline at end of file
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "dada_hdu.h" #include "dada_hdu.h"
#include "dada_def.h" #include "dada_def.h"
#include "psrdada_cpp/multilog.hpp" #include "psrdada_cpp/multilog.hpp"
#include "psrdada_cpp/common.hpp"
namespace psrdada_cpp { namespace psrdada_cpp {
...@@ -11,12 +12,14 @@ namespace psrdada_cpp { ...@@ -11,12 +12,14 @@ namespace psrdada_cpp {
{ {
private: private:
key_t _key; key_t _key;
protected:
dada_hdu_t* _hdu; dada_hdu_t* _hdu;
bool _connected; bool _connected;
MultiLog const& _log; MultiLog& _log;
public: public:
DadaClientBase(key_t key, MultiLog const& log); DadaClientBase(key_t key, MultiLog& log);
DadaClientBase(DadaClientBase const&) = delete; DadaClientBase(DadaClientBase const&) = delete;
~DadaClientBase(); ~DadaClientBase();
std::size_t data_buffer_size(); std::size_t data_buffer_size();
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
#include "psrdada_cpp/dada_client_base.hpp" #include "psrdada_cpp/dada_client_base.hpp"
#include "psrdada_cpp/raw_bytes.hpp" #include "psrdada_cpp/raw_bytes.hpp"
#include "psrdada_cpp/common.hpp"
namespace psrdada_cpp { namespace psrdada_cpp {
...@@ -15,7 +16,7 @@ namespace psrdada_cpp { ...@@ -15,7 +16,7 @@ namespace psrdada_cpp {
std::size_t _current_data_block_idx; std::size_t _current_data_block_idx;
public: public:
DadaReadClient(key_t key, MultiLog const& log); DadaReadClient(key_t key, MultiLog& log);
DadaReadClient(DadaReadClient const&) = delete; DadaReadClient(DadaReadClient const&) = delete;
~DadaReadClient(); ~DadaReadClient();
RawBytes& acquire_header_block(); RawBytes& acquire_header_block();
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
#include "psrdada_cpp/dada_client_base.hpp" #include "psrdada_cpp/dada_client_base.hpp"
#include "psrdada_cpp/raw_bytes.hpp" #include "psrdada_cpp/raw_bytes.hpp"
#include <memory> #include "psrdada_cpp/common.hpp"
namespace psrdada_cpp { namespace psrdada_cpp {
...@@ -15,7 +15,7 @@ namespace psrdada_cpp { ...@@ -15,7 +15,7 @@ namespace psrdada_cpp {
std::unique_ptr<RawBytes> _current_data_block; std::unique_ptr<RawBytes> _current_data_block;
public: public:
DadaWriteClient(key_t key, MultiLog const& log); DadaWriteClient(key_t key, MultiLog& log);
DadaWriteClient(DadaWriteClient const&) = delete; DadaWriteClient(DadaWriteClient const&) = delete;
~DadaWriteClient(); ~DadaWriteClient();
RawBytes& acquire_header_block(); RawBytes& acquire_header_block();
......
//#include "psrdada_cpp/multilog.hpp" #include "psrdada_cpp/multilog.hpp"
//#include "psrdada_cpp/raw_bytes.hpp" #include "psrdada_cpp/raw_bytes.hpp"
//#include "psrdada_cpp/dada_write_client.hpp" #include "psrdada_cpp/dada_write_client.hpp"
#include "boost/program_options.hpp" #include "boost/program_options.hpp"
......
#ifndef PSRDADA_CPP_MULTILOG_HPP #ifndef PSRDADA_CPP_MULTILOG_HPP
#define PSRDADA_CPP_MULTILOG_HPP #define PSRDADA_CPP_MULTILOG_HPP
#include <string>
#include "multilog.h" #include "multilog.h"
#include "psrdada_cpp/common.hpp"
namespace psrdada_cpp { namespace psrdada_cpp {
...@@ -35,7 +35,7 @@ namespace psrdada_cpp { ...@@ -35,7 +35,7 @@ namespace psrdada_cpp {
{ {
throw std::runtime_error("MultiLog must be opened before writing"); throw std::runtime_error("MultiLog must be opened before writing");
} }
multilog(_log, format, std::forward<Args>(args)...); multilog(_log, priority, format, std::forward<Args>(args)...);
} }
} //namespace psrdada_cpp } //namespace psrdada_cpp
......
#ifndef PSRDADA_CPP_RAW_BYTES_HPP #ifndef PSRDADA_CPP_RAW_BYTES_HPP
#define PSRDADA_CPP_RAW_BYTES_HPP #define PSRDADA_CPP_RAW_BYTES_HPP
#include "psrdada_cpp/common.hpp"
namespace psrdada_cpp { namespace psrdada_cpp {
class RawBytes class RawBytes
......
#include "psrdada_cpp/dada_client_base.hpp" #include "psrdada_cpp/dada_client_base.hpp"
#include <exception>
namespace psrdada_cpp { namespace psrdada_cpp {
DadaClientBase::DadaClientBase(key_t key, MultiLog const& log) DadaClientBase::DadaClientBase(key_t key, MultiLog& log)
: _key(key) : _key(key)
, _log(log) , _log(log)
{ {
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
namespace psrdada_cpp { namespace psrdada_cpp {
DadaReadClient::DadaReadClient(key_t key, MultiLog const& log) DadaReadClient::DadaReadClient(key_t key, MultiLog& log)
: DadaClientBase(key, log) : DadaClientBase(key, log)
, _locked(false) , _locked(false)
, _current_header_block(nullptr) , _current_header_block(nullptr)
...@@ -97,7 +97,7 @@ namespace psrdada_cpp { ...@@ -97,7 +97,7 @@ namespace psrdada_cpp {
} }
if (ipcio_close_block_read (_hdu->data_block, _current_data_block->used_bytes()) < 0) if (ipcio_close_block_read (_hdu->data_block, _current_data_block->used_bytes()) < 0)
{ {
log.write(LOG_ERR, "close_buffer: ipcio_close_block_read failed\n"); _log.write(LOG_ERR, "close_buffer: ipcio_close_block_read failed\n");
throw std::runtime_error("Could not close ipcio data block"); throw std::runtime_error("Could not close ipcio data block");
} }
_current_data_block.reset(nullptr); _current_data_block.reset(nullptr);
...@@ -109,7 +109,7 @@ namespace psrdada_cpp { ...@@ -109,7 +109,7 @@ namespace psrdada_cpp {
{ {
throw std::runtime_error("No data block currently acquired"); throw std::runtime_error("No data block currently acquired");
} }
return _current_data_block_idx return _current_data_block_idx;
} }
} //namespace psrdada_cpp } //namespace psrdada_cpp
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
namespace psrdada_cpp { namespace psrdada_cpp {
DadaWriteClient::DadaWriteClient(key_t key, MultiLog const& log) DadaWriteClient::DadaWriteClient(key_t key, MultiLog& log)
: DadaClientBase(key, log) : DadaClientBase(key, log)
, _locked(false) , _locked(false)
, _current_header_block(nullptr) , _current_header_block(nullptr)
...@@ -58,7 +58,7 @@ namespace psrdada_cpp { ...@@ -58,7 +58,7 @@ namespace psrdada_cpp {
throw std::runtime_error("No header block to be released"); throw std::runtime_error("No header block to be released");
} }
if (ipcbuf_mark_filled(_hdu->header_block) < 0) if (ipcbuf_mark_filled(_hdu->header_block, _current_header_block->used_bytes()) < 0)
{ {
_log.write(LOG_ERR, "Could not mark filled header block\n"); _log.write(LOG_ERR, "Could not mark filled header block\n");
throw std::runtime_error("Could not mark filled header block"); throw std::runtime_error("Could not mark filled header block");
...@@ -88,7 +88,7 @@ namespace psrdada_cpp { ...@@ -88,7 +88,7 @@ namespace psrdada_cpp {
{ {
if (ipcio_update_block_write (_hdu->data_block, _current_data_block->used_bytes()) < 0) if (ipcio_update_block_write (_hdu->data_block, _current_data_block->used_bytes()) < 0)
{ {
log.write(LOG_ERR, "close_buffer: ipcio_update_block_write failed\n"); _log.write(LOG_ERR, "close_buffer: ipcio_update_block_write failed\n");
throw std::runtime_error("Could not close ipcio data block"); throw std::runtime_error("Could not close ipcio data block");
} }
} }
...@@ -96,7 +96,7 @@ namespace psrdada_cpp { ...@@ -96,7 +96,7 @@ namespace psrdada_cpp {
{ {
if (ipcio_close_block_write (_hdu->data_block, _current_data_block->used_bytes()) < 0) if (ipcio_close_block_write (_hdu->data_block, _current_data_block->used_bytes()) < 0)
{ {
log.write(LOG_ERR, "close_buffer: ipcio_close_block_write failed\n"); _log.write(LOG_ERR, "close_buffer: ipcio_close_block_write failed\n");
throw std::runtime_error("Could not close ipcio data block"); throw std::runtime_error("Could not close ipcio data block");
} }
_current_data_block.reset(nullptr); _current_data_block.reset(nullptr);
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
namespace psrdada_cpp { namespace psrdada_cpp {
RawBytes::RawBytes(char* ptr, std::size_t total, std::size_t used=0) RawBytes::RawBytes(char* ptr, std::size_t total, std::size_t used)
: _ptr(ptr) : _ptr(ptr)
, _total_bytes(total) , _total_bytes(total)
, _used_bytes(used) , _used_bytes(used)
...@@ -23,12 +23,12 @@ namespace psrdada_cpp { ...@@ -23,12 +23,12 @@ namespace psrdada_cpp {
return _used_bytes; return _used_bytes;
} }
void RawBytes::used_bytes(std::sizt_t used) void RawBytes::used_bytes(std::size_t used)
{ {
_used_bytes = n; _used_bytes = used;
} }
char* ptr() char* RawBytes::ptr()
{ {
return _ptr; return _ptr;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment