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

Simplified subscription usage and updated the TriBool implementation #27

Merged

Conversation

jontje
Copy link
Contributor

@jontje jontje commented Sep 6, 2018

  • Simplified the RWS subscription usage for when the event content is inconsequential (part of issue Improve the RWS subscription implementation #24)

  • Updated the TriBool according to:

    • Moved the implementation from inside the RWSInterface class to rws_common.h.
      Reason: TriBool is useful outside of the RWSInterface class, and doesn't really have anything to do with the class per se.
    • Removed the implicit bool conversion operator, and implemented methods to check certain cases instead.
      Reason: The implicit bool conversion resulted in the following unintended behavior:
      TriBool tri_bool(TriBool::FALSE_VALUE);
      tri_bool == TriBool::UNKNOWN_VALUE // Resulted in false. Ok!
      TriBool::UNKNOWN_VALUE == tri_bool // Resulted in true. Not ok!

Copy link
Member

@gavanderhoorn gavanderhoorn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some minor comments

include/abb_librws/rws_common.h Outdated Show resolved Hide resolved
/**
* \brief An enum for the different accepted values.
*/
enum Values
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the plural? I know there are multiple valid values, but it gets weird when you declare a variable of this type: Values value. It really just holds a single value, does it not?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's how I usually do it, and I think it's logical to have the type as plural (since there are several accepted values) and then have singular in the instance. But I guess it's a bit subjective :)

@@ -333,7 +333,7 @@ POCOClient::POCOResult POCOClient::webSocketConnect(const std::string uri, const
{
result.addHTTPRequestInfo(request);
p_websocket_ = new WebSocket(client_session_, request, response);
p_websocket_->setReceiveTimeout(Poco::Timespan(60000000));
p_websocket_->setReceiveTimeout(Poco::Timespan(LONG_TIMEOUT));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LONG_TIMEOUT: name is a bit random ;)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, not too random I think since it's a longer timeout than the default timeout. Maybe the timeout should be made configurable in the future.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess my comment was more about why you chose this name. LONG_TIMEOUT is arbitrary, as the name does not convey anything about how long the timeout is. Reading your code I cannot deduce how long things will wait before timing out unless I go and lookup the declaration of the constant.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, then I misunderstood what you meant and it's true for the DEFAULT_TIMEOUT as well. Anyway, issue #28 should solve this.

@@ -178,7 +178,7 @@ bool RWSSimpleStateMachineInterface::toggleIOSignal(const std::string iosignal)
bool result = false;
int max_number_of_attempts = 5;

if (isAutoMode())
if (isAutoMode().isTrue())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should something happen / be printed when it isn't?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method will return false if it fails, so I don't think it's needed to print anything here. The log can be inspected, if needed, to see what failed.

@gavanderhoorn
Copy link
Member

Feel free to merge @jontje.

@jontje
Copy link
Contributor Author

jontje commented Nov 1, 2018

Great and thanks for the review @gavanderhoorn.

@jontje jontje merged commit 64affbd into ros-industrial:master Nov 1, 2018
@jontje jontje deleted the subscription_and_tri_bool_update branch November 1, 2018 14:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants