Results 1 to 7 of 7

Thread: lxpxml?

  1. #1
    Join Date
    Mar 2005
    Posts
    724

    Default lxpxml?

    anychace of getting lxpxml ported over? or is it already there?

    thanks,
    yonu

  2. #2
    Join Date
    Mar 2005
    Posts
    724

    Default

    ok I feel real stupid it turns out I hadn't updated my Virtual machin in a while

    Thanks, and feel free to delete the topic,
    yonu

  3. #3
    Join Date
    Mar 2005
    Posts
    724

    Default

    ok I am stuck I feel even stupider I am still getting an error here is the error I get in the lua console
    Code:
    Thu Jul 10 19:13:14 2014	ScriptDevice::scriptInit::examples.dmplugin.plugin / ...s/Promixis/Girder 6/lua/examples\dmplugin\device.lua:15: module 'lxp' not found:
    Thu Jul 10 19:13:14 2014		no field package.preload['lxp']
    Thu Jul 10 19:13:14 2014		no file './lxp.lua'
    Thu Jul 10 19:13:14 2014		no file 'C:/Program Files/Promixis/Girder 6/lua/lxp.lua'
    Thu Jul 10 19:13:14 2014		no file 'C:/Program Files/Promixis/Girder 6/lua/lxp/init.lua'
    Thu Jul 10 19:13:14 2014		no file '.\lxp.dll'
    Thu Jul 10 19:13:14 2014		no file 'C:\Program Files\Promixis\Girder 6\lxp.dll'
    Thu Jul 10 19:13:14 2014		no file 'C:\Program Files\Promixis\Girder 6\loadall.dll'

  4. #4
    Join Date
    Jan 1998
    Location
    Jupiter, FL
    Posts
    13,551

    Default

    Fear not, your are totally sane. It looks like I am building lxp with each release but the installer is not including it. I've attached the files. Pick the 32 or 64 bit version and place into the Girder installation directory.

    Sorry about the confusion. The installer has been fixed and next release will include this automatically.
    Attached Files Attached Files
    Ron
    No support through PM

  5. #5
    Join Date
    Mar 2005
    Posts
    724

    Default

    thanks back to the fun lol

  6. #6
    Join Date
    Mar 2005
    Posts
    724

    Default

    ok I am just reusing this thread since it involves lxp

    I am in the process of updating my code from g5 but I have a odd error going on it creates the gateway table and the devices but it basically is a endless loop with no data in the variable inspector however if I place a table.print gateway.devices at the end the data is there I am kind of confused if it is something I am doing wrong or if it is a bug.

    here is my code
    Code:
    tcpip = '192.168.1.121'
    require ('socket.http')
    print("update")
    lxp = require('lxp')
    --start parsing gateway
    
    function tcpparse()
    --print ('parse') --test parse start
    tcpstats = socket.http.request('http://'.. tcpip.. '/gwr/gop.php?cmd=GWRBatch&data=%3Cgwrcmds%3E%3Cgwrcmd%3E%3Cgcmd%3ERoomGetCarousel%3C/gcmd%3E%3Cgdata%3E%3Cgip%3E%3Cversion%3E1%3C/version%3E%3Ctoken%3E1234567890%3C/token%3E%3Cfields%3Ename,image,imageurl,control,power,product,class,realtype,status%3C/fields%3E%3C/gip%3E%3C/gdata%3E%3C/gwrcmd%3E%3C/gwrcmds%3E&fmt=xml')
    
        print ("tcpstats")
        local MAX_SSDP_RETRIES = 5
    
        -- create an empty gateway object
        gateway = {}
        gateway.initialized    = true
        gateway.autodiscovered = true
        gateway.error_text     = "TCP Lighting Gateway not yet initialized"  -- error text for last failed operation
        gateway.gateway_ip     = '192.168.1.121'
        gateway.devices        = {}    -- a cache of device info indexed by unique did
        gateway.HTTP_TIMEOUT   = 5     -- 5 seconds should be fine on a local network
        
        -- Local collection devices - will be added to master table after parsing
        new_devices = {}
    
        -- enumerate the XML elements that we want to load into our tables
        room_elements_of_interest = '|rid|name|desc|'
        device_elements_of_interest = '|did|name|desc|state|level|offline|type|rangemin|rangemax|power|poweravg|energy|manufacturer|prodbrand|prodmodel|prodtype|capability|'
    
        -- used to keep track of the current context during the parsing process
        current_room_object = nil
        current_device_object = nil
        current_element_name = nil
    
        -- XML parsing handler for the start of an element
        local function start_element_handler (parser, name)
            current_element_name = name
            --print(name)
            if name == "room" then
                print ("room test".. name)
                current_room_object = {}
            elseif name == "device" then
                current_device_object = {}
                current_device_object["gateway_ip"] = gateway.gateway_ip
                current_device_object["room"] = current_room_object
            end
        end
    
        -- XML parsing handler for the end of an element
        local function end_element_handler (parser, name)
            current_element_name = name
            if name == "room" then     
                current_room_object = nil
            elseif name == "device" then
                 new_devices[#new_devices+1] = current_device_object
                current_device_object = nil           
            end
        end
    
        -- XML parsing handler for the text of an element
        local function character_handler (parser, value)
            if current_device_object and string.find(device_elements_of_interest,"|"..current_element_name.."|") then
                current_device_object[current_element_name] = value
            elseif current_room_object and (not current_device_object) and string.find(room_elements_of_interest,"|"..current_element_name.."|") then
                current_room_object[current_element_name] = value
            end
        end
    
        -- Create a parser
        local callbacks = {StartElement = start_element_handler, EndElement = end_element_handler, CharacterData = character_handler}
        local parser, err = lxp.new(callbacks)
        if not parser then error("Error creating parser: "..tostring(err)) end
        
        -- Parse the XML
        parser:parse(tcpstats)
        parser:parse() -- finishes the document
        parser:close()
    --    table.print(gateway)
    
    -- Save the devices, uniquely indexed by did
        if table.getn(new_devices) > 0 then
            for i,device in ipairs(new_devices) do
                gateway.devices[device.did] = device
                -- tweak for interpretation of load level for dimmers - always set to zero if device is off
                if device.state == "0" then
                   device.level = "0"
                end
            end
            gateway.initialized = true
            gateway.error_text = nil
        else
            gateway.error_text = "No devices found at gateway " .. gateway.gateway_ip .. " while parsing " .. config_xml
        end
    
    table.print(gateway.devices) --to test if gateway is being parsed to table
    --print("test")
    end
    --end parsing gateway
    
    tcpparse()

  7. #7
    Join Date
    Mar 2005
    Posts
    724

    Default

    I forgot to mention if I do table.print(gateway.devices) in the lua console the data is there

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •