Page 1 of 5 123 ... LastLast
Results 1 to 10 of 41

Thread: controlpath in plugin

  1. #1
    Join Date
    Mar 2005
    Posts
    724

    Default controlpath in plugin

    ok this may be an odd question but I am not sure if there is a way to do this or not
    in my previous plugins I used this to check to see if a control existed before updating and which worked find as the device had a location I could match up to the girder DM
    Code:
    control, err = deviceManager.control( "Home///"..loc.."///"..self.device.name.."///".."led1")
    if control then
    --print ("control ".. devices.name.. " exists")
        if led1 == "0" then  
    		deviceManager.requestControlValueChange( control.id,"0" , "lua")
    		--print("Off")
        end  
        if led2 == "1" then  
    		deviceManager.requestControlValueChange( control.id,"1" , "lua")
    	--	print("On")
        end
    The problem now comes that I don't have a location to match upto is there builtin variable I can use to fill in loc or is where a simpler way inside of the plugin.

    Thanks,
    Yonu

  2. #2
    Join Date
    Jan 1998
    Location
    Jupiter, FL
    Posts
    13,550

    Default

    If I understand it correctly you are looking for all controls that belong to a certain device and you have the device name and device.id.

    Code:
    local controls = deviceManager.controls(device.id);
    table.print(controls)
    should do the trick.
    Ron
    No support through PM

  3. #3
    Join Date
    Mar 2005
    Posts
    724

    Default

    nope what I am trying to do is basically match the control before it updates I have an if for each control to opdate them but am trying to write it in a way that if I change the location in Devicemanager it will still update.

    Thanks,
    Yonu

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

    Default

    use internalId for storing your own identifications. Girder doesn't care what is in there as long as it is a string.

    Code:
    control.internalId = "doodaad_operator_1"
    Ron
    No support through PM

  5. #5
    Join Date
    Mar 2005
    Posts
    724

    Default

    right I get that but dow does that work when it checks the control path against what is in Device Manager

    like I have here for loc
    "Home///"..loc.."///"..self.device.name.."///".."led1"

    Thanks,
    Yonu

  6. #6
    Join Date
    Jan 1998
    Location
    Jupiter, FL
    Posts
    13,550

    Default

    You really should not use the device location in your device driver code.

    Code:
    local location = deviceManager.locations( device.locationId )
    table.print(location)
    Would give you the name of the location that the device is set to.
    Ron
    No support through PM

  7. #7
    Join Date
    Mar 2005
    Posts
    724

    Default

    perfect that is what i needed

    Thanks,
    Yonu

  8. #8
    Join Date
    Mar 2005
    Posts
    724

    Default

    what is the proper way to require socket or socket.http in a plugins component.lua no matter how I reference it I get attempt to index field 'http' (a nil value)

    Thanks,
    Yonu

  9. #9
    Join Date
    Jan 1998
    Location
    Jupiter, FL
    Posts
    13,550

    Default

    Without seeing the code it's hard to say what you are doing wrong. But briefly:

    Place this at the top with all the other requires before the "module" command.

    Code:
    local http = require('socket.http')
    Ron
    No support through PM

  10. #10
    Join Date
    Mar 2005
    Posts
    724

    Default

    Thanks that did it I apparently have when stupid I kept trying to reference it in the requires as socket instead of http

    Thanks,
    Yonu

Page 1 of 5 123 ... LastLast

Posting Permissions

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