Logic Machine Forum
grp.checkwrite and supported datatypes - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8)
+--- Thread: grp.checkwrite and supported datatypes (/showthread.php?tid=1085)



grp.checkwrite and supported datatypes - npinguin - 11.11.2017

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


RE: grp.checkwrite and supported datatypes - admin - 13.11.2017

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.


RE: grp.checkwrite and supported datatypes - Thomas - 13.11.2017

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.


RE: grp.checkwrite and supported datatypes - npinguin - 13.11.2017

Thank you for the clarification

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

Thanks
Nicky


RE: grp.checkwrite and supported datatypes - admin - 17.11.2017

Support for status object and non-boolean/numeric datatypes will be added in the next firmware.


RE: grp.checkwrite and supported datatypes - cdebackere - 10.09.2019

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.


RE: grp.checkwrite and supported datatypes - admin - 10.09.2019

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.


RE: grp.checkwrite and supported datatypes - Gadjoken - 12.09.2019

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.


RE: grp.checkwrite and supported datatypes - Daniel - 12.09.2019

Hi
Log value and see what you get there.
BR


RE: grp.checkwrite and supported datatypes - Gadjoken - 12.09.2019

(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.


RE: grp.checkwrite and supported datatypes - Daniel - 12.09.2019

You can check type by
Code:
type(value)



RE: grp.checkwrite and supported datatypes - Gadjoken - 12.09.2019

Thanks Daniel!


RE: grp.checkwrite and supported datatypes - Thomas - 13.09.2019

Hi
How about 3rd parameter as a callback function with two arguments returning boolean? It would be universal and pure Lua way solution.


RE: grp.checkwrite and supported datatypes - admin - 13.09.2019

For which types do you need this?