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