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.

Trend export
#4
I tried to integrate this into your example but it only types the data in the logs of the LM.

How do I change this script to get it to work?
I need the LM to export the log with 30 min resolution to my web server once a day.
When fetching the log i also need the values to be accurate. How is this data produced? Like the 13.00 log result, it should be the average of 12.45-13.15. Is that correct?
Code:
require('socket.ftp')
     
    logtime = os.time() - 60 * 60
    objects = {}
     
    query = 'SELECT address, datatype, name FROM objects WHERE disablelog=0'
    for _, object in ipairs(db:getall(query)) do
      objects[ tonumber(object.address) ] = {
        datatype = tonumber(object.datatype),
        name = tostring(object.name or ''),
      }
    end
     
    buffer = {}
     
   require('genohm-scada.trends')

time = os.time()

date = {
  stime = time - 3600,
  etime = time,
}

values = trends.fetch('watt lys', 'hour', date)

for _, data in ipairs(values) do
  value = data[ 2 ]

  date = os.date('%Y.%m.%d %H:%M', time)
  log(date, value)

  time = time + 60
end    

     
    if #buffer > 1 then
      data = table.concat(buffer, '\r\n')
      res, err = socket.ftp.put({
      host = 'x',
      user = 'x',
        password = 'x',
        command = 'appe',
      argument = 'x',
        source = ltn12.source.string(data)
      })
    end
     
    if err then
      alert('FTP upload error: %s', tostring(err))
    end
Reply


Messages In This Thread
Trend export - by PassivPluss - 22.09.2015, 21:11
RE: Trend export - by admin - 23.09.2015, 06:44
RE: Trend export - by PassivPluss - 23.09.2015, 07:53
RE: Trend export - by PassivPluss - 01.10.2015, 19:33
RE: Trend export - by admin - 02.10.2015, 06:57
RE: Trend export - by PassivPluss - 16.10.2015, 07:35
RE: Trend export - by admin - 16.10.2015, 08:44
RE: Trend export - by PassivPluss - 16.10.2015, 10:20
RE: Trend export - by admin - 16.10.2015, 10:52
RE: Trend export - by PassivPluss - 29.10.2015, 22:51
RE: Trend export - by Erwin van der Zwart - 02.11.2015, 07:28
RE: Trend export - by PassivPluss - 02.11.2015, 19:24

Forum Jump: