31 const Poco::Timespan timeout(5,0);
32 Poco::Net::StreamSocket& sock = this->socket();
37 int sent = sock.sendBytes(&setup_packet,
sizeof(setup_packet));
43 if ( (
m_buffers.size() > 0) && sock.poll(timeout, Poco::Net::Socket::SELECT_WRITE) )
45 std::list<TCPStreamEventDataNeutron*>::iterator it;
47 Poco::RWLock::ScopedReadLock _lock(
m_lock);
50 sent = sock.sendBytes(&((*it)->head),
sizeof((*it)->head));
51 sent = sock.sendBytes(&((*it)->head_n),
sizeof((*it)->head_n));
52 sent = sock.sendBytes(&((*it)->data[0]), (*it)->data.size() *
sizeof((*it)->data[0]));
54 Poco::RWLock::ScopedWriteLock _lock(
m_lock);
62 Poco::Thread::sleep(2000);
66 catch(
const std::exception& ex)
68 LOGSTR_WARNING(
"Terminating request from " + sock.peerAddress().toString() +
": " + ex.what());
76 Poco::RWLock::ScopedWriteLock _lock(
m_lock);
84 #define PPP_TO_UAMPH 1.738E-6
100 LOGSTR_WARNING(
"Starting to discard new events for live listener");
121 for(
int i=0; i<n; ++i)
124 t->
data[i].spectrum = spec;
132 Poco::RWLock::ScopedWriteLock _lock(
m_lock);
149 unsigned short port = 10000;
152 m_svs =
new Poco::Net::ServerSocket(port);
~TCPEventStreamConnection()
void allEventCallback(const DAEEventHeader *head, const DetectorEvent32 *det_ev, int n, int event_source_id, const int *mapping)
Poco::Net::TCPServer * m_srv
#define LOGSTR_NOTICE(__arg)
std::list< TCPStreamEventDataNeutron * > m_buffers
#define LOGSTR_WARNING(__arg)
int spectrumDAETR(int spec) const
int cardIndexFromPos(int pos) const
void clearCallbacks(const std::list< boost::signals2::connection > &callback_list)
std::list< boost::signals2::connection > addGoodEventCallback(const EventCallbackSlotType &slot)
#define LOGSTR_INFORMATION(__arg)
TCPStreamEventHeaderNeutron head_n
details of ISIS frame data was collected in and the number of neutron events in this packet ...
static void DAETimeToOffset(const DAEEventHeader::DAETime &daetime, time_t base, T &offset)
A factory for TimeServerConnection.
static float getTimeOffset(const ISISCRPT_STRUCT *crpt, const DetectorEvent32 *det_ev, int event_source_id, int tr, int i)
std::vector< TCPStreamEventNeutron > data
list of neutron events
int dae1SpecForCardIndex(int index, int dae2_spec) const
void setLoggerName(const std::string &logger_name)
TCPEventStreamConnection(const Poco::Net::StreamSocket &s, EventStore &es, const CRPTProxy &crpt)
TCPStreamEventHeaderSetup head_setup
static uint32_t MAX_BYTES_BACKLOG
layout of initial data packet send on initial connection and on a state change e.g. run number changes
Poco::Net::ServerSocket * m_svs
TCPEventStreamer(EventStore &es, const CRPTProxy &crpt)
TCPStreamEventHeader head
LONGLONG m_discarded_events