-
Notifications
You must be signed in to change notification settings - Fork 5k
move notification out of device; more generic; uses json #11042
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
Conversation
…be added only when stopped
About the data side, I saw a d4xx device with more than 200 profiles, So you say you have currently 5034/6741 but the limit is 4096? |
third-party/realdds/include/realdds/topics/notification/notification-msg.h
Show resolved
Hide resolved
|
|
||
| // Forward declaration | ||
| namespace topics { | ||
| class notification; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain when is a topic "raw"?
Why is device_info raw but notification not?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the non-raw notification you're looking at. There's a raw::notification, too
| { | ||
| module raw | ||
| { | ||
| module device |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Notification topic name does not include the device name? e.g. /realsense/D455/notification?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Topic name? Not sure what you mean. This is a general-purpose notification topic. What does it have to do with a device?
| static void construct_raw_message( msg_type msg_id, const T& msg, raw::device::notification& raw_msg ) | ||
| // Get the custom data with casting to the desired type | ||
| // Syntax: auto stream_info = msg.get< STREAM_INFO >(); | ||
| // if ( msg ) do something with it; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure I understand. What is get? Shouldn't it be
// Syntax: auto stream_info = msg.custom_data< STREAM_INFO >();
// if ( stream_info ) do something with it;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copy paste issue - get was renamed to custom_data. I'll update.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
| using type = raw::device::notificationPubSubType; | ||
| using type = raw::notificationPubSubType; | ||
|
|
||
| enum class data_type |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think data_formatting will be a better name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's the type of the data... data_format is OK I guess but why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds better to me :-)
Data type might mean other stuff as well. Format just means "the way in which something is arranged or set out."
Also when looking JSON and CBOR, wikipedia specifies they are data formats
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed.
| ~dds_notification_server(); | ||
|
|
||
| // By default we're not started, to avoid on-discovery before all discovery messages have been collected | ||
| void start(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In other classes it is called run()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, will change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed.
| "more streams than expected (" + std::to_string( n_streams_expected ) | ||
| + ") received" ); | ||
| auto type = utilities::json::get< std::string >( j, "type" ); | ||
| auto stream_name = utilities::json::get< std::string >( j, "name" ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are the messages defined somewhere, like a readme? Can we pass it to Yoram's group so they will know what we expect?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, eventually. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just making sure, this PR still keeps the profiles transfer works server --> client right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What other option is there? Everything is always server --> client...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean that the functionality still works? like before this PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unit-tests pass. Functionality is still there. Notifications are sent, processed, etc. and streams are created on the client.
I don't understand the question, I guess.
| profiles += sp->to_json(); | ||
| json msg = { | ||
| { "id", "stream-header" }, | ||
| { "type", stream->profiles().front()->type_to_string() }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To support rs2 features we will need to add a dds_stream_xxx type system and a conversion back to rs2_stream+index (like we convert dds_stream_format to and from rs2_format)
This will be able to replace the changes I made in my PR ( #11045, you did add some comments about it)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will also need some factory to create all the different stream types
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once both our PRs are in, I'll add all the other classes
| auto & stream = _streams[stream_name]; | ||
| if( stream ) | ||
| DDS_THROW( runtime_error, "stream '" + stream_name + "' already exists" ); | ||
| stream = std::make_shared< dds_video_stream >( stream_name, sensor_name ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hard to see in this UI
Where is dds_motion_stream created?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was a bug. Once we have it working we need to add some unit-tests with motion streams...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a test-case.
Moved profile type_to_string() into stream-base type_string().
Added type-check: when creating a stream in device-impl, it checks that its type is now the same as that given in the json.
There's still a
uidbut it's no longer transmitted with profiles. To be removed in another PR.Notifications are now
topics::notification(no longer insidedevice::).Notifications now primarily have a
data_typeandversion, nothing else. Thedatacan be in the format specified in thedata_type(which currently supportsCUSTOM,JSON, andCBOR). The data is bound at4096bytes (from what I saw in the code, it was at 100 before, but that obviously wasn't a limit -- this needs more looking into). Testing shows that, for a L515, the color stream has the most profiles (114) and this comes out to6741in raw json or5034in CBOR.Notifications now communicate using JSON. This code mostly resides in the device and device-server. Should be a lot more flexible.
Additionally:
guard against device-server::init() failures
add L515 stream-format
move expected stream number out of device-impl (only used in init())
notification-server no longer starts automatically; on-discovery notifications can only be added when stopped
change device destruction in device-watcher to another thread