I wrote a panel today to send telnet commands to our VideoHub router to make simple routing changes. I needed something simple for volunteers where they could click a clear, distinct, labeled button and have it do the macro. Here it is in case anyone can use it. It's still a work in progress but it is functioning fine at this point. I couldn't get telnet to work without calling it via AppleScript, but it works fine doing that. If anyone has experience with the telnet side and wants to jump in, let me know!
Thanks,
Joseph
Panel code:
<abs contexttype="opengear" id="topLevel" name="VideoHubControl">
<meta>
<api>function runAppleScript(applescriptCommand)
{
var runtime = java.lang.Runtime.getRuntime();
var args = ["osascript", "-e", applescriptCommand];
var process = runtime.exec(args);
}
function tellVideoHub(destination, source)
{
// everything is zero based including the array so we just go ahead and drop it down
params.setValue(0x3, (destination-1), (source-1));
}
function executeCommands()
{
var telnetScript = "VIDEO OUTPUT ROUTING:\n";
for (var i = 0; i < 72; i = i + 1)
{
if (params.getValue(0x3,i) != -1)
{
telnetScript = telnetScript + i + ' ' + params.getValue(0x3,i) + "\n";
}
}
ogscript.debug(telnetScript);
var telnetCommand = "telnet " + ogscript.getPrivateString('hosts', 'VideoHub.address') + " " + ogscript.getPrivateString('hosts', 'VideoHub.port')
var appleScriptCommand = "set telnet to \"" + telnetCommand + "\n" + telnetScript + "\n" + "exit" + "\"\n" +
"tell application \"Terminal\"\n" +
"run\n" +
"do script telnet\n" +
"delay 1\n" +
"quit \n" +
"end tell";
runAppleScript(appleScriptCommand);
clearCommands();
}
function clearCommands()
{
for (var i = 0; i < 72; i = i + 1)
{
params.setValue(0x3,i,-1);
}
}</api>
<params>
<param access="1" maxlength="0" name="VideoHub_Address" oid="0x1" type="STRING" value="192.168.11.128" widget="default"/>
<param access="1" maxlength="0" name="VideoHub_Port" oid="0x2" type="STRING" value="9990" widget="default"/>
<param access="1" constrainttype="INT_NULL" name="VideoHub_Destinations" oid="0x3" precision="2" type="INT32_ARRAY" value="-1;-1;-1;-1;-1;-1;-1;-1;-1;-1;-1;-1;-1;-1;-1;-1;-1;-1;-1;-1;-1;-1;-1;-1;-1;-1;-1;-1;-1;-1;-1;-1;-1;-1;-1;-1;-1;-1;-1;-1;-1;-1;-1;-1;-1;-1;-1;-1;-1;-1;-1;-1;-1;-1;-1;-1;-1;-1;-1;-1;-1;-1;-1;-1;-1;-1;-1;-1;-1;-1;-1;-1" widget="default"/>
</params>
<lookup id="hosts">
<entry key="VideoHub.address">192.168.11.128</entry>
<entry key="VideoHub.port">9990</entry>
</lookup>
<ogscript handles="onload" id="tbSetup" name="onload" targetid="topLevel">params.setValue(0x1, 0, ogscript.getPrivateString('hosts', 'VideoHub.address'));
params.setValue(0x2, 0, ogscript.getPrivateString('hosts', 'VideoHub.port'));
ogscript.debug('tbSetup onload complete.');</ogscript>
<ogscript handles="onload" id="tbProduction" name="onload" targetid="topLevel">ogscript.debug('tbProduction onload complete.');</ogscript>
</meta>
<abs height="227" left="50" style="bg-align:center;bg-fill:fit;bg-u:FG%20Logo.png;" top="0" width="600"/>
<label height="40" left="50" name="VideoHub Macros" style="txt-align:west;size:Big;" top="185" width="200"/>
<tab height="510" id="theControl" left="50" top="225" width="491">
<abs id="tbProduction" name="Production">
<meta/>
<table>
<tr>
<table style="bg#dark;bdr:etched;">
<tr>
<label anchor="center" height="32" id="lblMacros" left="3" name="<html><center>Simulcast</center></html>" top="2" width="90"/>
<button buttontype="push" height="80" id="btnMacro_01" left="0" name="<html><center>Rear Projectors to Cameras for Simulcast</center></html>" style="size:Normal;bg#66001D;txt-align:center;" top="30" width="150">
<task tasktype="ogscript">tellVideoHub(46,22);
tellVideoHub(64,21);
executeCommands();</task>
</button>
<button buttontype="push" height="80" id="btnMacro_02" left="165" name="<html><center>Rear Projectors to Normal</center></html>" style="size:Normal;bg#00660D;" top="30" width="120">
<task tasktype="ogscript">tellVideoHub(46,29);
tellVideoHub(64,67);
executeCommands();</task>
</button>
</tr>
</table>
</tr>
<tr>
<table style="bg#dark;bdr:etched;">
<tr>
<label height="32" id="lblMacros" left="3" name="<html><center>Auditorium 1 Projectors</center></html>" top="2" width="90"/>
<button buttontype="push" height="80" id="btnMacro_03" left="0" name="<html><center>All Projectors to Aud 1 CG</center></html>" style="size:Normal;bg#66001D;txt-align:center;" top="200" width="150">
<task tasktype="ogscript">tellVideoHub(44,27);
tellVideoHub(45,27);
tellVideoHub(46,27);
executeCommands();</task>
</button>
<button buttontype="push" height="80" id="btnMacro_04" left="165" name="<html><center>Return Projectors to Normal</center></html>" style="size:Normal;bg#00660D;" top="200" width="120">
<task tasktype="ogscript">tellVideoHub(44,10);
tellVideoHub(45,10);
tellVideoHub(46,29);
executeCommands();</task>
</button>
</tr>
</table>
</tr>
<tr>
<table style="bg#dark;bdr:etched;">
<tr>
<label height="32" id="lblMacros" left="3" name="<html><center>Auditorium 1 Audio</center></html>" top="2" width="90"/>
<button buttontype="push" height="80" id="btnMacro_05" left="0" name="<html><center>DEMB1 to Aud 1 CG</center></html>" style="size:Normal;bg#000066;txt-align:center;" top="200" width="150">
<task tasktype="ogscript">tellVideoHub(41,27);
executeCommands();</task>
</button>
<button buttontype="push" height="80" id="btnMacro_06" left="165" name="<html><center>DEMB1 to Control Room 1 CG</center></html>" style="size:Normal;bg#000066;" top="200" width="150">
<task tasktype="ogscript">tellVideoHub(41,30);
executeCommands();</task>
</button>
</tr>
</table>
</tr>
<tr>
<table style="bg#dark;bdr:etched;">
<tr>
<label height="32" id="lblMacros" left="3" name="<html><center>Auditorium 2 Projectors</center></html>" top="2" width="90"/>
<button buttontype="push" height="80" id="btnMacro_07" left="0" name="<html><center>All Projectors to Aud 1 CG</center></html>" style="size:Normal;bg#66001D;txt-align:center;" top="200" width="150">
<task tasktype="ogscript">tellVideoHub(62,66);
tellVideoHub(63,66);
tellVideoHub(64,66);
executeCommands();</task>
</button>
<button buttontype="push" height="80" id="btnMacro_08" left="165" name="<html><center>Return Projectors to Normal</center></html>" style="size:Normal;bg#00660D;" top="200" width="120">
<task tasktype="ogscript">tellVideoHub(62,20);
tellVideoHub(63,20);
tellVideoHub(64,67);
executeCommands();</task>
</button>
</tr>
</table>
</tr>
<tr>
<table style="bg#dark;bdr:etched;">
<tr>
<label height="32" id="lblMacros" left="3" name="<html><center>Auditorium 2 Audio</center></html>" top="2" width="90"/>
<button buttontype="push" height="80" id="btnMacro_09" left="0" name="<html><center>DEMB1 to Aud 2 CG</center></html>" style="size:Normal;bg#000066;txt-align:center;" top="200" width="150">
<task tasktype="ogscript">tellVideoHub(55,66);
executeCommands();</task>
</button>
<button buttontype="push" height="80" id="btnMacro_10d" left="165" name="<html><center>DEMB1 to Control Room 2 CG</center></html>" style="size:Normal;bg#000066;" top="200" width="150">
<task tasktype="ogscript">tellVideoHub(55,34);
executeCommands();</task>
</button>
</tr>
</table>
</tr>
</table>
</abs>
<abs id="tbSetup" name="Setup">
<label name="VideoHub Settings"/>
<table>
<tr>
<label height="40" name="IP Address:" width="150"/>
<param oid="0x1" pheight="50" pwidth="250" style="size:Normal;" width="150"/>
</tr>
<tr>
<label height="40" name="Port:" width="150"/>
<param oid="0x2" pheight="50" pwidth="250" style="size:Normal;" width="50"/>
</tr>
<tr>
<button buttontype="push" colspan="1" fill="both" height="50" left="0" name="Set" pheight="38" pwidth="179" rowspan="1" style="size:Normal;" width="215">
<task tasktype="ogscript">ogscript.putPrivateString('hosts', 'VideoHub.address', params.getValue(0x1,0));
ogscript.putPrivateString('hosts', 'VideoHub.port', params.getValue(0x2,0));</task>
</button>
</tr>
</table>
<label height="50" left="0" name="<html><center>The panel is configured for a 72x72 router. If you need something higher, just add more rows to the array. There's probably a more elegant way to do this.</center></html>" top="125" width="350"/>
</abs>
</tab>
</abs>