0.4.1
Loading...
Searching...
No Matches
NAV::Demo Class Reference

Demonstrates the basic GUI functionality of nodes. More...

Data Structures

struct  DemoData
 Data struct transmitted over an output port. More...
 

Public Types

enum class  DemoPins : uint8_t {
  Delegate ,
  Flow ,
  Bool ,
  Int ,
  Float ,
  Double ,
  String ,
  Object ,
  Matrix
}
 Pin types used in this demo. More...
 
- Public Types inherited from NAV::Node
enum class  Mode : uint8_t {
  REAL_TIME ,
  POST_PROCESSING
}
 Different Modes the Node can work in. More...
 
enum class  State : uint8_t {
  Disabled ,
  Deinitialized ,
  DoInitialize ,
  Initializing ,
  Initialized ,
  DoDeinitialize ,
  Deinitializing ,
  DoShutdown ,
  Shutdown
}
 Possible states of the node. More...
 

Public Member Functions

void afterDeleteLink (OutputPin &startPin, InputPin &endPin) override
 Called when a link was deleted.
 
void deinitialize () override
 Deinitialize the node.
 
 Demo ()
 Default constructor.
 
 Demo (const Demo &)=delete
 Copy constructor.
 
 Demo (Demo &&)=delete
 Move constructor.
 
std::optional< size_t > getPinIdx (DemoPins pinType) const
 Calculates the pin index for the given type.
 
void guiConfig () override
 ImGui config window which is shown on double click.
 
bool initialize () override
 Initialize the node.
 
bool onCreateLink (OutputPin &startPin, InputPin &endPin) override
 Called when a new link is to be established.
 
Demooperator= (const Demo &)=delete
 Copy assignment operator.
 
Demooperator= (Demo &&)=delete
 Move assignment operator.
 
std::shared_ptr< const NodeDatapeekPollData (bool peek=false)
 Polls data from the file. This function is needed, if we have multiple output pins, polling data.
 
std::shared_ptr< const NodeDatapollData ()
 Polls data from the file.
 
void receiveData (InputPin::NodeDataQueue &queue, size_t pinIdx)
 Receive callback on the Flow pin.
 
bool resetNode () override
 Resets the node. It is guaranteed that the node is initialized when this is called.
 
void restore (const json &j) override
 Restores the node from a json object.
 
json save () const override
 Saves the node into a json object.
 
void stringUpdatedNotifyFunction (const InsTime &insTime, size_t pinIdx)
 Function to call when the string is updated.
 
std::string type () const override
 String representation of the Class Type.
 
void updateOutputFlowPin ()
 Updates the output flow pin depending on the GUI selection.
 
void updatePins ()
 Update the pins depending on the GUI.
 
 ~Demo () override
 Destructor.
 
- Public Member Functions inherited from NAV::Node
virtual void afterCreateLink (OutputPin &startPin, InputPin &endPin)
 Called when a new link was established.
 
bool doDeinitialize (bool wait=false)
 Asks the node worker to deinitialize the node.
 
bool doDisable (bool wait=false)
 Asks the node worker to disable the node.
 
bool doEnable ()
 Enable the node.
 
bool doInitialize (bool wait=false)
 Asks the node worker to initialize the node.
 
bool doReinitialize (bool wait=false)
 Asks the node worker to reinitialize the node.
 
virtual void flush ()
 Function called by the flow executer after finishing to flush out remaining data.
 
template<typename T>
std::optional< InputPin::IncomingLink::ValueWrapper< T > > getInputValue (size_t portIndex) const
 Get Input Value connected on the pin. Only const data types.
 
Mode getMode () const
 Get the current mode of the node.
 
const ImVec2 & getSize () const
 Get the size of the node.
 
State getState () const
 Get the current state of the node.
 
bool hasInputPinWithSameTime (const InsTime &insTime) const
 Checks wether there is an input pin with the same time.
 
InputPininputPinFromId (ax::NodeEditor::PinId pinId)
 Returns the pin with the given id.
 
size_t inputPinIndexFromId (ax::NodeEditor::PinId pinId) const
 Returns the index of the pin.
 
void invokeCallbacks (size_t portIndex, const std::shared_ptr< const NodeData > &data)
 Calls all registered callbacks on the specified output port.
 
bool isDisabled () const
 Checks if the node is disabled.
 
bool isInitialized () const
 Checks if the node is initialized.
 
bool isOnlyRealtime () const
 Checks if the node is only working in real time (sensors, network interfaces, ...)
 
bool isTransient () const
 Checks if the node is changing its state currently.
 
std::string nameId () const
 Node name and id.
 
 Node (const Node &)=delete
 Copy constructor.
 
 Node (Node &&)=delete
 Move constructor.
 
 Node (std::string name)
 Constructor.
 
void notifyOutputValueChanged (size_t pinIdx, const InsTime &insTime, const std::scoped_lock< std::mutex > &&guard)
 Notifies connected nodes about the change.
 
virtual void onDeleteLink (OutputPin &startPin, InputPin &endPin)
 Called when a link is to be deleted.
 
Nodeoperator= (const Node &)=delete
 Copy assignment operator.
 
Nodeoperator= (Node &&)=delete
 Move assignment operator.
 
OutputPinoutputPinFromId (ax::NodeEditor::PinId pinId)
 Returns the pin with the given id.
 
size_t outputPinIndexFromId (ax::NodeEditor::PinId pinId) const
 Returns the index of the pin.
 
void releaseInputValue (size_t portIndex)
 Unblocks the connected node. Has to be called when the input value should be released and getInputValue was not called.
 
std::scoped_lock< std::mutex > requestOutputValueLock (size_t pinIdx)
 Blocks the thread till the output values was read by all connected nodes.
 
virtual void restoreAtferLink (const json &j)
 Restores link related properties of the node from a json object.
 
void wakeWorker ()
 Wakes the worker thread.
 
virtual ~Node ()
 Destructor.
 

Static Public Member Functions

static std::string category ()
 String representation of the Class Category.
 
static void readSensorDataThread (void *userData)
 Function which performs the async data reading.
 
static std::string typeStatic ()
 String representation of the Class Type.
 
- Static Public Member Functions inherited from NAV::Node
static std::string toString (State state)
 Converts the state into a printable text.
 

Data Fields

bool _enableBool
 Switch to enable the bool pin.
 
bool _enableDelegate
 Switch to enable the delegate pin.
 
bool _enableDouble
 Switch to enable the double pin.
 
bool _enableFloat
 Switch to enable the float pin.
 
bool _enableFlow
 Switch to enable the flow pin.
 
bool _enableInt
 Switch to enable the int pin.
 
bool _enableMatrix
 Switch to enable the matrix pin.
 
bool _enableObject
 Switch to enable the object pin.
 
bool _enableString
 Switch to enable the string pin.
 
bool _fileReaderInsteadSensor
 Whether to have a file reader instead of a sensor output pin.
 
int _iPollData
 Counter for data Reading.
 
int _nPollData
 Amount of Observations to be read.
 
int _outputFrequency
 Output frequency for the simulated sensor data.
 
int _receivedDataCnt
 Counter how often data was received.
 
size_t _stringUpdateCounter
 Counter of how often the string was updated.
 
CallbackTimer _timer
 Timer object to handle async data requests.
 
bool _valueBool
 Value which is represented over the Bool pin.
 
double _valueDouble
 Value which is represented over the Double pin.
 
float _valueFloat
 Value which is represented over the Float pin.
 
int _valueInt
 Value which is represented over the Int pin.
 
Eigen::MatrixXd _valueMatrix
 Value which is represented over the Matrix pin.
 
DemoData _valueObject
 Value which is represented over the Object pin.
 
std::string _valueString
 Value which is represented over the String pin.
 
- Data Fields inherited from NAV::Node
bool callbacksEnabled
 Enables the callbacks.
 
ax::NodeEditor::NodeId id
 Unique Id of the Node.
 
std::vector< InputPininputPins
 List of input pins.
 
Kind kind
 Kind of the Node.
 
std::string name
 Name of the Node.
 
std::vector< OutputPinoutputPins
 List of output pins.
 
std::multimap< InsTime, std::pair< OutputPin *, size_t > > pollEvents
 Map with callback events (sorted by time)
 

Additional Inherited Members

- Protected Attributes inherited from NAV::Node
ImVec2 _guiConfigDefaultWindowSize
 
bool _hasConfig
 Flag if the config window should be shown.
 
bool _lockConfigDuringRun
 Lock the config when executing post-processing.
 
bool _onlyRealTime
 Whether the node can run in post-processing or only real-time.
 

Detailed Description

Demonstrates the basic GUI functionality of nodes.

Definition at line 27 of file Demo.hpp.

Member Enumeration Documentation

◆ DemoPins

enum class NAV::Demo::DemoPins : uint8_t
strong

Pin types used in this demo.

Enumerator
Delegate 

Delegate pins giving access to the complete connected node.

Flow 

Flow pins transmitting data as timestamped shared pointers.

Bool 

Booleans.

Int 

Integer numbers.

Float 

Float numbers.

Double 

Double numbers.

String 

Strings.

Object 

Custom objects.

Matrix 

Matrix objects.

Definition at line 96 of file Demo.hpp.

Constructor & Destructor Documentation

◆ Demo() [1/3]

NAV::Demo::Demo ( )

Default constructor.

Definition at line 75 of file Demo.cpp.

◆ ~Demo()

NAV::Demo::~Demo ( )
override

Destructor.

Definition at line 93 of file Demo.cpp.

◆ Demo() [2/3]

NAV::Demo::Demo ( const Demo & )
delete

Copy constructor.

◆ Demo() [3/3]

NAV::Demo::Demo ( Demo && )
delete

Move constructor.

Member Function Documentation

◆ afterDeleteLink()

void NAV::Demo::afterDeleteLink ( OutputPin & startPin,
InputPin & endPin )
overridevirtual

Called when a link was deleted.

Parameters
[in]startPinPin where the link starts
[in]endPinPin where the link ends

Reimplemented from NAV::Node.

Definition at line 676 of file Demo.cpp.

◆ category()

std::string NAV::Demo::category ( )
staticnodiscard

String representation of the Class Category.

Definition at line 108 of file Demo.cpp.

◆ deinitialize()

void NAV::Demo::deinitialize ( )
overridevirtual

Deinitialize the node.

Reimplemented from NAV::Node.

Definition at line 496 of file Demo.cpp.

◆ getPinIdx()

std::optional< size_t > NAV::Demo::getPinIdx ( DemoPins pinType) const

Calculates the pin index for the given type.

Parameters
[in]pinTypePin type to use
Returns
Index of the pin (input and output pins have same indices)

Definition at line 586 of file Demo.cpp.

◆ guiConfig()

void NAV::Demo::guiConfig ( )
overridevirtual

ImGui config window which is shown on double click.

Attention
Don't forget to set _hasConfig to true in the constructor of the node

Reimplemented from NAV::Node.

Definition at line 113 of file Demo.cpp.

◆ initialize()

bool NAV::Demo::initialize ( )
overridevirtual

Initialize the node.

Reimplemented from NAV::Node.

Definition at line 475 of file Demo.cpp.

◆ onCreateLink()

bool NAV::Demo::onCreateLink ( OutputPin & startPin,
InputPin & endPin )
overridevirtual

Called when a new link is to be established.

Parameters
[in]startPinPin where the link starts
[in]endPinPin where the link ends
Returns
True if link is allowed, false if link is rejected

Reimplemented from NAV::Node.

Definition at line 664 of file Demo.cpp.

◆ operator=() [1/2]

Demo & NAV::Demo::operator= ( const Demo & )
delete

Copy assignment operator.

◆ operator=() [2/2]

Demo & NAV::Demo::operator= ( Demo && )
delete

Move assignment operator.

◆ peekPollData()

std::shared_ptr< const NAV::NodeData > NAV::Demo::peekPollData ( bool peek = false)
nodiscard

Polls data from the file. This function is needed, if we have multiple output pins, polling data.

Note
Not used in the node as only one output flow pin which does not need peeking and therefore utilizes the NAV::Demo::pollData() function
Parameters
[in]peekSpecifies if the data should be peeked (without moving the read cursor) or read
Returns
The read observation

Definition at line 741 of file Demo.cpp.

◆ pollData()

std::shared_ptr< const NAV::NodeData > NAV::Demo::pollData ( )
nodiscard

Polls data from the file.

Returns
The read observation

Definition at line 766 of file Demo.cpp.

◆ readSensorDataThread()

void NAV::Demo::readSensorDataThread ( void * userData)
static

Function which performs the async data reading.

Parameters
[in]userDataPointer to the object

Definition at line 694 of file Demo.cpp.

◆ receiveData()

void NAV::Demo::receiveData ( InputPin::NodeDataQueue & queue,
size_t pinIdx )

Receive callback on the Flow pin.

Parameters
[in]queueQueue with all the received data messages
[in]pinIdxIndex of the pin the data is received on

Definition at line 686 of file Demo.cpp.

◆ resetNode()

bool NAV::Demo::resetNode ( )
overridevirtual

Resets the node. It is guaranteed that the node is initialized when this is called.

Reimplemented from NAV::Node.

Definition at line 625 of file Demo.cpp.

◆ restore()

void NAV::Demo::restore ( const json & j)
overridevirtual

Restores the node from a json object.

Parameters
[in]jJson object with the node state

Reimplemented from NAV::Node.

Definition at line 445 of file Demo.cpp.

◆ save()

json NAV::Demo::save ( ) const
nodiscardoverridevirtual

Saves the node into a json object.

Reimplemented from NAV::Node.

Definition at line 416 of file Demo.cpp.

◆ stringUpdatedNotifyFunction()

void NAV::Demo::stringUpdatedNotifyFunction ( const InsTime & insTime,
size_t pinIdx )

Function to call when the string is updated.

Parameters
[in]insTimeTime the data was received
[in]pinIdxIndex of the pin the data is received on

Definition at line 782 of file Demo.cpp.

◆ type()

std::string NAV::Demo::type ( ) const
nodiscardoverridevirtual

String representation of the Class Type.

Implements NAV::Node.

Definition at line 103 of file Demo.cpp.

◆ typeStatic()

std::string NAV::Demo::typeStatic ( )
staticnodiscard

String representation of the Class Type.

Definition at line 98 of file Demo.cpp.

◆ updateOutputFlowPin()

void NAV::Demo::updateOutputFlowPin ( )

Updates the output flow pin depending on the GUI selection.

Definition at line 635 of file Demo.cpp.

◆ updatePins()

void NAV::Demo::updatePins ( )

Update the pins depending on the GUI.

Definition at line 509 of file Demo.cpp.

Field Documentation

◆ _enableBool

bool NAV::Demo::_enableBool

Switch to enable the bool pin.

Definition at line 154 of file Demo.hpp.

◆ _enableDelegate

bool NAV::Demo::_enableDelegate

Switch to enable the delegate pin.

Definition at line 152 of file Demo.hpp.

◆ _enableDouble

bool NAV::Demo::_enableDouble

Switch to enable the double pin.

Definition at line 157 of file Demo.hpp.

◆ _enableFloat

bool NAV::Demo::_enableFloat

Switch to enable the float pin.

Definition at line 156 of file Demo.hpp.

◆ _enableFlow

bool NAV::Demo::_enableFlow

Switch to enable the flow pin.

Definition at line 153 of file Demo.hpp.

◆ _enableInt

bool NAV::Demo::_enableInt

Switch to enable the int pin.

Definition at line 155 of file Demo.hpp.

◆ _enableMatrix

bool NAV::Demo::_enableMatrix

Switch to enable the matrix pin.

Definition at line 160 of file Demo.hpp.

◆ _enableObject

bool NAV::Demo::_enableObject

Switch to enable the object pin.

Definition at line 159 of file Demo.hpp.

◆ _enableString

bool NAV::Demo::_enableString

Switch to enable the string pin.

Definition at line 158 of file Demo.hpp.

◆ _fileReaderInsteadSensor

bool NAV::Demo::_fileReaderInsteadSensor

Whether to have a file reader instead of a sensor output pin.

Definition at line 133 of file Demo.hpp.

◆ _iPollData

int NAV::Demo::_iPollData

Counter for data Reading.

Definition at line 148 of file Demo.hpp.

◆ _nPollData

int NAV::Demo::_nPollData

Amount of Observations to be read.

Definition at line 150 of file Demo.hpp.

◆ _outputFrequency

int NAV::Demo::_outputFrequency

Output frequency for the simulated sensor data.

Definition at line 143 of file Demo.hpp.

◆ _receivedDataCnt

int NAV::Demo::_receivedDataCnt

Counter how often data was received.

Definition at line 145 of file Demo.hpp.

◆ _stringUpdateCounter

size_t NAV::Demo::_stringUpdateCounter

Counter of how often the string was updated.

Definition at line 169 of file Demo.hpp.

◆ _timer

CallbackTimer NAV::Demo::_timer

Timer object to handle async data requests.

Definition at line 136 of file Demo.hpp.

◆ _valueBool

bool NAV::Demo::_valueBool

Value which is represented over the Bool pin.

Definition at line 162 of file Demo.hpp.

◆ _valueDouble

double NAV::Demo::_valueDouble

Value which is represented over the Double pin.

Definition at line 165 of file Demo.hpp.

◆ _valueFloat

float NAV::Demo::_valueFloat

Value which is represented over the Float pin.

Definition at line 164 of file Demo.hpp.

◆ _valueInt

int NAV::Demo::_valueInt

Value which is represented over the Int pin.

Definition at line 163 of file Demo.hpp.

◆ _valueMatrix

Eigen::MatrixXd NAV::Demo::_valueMatrix

Value which is represented over the Matrix pin.

Definition at line 168 of file Demo.hpp.

◆ _valueObject

DemoData NAV::Demo::_valueObject

Value which is represented over the Object pin.

Definition at line 167 of file Demo.hpp.

◆ _valueString

std::string NAV::Demo::_valueString

Value which is represented over the String pin.

Definition at line 166 of file Demo.hpp.


The documentation for this class was generated from the following files: