1

Custom PlugIn PJLink Control

Wrote a script for PJLink compatible hardware, so you can turn on/off a projector or similiar.

Use it with "Send Plugin Message" - device-ip adress#ON/OFF

e.g 192.168.0.1#ON

I only needed on and off, so a if - else if did the job, I guess for more commands an assoziative array would be more handy.

If you want to control more than one device, seperate the send states with timeout events (1 sec) otherwise it isn't reliable.

For some hardware (e.g. Panasonic projectors) you'll have to deactivate the net control password.

function PJLinkControl_Initialize(msgPort as Object, userVariables as Object, o as Object)

    PJLinkControlBuilder = newPJLinkControlBuilder(msgPort, userVariables)

    return PJLinkControlBuilder
 
end function
 
function newPJLinkControlBuilder(msgPort as Object, userVariables as Object)

    PJLinkControlBuilder                = { }
    PJLinkControlBuilder.msgPort        = msgPort
    PJLinkControlBuilder.userVariables    = userVariables
    PJLinkControlBuilder.objectName     = "PJLinkControl_object"
    PJLinkControlBuilder.ProcessEvent     = PJLinkControl_ProcessEvent
    
    return PJLinkControlBuilder
     
end function
 
function PJLinkControl_ProcessEvent(event as Object)
 
    'handle Message and send PJLinkCommand
    
    projector_port            = 4352
    projector_ip$            = ""
    
    'add needed commands here
    projectorOn_message$     = "2531504f575220310d"
    projectorOff_message$    = "2531504f575220300d"
    
    print event
    
    if type(event) = "roAssociativeArray" then
        if type(event["EventType"]) = "roString"
            if event["EventType"] = "SEND_PLUGIN_MESSAGE" then
                if event["PluginName"] = "PJLinkControl" then
                    pluginMessage$ = event["PluginMessage"]
                    
                    sock=CreateObject("roTCPStream")
                    if sock=invalid then
                        print"Failed to create roTCPClient object"
                    else
                        comLength    = len(pluginMessage$)
                        hashPos        = Instr(1, pluginMessage$, "#")
                        projector_ip$         = Left( pluginMessage$, (hashPos - 1))
                        com$        = Ucase( Right( pluginMessage$, (comLength - hashPos)))
                        
                        print "*************************************************"
                        print "pluginMessage:";pluginMessage$
                        print "IP:";projector_ip$
                        print "Command:";com$
                        print "*************************************************"
                        
                        if sock.ConnectTo(projector_ip$, projector_port) then
                            bytes = CreateObject("roByteArray")
                            sleep(500)
                            
                            'handle more commands here
                            if com$ = "ON" then
                                print("Projector ON")
                                bytes.FromHexString(projectorOn_message$)
                            else if com$ = "OFF" then
                                print("Projector OFF")
                                bytes.FromHexString(projectorOff_message$)
                            endif
                            sock.SendBlock(bytes)
                        else
                            print"Failed to connect to projector"
                            sock=invalid
                        endif
                    endif
                endif
            endif
        endif
    endif
    
    return false
end function

 
 
 
 

7 comments

  • 0
    Avatar
    Pwille

    Lukas, Thanks for providing this.  It is the only one in this section that works with my system.  Your comments at helpful.

    I am having one problem.  If I don' have a TCP connection open with the correct port, it locks up the brighsign player and eventually will cause the BS to reboot.  Your code looks like it is set up to make sure there is a connection and quit if there isn't, but that does not seem to be working.

    I am trying to control 5 different monitors in a museum installation and I'm concerned that if one of them has an issue, it will shit down everything.

    Any idea how to make this work?

  • 0
    Avatar
    Lukas Uebachs

    Are you sure, that you disabled the network access password? Did you enabled telnet on your device and looked on the bs output with your pc?

  • 0
    Avatar
    Pwille

    I am sending the password and log in.  It works perfectly.  However, when I test it with nothing connected, it locks up the brightsign.  I'm worried that if something goes wrong with the TCP connnection, it doesn't lock up the entire system.   I wanted an if the connection is no good, just skip everything.

    Does this make sense?

  • 0
    Avatar
    Lukas Uebachs

    Please check the output of your Brightsign with a telnet connection, otherwise it is just guessing.

  • 0
    Avatar
    Pwille

    Here is the telnet log and the slightly modified script.  I am sending in the user name, password, command and log off.  Everything works well until I terminate the TCP connection- simulating a problem with the TV or network.  When I do this, it locks up the brightsign player. The point where this happens is commented in the log.

    What I was hoping for was an error routine that would stop the script and allow the BS to continue with the terminated connection.

     

    Thanks.https://drive.google.com/open?id=16EI7i8EHMK3-wgMLzP91mhJYVW5cQHDp 

  • 0
    Avatar
    Alex Tennyson

    Script works great for me, until I tried to add a couple of extra commands (to switch source on the projector).

    I've added code in the appropriate places, the original commands still function.

     

    function PJLinkControl_Initialize(msgPort as Object, userVariables as Object, o as Object)

        PJLinkControlBuilder = newPJLinkControlBuilder(msgPort, userVariables)

        return PJLinkControlBuilder
     
    end function
     
    function newPJLinkControlBuilder(msgPort as Object, userVariables as Object)

        PJLinkControlBuilder                = { }
        PJLinkControlBuilder.msgPort        = msgPort
        PJLinkControlBuilder.userVariables    = userVariables
        PJLinkControlBuilder.objectName     = "PJLinkControl_object"
        PJLinkControlBuilder.ProcessEvent     = PJLinkControl_ProcessEvent
        
        return PJLinkControlBuilder
         
    end function
     
    function PJLinkControl_ProcessEvent(event as Object)
     
        'handle Message and send PJLinkCommand
        
        projector_port            = 4352
        projector_ip$            = ""
        
        'add needed commands here
        projectorOn_message$     = "2531504f575220310d"
        projectorOff_message$    = "2531504f575220300d"
        digitalInput_33$         = "2531494E5054203333"
        digitalInput_32$          = "2531494E5054203332"

        print event
        
        if type(event) = "roAssociativeArray" then
            if type(event["EventType"]) = "roString"
                if event["EventType"] = "SEND_PLUGIN_MESSAGE" then
                    if event["PluginName"] = "PJLinkControl" then
                        pluginMessage$ = event["PluginMessage"]
                        
                        sock=CreateObject("roTCPStream")
                        if sock=invalid then
                            print"Failed to create roTCPClient object"
                        else
                            comLength    = len(pluginMessage$)
                            hashPos        = Instr(1, pluginMessage$, "#")
                            projector_ip$         = Left( pluginMessage$, (hashPos - 1))
                            com$        = Ucase( Right( pluginMessage$, (comLength - hashPos)))
                            
                            print "*************************************************"
                            print "pluginMessage:";pluginMessage$
                            print "IP:";projector_ip$
                            print "Command:";com$
                            print "*************************************************"
                            
                            if sock.ConnectTo(projector_ip$, projector_port) then
                                bytes = CreateObject("roByteArray")
                                sleep(500)
                                
                                'handle more commands here
                                if com$ = "ON" then
                                    print("Projector ON")
                                    bytes.FromHexString(projectorOn_message$)
                                else if com$ = "OFF" then
                                    print("Projector OFF")
                                    bytes.FromHexString(projectorOff_message$)
                                else if com$ = "INPUT" then
                                    print("Input Selected")
                                    bytes.FromHexString(digitalInput_33$)
                                else if com$ = "INPUT2" then
                                    print("Input Selected")
                                    bytes.FromHexString(digitalInput_32$)

                                endif
                                sock.SendBlock(bytes)
                            else
                                print"Failed to connect to projector"
                                sock=invalid
                            endif
                        endif
                    endif
                endif
            endif
        endif
        
        return false
    end function

  • 0
    Avatar
    Lukas Uebachs

    Looks good for me, can only imagine two sources for errors:

    - the hex code for the switching is wrong

    - the sended plugin message is wrong or has whitespaces at start or end of the string

     

Please sign in to leave a comment.