Falcon
Toggle main menu visibility
Loading...
Searching...
No Matches
levelcrossingdetector.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
#include <vector>
24
25
#include "eventdata/eventdata.hpp"
26
#include "iprocessor.hpp"
27
#include "options/units.hpp"
28
#include "timeseriesdata/timeseriesdata.hpp"
29
30
class
LevelCrossingDetector :
public
IProcessor {
31
// CONSTRUCTOR and OVERLOADED METHODS
32
public
:
33
LevelCrossingDetector();
34
void
CreatePorts()
override
;
35
void
CompleteStreamInfo()
override
;
36
void
Preprocess(
ProcessingContext
& context)
override
;
37
void
Process(
ProcessingContext
& context)
override
;
38
void
Postprocess(
ProcessingContext
& context)
override
;
39
40
// DATA PORTS
41
protected
:
42
PortIn<TimeSeriesType<double>
>* data_in_port_;
43
PortOut<EventType>
* data_out_port_;
44
45
// STATES
46
protected
:
47
StaticState<double>* threshold_;
48
StaticState<bool>* upslope_;
49
StaticState<unsigned int>* post_detect_block_;
50
51
// VARIABLES
52
protected
:
53
std::vector<double> previous_sample_;
54
uint64_t n_detections_ = 0;
55
TimeSeriesType<double>::Data* data_in_;
56
EventType::Data* data_out_;
57
58
// METHODS
59
protected
:
60
/* When the post detection block state is updated, it checks if it is
61
* upper a certain level, log the info, and transform it in microsecs
62
*
63
* @input post_detection_block new value from the post detection block state
64
*/
65
void
post_detection_block_update(
unsigned
int
post_detection_block);
66
67
// CONSTANTS
68
public
:
69
const
std::string DEFAULT_EVENT =
"threshold_crossing"
;
70
const
unsigned
int
LOW_POST_DETECTION_BLOCK_US = 30;
71
const
std::string THRESHOLD =
"threshold"
;
72
const
std::string UPSLOPE =
"upslope"
;
73
const
std::string POST_DETECT_BLOCK =
"post_detect_block"
;
74
75
// OPTIONS
76
protected
:
77
options::Double initial_threshold_{0.0};
78
options::Bool initial_upslope_{
true
};
79
80
options::Measurement<unsigned int, false> initial_post_detect_block_{2,
"sample"
};
81
82
options::Value<EventType::Data, false> event_prototype_{DEFAULT_EVENT,
83
options::notempty<EventType::Data>()};
84
};
PortIn
Definition
streamports.hpp:256
PortOut
Definition
streamports.hpp:98
ProcessingContext
Definition
runinfo.hpp:248
extensions
falcon-fklab-extensions
processors
levelcrossingdetector
levelcrossingdetector.hpp
Generated by
1.18.0