Results 1 to 10 of 25

Thread: DMX lighting controlled via Girder using lanbox

Threaded View

  1. #1
    Join Date
    Jan 2004
    Location
    The Netherlands
    Posts
    2,140

    Default DMX lighting controlled via Girder using lanbox

    I got one of these DMX 512 controllers :

    http://www.lanbox.com/products/LCEDataSheet.html

    connected to some of these RGB led panels (see picture) :

    http://www.hqpower.com/product/view/?lang=en&id=368110

    The nice thing about the lanbox is, that it can work 'stand alone'.

    I.e. you define some cuelists, that can contain animations, (cross)fades, chases etc.
    and then you can simply start a cue from girder.
    so you don't need to animate each channel from girder over time (although you can)

    for example, I made a simple cuelist that slowly brightens the panels from 'off' to 'full on white' in 15 minutes, to replicate this :

    http://www.wakeuplight.philips.com



    this is the lanbox.lua file to start a cue list or manipulate channels directly :

    Code:
     
    --------------------------------------------------------------------------------
    -- LanBox                                                     --
    --------------------------------------------------------------------------------
    print('Loading marcel\\LanBox.lua')
    Marcel = Marcel or {}
    Marcel.LanBox = {}
    function Marcel.LanBox.SendCommand (address,port,commandstring)
      local switch16bitcommand = "*65ff#";
      local step = 0;
      for j = 1,3 do -- retry
        local socket = gip.Open(address, port)
        if  not socket then
          gir.LogMessage ("Marcel.LanBox","Error Connecting",1)
        else
          for i = 1,2000 do -- wait until command done (for 2 seconds max.)
            data = socket:Read (128);
            if (data) and (data ~= "") then
              print ("&"..data);
              if string.find (data,"?",1,1) ~= nil then
                gir.LogMessage ("Marcel.LanBox","Error Received",1)
                socket:Close();
                return;
              elseif string.find (data,">",1,1) ~= nil then
                if (step ==0) then
                  print (commandstring);
                  socket:Write(commandstring);
                  step=1;
                elseif (step==1) then
                  socket:Close();
                  return;
                end
              elseif string.find (data,":",1,1) ~= nil then -- 'enter password :'
                socket:Write('777\r');
              elseif string.find (data,"d",1,1) ~= nil then -- 'connected'
                print (switch16bitcommand);
                socket:Write(switch16bitcommand);
              else
                win.Sleep (1)
              end
            else
              win.Sleep (1)
            end
          end
          socket:Close();
          gir.LogMessage ("Marcel.LanBox","Timeout While Sending Command",1)
        end
      end
    end
    function Marcel.LanBox.StartCue (address,port,cuenumber)
      local commandstring = "*5601"..string.format("%04X",cuenumber).."01#";
      gir.LogMessage ("Marcel.LanBox","Sending Command "..commandstring,0)
      Marcel.LanBox.SendCommand (address,port,commandstring)
    end
    function Marcel.LanBox.SetBedRoomColor (address,port,R,G,B)
      local commandstring = "*C901";
      for i = 0,3 do
        commandstring = commandstring..string.format("%04X",i*13+1).."FF";
        for j = 0,3 do
          commandstring = commandstring .. string.format("%04X",i*13+j*3+2) .. string.format("%02X",R);
          commandstring = commandstring .. string.format("%04X",i*13+j*3+3) .. string.format("%02X",G);
          commandstring = commandstring .. string.format("%04X",i*13+j*3+4) .. string.format("%02X",B);
        end
      end
      commandstring = commandstring.."#";
      gir.LogMessage ("Marcel.LanBox","Sending Command "..commandstring,0)
      Marcel.LanBox.SendCommand (address,port,commandstring)
    end
    function Marcel.LanBox.SetLivingRoomColor (address,port,R,G,B)
      local commandstring = "*C901";
      for i = 0,1 do
        commandstring = commandstring .. string.format("%04X",i*3+100) .. string.format("%02X",R);
        commandstring = commandstring .. string.format("%04X",i*3+101) .. string.format("%02X",G);
        commandstring = commandstring .. string.format("%04X",i*3+102) .. string.format("%02X",B);
      end
      commandstring = commandstring.."#";
      gir.LogMessage ("Marcel.LanBox","Sending Command "..commandstring,0)
      Marcel.LanBox.SendCommand (address,port,commandstring)
    end
    
    print('Loaded marcel\\LanBox.lua')
    Ron/Rob :

    note, that I had coded this using socket:Callback(4.... before.
    The manual said that this results in a callback each character ?
    It seems to be called every ip packet. (so data is > 1 character)

    Also, this method doesn't work properly when called from inside HandleDMEvent :
    DeviceManager:Subscribe(function (...) Marcel.X10.HandleDMEvent(unpack(arg)) end)

    old code :

    Code:
     
    function Marcel.LanBox.SendCommand (address,port,commandstring)
      local commandbusy=true;
      local socket = nil;
     
     function  Marcel.LanBox.DataCB ( data, code)
       if (code==gip.CONNECTIONCLOSED) then
      --print ("LANBOX : Disconnected")
      commandbusy = false;
       elseif (code==gip.CONNECTIONESTABLISHED) then
      local err = tonumber (data)
      if err >0 then
        gir.LogMessage ("Marcel.LanBox","Error Connecting",1)
        commandbusy = false;
      end
       elseif (code==gip.RXCHAR) then
      print ("*"..data);
      if string.find (data,">",1,1) ~= nil then
        commandbusy = false;
      elseif string.find (data,"password :",1,1) ~= nil then
        socket:Write('777\r');    
      elseif string.find (data,"connected",1,1) ~= nil then
      print (commandstring);
        socket:Write(commandstring); 
      end
       end
     end
     
      socket = gip.Open(address, port)
      if  not socket then
        gir.LogMessage ("Marcel.LanBox","Error Connecting",1)
      else    
        socket:Callback(4, function (...) return Marcel.LanBox.DataCB (unpack (arg)) end )
        for i = 1,2000 do -- wait until command done (for 2 seconds max.)
       if (commandbusy == false) then
      socket:Close();
      return
       end
          win.Sleep (1)
        end
     socket:Close();
     gir.LogMessage ("Marcel.LanBox","Timeout While Sending Command",1)
      end   
    end

    maybe some threading issue or some strange garbage collection issue ?
    I see the data come in and then immediately a gip.CONNECTIONCLOSED.

    if I called it from the console, it worked fine..

    anyway, socket:read works...

    Marcel
    Attached Thumbnails Attached Thumbnails Click image for larger version. 

Name:	20071208 003 (Small).jpg 
Views:	162 
Size:	30.1 KB 
ID:	4382  
    Last edited by mhwlng; December 28th, 2007 at 01:34 PM.

Posting Permissions

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