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.

Group Address export for ETS
#1
Hi,

I would like to export all group address from the logicmachine and import them into ETS.  Can this be done?

Reason being you can add lots of modbus data points and automatically link group addresses to them quickly in the logicmachine.
Reply
#2
This old script by Erwin might work: https://forum.logicmachine.net/showthrea...13#pid6713
Reply
#3
(17.10.2023, 13:38)admin Wrote: This old script by Erwin might work: https://forum.logicmachine.net/showthrea...13#pid6713

Thanks,

I actually used the script by Daniel,  Used ftp to download the file which worked well.  Only issue it doesn't have data type assigned,  Could this be added?
Reply
#4
This script generates CSV with datatypes that can be imported into ETS 6.1.0. csv variable contains the CSV file data as a string.
Code:
function csvescape(val)
  val = tostring(val)
  val = val:gsub('"', '""'):gsub('^[-=+@\t\r]', "'%0")
  return '"' .. val .. '"'
end

function getdpst(dpt)
  dpt = tonumber(dpt)

  if not dpt then
    return ''
  elseif dpt < 1000 then
    return 'DPT-' .. dpt
  else
    local mdpt = dpt % 1000
    dpt = math.floor(dpt / 1000)

    return 'DPST-' .. dpt .. '-' .. mdpt
  end
end

objs = grp.all()

buf = { '"Group name";"Address";"Central";"Unfiltered";"Description";"DatapointType"' }

for _, obj in ipairs(objs) do
  if obj.id < 0x10000 then
    row = {
      csvescape(obj.name or ''),
      csvescape(obj.address),
      '""',
      '""',
      csvescape(obj.comment or ''),
      csvescape(getdpst(obj.datatype)),
    }

    buf[ #buf + 1 ] = table.concat(row, ';')
  end
end

csv = table.concat(buf, '\n')
Reply


Forum Jump: