0.2.0
Loading...
Searching...
No Matches
Demo.hpp
Go to the documentation of this file.
1// This file is part of INSTINCT, the INS Toolkit for Integrated
2// Navigation Concepts and Training by the Institute of Navigation of
3// the University of Stuttgart, Germany.
4//
5// This Source Code Form is subject to the terms of the Mozilla Public
6// License, v. 2.0. If a copy of the MPL was not distributed with this
7// file, You can obtain one at https://mozilla.org/MPL/2.0/.
8
13
14#pragma once
15
17
18#include "util/Eigen.hpp"
19#include <array>
21
22namespace NAV
23{
25class Demo : public Node
26{
27 public:
31 ~Demo() override;
33 Demo(const Demo&) = delete;
35 Demo(Demo&&) = delete;
37 Demo& operator=(const Demo&) = delete;
39 Demo& operator=(Demo&&) = delete;
40
42 [[nodiscard]] static std::string typeStatic();
43
45 [[nodiscard]] std::string type() const override;
46
48 [[nodiscard]] static std::string category();
49
52 void guiConfig() override;
53
55 [[nodiscard]] json save() const override;
56
59 void restore(const json& j) override;
60
62 bool resetNode() override;
63
68 bool onCreateLink(OutputPin& startPin, InputPin& endPin) override;
69
73 void onDeleteLink(OutputPin& startPin, InputPin& endPin) override;
74
76 struct DemoData
77 {
78 std::array<int, 3> integer = { 12, -2, 2 };
79 bool boolean = false;
80 };
81
82 private:
83 constexpr static size_t OUTPUT_PORT_INDEX_FLOW = 1;
84 constexpr static size_t OUTPUT_PORT_INDEX_BOOL = 2;
85 constexpr static size_t OUTPUT_PORT_INDEX_INT = 3;
86 constexpr static size_t OUTPUT_PORT_INDEX_FLOAT = 4;
87 constexpr static size_t OUTPUT_PORT_INDEX_DOUBLE = 5;
88 constexpr static size_t OUTPUT_PORT_INDEX_STRING = 6;
89 constexpr static size_t OUTPUT_PORT_INDEX_DEMO_DATA = 7;
90 constexpr static size_t OUTPUT_PORT_INDEX_MATRIX = 8;
91 constexpr static size_t INPUT_PORT_INDEX_DEMO_NODE = 0;
92 constexpr static size_t INPUT_PORT_INDEX_FLOW = 1;
93 constexpr static size_t INPUT_PORT_INDEX_BOOL = 2;
94 constexpr static size_t INPUT_PORT_INDEX_INT = 3;
95 constexpr static size_t INPUT_PORT_INDEX_FLOAT = 4;
96 constexpr static size_t INPUT_PORT_INDEX_DOUBLE = 5;
97 constexpr static size_t INPUT_PORT_INDEX_STRING = 6;
98 constexpr static size_t INPUT_PORT_INDEX_DEMO_DATA = 7;
99 constexpr static size_t INPUT_PORT_INDEX_MATRIX = 8;
100
102 bool initialize() override;
103
105 void deinitialize() override;
106
110 void receiveData(InputPin::NodeDataQueue& queue, size_t pinIdx);
111
115 [[nodiscard]] std::shared_ptr<const NodeData> peekPollData(bool peek = false);
116
119 [[nodiscard]] std::shared_ptr<const NodeData> pollData();
120
122 void updateOutputFlowPin();
123
125 bool _fileReaderInsteadSensor = false;
126
128 CallbackTimer _timer;
129
132 static void readSensorDataThread(void* userData);
133
135 int _outputFrequency = 1;
137 int _receivedDataCnt = 0;
138
140 int _iPollData = 0;
142 int _nPollData = 20;
143
144 bool _valueBool = true;
145 int _valueInt = -1;
146 float _valueFloat = 65.4F;
147 double _valueDouble = 1242.342;
148 std::string _valueString = "Demo";
149 DemoData _valueObject;
150 Eigen::MatrixXd _valueMatrix = Eigen::MatrixXd::Identity(3, 3);
151 size_t _stringUpdateCounter = 0;
152
156 void stringUpdatedNotifyFunction(const InsTime& insTime, size_t pinIdx);
157};
158
159} // namespace NAV
Starts a Periodic Timer.
Vector space operations.
nlohmann::json json
json namespace
Definition FlowManager.hpp:21
Node Class.
Manages a thread which calls a specified function at a specified interval.
Definition CallbackTimer.hpp:22
Demonstrates the basic GUI functionality of nodes.
Definition Demo.hpp:26
bool onCreateLink(OutputPin &startPin, InputPin &endPin) override
Called when a new link is to be established.
Demo(Demo &&)=delete
Move constructor.
static std::string typeStatic()
String representation of the Class Type.
bool resetNode() override
Resets the node. It is guaranteed that the node is initialized when this is called.
static std::string category()
String representation of the Class Category.
void restore(const json &j) override
Restores the node from a json object.
void onDeleteLink(OutputPin &startPin, InputPin &endPin) override
Called when a link is to be deleted.
Demo(const Demo &)=delete
Copy constructor.
Demo & operator=(const Demo &)=delete
Copy assignment operator.
std::string type() const override
String representation of the Class Type.
void guiConfig() override
ImGui config window which is shown on double click.
Demo()
Default constructor.
json save() const override
Saves the node into a json object.
Demo & operator=(Demo &&)=delete
Move assignment operator.
~Demo() override
Destructor.
Input pins of nodes.
Definition Pin.hpp:491
The class is responsible for all time-related tasks.
Definition InsTime.hpp:667
Abstract parent class for all nodes.
Definition Node.hpp:86
Output pins of nodes.
Definition Pin.hpp:338
Data struct transmitted over an output port.
Definition Demo.hpp:77
std::array< int, 3 > integer
Integer inside the DemoData.
Definition Demo.hpp:78