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.

Export - Import Tags of LM Objects
#1
Hi, Happy New Year to all!

I would like to ask if it is possible to export Tags of LM objects and then after changes to the these objects to be able to import the file again and update the Tags to the new LM Objects.

The issue I am facing is that I link Tag names to scripts and after changes to ETS project and importing of .esf file, Tags disappear and so I have to enter them manually.

I guess Tags (at least manually) could be linked to object names (for the case of GA shifting) or to GA (for the case of name changes).

Thank you in advance.
Reply
#2
The thing you ask for is not easly possible. Try this script, it automatically tag objects based on its name. It use defined separators to define tag from name.
Code:
seperators = '.,_ =+'

-- Start address of objects (min: 0/0/1 = main/sub/address)
start_main = 0
start_sub = 0
start_address = 1

-- End address of objects (max: 31/7/255 = main/sub/address)
end_main = 15
end_sub = 7
end_address = 255

------------------------------------------ End Parameters ------------------------------------------
------------------------------ DON'T CHANGE ANYTHING UNDER THIS LINE -------------------------------

function split(source, delimiters)
        local elements = {}
        local pattern = '([^'..delimiters..']+)'
        string.gsub(source, pattern, function(value) elements[#elements + 1] =     value;  end);
        return elements
end

-- Calculate start address to DB format
start_objectaddress = ((start_main * 2048) + (start_sub * 256) + start_address)

-- Calculate end address to DB format
end_objectaddress = ((end_main * 2048) + (end_sub * 256) + end_address)

-- Get all objects from DB
all_objects = db:getall('SELECT address, name, tagcache FROM objects')
for _, object in ipairs(all_objects) do
  -- Check if object is inside given range
  if object.address >= start_objectaddress and object.address <= end_objectaddress then
     currentrowaddress = object.address
    myobject = grp.find(currentrowaddress)
    nameTable = split(myobject.name, seperators)  --spliting  object string in to table
   
  --  log(nameTable)
    for _, tag in ipairs(nameTable) do
      tagvalue = tag
   
       -- Check if object tag already exists inside DB
     current_object_tag = db:getall('SELECT object, tag FROM objecttags WHERE object = ' .. currentrowaddress .. ' AND tag = "' .. tagvalue .. '"')
     object_tagcache = db:getone('SELECT tagcache FROM objects WHERE address = ' .. currentrowaddress .. '')
     if #current_object_tag == 0 then
        -- Add object to table objecttags
        db:insert('objecttags', {object = currentrowaddress, tag = tagvalue, })
          -- Check if object already has other tag values inside DB and add new values to tagcache
        if object_tagcache == nil or object_tagcache == "" then
          db:update('objects', { tagcache = tagvalue }, { address = currentrowaddress })
            else
          tag_string = "" .. object_tagcache .. ", " .. tagvalue .. ""
               log(tag_string)
          db:update('objects', { tagcache = tag_string }, { address = currentrowaddress })
          end
     end
   
    end
  end
end

script.disable(_SCRIPTNAME)
------------------------------
Ctrl+F5
Reply
#3
Hi,

Thanks for the reply and script.

Basically, I was hoping that there is a way to export and import LM objects (including their Tags).

I believe that it should be part of configuration environment as it is common to have an option to export and import objects. This way is really easy to make changes, keep archive and much more.

Hope to be included some time because right now I find it really difficult to make changes and to reuse parts of one project to another.
Same applies to other sections of the environment like script where for example I want to import only two scripts which I don' t have a way to export them separately and to append them later.

Thanks one more!
Reply
#4
[quote pid='15202' dateline='1578081499']
Hi,

For those who are interested I found a solution with help of excel.

I attach sample file which shows the logic which is:
  1. Insert LM Object Data in left table
  2. Refresh right table (right click-->refresh)
  3. Copy paste-code into LM script.
However, I have created an excel file which uses ETS data so you can use it instead of .esf import.
The whole process for that file is as follows:
  1. Export GA from ETS
  2. In Excel enter path and file name of exported ".csv" in a table
  3. Automatically get a table like the left of attached file with KNX DPT mapped to LM Objects DPT
  4. Complete manually desired fields like units or Tags
    (Note: With little knowledje of Power Query Tags can be extracted really easily from GA name or Main and Middle parts of GA can be appended to name and so on.)
  5. Refresh table which produces script code
  6. Copy-Paste into LM script (copy all rows of table and do a single paste into script editor)
  7. Run script
Also, that same file can be used for some management of GA, like renaming or creating new empty GA really easily because it gathers modified GA and new GA entries and creates the desired format for ETS automatically.

The advantage of this process in my opinion is that first you keep archive through excel file. Then you bind LM Objects to ETS Objects (ETS can be used as a tool even with modbus e.t.c.) and its really easy to make changes to objects. Just change objects fields, refresh, paste and run.
In addition there is no need to use dummy Group Objects linked to GA (that are created only for the sake of organizing the objects) in order for those to be part of ETS's ".esf" exported file...

For anyone interested I can send him that file. Just PM me and give your e-mail.

[/quote]

Attached Files
.xlsx   Create LM Objects.xlsx (Size: 17.76 KB / Downloads: 36)
Reply


Forum Jump: