What is the default behavior of the noset attribute of a Sequence (to perform mathematical operations on incoming parameters)?
The Development Library definition is tricky to interpret and does not match what I would expect.
Case: SNMP Parameter with incoming value -30. Read: "div:10". Write:"factor:10"
Read parameter with noset=true and div:10
Get parameter is retrieved as -3. It is shown as -3 on the element and a get will return -3.
Read parameter with noset=false and div:10
Get parameter is retrieved as -30. It is shown as -30 on the element and a get will return -30.
What is the advantage of this configuration? Simply nothing seems to happen in this case.
The development library mentions at least that the displayed value on the element should be -3.
After reading the description in depth, I believe the idea is that whilst on the element the value should be -3, then the parameter itself should hold the value -30, even if that's not how it seems to work at this point.
Conclusion for reads:
We can use noset="true" as it's the only option with visible results in the element.
For a read with noset= true, write parameter with noset=true and factor:10, set to -4
A write parameter with noset = true will use -40 as an SNMP set.
For a read with noset= true, write parameter with noset=false and factor:10, set to -4
A write parameter with noset = false will use -40 as an SNMP set.
Conclusion for writes:
The behavior for writes with attribute noset="true" seems to be the same for both true and false.
Is this expected behavior? I would've expected at least some difference in behavior.
Hi Laurens,
Thank you for asking this question because it is on the lips of many of us.
Let's start with what matters the most to me: "When and how to use the Sequence tag and its noset attribute":
- Only use it on communication parameters (parameters filled in by polling via SNMP, Serial, HTTP...) -> don't use it for custom/retrieved parameters (parameters filled in via QActions...)
- On read parameters: always use it with the noset attribute set to true.
- On write parameters: always use it with the noset attribute set to true and with the opposite math operation compared to the corresponding read parameter.
Example:
- Read Param : <Sequence noset="true">div:100</Sequence>
- Write Param : <Sequence noset="true">factor:100</Sequence> or <Sequence noset="true">*:100</Sequence>
Other than the above use-case, let's be transparent here, the exact behavior and explanation of the noset attribute is to be considered undefined or you could even probably say "buggy".
This may not sound very glorious but in the end, there is no much need/use for the Sequence tag in any other situation than the above mentioned one so I don't think it's worth further fine-tuning its implementation.
Example: for a parameter set from a QAction, you would be much better off directly applying any sequence in the QAction code directly rather than trying to use the Sequence tag.
Documentation has now been updated accordingly.
Additional information:
When calling the GetParameter() method on a parameter containing the Sequence tag (with its noset attribute set to true), keep in mind you’ll always receive the value displayed in the UI (Cube) which means:
– after the sequence is applied for read parameters.
– before the sequence is applied for write parameters.