![]() |
Json virtual object - 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: Json virtual object (/showthread.php?tid=1517) |
Json virtual object - Evens - 08.08.2018 Hi, Do any have an example of how to mass greate virtual objects in json? BR Even Sundgot. RE: Json virtual object - admin - 08.08.2018 Why not use a script with grp.create in a loop? What kind of objects do you want to create? RE: Json virtual object - Evens - 08.08.2018 That`s probably just as good. Im doing some testing and want to create 200 objects like this: BACnet_001 to BACnet_200 And I want them to start at 32\1\1 Datatype 1 Byte scale RE: Json virtual object - admin - 08.08.2018 Code: for i = 1, 200 do RE: Json virtual object - Evens - 08.08.2018 (08.08.2018, 07:49)admin Wrote: Perfect! ![]() Thanks! RE: Json virtual object - Evens - 08.08.2018 Is there any way to add the same script to several objects, but with one thing changing everytime? I have this script that i want to add to 200 objects, but the ID needs to be changed everytime. from 65793 to 65992 require('bacnet') value = event.getvalue() bacnet.write(127001, 'analog value', 65809, value) RE: Json virtual object - admin - 08.08.2018 You can attach event script to a tag. Use event.dstraw to calculate BACnet object id from the group address that triggered the script. RE: Json virtual object - Evens - 08.08.2018 Can you give me an example of this? RE: Json virtual object - admin - 08.08.2018 First, add a certain tag to all objects via mass edit. Then create an event script which is mapped to the tag you've added. If your range is 32/1/1..32/1/200 then you don't need any extra conversion since it is 65793..65992 in numeric form. Code: require('bacnet') RE: Json virtual object - Evens - 08.08.2018 (08.08.2018, 11:00)admin Wrote: First, add a certain tag to all objects via mass edit. Then create an event script which is mapped to the tag you've added. If your range is 32/1/1..32/1/200 then you don't need any extra conversion since it is 65793..65992 in numeric form. I dont understand how, but it works! ![]() Thanks! RE: Json virtual object - Evens - 09.08.2018 Is there any way to adjust this script to match the range 32/2/1 - 32/2/250 and 32/3/1 - 32/3/250 (all have the same Tag) I have 500 objects that i want to link to ID 0- 500. RE: Json virtual object - Daniel - 09.08.2018 (09.08.2018, 13:29)Evens Wrote: Is there any way to adjust this script to match the range 32/2/1 - 32/2/250 and 32/3/1 - 32/3/250 (all have the same Tag) Nothing has to be modified it will work. your bacnet range will be 66049 - 66290 and 66305 - 66554 RE: Json virtual object - admin - 10.08.2018 event.dstraw is an integer value of group address. You can easily convert to a 0..499 range like this: Code: id = event.dstraw RE: Json virtual object - Evens - 10.08.2018 Thanks! I can’t get it to work properly. maybe I’m doing something wrong. How do you convert from Group Address to the number? RE: Json virtual object - admin - 10.08.2018 H/M/L H * 2048 + M * 256 + L RE: Json virtual object - Evens - 10.08.2018 Thanks! This event.dstraw, do you have an easy explanation for it, I’d like to understand what it does. RE: Json virtual object - admin - 10.08.2018 event.dst is group address that triggered the script in H/M/L format, event.dstraw is the same address but in numeric form. RE: Json virtual object - Evens - 13.08.2018 Thanks, Now i understand ![]() |