-
Notifications
You must be signed in to change notification settings - Fork 34
Conversation
struct timeval tv; | ||
gettimeofday(&tv, nullptr); | ||
|
||
auto state = Tango::DevState::MOVING; |
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.
@Ingvord Are we now always using C++11?
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.
No, this is just an intermediate Progress commit. This PR will be cleaned up before labeled as Ready For Merge
Tango::DevString status = "some status"; | ||
|
||
//set_state(state); | ||
//set_status(status); |
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.
Currently it is required to manually set state and/or status before pushing them, see commented lines. Otherwise these values are only send to client and not set in the device i.e. in a few seconds (depending on server side polling rate) client will get an event with an old value:
I have received an event for attribute tango://172.17.0.3:10000/test/debian8/10/Status
Quality = 0
Wed Dec 12 16:42:25 2018 (1544629345,263640 sec) : Status (dim_x = 1, dim_y = 0, w_dim_x = 0, w_dim_y = 0, Data quality factor = VALID, Data format = SCALAR, Data type = DevString)
Element number [0] = some status
I have received an event for attribute tango://172.17.0.3:10000/test/debian8/10/Status
Quality = 0
Wed Dec 12 16:42:34 2018 (1544629354,286715 sec) : Status (dim_x = 1, dim_y = 0, w_dim_x = 0, w_dim_y = 0, Data quality factor = VALID, Data format = SCALAR, Data type = DevString)
Element number [0] = The device is in ON state.
Is this OK?
From API point of view I would add a couple of methods:
push_state_change_event(DevState,...)
//and
push_status_change_event(DevString,...)
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.
Currently it is required to manually set state and/or status before pushing them, see commented lines. Otherwise these values are only send to client and not set in the device i.e. in a few seconds (depending on server side polling rate) client will get an event with an old value:
I have received an event for attribute tango://172.17.0.3:10000/test/debian8/10/Status Quality = 0 Wed Dec 12 16:42:25 2018 (1544629345,263640 sec) : Status (dim_x = 1, dim_y = 0, w_dim_x = 0, w_dim_y = 0, Data quality factor = VALID, Data format = SCALAR, Data type = DevString) Element number [0] = some status I have received an event for attribute tango://172.17.0.3:10000/test/debian8/10/Status Quality = 0 Wed Dec 12 16:42:34 2018 (1544629354,286715 sec) : Status (dim_x = 1, dim_y = 0, w_dim_x = 0, w_dim_y = 0, Data quality factor = VALID, Data format = SCALAR, Data type = DevString) Element number [0] = The device is in ON state.
Is this OK?
Since DeviceImpl::push_change_event(String, DevState *,...) methods are invoking attr.set_value() or attr.set_value_date_quality(), it would be interesting to invoke set_state() or set_status() at some point in these methods when attr_name is "state" or "status"... or maybe to do it directly in these set_value() or set_value_date_quality() methods when the attribute name is state or status?
From API point of view I would add a couple of methods:
push_state_change_event(DevState,...) //and push_status_change_event(DevString,...)
Fine with me.
I would even add:
push_status_change_event(const std::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.
Since DeviceImpl::push_change_event(String, DevState *,...) methods are invoking attr.set_value() or attr.set_value_date_quality(), it would be interesting to invoke set_state() or set_status() at some point in these methods when attr_name is "state" or "status"... or maybe to do it directly in these set_value() or set_value_date_quality() methods when the attribute name is state or status?
Frankly speaking, I would not do that. As this introduces yet another if hence some side effect. I am not sure whether in case of non-"State"/"Status" attributes push_ sets the value. Anyway I would keep push_ for pushing into event system while actual set value must be done independently. Correct me if I am wrong but the main use case for a client is to: calculate new value; store it; push it. We can add a new convenience function like: set_and_push_state_change_event
and alike
This PR changes behavior of
Which is IMHO fine, because method |
This is changing the behaviour of DeviceImpl::push_change_event(string, DevFailed*) method which is documented as followed in doxygen:
So I would avoid to change the behaviour of the method if possible. Is there a way to keep the behaviour of DeviceImpl::push_change_event(string, DevFailed*) and DeviceImpl::push_archive_event(string, DevFailed*) as it was before and also find a way to use the other versions of push_change_event(DevState *, ...) and push-archive_event(DevState *,...) methods with state and status attribute without memory leak? |
When using push_change_event(DevState *, ...) and push_archive_event(DevState *,...) methods, I think the value provided by the user, as well as the timestamp provided by the user should be taken into account. About the quality factor. I am not 100% sure of what we should do... As it is now, when you read a state or status attribute, you always get a VALID quality factor. |
I would put API clarity on top of consistency in this case. When you invoke a method you usually expect certain things, AFAIK you would never expect that your values are ignored. As most of the time you want a certain method due to certain requirements. So it may be perfectly fine to get VALID via read, but push something else. Finally the documentation should not be an excuse to confusing code. The truth is that usually developers do not read docs, until there is a severe issue they fight with... |
I would tend to agree with @Ingvord. We should fix confusing behaviour. The side effects for old code will need to be handled of course. But that can be less of a surprise than non-logical APIs. |
I fully agree with you on this point. I don't like that.
What I don't like in this topic are the inconsistencies... because this also leads to confusions... As it is now, when you read the state attribute, you will always get a VALID quality factor so it is not logical to be able to push events for State attribute with a different quality factor. So the big question is: should we allow quality factors different than VALID for state and status attributes? If yes, then I think we should allow it in every situation, and if we don't, we should force the quality factor to VALID in every situation and clearly document this point, not only in doxygen, but also on readthedocs. This could help at least new users which are reading the doc to learn Tango.
I agree with you! But we are in a confused situation and we need to find ways to reduce this confusion... |
Well, we can preserve consistence - in this case push_change_event(string, DevState /DevString, ...) must throw IllegalArgumentException in case "State"/"Status" saying user that these method ignores input values and for "State"/"Status" he must use short form. Then it is 100% clear, State/Status always VALID etc... |
I like this idea of throwing an IllegalArgumentException. I personally would be in favour of push_change_event(string, DevState /DevString, ...) throwing an IllegalArgumentException if the provided quality factor is different than VALID and give the possibility to the user to send events with specific timestamps. |
@bourtemb I think the question label can be removed or? |
Right! I remove it.
|
refactorsame as in PR to fix #359 #503