So I've managed to make this work now. It just seems a little clunky to me and I was wondering if there might be any easier ways of achieving what I'm doing (or cleaning it up a bit)?
function GetRouterSrcDstXptNames() //Read all Router Source and Destination Names from Matrix
{
var nkSystem = nk.getActiveSystem();
if (nkSystem != null)
{
var settings = nkSystem.getSettings();
if (settings != null)
{
var srcs = settings.getInputs();
var dsts = settings.getOutputs();
params.setValue(0x21,0,"");
params.setValue(0x22,0,"");
params.setValue(0x23,0,"");
for (count = 0; count < params.getValue(0x67,0); count = count + 1)
{
params.setValue(0x12,count,srcs.getLabelForValue(count));
params.setValue(0x11,count,dsts.getLabelForValue(count));
params.setValue(0x21,0,params.getValue(0x21,0)+dsts.getLabelForValue(count)+";");
params.setValue(0x22,0,params.getValue(0x22,0)+srcs.getLabelForValue(count)+";");
}
for (output = 0; output < params.getValue(0x67,0); output = output + 1)
{
debug("GetCurrentSource "+(nk.getStatus(output+1,1)-1));
params.setValue(0x13,output,srcs.getLabelForValue((nk.getStatus(output+1,1))-1));
params.setValue(0x23,0,params.getValue(0x23,0)+srcs.getLabelForValue((nk.getStatus(output+1,1))-1)+";");
}
ogscript.saveToFile('T:\\Export\\outputs.txt', params.getValue(0x21,0), true);
ogscript.saveToFile('T:\\Export\\inputs.txt', params.getValue(0x22,0), true);
ogscript.saveToFile('T:\\Export\\current.txt', params.getValue(0x23,0), true);
}
}
debug("Function GetRouterSrcDstXptNames Complete");
}
function GetCurrentSourcesNK(ChangeEvent) //Get Current Router Sources NK
{
var nkSystem = nk.getActiveSystem();
if (nkSystem != null)
{
var settings = nkSystem.getSettings();
if (settings != null)
{
var cursrcs = settings.getInputs();
debug("GetCurrentSourceNK "+(nk.getStatus(ChangeEvent+1,1)-1));
params.setValue(0x13,ChangeEvent,cursrcs.getLabelForValue((nk.getStatus(ChangeEvent+1,1))-1));
}
params.setValue(0x23,0,"");
for (output = 0; output < params.getValue(0x67,0); output = output + 1)
{
params.setValue(0x23,0,params.getValue(0x23,0)+cursrcs.getLabelForValue((nk.getStatus(output+1,1))-1)+";");
}
ogscript.saveToFile('T:\\Export\\current.txt', params.getValue(0x23,0), true);
}
debug("Function GetCurrentSources Complete NK");
}
On the Webpage side, it's just a bit of a mess of javascript, that reads the 3 txt files, and loads them into Dropdowns, then when you do a Take, it sends the variables, and shows the server response so you know it has been received, then it reloads the current.txt file, and re-reads the current source, so you also have a visual proof that the change has taken.
#DashBoard