Hi Kim,
Here is an panel that controls a GrandMA2. You can look at the API in the meta to see what messages we are sending over UDP.
<abs contexttype="opengear" gridsize="20">
<meta>
<params>
<param access="1" maxlength="0" name="grandMAHost" oid="grandMAHost" type="STRING" value="1.2.3.4" widget="text"/>
<param access="1" constrainttype="INT_NULL" name="grandMAPort" oid="grandMAPort" precision="0" type="INT32" value="1234" widget="default"/>
<param access="1" maxlength="0" name="executor" oid="executor" type="STRING" value="01.1" widget="text"/>
<param access="1" maxlength="0" name="cue" oid="cue" type="STRING" value="02.000" widget="text"/>
<param access="1" constraint="0.0;255.0;0.0;255.0;1" constrainttype="INT_STEP_RANGE" name="macro" oid="macro" precision="0" type="INT32" value="10" widget="spinner"/>
</params>
</meta>
<meta>
<api>function bin2String(array) {
var msg = "";
var msg2 = "";
for (var i = 0; i < array.length; i++) {
msg = msg + " " + array[i].toString(16);
msg2 = msg2 + " " + String.fromCharCode(array[i]);
}
return msg;
}
function go(executor, cue) {
// EXECUTOR MUST BE IN THE FORMAT PP.E (where PP is the 2 digit page, and E is the executor number).
// CUE MUST BE IN THE FORMAT XX.XXX
//var toSend = [0x47, 0x4d, 0x41, 0x00, 0x4d, 0x53, 0x43, 0x00, 0x1c, 0x00, 0x00, 0x00, -0x10, 0x7f, 0x7f, 0x02, 0x7f, 0x01, 0x30, 0x31, 0x2e, 0x30, 0x30, 0x30, 0x00, 0x30, 0x31, 0x2e, 0x31, -0x09];
var toSend = [0x47, 0x4d, 0x41, 0x00, 0x4d, 0x53, 0x43, 0x00, 0x1c, 0x00, 0x00, 0x00, -0x10, 0x7f, 0x7f, 0x02, 0x7f, 0x01]
var message= ogscript.createMessageBuilder();
message.writeByteArray(toSend);
message.writeString(cue);
message.writeByte(0x00);
message.writeString(executor);
message.writeByte(-0x09);
ogscript.debug("SENDING " + bin2String(message.toByteArray()));
ogscript.sendUDPBytes(params.getValue('grandMAHost',0), params.getValue('grandMAPort',0), message.toByteArray());
}
function off(executor) {
var toSend = [0x47, 0x4d, 0x41, 0x00, 0x4d, 0x53, 0x43, 0x00, 0x1c, 0x00, 0x00, 0x00, -0x10, 0x7f, 0x7f, 0x02, 0x7f, 0x0A, 0x30, 0x31, 0x2e, 0x30, 0x30, 0x30, 0x00];
//var toSend = [0x47, 0x4d, 0x41, 0x00, 0x4d, 0x53, 0x43, 0x00, 0x1c, 0x00, 0x00, 0x00, -0x10, 0x7f, 0x7f, 0x02, 0x7f, 0x01]
var message= ogscript.createMessageBuilder();
message.writeByteArray(toSend);
message.writeString(executor);
message.writeByte(-0x09);
ogscript.debug("SENDING " + bin2String(message.toByteArray()));
ogscript.sendUDPBytes(params.getValue('grandMAHost',0), params.getValue('grandMAPort',0), message.toByteArray());
}
function fire(macro) {
// MACRO IS A NUMBER BETWEEN 0 and 255
var toSend = [0x47, 0x4d, 0x41, 0x00, 0x4d, 0x53, 0x43, 0x00, 0x1c, 0x00, 0x00, 0x00, -0x10, 0x7f, 0x7f, 0x02, 0x01, 0x07];
//var toSend = [0x47, 0x4d, 0x41, 0x00, 0x4d, 0x53, 0x43, 0x00, 0x1c, 0x00, 0x00, 0x00, -0x10, 0x7f, 0x7f, 0x02, 0x7f, 0x01]
var message= ogscript.createMessageBuilder();
message.writeByteArray(toSend);
message.writeByte(macro);
message.writeByte(-0x09);
ogscript.debug("SENDING " + bin2String(message.toByteArray()));
ogscript.sendUDPBytes(params.getValue('grandMAHost',0), params.getValue('grandMAPort',0), message.toByteArray());
}
/*var header = [0x47, 0x4d, 0x41 , 0x00, 0x4d, 0x53, 0x43, 0x00]
var command = ogscript.createMessageBuilder();
var commHeader = [0x7F, 0x7F, 0x02, 0x7F];
command.writeByte(0xf0);
command.writeByteArray(commHeader);
command.writeString("01.000");
command.writeByte(0x7F);
var commandBytes = command.toByteArray();
var msgSize = commandBytes.length + header.length + 4
var sizearray = [msgSize, 0x00, 0x00, 0x00];
var message= ogscript.createMessageBuilder();
message.writeByteArray(header);
message.writeByteArray(sizearray);
message.writeByteArray(commandBytes);
bin2String(message.toByteArray());
*/
/*
var header = [0x47, 0x4d, 0x41, 0x00, 0x4d, 0x53, 0x43, 0x00, 0x18, 0x00, 0x00, 0x00, -0x10, 0x7f, 0x7f, 0x02, 0x7f]
var message= ogscript.createMessageBuilder();
message.writeByteArray(header);
message.writeString("01.000");
message.writeByte(0x7F);
bin2String(message.toByteArray());
*/
</api>
</meta>
<button buttontype="push" height="60" left="280" name="GO" top="160" width="160">
<task tasktype="ogscript">go(params.getValue('executor', 0), params.getValue('cue', 0));
</task>
</button>
<param expand="true" height="20" left="120" oid="grandMAHost" top="20" width="200"/>
<param expand="true" height="20" left="440" oid="grandMAPort" showlabel="false" top="20" width="200"/>
<label height="20" left="40" name="Grand MA IP" style="txt-align:west" top="20" width="80"/>
<label height="20" left="340" name="Grand MA Port" style="txt-align:west" top="20" width="100"/>
<param expand="true" height="20" left="180" oid="executor" top="160" width="80"/>
<label height="20" left="60" name="Executor.Page" style="txt-align:west;" top="160" width="100"/>
<label height="20" left="60" name="Cue" style="txt-align:west" top="200" width="100"/>
<param expand="true" height="20" left="180" oid="cue" top="200" width="80"/>
<button buttontype="push" height="60" left="460" name="OFF" top="160" width="160">
<task tasktype="ogscript">off(params.getValue('executor', 0));
</task>
</button>
<button buttontype="push" height="60" left="280" name="FIRE" top="320" width="160">
<task tasktype="ogscript">fire(params.getValue('macro', 0));
</task>
</button>
<label height="20" left="60" name="Macro #" style="txt-align:west" top="320" width="120"/>
<param expand="true" height="20" left="180" oid="macro" top="320" width="80"/>
<label height="40" left="60" name="Go and Off" style="txt-align:west;size:Bigger;" top="100" width="340"/>
<label height="40" left="60" name="Macros" style="txt-align:west;size:Bigger;" top="260" width="340"/>
</abs>
Let me know if this works for you.
#DashBoard