Facility Control

 View Only
Expand all | Collapse all

Dashboard Webcontrol

  • 1.  Dashboard Webcontrol

    Posted 12-17-2017 13:32
    Hi,

    I've asked this in the NK Router section already, but not got any response, so I'll ask here and phrase it a little differently.

    Does anyone know if it is possible to provide any kind of feedback, or updating display to a web published panel?

    I am trying to make a basic 'engineers tool' for switching crosspoint on an NK, from a phone/tablet (non windows)

    Ideally I would have:
    1) dropdown with all destinations.
    2) current source for that destination
    3) dropdown to select new source
    4) TAKE button.

    At the moment, as far as I can tell I have to have individual buttons to be triggered from the web published page, but for a 72x72 matrix, that would mean over 5000 buttons on the page!

    I can write the code to get all the dst/src names, and do the lookup /take in dashboard, but unless I can make it accessible to a browser it doesn't really work.

    If anyone has any ideas on how to go about this it would be very much appreciated.

    Cheers
    James


  • 2.  RE: Dashboard Webcontrol

    Posted 12-18-2017 16:18

    DashBoard only currently has the ability to publish the basic grid of GPI buttons as an HTML page.
    There is a trick that allows you to pass more information to the GPI trigger via its "state" component. You can do this by triggering the GPIs directly instead of through the web page.

    Exposing an NK take as a GPI trigger is a little tricky so I will provide you an example here:

    <abs contexttype="opengear" httptriggerport="8080" virtualheight="914" virtualwidth="1408">
       <abs bottom="0" contexttype="nk-router" left="0" right="0" top="0" virtualheight="914" virtualwidth="1408">
          <meta>
             <ogscript handles="onload">function triggerFunction(event)
    {
       var triggerID = event.getTrigger();
       var state = event.getState() + "";
       var pieces = state.split("_");
       nk.doSwitchWithLabels(pieces[0], pieces[1], pieces[2]);
    }
    
    var trigger = ogscript.addRemoteTrigger('DoTake', 'Take', triggerFunction);
    var oldTrigger = ogscript.getObject('take-trigger');
    if (oldTrigger != null)
    {
       oldTrigger.close();
    }
    ogscript.putObject('take-trigger', trigger);</ogscript>
          </meta>
          <simplegrid height="83" left="2" right="8" rows="1" top="4">
             <ipslist/>
          </simplegrid>
          <lvlstatus dst="all" height="732" left="843" right="8" scroll="vertical" showlabel="true" style="font:mono;size:small;bg#efffbe;fg#000000;t:bg#c8d5a0;t:fg#000000;" top="88"/>
          <flow height="730" horizontalfill="true" left="4" right="610" scroll="vertical" top="92" verticalfill="true">
             <dstlist height="64" style="style:toggleButton;t:bg#F1A000;" width="95"/>
             <srclist height="64" style="style:toggleButton;" width="95"/>
             <lvllist height="64" style="style:toggleButton;t:bg#9800FD;" width="95"/>
          </flow>
          <nkfunction function="take" height="79" left="6" top="826" width="1399"/>
       </abs>
    </abs>

    With this, I can trigger a router crosspoint change directly with the following URL:

    http://localhost:8080/ajax/DoTake/Out%201_In%206_An%20Vid

    Where it is basically:
    view-source:http://localhost:8080/ajax/DoTake/NAME OF DESTINATION_NAME OF SOURCE_NAME OF LEVEL


    #DashBoard


  • 3.  RE: Dashboard Webcontrol

    Posted 12-20-2017 02:02
    Hi James, That is very nifty!

    I've got that to work OK (and bypassed the need to specify the router layer), now to make a nice neat webpage to wrap it all up and make the remembering source/destination names part a little simpler.

    I'll see what I can come up with over the next week, and let you know how it goes.

    Cheers
    James
    #DashBoard


  • 4.  RE: Dashboard Webcontrol

    Posted 12-20-2017 14:49
    Glad to help.
    Naturally, you can modify this and use the technique to do any number of different things.

    Let us know how it goes!

    Cheers.

    James
    #DashBoard


  • 5.  RE: Dashboard Webcontrol

    Posted 12-28-2017 22:05

    Hi James,

    At the moment I'm trying to dump some arrays to some kind of file (txt, xml, csv, or pretty much anything that I can parse externally) that I can read from a webpage.

    At the moment this is what I have:

    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();
          for (count = 0; count &lt; params.getValue(0x67,0); count = count + 1)
            {
            params.setValue(0x12,count,srcs.getLabelForValue(count));
            params.setValue(0x11,count,dsts.getLabelForValue(count));
            }
          for (output = 0; output &lt; params.getValue(0x67,0); output = output + 1)
            {
            params.setValue(0x13,output,srcs.getLabelForValue((nk.getStatus(output+1,1))-1));
            }
        ogscript.saveToFile('T:\\Export\\outputs.txt', params.getAllValues(0x11), true);
        ogscript.saveToFile('T:\\Export\\inputs.txt', params.getAllValues(0x12), true);
        ogscript.saveToFile('T:\\Export\\current.txt', params.getAllValues(0x13), true);
          }
        }
      debug("Function GetRouterSrcDstXptNames Complete");
      }

    But I can't seem to actually export the data to an external file. I can export a single value ok using a params.getValue(0x??,n);, just I get nothing when I try and do more than that.

    I can see that all the arrays carry the correct data, I just can't push it out. Is there a better way of doing this, or is there something really obvious that I am missing here?

    Cheers
    James


    #DashBoard


  • 6.  RE: Dashboard Webcontrol

    Posted 12-30-2017 16:57

    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 &lt; 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 &lt; 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 &lt; 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


  • 7.  RE: Dashboard Webcontrol

    Posted 01-02-2018 15:00

    You might find it easier to write a 'stringify' function that an take the array of parameter values and return them as a single string in the format you're looking for. There is no need to create params objects to hold the data when a JavaScript "var" will work just fine.

    In this scenario, your first function would look like this:

    function stringifyValue(val)
    {
      var str = "";
      for (var i = 0; i &lt; val.length; i++)
      {
        str += val[i] + ';';
      }
      return str;
    }
    
    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();
    
          for (var count = 0; count &lt; params.getValue(0x67,0); count = count + 1)
          {
            params.setValue(0x11,count,dsts.getLabelForValue(count));
            params.setValue(0x12,count,srcs.getLabelForValue(count));
            params.setValue(0x13,count,srcs.getLabelForValue((nk.getStatus(count+1,1))-1));
          }
    
    
        ogscript.saveToFile('T:\\Export\\outputs.txt', stringifyValue(params.getAllValues(0x11)), true);
        ogscript.saveToFile('T:\\Export\\inputs.txt', stringifyValue(params.getAllValues(0x12)), true);
        ogscript.saveToFile('T:\\Export\\current.txt', stringifyValue(params.getValue(0x13)), true);
          }
        }
      debug("Function GetRouterSrcDstXptNames Complete");
      }

    You could also adapt your second function to use "stringifyValue".

    Another piece of advice I would offer is to use string names (eg. 'params.dests') for your OIDs instead of the default 'magic numbers' like 0x11, 0x12, etc.


    #DashBoard


  • 8.  RE: Dashboard Webcontrol

    Posted 01-09-2018 22:44
    Hi James,

    Good shout on making the stringify function, and noted with the variables point. I need to get into the practice of simplifying things like that once I've got them working.

    I'll have a look at changing my OID names over when I make some more panels, but I've got pretty good at remembering the 0x?? OID's after everything I've done so far!

    I think the next challenge once I have a bit more time free will be to make a similar webpage to control a Carbonite.
    #DashBoard


  • 9.  RE: Dashboard Webcontrol

    Posted 01-22-2018 14:14
    How about running preview video inside a Dashboard panel in a web page ? Is it possible to include an iFrame from another system, into a Dashboard panel ?

    If you combine NDI Source Multi and NDI WebLink it's technically possible to get 8 SDI feeds into a mechanism which ultimately delivers low latency on-demand video preview into an HTML page.

    If any DashBoard programmer here fancies trying that, please contact me and I will set you up with the NDI software to try it. Might be really interesting.
    #DashBoard


  • 10.  RE: Dashboard Webcontrol

    Posted 01-22-2018 15:04
    Dashboard has a built-in NDI viewer as a widget. I have a panel that uses it along with Sienna's NDI Source, which is fed off our video router into a Mac Mini with an Ultrastudio 4k. I wrote code to allow Dashboard to make video router destination changes, so I essentially have a remote viewer of any router source. We don't rely on it for production though, because NDI Source crashes all the time, at least on our system.
    #DashBoard


  • 11.  RE: Dashboard Webcontrol

    Posted 01-22-2018 21:16
    Dashboard has a built-in NDI viewer as a widget. I have a panel that uses it along with Sienna's NDI Source, which is fed off our video router into a Mac Mini with an Ultrastudio 4k. I wrote code to allow Dashboard to make video router destination changes, so I essentially have a remote viewer of any router source.

    That's very interesting. I had no idea Dashboard supported NDI Directly. I will add that to the NDI Wikipedia page

    Other than XPression, where else does NDI feature in the Ross product line ?

    #DashBoard