common_signal_target.h
Go to the documentation of this file.
1 /*********************************************************************
2  *
3  * Software License Agreement
4  *
5  * Copyright (c) 2020,
6  * TU Dortmund - Institute of Control Theory and Systems Engineering.
7  * All rights reserved.
8  *
9  * This program is free software: you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation, either version 3 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program. If not, see <https://www.gnu.org/licenses/>.
21  *
22  * Authors: Christoph Rösmann
23  *********************************************************************/
24 
25 #ifndef SRC_CORE_INCLUDE_CORBO_CORE_COMMON_SIGNAL_TARGET_H_
26 #define SRC_CORE_INCLUDE_CORBO_CORE_COMMON_SIGNAL_TARGET_H_
27 
29 
30 #include <memory>
31 #include <string>
32 #include <unordered_map>
33 #include <vector>
34 
35 namespace corbo {
36 
53 class CommonSignalTarget : public SignalTargetInterface
54 {
55  public:
57  struct SignalGroup
58  {
59  std::string group_name;
60  std::vector<SignalInterface::Ptr> group_signals;
61  std::vector<SignalGroup> children;
62  SignalGroup* parent = nullptr;
63  };
64 
65  using Ptr = std::shared_ptr<CommonSignalTarget>;
66 
68  virtual ~CommonSignalTarget() {}
69 
70  // implements interface method
71  void registerMeasurement(const std::string& /*unique_name*/, int /*value_dimension*/, const std::vector<std::string>& /*value_labels*/ = {},
72  bool zero_order_hold = false) override
73  {
74  }
75 
76  // implements interface method
77  void registerTimeSeries(const std::string& /*unique_name*/, int /*value_dimension*/, bool zero_order_hold = false) override {}
78 
79  // implements interface method
80  void sendMeasurement(Measurement::ConstPtr measurement) override;
81 
82  // implements interface method
83  void sendTimeSeries(TimeSeriesSignal::Ptr time_series) override;
84 
85  // implements interface method
86  void sendIndexedValues(IndexedValuesSignal::Ptr indexed_values) override;
87 
88  // implements interface method
89  void sendIndexedValuesSet(IndexedValuesSetSignal::Ptr indexed_values_set) override;
90 
91  // implements interface method
92  void sendMatrix(MatrixSignal::Ptr matrix) override;
93 
94  void setTopLevelGroupName(const std::string& name) { _signals.group_name = name; }
95 
96  // const SignalGroup* getSignalGroup(const std::string full_signal_name) const { return resolveGroupLevel(full_signal_name); }
97 
98  void removeSignal(const std::string& name);
99 
100  SignalGroup* getGroup(const std::string& full_group_name);
101  SignalInterface::Ptr getSignal(const std::string& full_signal_name);
102 
103  bool isEmpty() { return _signals.children.empty(); }
104 
109  const SignalGroup& getSignals() const { return _signals; }
110 
112 
114  void clear();
115 
116  protected:
132  SignalGroup* expandGroups(const std::string full_signal_name, std::string* signal_name_out = nullptr, SignalInterface::Ptr* signal = nullptr);
133 
134  private:
136 };
137 
138 } // namespace corbo
139 
140 #endif // SRC_CORE_INCLUDE_CORBO_CORE_COMMON_SIGNAL_TARGET_H_
signal_target_interface.h
corbo::MatrixSignal::Ptr
std::shared_ptr< MatrixSignal > Ptr
Definition: signals.h:564
corbo::CommonSignalTarget::sendIndexedValuesSet
void sendIndexedValuesSet(IndexedValuesSetSignal::Ptr indexed_values_set) override
Send signal containing a set of values indexed by integers (int to double[] map)
Definition: common_signal_target.cpp:145
corbo::CommonSignalTarget::SignalGroup::parent
SignalGroup * parent
Definition: common_signal_target.h:128
corbo
Definition: communication/include/corbo-communication/utilities.h:37
corbo::SignalInterface::Ptr
std::shared_ptr< SignalInterface > Ptr
Definition: signals.h:158
corbo::CommonSignalTarget::expandGroups
SignalGroup * expandGroups(const std::string full_signal_name, std::string *signal_name_out=nullptr, SignalInterface::Ptr *signal=nullptr)
Parse full signal name, create tree-sub-groups if not found and return related signal group.
Definition: common_signal_target.cpp:287
matrix
Map< Matrix< T, Dynamic, Dynamic, ColMajor >, 0, OuterStride<> > matrix(T *data, int rows, int cols, int stride)
Definition: common.h:102
corbo::CommonSignalTarget::Ptr
std::shared_ptr< CommonSignalTarget > Ptr
Virtual destructor.
Definition: common_signal_target.h:111
corbo::CommonSignalTarget::sendMeasurement
void sendMeasurement(Measurement::ConstPtr measurement) override
Send a measurement to the target.
Definition: common_signal_target.cpp:56
corbo::CommonSignalTarget::sendMatrix
void sendMatrix(MatrixSignal::Ptr matrix) override
Send a matrix to the target.
Definition: common_signal_target.cpp:167
corbo::CommonSignalTarget::SignalGroup::children
std::vector< SignalGroup > children
Container for children (sub-namespace)
Definition: common_signal_target.h:127
corbo::CommonSignalTarget::getSignalsRef
SignalGroup & getSignalsRef()
Definition: common_signal_target.h:155
corbo::CommonSignalTarget::sendIndexedValues
void sendIndexedValues(IndexedValuesSignal::Ptr indexed_values) override
Send signal containing values indexed by a single integer.
Definition: common_signal_target.cpp:114
corbo::CommonSignalTarget::sendTimeSeries
void sendTimeSeries(TimeSeriesSignal::Ptr time_series) override
Send a time series to the target.
Definition: common_signal_target.cpp:87
corbo::CommonSignalTarget::SignalGroup::group_signals
std::vector< SignalInterface::Ptr > group_signals
set of signals in the current group
Definition: common_signal_target.h:126
corbo::CommonSignalTarget::getGroup
SignalGroup * getGroup(const std::string &full_group_name)
Definition: common_signal_target.cpp:221
corbo::CommonSignalTarget::getSignal
SignalInterface::Ptr getSignal(const std::string &full_signal_name)
Definition: common_signal_target.cpp:254
corbo::CommonSignalTarget::_signals
SignalGroup _signals
Root element of the signal tree.
Definition: common_signal_target.h:179
corbo::CommonSignalTarget::~CommonSignalTarget
virtual ~CommonSignalTarget()
Definition: common_signal_target.h:112
corbo::CommonSignalTarget::SignalGroup::group_name
std::string group_name
Identifier for the current group / signal namespace.
Definition: common_signal_target.h:125
corbo::CommonSignalTarget::setTopLevelGroupName
void setTopLevelGroupName(const std::string &name)
Definition: common_signal_target.h:138
corbo::IndexedValuesSignal::Ptr
std::shared_ptr< IndexedValuesSignal > Ptr
Definition: signals.h:415
corbo::CommonSignalTarget::registerTimeSeries
void registerTimeSeries(const std::string &, int, bool zero_order_hold=false) override
Register a time series type at current target.
Definition: common_signal_target.h:121
corbo::IndexedValuesSetSignal::Ptr
std::shared_ptr< IndexedValuesSetSignal > Ptr
Definition: signals.h:499
corbo::CommonSignalTarget::clear
void clear()
Erase stored signals.
Definition: common_signal_target.cpp:342
corbo::CommonSignalTarget::removeSignal
void removeSignal(const std::string &name)
Definition: common_signal_target.cpp:198
corbo::CommonSignalTarget::getSignals
const SignalGroup & getSignals() const
Retrieve read-only-access to the underlying signal-tree.
Definition: common_signal_target.h:153
corbo::CommonSignalTarget::isEmpty
bool isEmpty()
Definition: common_signal_target.h:147
corbo::CommonSignalTarget::registerMeasurement
void registerMeasurement(const std::string &, int, const std::vector< std::string > &={}, bool zero_order_hold=false) override
Register a measurement type at current target.
Definition: common_signal_target.h:115
corbo::Measurement::ConstPtr
std::shared_ptr< const Measurement > ConstPtr
Definition: signals.h:197
corbo::CommonSignalTarget::SignalGroup
Tree node containing a group of signals and a set of child tree nodes.
Definition: common_signal_target.h:101
corbo::TimeSeriesSignal::Ptr
std::shared_ptr< TimeSeriesSignal > Ptr
Definition: signals.h:269


control_box_rst
Author(s): Christoph Rösmann
autogenerated on Wed Mar 2 2022 00:05:39