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.create()
#7
(12.02.2024, 08:20)tomnord Wrote: What is the best way, when using grp.create, to check if the GA is allready created? I'm thinking of making a dynamic script, so that when I add new GA's and tag them correctly the script will generate new virtual GA's.

I use function block like this when automatically generating addresses in my programs...

Code:
--**********CREATE GROUP ADDRESSES******************
function createga(groupaddress,datatype,name)
  exist = grp.alias(groupaddress)
  if exist == nil then
    address = grp.create({
    datatype = datatype,
    address = groupaddress,
    name = name,
    comment = 'Automatically created object',
    units = '',
    tags = { },
    })
  end
end
On some systems I use user script where I put all needed group addresses (so they all are on the same file and it's quite easy to change them)..

User script (HEATING_config):
Code:
Main_GA = '33'

group_address_for_frontend_update = '/0/0'        --If any modifications on values or chart must be updated, this variable is used.
group_address_for_backend_update = '/0/1'        --If any modifications on values or data file must be updated, this variable is used.

Scheduled/Resident/Event script:
Code:
require('user.HEATING_config')
createga( Main_GA .. group_address_for_backend_update, dt.bool,'HEATING - Update backend')
createga( Main_GA .. group_address_for_frontend_update, dt.bool,'HEATING - Update frontend')

--DO SOMETHING


Hope this helps...
Reply


Messages In This Thread
grp.create() - by tomnord - 02.02.2024, 13:34
RE: grp.create() - by admin - 02.02.2024, 13:38
RE: grp.create() - by tomnord - 12.02.2024, 08:20
RE: grp.create() - by fleeceable - 12.02.2024, 10:33
RE: grp.create() - by admin - 12.02.2024, 08:35
RE: grp.create() - by tomnord - 12.02.2024, 10:22
RE: grp.create() - by admin - 12.02.2024, 10:30
RE: grp.create() - by tomnord - 12.02.2024, 12:55
RE: grp.create() - by victor.back - 12.04.2024, 17:57
RE: grp.create() - by admin - 13.04.2024, 08:44
RE: grp.create() - by victor.back - 13.04.2024, 10:51

Forum Jump: