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.

Jupiter System For gas tanks monitor
#5
Adjust URL and all parameters as needed. The resulting sites table will have the data that you need.
Code:
url = 'http://192.168.1.1/WacMobileService/WebService1.asmx/GetWacStatuses?UserName=string&Password=string&GroupId=string&SubGroupId=string&bOnlyWithAlerts=string&RequiredAlertsBitmap=string&MaxResults=string'
data, err = require('socket.http').request(url)

log('result', data, err)

if not data then
  return
end

sites = {}

callbacks = {
  StartElement = function(p, tag)
    ctag = tag

    if tag == 'wSiteStatus' then
      site = { status = {} }
      state = 'site'
    elseif tag == 'wBulkStatus' then
      status = {}
      state = 'status'
    end
  end,
  EndElement = function(p, tag)
    ctag = nil

    if tag == 'wSiteStatus' then
      state = nil

      if site.SiteId then
        sites[ site.SiteId ] = site
      end
    elseif tag == 'wBulkStatus' then
      state = 'site'

      if status.BulkId then
        site.status[ status.BulkId ] = status
      end
    end
  end,
  CharacterData = function(p, value)
    value = value:trim()

    if #value == 0 or not ctag then
      return
    end

    if state == 'site' then
      site[ ctag ] = value
    elseif state == 'status' then
      status[ ctag ] = value
    end
  end
}

parser = require('lxp').new(callbacks)
parser:parse(data)
parser:close()

log(sites)
Reply


Messages In This Thread
RE: Jupiter System For gas tanks monitor - by admin - 13.09.2022, 07:39

Forum Jump: