Falcon
Loading...
Searching...
No Matches
nlxpurereader.hpp
1// ---------------------------------------------------------------------
2// This file is part of falcon-core.
3//
4// Copyright (C) 2015, 2016, 2017 Neuro-Electronics Research Flanders
5//
6// Falcon-server is free software: you can redistribute it and/or modify
7// it under the terms of the GNU General Public License as published by
8// the Free Software Foundation, either version 3 of the License, or
9// (at your option) any later version.
10//
11// Falcon-server is distributed in the hope that it will be useful,
12// but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14// GNU General Public License for more details.
15//
16// You should have received a copy of the GNU General Public License
17// along with falcon-core. If not, see <http://www.gnu.org/licenses/>.
18// ---------------------------------------------------------------------
19
20#pragma once
21
22#include <arpa/inet.h>
23#include <netinet/in.h>
24#include <sys/select.h>
25#include <sys/time.h>
26
27#include <limits>
28
29#include "iprocessor.hpp"
30#include "neuralynx/nlx.hpp"
31#include "options/options.hpp"
32#include "utilities/time.hpp"
33#include "vectordata/vectordata.hpp"
34
35class NlxPureReader : public IProcessor {
36 // CONSTRUCTOR and OVERLOADED METHODS
37 public:
38 NlxPureReader();
39 void CreatePorts() override;
40 void CompleteStreamInfo() override;
41 void Prepare(GlobalContext& context) override;
42 void Preprocess(ProcessingContext& context) override;
43 void Process(ProcessingContext& context) override;
44 void Postprocess(ProcessingContext& context) override;
45
46 // PORTS
47 protected:
48 PortOut<VectorType<uint32_t>>* output_port_;
49
50 // STATES
51 protected:
52 BroadcasterState<uint64_t>* n_invalid_;
53
54 // VARIABLES
55 protected:
56 fd_set file_descriptor_set_;
57 int udp_socket_;
58 int udp_socket_select_;
59 struct sockaddr_in server_addr_;
60 uint64_t valid_packet_counter_;
61 struct timeval timeout_;
62 TimePoint first_valid_packet_arrival_time_;
63 ssize_t size_;
64 int recvlen_;
65 VectorType<uint32_t>::Data* data_out_;
66
67 // CONSTANTS
68 public:
69 const decltype(timeout_.tv_sec) TIMEOUT_SEC = 3;
70
71 // OPTIONS
72 protected:
73 options::String address_{"127.0.0.1"};
74 options::Value<unsigned int, false> port_{5000};
75 options::Value<std::uint64_t, false> npackets_{0, options::zeroismax<std::uint64_t>()};
76 options::Value<unsigned int, false> nchannels_{nlx::NLX_DEFAULT_NCHANNELS};
77};
Definition context.hpp:54
Definition streamports.hpp:98
Definition runinfo.hpp:248