Jump to content

Numeric 'Value Change' event still triggers when coerced minimum and maximum are defined


dhakkan

Recommended Posts

Hello,

 

I searched within this site and via Google for any related queries. Couldn't find any. Hence this post...

 

Example of Situation:

I configured an I8 Numeric with non-default limits in its 'Properties >> Data Entry' window...

Minimum of -2 (coerced); Maximum of 2 (coerced). I set up a simple event that looks for 'Value Change' of this Numeric.

 

Expectation:

No matter what the 'Increment' value and 'Response to value outside limits' are set to, the 'Value Change' must NOT trigger if the numeric is already at the limit and cannot be changed further. To explain, If current value of Numeric is 2 and I try to increment it, its value must remain at 2 and no event should be triggered. Similarly, with current value of Numeric at -2, if I try to decrement it, its value must remain at -2 and no event should be triggered.

 

What I found was that the value does remain at the limit, but an event is still triggered when the 'Increment' setting is non-zero. Is this normal behavior?

 

Test Numeric Event Triggering.vi coded in LV2014

Link to comment

What I found was that the value does remain at the limit, but an event is still triggered when the 'Increment' setting is non-zero. Is this normal behavior?

Yes, a value change event does not necessarily mean a different value than the previous one.  You can use the Value (Sig) property to set a control to the current value and the event is still triggered, same with this.

 

The solution seems like an easy one.  If the old value, is equal to the new value, do nothing.  The old and new values are available in the event that is triggered.

Link to comment

Yes, a value change event does not necessarily mean a different value than the previous one.  You can use the Value (Sig) property to set a control to the current value and the event is still triggered, same with this.

 

The solution seems like an easy one.  If the old value, is equal to the new value, do nothing.  The old and new values are available in the event that is triggered.

 

Thanks for the response, Hoovahh. Understood and agreed regarding the 'Val (Sig)' property. In this case, the LV Developer is forcing LV to trigger an event.

 

However, my expectation from the Front Panel standpoint was for LabVIEW to not even trigger the event, i.e. LV checks for value actually changing before deciding to generate the event internally.

 

IMHO, if one is using 'value change' events, the current implementation pretty much defeats the purpose of the minimum and maximum limits set in the Numeric's properties - depending on data validation requirements, the Developer would be forced to perform a check in the event structure to discard further action.

 

To give you a background, my thought process for this started when I realized some subVI was coercing numeric values coming in even though no 'in range and coerce' equivalent functionality was implemented in its block diagram. That led me to realize that it's obviously not a good practice to validate inputs' range via front panel properties, unless some in-code documentation clearly states so. More importantly, as several sources rightly state, coercing values without alerting the user is not a good practice. Then, I wanted to see if this coercion was OK for front panels meant to be direct user interfaces.

 

Ummm, I guess I refuted my own statement... with the event triggered even when there is no value change, it would after all be good programming to alert the user that a 'limit' has been reached and offer alternatives (instead of 'discarding' further action as I mis-stated above).

 

Thanks! for the mini-discussion.  :)

Link to comment

Thanks for the response, Hoovahh. Understood and agreed regarding the 'Val (Sig)' property. In this case, the LV Developer is forcing LV to trigger an event.

 

However, my expectation from the Front Panel standpoint was for LabVIEW to not even trigger the event, i.e. LV checks for value actually changing before deciding to generate the event internally.

 

IMHO, if one is using 'value change' events, the current implementation pretty much defeats the purpose of the minimum and maximum limits set in the Numeric's properties - depending on data validation requirements, the Developer would be forced to perform a check in the event structure to discard further action.

 

To give you a background, my thought process for this started when I realized some subVI was coercing numeric values coming in even though no 'in range and coerce' equivalent functionality was implemented in its block diagram. That led me to realize that it's obviously not a good practice to validate inputs' range via front panel properties, unless some in-code documentation clearly states so. More importantly, as several sources rightly state, coercing values without alerting the user is not a good practice. Then, I wanted to see if this coercion was OK for front panels meant to be direct user interfaces.

 

Ummm, I guess I refuted my own statement... with the event triggered even when there is no value change, it would after all be good programming to alert the user that a 'limit' has been reached and offer alternatives (instead of 'discarding' further action as I mis-stated above).

 

Thanks! for the mini-discussion.  :)

 

I'm not really understanding what you are saying. For one, the case that UI controls configured to coerce their values would do the coercion also when the VI is used as subVI: that was true in LabVIEW 3.0 and maybe 4.0 but was removed after that because it was considered indeed a bad idea. I should say that quite a few people got upset at this back then :D, but you seem to agree that this is not desirable.

 

As to using the fact that the Value Change event does not get triggered to allow you to alert a user that there was a coercion??? Sorry but I'm not following you here at all. How can you use an event that does NOT occur, to trigger any action?? That sounds so involved and out of our space-time continium that my limited brain capacity can't comprehend it.  :P

 

But you can't use the fact that the value is the same to mean that a limit has been reached. The user is free to go to the control, type in exactly the same value as is seen already, and hit enter or click on something else in the panel and the Value Change event will be triggered. Value Changed simply doesn't mean that there is a different value, only that the user did something with the control to change the control to the same or a different value. Sounds involved I know but there have been many discussions both in the LabVIEW devlopment team as well as in many other companies who design UI widget libraries and they generally all agree that you want to trigger on user interaction with the control for maximum functionality and leave the details about if an equal value should mean something or not to the actual implementor. The name for the event may indeed be somewhat misleading here. In LabWindows CVI NI used the VALUE_COMMIT term for the same event. However I suppose the word "commit" was considered to technical for use in LabVIEW.

Link to comment

Hello Rolf,

 

... As to using the fact that the Value Change event does not get triggered to allow you to alert a user that there was a coercion??? ...

 

Not sure where I implied that... Sorry, if the write-up was not clear. I was of a different opinion when I started writing that post as compared to when I finished it a few minutes later.  :rolleyes:

 
Should I retract or re-write that post?

 

In any case, the rest of your post indicates we are on the same page.

 

Yes, the event name could be considered misleading. Variations of VALUE_ENTER or VALUE_SUBMIT may have helped. But, that's up to the NI gurus, isn't it.

Link to comment

Hello Rolf,

 

Not sure where I implied that... Sorry, if the write-up was not clear. I was of a different opinion when I started writing that post as compared to when I finished it a few minutes later.  :rolleyes:

 

Yeah after rereading it a few more times I got the feeling that something like that had happened. :D

 

 

Should I retract or re-write that post?

 

I think it's not worth the effort. Things are pretty clear now and editing posts substantially after the fact is something that is generally not considered helpful nor correct. We all write sometimes things that turn out later to be badly written. For myself I usually limit editing for posts to fixing typos and adding an occasional extra information that seems useful.

Link to comment

...

I think it's not worth the effort. Things are pretty clear now and editing posts substantially after the fact is something that is generally not considered helpful nor correct. We all write sometimes things that turn out later to be badly written. For myself I usually limit editing for posts to fixing typos and adding an occasional extra information that seems useful.

 

Gotcha. Thanks for the tips too! (I'm pretty new to posting on discussion forums in general, let alone LAVA.)

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.