Hiya
Using this fix (which I needed, as I too had clips cued wrong, and includes the missing + ); I get a bung response here in the debug:
15:37:15:678: end of response
15:37:15:684: making callback with [object Object],[object Object],[object Object],[object Object],[object Object]
15:37:15:691: WE GOT SOMETHING![object Object]
What is the obvious that I've missed?
FYI this is one deck in a grid of 5 of these controller panels. Below is the code from one.
<tab bottom="0" colspan="1" fill="both" height="696" id="SSD1" left="0" rowspan="1" style="bdr#0C7FF2;bdr:thick;" tabposition="north" top="0" weightx="1.0" weighty="1.0" width="298">
<abs name="Clip Player">
<simplegrid bottom="40" cols="1" left="40" right="40" rows="4" top="40" vspace="10">
<label name="CR1 SSD1 - BG" style="font:bold;size:Bigger;txt-align:center;"/>
<button buttontype="push" insets="2,2,2,2" name="Refresh Clip List" style="o#000000;size:Big;bg#selectedmuted;">
<task tasktype="ogscript">//This is our callback
//We will pass it to the listener and the listener will notify it when
//it has received the complete response to the command we sent
var callbackFunction = function(result) {
//Reset our 'busy' state
ogscript.putObject('busy', false);//Stop the command sender
ogscript.getListenerById('commandSender1').stop();
//ogscript.getAllById('commandSender1')[0].stop();
//If we didn't get a result, we can't do much more
if (result == null || result == undefined) {
ogscript.debug('no result');
return;
}
else
{
ogscript.debug('WE GOT SOMETHING!' + result[0]);
}
//If we did, let's update our clip list
params.replaceConstraint(0x1, params.createIntChoiceConstraint(result));
};
//If we are already processing something, we can't process something ELSE
if (ogscript.getObject('busy')) {
ogscript.debug('can\'t do anything. already busy');
} else {
//Put the connection into a known state
ogscript.getListenerById('commandSender1').stop();
//ogscript.getAllById('commandSender1')[0].stop();
//Mark oursevles as 'busy' so nothing else gets sent
ogscript.putObject('busy', true);
//Store this so the listener knows what to send
ogscript.putObject('sendCommand', 'clips get');
//Add a callback for the listener to call when we are done
ogscript.putObject('callback', callbackFunction);
//start the listener so it can send the command and read the result
ogscript.getListenerById('commandSender1').start();
//ogscript.getAllById('commandSender1')[0].start();
}</task>
</button>
<param anchor="west" expand="true" id="" oid="0x1" weightx="1.0"/>
<button buttontype="push" insets="2,2,2,2" name="Load" style="size:Big;bg#0C7FF2;">
<task tasktype="ogscript">var CueClip = params.getValue(0x1, 0);
ogscript.debug(CueClip);
rosstalk.sendMessage(params.getValue(0x21, 0), parseInt(ogscript.getPrivateString('hosts', 'BlackmagicDeck1.port')), ' stop');
rosstalk.sendMessage(params.getValue(0x21, 0), parseInt(ogscript.getPrivateString('hosts', 'BlackmagicDeck1.port')), ' goto: clip id: ' + CueClip);
rosstalk.sendMessage(params.getValue(0x21, 0), parseInt(ogscript.getPrivateString('hosts', 'BlackmagicDeck1.port')), ' play: single clip: true loop: true');</task>
</button>
</simplegrid>
</abs>
<abs name="Settings">
<table bottom="0" id="commsTable1" left="0" right="0" top="0">
<tr>
<param left="0" oid="0x21" pheight="100" pwidth="228" style="size:Big;" top="0"/>
<button buttontype="push" name="Set" pheight="100" pwidth="58" style="size:Bigger;">
<task tasktype="ogscript">ogscript.putPrivateString('hosts', 'BlackmagicDeck1.host', params.getValue(0x21,0));
ogscript.debug('Set IP address to: ' + ogscript.getPrivateString('hosts', 'BlackmagicDeck1.host'));
var choices1 = new Array();
choices1.push('no clips loaded');
var choiceConstraint1 = params.createIntChoiceConstraint(choices1);
params.replaceConstraint(0x1, choiceConstraint1);
params.setValue(0x1, 0, 0);
//Reset our 'busy' state
ogscript.putObject('busy', false);
ogscript.reload('commsTable1');</task>
</button>
<listener autostart="false" buttontype="toggle" connecthost="%value[0x21][0]%" connectport="%const['hosts']['BlackmagicDeck1.port']%" delimitertype="newline" id="commandSender1" left="0" name="Comms" pheight="100" pwidth="110" style="style:ToggleButtons;" top="0">
<task tasktype="ogscript">if (event.isConnectEvent()) {
ogscript.rename('ConnectLabel1', 'Connected<fg#00FF00>');
var commandToSend = ogscript.getObject('sendCommand');
ogscript.putObject('sendCommand', null);
if (commandToSend != null) {
ogscript.debug('sending command: ' + commandToSend);
this.writeString(commandToSend + '\n', false);
} else {
ogscript.debug ('command to send was null');
}
} else if (event.isMessageEvent()) {
var message = event.getBytesAsString().trim();
var startmsgsearch = message.indexOf('clip count: ');
if (startmsgsearch != -1) {
var clipsnum = message.substr(12, message.length-1);
ogscript.putObject('ClipsNum', clipsnum);
ogscript.putObject('ClipsCount', 0);
ogscript.debug('Number of Clips = ' + clipsnum);
ogscript.putObject('responseBuilder', new Array());
} else {
var clipsnum = ogscript.getObject('ClipsNum');
var clipscount = ogscript.getObject('ClipsCount');
if (clipsnum != null) {
if (clipsnum == clipscount) {
ogscript.debug('end of response');
ogscript.putObject('busy', false);
var responseObject = ogscript.getObject('responseBuilder');
var callback = ogscript.getObject('callback');
if (callback != null) {
ogscript.debug('making callback with ' + responseObject);
callback(responseObject);
}
ogscript.putObject('ClipsNum', null);
ogscript.putObject('ClipsCount', null);
} else if (clipsnum != clipscount) {
var clipnamestart = message.indexOf(':');
var clipnameend = message.indexOf('.');
var clipnameparsed = message.substr(clipnamestart + 2, clipnameend - clipnamestart - 2);
var clipid = parseInt(message.substring(0, clipnamestart));
ogscript.debug('clip received: '+ clipid +' ' + clipnameparsed + ' ' + clipnamestart + ' ' + clipnameend + ' ' + clipnameparsed.length);
ogscript.debug('clip received: ' + message);
ogscript.getObject('responseBuilder').push({"key":clipid, "value":clipnameparsed});
clipscount++;
ogscript.putObject('ClipsCount', clipscount);
} else {
ogscript.debug('message received ' + message);
}
}
}
} else if (event.isDisconnectEvent()) {
ogscript.rename('ConnectLabel1', 'Disconnected<fg#FF0000>');
ogscript.debug('connection closed');
ogscript.putObject('busy', false);
} else {
ogscript.debug('no event info');
}</task>
</listener>
</tr>
</table>
<label id="ConnectLabel1" name="Disconnected" right="10" style="font:bold;bdr:etched;bg#dark;size:Big;fg#F60505;txt-align:center;" top="10"/>
</abs>
</tab>
#DashBoard