Jpp 19.3.0-rc.3
the software that should make you happy
Loading...
Searching...
No Matches
KM3NeT_Acoustic_Link Class Reference

#include <KM3NeT_Acoustic_Link.h>

Inheritance diagram for KM3NeT_Acoustic_Link:

Public Member Functions

 KM3NeT_Acoustic_Link (boost::asio::io_service &io_service, std::map< std::size_t, pDOM > &doms, uint32_t buffer_size=STD_DIM_BUFFER)
 
virtual ~KM3NeT_Acoustic_Link ()
 
boost::asio::ip::tcp::socket & Socket ()
 
void Start_reading ()
 
void Disconnect (bool Soft=true)
 

Static Public Attributes

static const int DEBUG_LEVEL =3
 

Private Member Functions

void Read_completed (const boost::system::error_code &error, std::size_t transferred)
 

Private Attributes

boost::asio::io_service::strand strand_
 
boost::asio::ip::tcp::socket socket_
 
uint8_t * buffer_
 
uint32_t buffer_size_
 
uint32_t data_size_
 
std::map< std::size_t, pDOM > & dom_map_
 
uint32_t dom_id_
 
bool header_received_
 

Detailed Description

Author
fsimeone

Definition at line 25 of file KM3NeT_Acoustic_Link.h.

Constructor & Destructor Documentation

◆ KM3NeT_Acoustic_Link()

KM3NeT_Acoustic_Link::KM3NeT_Acoustic_Link ( boost::asio::io_service & io_service,
std::map< std::size_t, pDOM > & doms,
uint32_t buffer_size = STD_DIM_BUFFER )
Author
fsimeone

Definition at line 17 of file KM3NeT_Acoustic_Link.cc.

20 : strand_(io_service),\
21 socket_(io_service),\
22 dom_map_(doms)
23{
24 DEBUG_MSG("Constructor",3);
27 buffer_=(uint8_t*)malloc(buffer_size_);
28 header_received_=false;
29}
#define DEBUG_MSG(str, lev)
#define AUDIO_PACKET_FIXED_SIZE
static const size_t buffer_size

◆ ~KM3NeT_Acoustic_Link()

KM3NeT_Acoustic_Link::~KM3NeT_Acoustic_Link ( )
virtual

Definition at line 31 of file KM3NeT_Acoustic_Link.cc.

32{
33 DEBUG_MSG("Destructor",3);
34 Disconnect();
35 free(buffer_);
36}

Member Function Documentation

◆ Socket()

boost::asio::ip::tcp::socket & KM3NeT_Acoustic_Link::Socket ( )
inline

Definition at line 36 of file KM3NeT_Acoustic_Link.h.

36{return socket_;};

◆ Start_reading()

void KM3NeT_Acoustic_Link::Start_reading ( )

Definition at line 49 of file KM3NeT_Acoustic_Link.cc.

50{
52 {
53 DEBUG_MSG("Realloc: free " << (void*) buffer_<<" - "<<buffer_size_<<" byte",1);
54 free(buffer_);
56 buffer_=(uint8_t*)malloc(buffer_size_);
57 DEBUG_MSG("Realloc: alloc " << (void*) buffer_<<" - "<<buffer_size_<<" byte",1);
58 }
59
60 async_read(socket_,boost::asio::buffer(buffer_,buffer_size_),boost::asio::transfer_exactly(data_size_),strand_.wrap(boost::bind(&KM3NeT_Acoustic_Link::Read_completed, shared_from_this(), _1, _2)));
61}

◆ Disconnect()

void KM3NeT_Acoustic_Link::Disconnect ( bool Soft = true)

Definition at line 38 of file KM3NeT_Acoustic_Link.cc.

39{
40 DEBUG_MSG("Disconnect",3);
41 if (soft)
42 {
43 boost::system::error_code l_ignore;
44 socket_.shutdown(boost::asio::ip::tcp::socket::shutdown_both, l_ignore);
45 }
46 socket_.close();
47}

◆ Read_completed()

void KM3NeT_Acoustic_Link::Read_completed ( const boost::system::error_code & error,
std::size_t transferred )
private

Definition at line 63 of file KM3NeT_Acoustic_Link.cc.

64{
65 if (!error)
66 {
67 DEBUG_MSG("Read completed " << transferred << " bytes ",1);
69 {
72 DEBUG_MSG("h seconds="<<l_pheader->Common_Header.Time_Stamp_seconds,0);
73 DEBUG_MSG("h tick="<<l_pheader->Common_Header.Time_Stamp_ticks,0);
76
78 if (i!=dom_map_.end()) i->second->Check_time_async(*l_pheader);
79 }
80 else
81 {
83 if (i!=dom_map_.end())
84 {
85 uint8_t* tmp_buffer=(uint8_t*)malloc(transferred);
86 memcpy(tmp_buffer,buffer_,transferred);
87 i->second->Handle_samples_async(tmp_buffer,transferred);
88 }
90 header_received_=false;
91 }
93 }
94 else
95 {
96 DEBUG_MSG("Read completed err " << error <<" "<< transferred << " bytes",3);
97 Disconnect();
98 }
99}
DAQ_Common_Header Common_Header

Member Data Documentation

◆ DEBUG_LEVEL

const int KM3NeT_Acoustic_Link::DEBUG_LEVEL =3
static

Definition at line 30 of file KM3NeT_Acoustic_Link.h.

◆ strand_

boost::asio::io_service::strand KM3NeT_Acoustic_Link::strand_
private

Definition at line 43 of file KM3NeT_Acoustic_Link.h.

◆ socket_

boost::asio::ip::tcp::socket KM3NeT_Acoustic_Link::socket_
private

Definition at line 44 of file KM3NeT_Acoustic_Link.h.

◆ buffer_

uint8_t* KM3NeT_Acoustic_Link::buffer_
private

Definition at line 45 of file KM3NeT_Acoustic_Link.h.

◆ buffer_size_

uint32_t KM3NeT_Acoustic_Link::buffer_size_
private

Definition at line 46 of file KM3NeT_Acoustic_Link.h.

◆ data_size_

uint32_t KM3NeT_Acoustic_Link::data_size_
private

Definition at line 47 of file KM3NeT_Acoustic_Link.h.

◆ dom_map_

std::map<std::size_t,pDOM>& KM3NeT_Acoustic_Link::dom_map_
private

Definition at line 48 of file KM3NeT_Acoustic_Link.h.

◆ dom_id_

uint32_t KM3NeT_Acoustic_Link::dom_id_
private

Definition at line 49 of file KM3NeT_Acoustic_Link.h.

◆ header_received_

bool KM3NeT_Acoustic_Link::header_received_
private

Definition at line 50 of file KM3NeT_Acoustic_Link.h.


The documentation for this class was generated from the following files: