Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[21812 ] Add new functionalities to spy CommandLine interface #99

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion docs/rst/user_manual/commands/commands.rst
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,12 @@ Summary
- Show Topic info
- ``_`` |br|
``verbose`` |br|
``vv`` |br|
``<topic name>``
- ``topic`` ``topics`` |br|
``t`` ``T``

* - :ref:`user_manual_command_show`
* - :ref:`user_manual_command_echo`
- Show real-time receiving user data.
- ``<topic name>`` |br|
``<topic name> verbose`` |br|
Expand Down
29 changes: 20 additions & 9 deletions docs/rst/user_manual/commands/data.rst
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
.. include:: ../../exports/alias.include
.. include:: ../../exports/roles.include

.. _user_manual_command_show:
.. _user_manual_command_echo:

####
Show
Echo
####

This command prints every User Data received in a human readable way.
Expand All @@ -19,7 +19,7 @@ Key-words
=========

These are the key-words recognize as this command:
``show`` ``print`` ``s`` ``S``.
``echo`` ``show`` ``print`` ``s`` ``S``.

Data Type discovered
====================
Expand All @@ -30,25 +30,36 @@ The information whether the topic data type is already discovered be the applica
Arguments
=========

**Show** command support different combination of arguments:
**Echo** command support different combination of arguments:

Topic name
----------

When a topic name is given, the information shown is the data received in real-time in the topic specified.
The output format is as follows: :ref:`user_manual_command_show_output_simple`.
The output format is as follows: :ref:`user_manual_command_echo_output_simple`.

Topic name with wildcards
-------------------------
When a topic name is provided with wildcards (*), the command will display real-time information for all topics whose names match the given filter.

For example, if you enter ``sensor_*``, the command will print data from all topics starting with ``sensor_``, such as ``sensor_temperature``, ``sensor_humidity``, etc.

Topic name + Verbose
--------------------

Giving a topic name and the the :ref:`verbose argument <user_manual_commands_input_verbose>` the output is the data received in real-time with additional meta-information as the topic name, the source timestamp, and the source :term:`DataWriter` :term:`Guid`.
Data is printing using :ref:`user_manual_command_show_output_verbose`.
Data is printing using :ref:`user_manual_command_echo_output_verbose`.

Topic name prefix + * + Verbose
-------------------------------

When a topic name is provided with wildcards (*) and the :ref:`verbose argument <user_manual_commands_input_verbose>`, the command displays detailed real-time information and meta-information for all topics that match the given filter.

All
---

This argument prints all topics which Data Type has been discovered.
Data is printing using :ref:`user_manual_command_show_output_verbose`.
Data is printing using :ref:`user_manual_command_echo_output_verbose`.

Output Format
=============
Expand All @@ -60,7 +71,7 @@ Output Format

The data information is retrieved in 2 formats depending on the verbose option.

.. _user_manual_command_show_output_simple:
.. _user_manual_command_echo_output_simple:

Simple Data format
------------------
Expand All @@ -74,7 +85,7 @@ Only shows the data, by
...
---

.. _user_manual_command_show_output_verbose:
.. _user_manual_command_echo_output_verbose:

Verbose Data format
-------------------
Expand Down
15 changes: 15 additions & 0 deletions docs/rst/user_manual/commands/format.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,21 @@

.. _user_manual_commands_input:

.. _user_manual_commands_input_compact:

Compact
=======

The compact argument provides a simplified and concise output format for the information received by the command.
This format is useful when a more streamlined view of the data is preferred, reducing the amount of metadata shown and
focusing on the essential data values from the topics.

Key-words
---------

These are the key-words recognize as this argument:
``compact`` ``c`` ``-c`` ``--c`` ``C``.

.. _user_manual_commands_input_verbose:

Verbose
Expand Down
30 changes: 20 additions & 10 deletions docs/rst/user_manual/commands/topic.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ These are the key-words recognize as this command:
Arguments
=========

**Topic** command support 0 or 1 argument:
**Topic** command support from 0 to 2 arguments:

*No argument*
-------------
Expand All @@ -30,8 +30,7 @@ The output format is as follows: :ref:`user_manual_command_topic_output_simple`.
Verbose
-------

This argument queries for more complete information about each of the topics in the network.
It adds the Guid of each endpoint on the topic and the whether the type has been discovered.
This argument (``v`` or ``vv``) queries for more complete information about each of the topics in the network.
The output is a **list** of data with :ref:`verbose information <user_manual_command_topic_output_verbose>`.
Check the :ref:`verbose <user_manual_commands_input_verbose>` section in order to know which key-words are available for this argument.

Expand All @@ -47,15 +46,28 @@ This Guid must exist inside the DDS network.
If there are 2 topics with the same name and different Topic Data Type, only one of them could be visible.
These is a circumstance that :term:`DDS` allows, but it is strongly suggested not to do.

Topic name with wildcards
-------------------------

When a topic name is with wildcards (*), this command retrieves :ref:`verbose information <user_manual_command_topic_output_verbose>` for all topics that matches the given filter.
This allows users to query multiple topics in a single command, making it easier to gather related data quickly.

Output Format
=============

The topic information is retrieved in 2 formats depending on the verbose option.
The topic information is retrieved in multiple formats depending on the verbosity option.

.. _user_manual_command_topic_output_simple:

Simple Writer info
-----------------------
Topics info
-----------

- topic: <topic name> (<topic type name>) (<n writers>|<n readers>) [<rate> Hz]

.. _user_manual_command_topic_output_verbose:

Topics info in verbose mode
---------------------------

.. code-block:: yaml

Expand All @@ -65,10 +77,8 @@ Simple Writer info
datareaders: <number of datareaders currently active>
rate: <samples per second> Hz

.. _user_manual_command_topic_output_verbose:

Verbose Writer info
------------------------
Topics info in high verbosity mode
----------------------------------

.. code-block:: yaml

Expand Down
2 changes: 0 additions & 2 deletions docs/rst/user_manual/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,6 @@ The type of the logs published is defined as follows:
enable: true
domain: 84
topic-name: "FastDdsSpyLogs"
publish-type: false
stdout: true

.. _user_manual_configuration_default:
Expand Down Expand Up @@ -438,5 +437,4 @@ A complete example of all the configurations described on this page can be found
enable: true
domain: 0
topic-name: "FastDdsSpyLogs"
publish-type: false
stdout: true
8 changes: 4 additions & 4 deletions docs/rst/user_manual/tool.rst
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ Using the :ref:`user_manual_user_interface_interactive_app`, this will be the pr

.. code-block:: console

<path>$ fastddsspy
$ fastddsspy

____| | __ \ __ \ ___| ___|
| _` | __| __| | | | | \___ \ \___ \ __ \ | |
Expand All @@ -263,13 +263,13 @@ Using the :ref:`user_manual_user_interface_interactive_app`, this will be the pr

Insert a command for Fast DDS Spy:
>> quit
<path>$
$

However, using :ref:`user_manual_user_interface_one_shot` this will be expected result:

.. code-block:: console

<path>$ fastddsspy participants
$ fastddsspy participants
- name: Fast DDS ShapesDemo Participant
guid: 01.0f.44.59.21.58.14.d2.00.00.00.00|0.0.1.c1
<path>$
$
73 changes: 36 additions & 37 deletions docs/rst/user_manual/usage_example.rst
Original file line number Diff line number Diff line change
Expand Up @@ -85,29 +85,25 @@ Try out all the commands DDS Spy has to offer:

.. code-block:: output

- name: Circle
type: ShapeType
datawriters: 2
datareaders: 2
rate: 13.0298 Hz
- name: Square
type: ShapeType
datawriters: 3
datareaders: 2
rate: 26.6975 Hz
- topic: Circle (ShapeType) (1|2) [9.000000Hz]
- topic: Square (ShapeType) (1|0) [12.412500Hz]
- topic: Triangle (ShapeType) (0|1) [0.000000Hz]
- ...

* ``topics Square``
* ``topics Circle vv``

.. code-block:: output

name: Circle
type: ShapeType
datawriters:
- 01.0f.44.59.da.57.de.ec.00.00.00.00|0.0.6.2
datareaders:
- 01.0f.44.59.c9.65.78.e5.00.00.00.00|0.0.2.7
rate: 13.0418 Hz
dynamic_type_discovered: true
- name: Circle
type: ShapeType
datawriters:
- 01.0f.93.86.fb.9a.7f.92.00.00.02.00|0.0.3.2
datareaders:
- 01.0f.93.86.fb.9a.7f.92.00.00.02.00|0.0.1.7
- 01.0f.93.86.fb.9a.7f.92.00.00.02.00|0.0.2.7
rate: 11.2986 Hz
dynamic_type_discovered: false


* ``help``

Expand All @@ -118,24 +114,27 @@ Try out all the commands DDS Spy has to offer:
Fast DDS Spy is an interactive CLI that allow to instrospect DDS networks.
Each command shows data related with the network in Yaml format.
Commands available and the information they show:
help : this help.
version : tool version.
quit : exit interactive CLI and close program.
participants : DomainParticipants discovered in the network.
participants verbose : verbose information about DomainParticipants discovered in the network.
participants <Guid> : verbose information related with a specific DomainParticipant.
writers : DataWriters discovered in the network.
writers verbose : verbose information about DataWriters discovered in the network.
writers <Guid> : verbose information related with a specific DataWriter.
reader : DataReaders discovered in the network.
reader verbose : verbose information about DataReaders discovered in the network.
reader <Guid> : verbose information related with a specific DataReader.
topics : Topics discovered in the network.
topics verbose : verbose information about Topics discovered in the network.
topics <name> : verbose information related with a specific Topic.
show <name> : data of a specific Topic (Data Type must be discovered).
show <name> verbose : data with additional source info of a specific Topic.
show all : verbose data of all topics (only those whose Data Type is discovered).
help : this help.
version : tool version.
quit : exit interactive CLI and close program.
participants : DomainParticipants discovered in the network.
participants verbose : verbose information about DomainParticipants discovered in the network.
participants <Guid> : verbose information related with a specific DomainParticipant.
writers : DataWriters discovered in the network.
writers verbose : verbose information about DataWriters discovered in the network.
writers <Guid> : verbose information related with a specific DataWriter.
reader : DataReaders discovered in the network.
reader verbose : verbose information about DataReaders discovered in the network.
reader <Guid> : verbose information related with a specific DataReader.
topics : Topics discovered in the network in compact format.
topics v : Topics discovered in the network.
topics vv : verbose information about Topics discovered in the network.
topics <name> : Topics discovered in the network filtered by name (wildcard allowed (*)).
echo <name> : data of a specific Topic (Data Type must be discovered).
echo <wildcard_name> : data of a Topics matching the wildcard name (Data Type must be discovered).
echo <name> verbose : data with additional source info of a specific Topic.
echo <wildcard_name> verbose : data with additional source info of Topics with prefix <name_prefix>.
echo all : verbose data of all topics (only those whose Data Type is discovered).

Notes and comments:
To exit from data printing, press enter.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,19 @@

#pragma once

#include <iostream>
#include <functional>
#include <iostream>
#include <shared_mutex>
#include <tuple>
#include <unordered_map>

#include <fastcdr/cdr/fixed_size_string.hpp>

#include <fastdds/dds/xtypes/dynamic_types/DynamicType.hpp>

#include <ddspipe_core/types/topic/dds/DdsTopic.hpp>
#include <ddspipe_core/types/dds/Payload.hpp>
#include <ddspipe_core/types/topic/dds/DdsTopic.hpp>
#include <ddspipe_core/types/topic/filter/WildcardDdsFilterTopic.hpp>

#include <fastddsspy_participants/library/library_dll.h>
#include <fastddsspy_participants/model/TopicRateCalculator.hpp>
Expand All @@ -51,7 +53,8 @@ class DataStreamer : public TopicRateCalculator

FASTDDSSPY_PARTICIPANTS_DllAPI
bool activate(
const ddspipe::core::types::DdsTopic& topic_to_activate,
const ddspipe::core::types::WildcardDdsFilterTopic& topic_to_activate,
const std::set<eprosima::ddspipe::core::types::DdsTopic>& topics,
const std::shared_ptr<CallbackType>& callback);

FASTDDSSPY_PARTICIPANTS_DllAPI
Expand All @@ -71,21 +74,30 @@ class DataStreamer : public TopicRateCalculator
bool is_topic_type_discovered(
const ddspipe::core::types::DdsTopic& topic_to_activate) const noexcept;

FASTDDSSPY_PARTICIPANTS_DllAPI
bool is_any_topic_type_discovered(
const std::set<eprosima::ddspipe::core::types::DdsTopic>& topics) const noexcept;

protected:

bool is_topic_type_discovered_nts_(
const ddspipe::core::types::DdsTopic& topic_to_activate) const noexcept;

bool is_any_topic_type_discovered_nts_(
const std::set<eprosima::ddspipe::core::types::DdsTopic>& topics) const noexcept;

bool activated_ {false};

std::shared_ptr<CallbackType> callback_;

bool activated_all_ {false};

ddspipe::core::types::DdsTopic activated_topic_;
ddspipe::core::types::WildcardDdsFilterTopic activated_topic_;

std::map<std::string, fastdds::dds::DynamicType::_ref_type> types_discovered_;

std::unordered_map<std::string, std::string> topic_type_discovered_;

mutable std::shared_timed_mutex mutex_;
};

Expand Down
Loading
Loading