Falcon
Loading...
Searching...
No Matches
eventsync.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 <string>
23
24#include "eventdata/eventdata.hpp"
25#include "iprocessor.hpp"
26#include "utilities/general.hpp"
27#include "utilities/time.hpp"
28
29class EventSync : public IProcessor {
30 // CONSTRUCTOR and OVERLOADED METHODS
31 public:
32 EventSync();
33 void CreatePorts() override;
34 void Process(ProcessingContext& context) override;
35 void Postprocess(ProcessingContext& context) override;
36
37 // METHODS
38 protected:
39 /* Keep in memory the latest source and hardware timestamps
40 * @input data_in Current event data from the input port
41 */
42 void update_latest_ts(EventType::Data* data_in);
43
44 /*
45 * During post-processing, log as info if all counters are consistent
46 * and as warning if not, all counters used: number of events received,
47 * with the number of targeted, and non-target and finally reset them.
48 *
49 * @input port_name name of the input port
50 * @input counter counter structure with three counters to log
51 * (all_received, target, non_target)
52 */
53 void log_and_reset_counters(std::string port_name, EventCounter& counter);
54
55 // DATA PORTS
56 protected:
57 PortIn<EventType>* data_in_port_;
58 PortOut<EventType>* data_out_port_;
59
60 // variables
61 protected:
62 EventCounter event_counter_;
63 uint64_t n_events_synced_;
64 TimestampRegister timestamps_;
65
66 // OPTIONS
67 protected:
68 options::Value<EventType::Data, false> target_event_{DEFAULT_EVENT,
69 options::notempty<EventType::Data>()};
70};
Definition streamports.hpp:256
Definition streamports.hpp:98
Definition runinfo.hpp:248