This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

grp.checkwrite and supported datatypes
#1
Hi

I am updating my scripts to use grp.checkwrite instead of my own wrapper that simply wrote things in memory and then did a string compare to prevent unnecessary bus load

so far I have the following experience
- booleans it seems to work fine

- floats only works fine,  if I add the delta argument at the end for example grp.checkwrite(KNXGROUP, newValue, 1)
but why is this needed ? 
in my opinion it should have a default behaviour if there is a difference then write to the bus

- text does not work fine ? grp.checkwrite(KNXGROUP, newValue, 1)
It always writes the newValue to the bus ? How can I prevent this with grp.checkwrite ?
For now I use my own wrapper again for this

Thanks
Nicky
Reply
#2
It only supports numeric and boolean data types, for other data types it behaves the same as grp.write. If no delta is set values must have an exact match. This might not always work for floating point values due to their internal representation so it is recommended to set delta for floats.
Reply
#3
Hi Admin
Could you please add "feedback" argument? I mean
grp.checkwrite(target_group, newValue, delta, test_group)
Because sometimes I want to change the value only in case fedback value doesn't match to newvalue.

Delta is important in case you work with 5.001 scale (integer percents) and its crappy implementation in KNX.
LM5Lp, firmware: 2018.08.22 and 2021.12.15, FlashSYS v2, ARMv7 Processor rev 5 (v7l), kernel 4.4.151 and 4.4.259
Reply
#4
Thank you for the clarification

Could you add in a future release a default implementation like a string compare for unsupported datatypes?

Thanks
Nicky
Reply
#5
Support for status object and non-boolean/numeric datatypes will be added in the next firmware.
Reply
#6
how was this implemented for non boolean/numeric? What does it dop with the 3rd argument?

I ask, because in the FB editor, checkwrite is only inserted as code if an argument is provided. For numeric a 0 or delta is clear.
But how does is behave on string for instance?
Does it ignore the 3rd argument?
How to configure FB editor output to have a checkwrite without 3rd argument for string (I tried typing nil, but not accepted)


thx
C.
Don't ask what we can do in KNX but wonder what we can't - www.KNXlogic.eu
Reply
#7
Minimum delta (3rd arg) works only for numeric data types, it is ignored otherwise. Checkwrite can also compare tables for date/time types. Strings are just checked for equality.
Reply
#8
Hello,
It's possible to send value only when this value is > x like :

Code:
require('bacnet')

for i = 1, 14 do
  id = 16000 + i
  value = bacnet.readvalue(id, 'analog value', 1) -- Prise de la temp. Ambiante
  if value > 7 then
    grp.checkwrite('5/2/' .. i, value)
  end
end

Sometimes i have error :
Resident script:6: attempt to compare number with string
stack traceback:


Thanks.
B.R.
Reply
#9
Hi
Log value and see what you get there.
BR
------------------------------
Ctrl+F5
Reply
#10
(12.09.2019, 08:46)niel. Wrote: Hi
Log value and see what you get there.
BR
Hi,
Log(value) and error log attached.

Yet the values are temperature setpoints ...
Can be a communication error that comes to write other than a numerical value?
Can we check and advance in the script i and only if ther are numeric values in 'value' ?
to no longer have the error log?
Thanks B.R.

Attached Files Thumbnail(s)
       
Reply
#11
You can check type by
Code:
type(value)
------------------------------
Ctrl+F5
Reply
#12
Thanks Daniel!
Reply
#13
Hi
How about 3rd parameter as a callback function with two arguments returning boolean? It would be universal and pure Lua way solution.
LM5Lp, firmware: 2018.08.22 and 2021.12.15, FlashSYS v2, ARMv7 Processor rev 5 (v7l), kernel 4.4.151 and 4.4.259
Reply
#14
For which types do you need this?
Reply


Forum Jump: