Facility Control

 View Only
  • 1.  Stuck in loop... Set self parameter value on click/toggle.

    Posted 12-13-2017 22:28

    Got another one for you @jamespeltzer ! Heh...

    So... In the dashboard I am creating, I wan to incorporate two buttons that both control out Carbonite switcher.
    What I want the two buttons to do are the following.

      • Show Preview GFX / Hide Preview GFX: Basically this calls on a CustomControl on the Carbonite. What it does is that it takes the graphics in M1, and keys them in on keyer 1 in the PV window in the Multivew with whatever background it has in PV.
      • The button is based on a toggle button that has a value of 0 (when not showing) and 1 (when showing in preview).
        • First click brings the graphics up in PV and sets value to 1 (works fine).
        • Second click takes off the GFX from the PV and sets the value to 0 (works fine, kinda).
      • Show GFX PGM / Hide GFX PGM: This one just includes the key 1 in transitions, then performs a key transition NOT taking with the background from PV (want that as a separate button). This one too it based on a toogle button with parameter value of 0 (not showing) and 1 (showing).
        • First click transitions in key 1 on top of PGM and sets value to 1(works fine, in theory).
        • Second click transitions out key 1 from PGM into PV again. (also works).


    Here's the problem however:

      • Show/Hide Preview GFX:
        • IF Show/Hide GFX PGM is value 1 this button should be disabled (not do anything).
          • Set the Preview paramter value to 1 (giving the button the right appereance).
            • This is where the problem is. If this fires, it goes into a loop when it tries to set itself back to 1 (I dont want the appereance to change when it "cant" remove the preview). It will also continue to spam the debug window with the following message...
          • Debug message: "GFX showing. Cannot hide...
        • ELSE (Show GFX PGM is value 0) this button should take away the keyer on PV (another Custom Control).
          • Run CC B1:C2 removes the GFX from PV.
          • Sets the parameter to 0 just from the click.
      • Show/Hide GFX PGM:
        • "‹IF Show/Hide Preview GFX is value 0 this button should be disabled (not do anything).
          • Set the Program parameter value to 0 (giving the button the right appereance).
            • This is where the problem is. Same thing as above. Setting the value of self back to what it was when pressed send it into a loop.
          • Debug message: "No preview. Cannot show GFX."
        • ELSE (Preview GFX is value 1) this button should take key 1 and transition this into PGM.
          • Include Key 1 in transition.
          • Perform key 1 transition.


    I'll include the code for this that fails. So beware whoever takes this code.
    You will have to shut down DashBoard through Task Manager (or MAC equivalent).

    <abs contexttype="opengear">
         <meta>
            <params>
               <param access="1" constrainttype="INT_CHOICE" name="GFX Preview" oid="GFX_Preview" precision="0" type="INT32" value="0" widget="toggle">
                  <constraint key="0">Show GFX PV</constraint>
                  <constraint key="1">Hide GFX PV</constraint>
               </param>
               <param access="1" constrainttype="INT_CHOICE" name="GFX PGM" oid="GFX_PGM" precision="0" type="INT32" value="0" widget="toggle">
                  <constraint key="0">Show GFX PGM</constraint>
                  <constraint key="1">Hide GFX PGM</constraint>
               </param>
            </params>
            <context contexttype="opengear" id="Carbonite.1" objectid="Carbonite 00:0F:9B:02:F4:E8&lt;br&gt;Slot 0&lt;br&gt;Carbonite" objecttype="Carbonite"/>
         </meta>
         <param expand="true" height="76" left="120" oid="GFX_Preview" style="style:toggleButton;" top="80" width="114">
            <task tasktype="ogscript">/*! block id=1001,1000,1005,1006,1004,1007,1009,1008 !*/
      if (params.getValue('GFX_PGM', 0)  ==  1) {
         params.setValue('GFX_Preview', 0, 1);
         ogscript.debug("GFX Showing. Cannot hide...");
      } else {
      if (params.getValue('GFX_Preview', 0)  ==  1) { rosstalk.sendMessage("192.168.38.150", 7788, "CC " + 1 + ":" + 1);
      ogscript.debug("Showing Preview");
      } else { rosstalk.sendMessage("192.168.38.150", 7788, "CC " + 1 + ":" + 2);
      ogscript.debug("Hiding Preview");
      }
      }
      /*!!
       &lt;block id="1001" type="if" x="302" y="69" w="268" INPUT1="ID:1000" OPERATION="equals" INPUT2="1" TRUE="" FALSE="ID:1005" IGNORE="" /&gt;
      &lt;block id="1000" type="param_GFX PGM (GFX_PGM)[0]" x="24" y="54" w="243" SET="" /&gt;
      &lt;block id="1005" type="if" x="518" y="279" w="268" INPUT1="ID:1006" OPERATION="equals" INPUT2="1" TRUE="ID:1004" FALSE="ID:1009" IGNORE="" /&gt;
      &lt;block id="1006" type="param_GFX Preview (GFX_Preview)[0]" x="255" y="312" w="243" SET="" /&gt;
      &lt;block id="1004" type="Carbonite.1_carbonite_runCC" x="854" y="249" w="243" BANK="1" CC="1"  next="ID:1007" /&gt;
      &lt;block id="1007" type="ogscript_debug" x="854" y="353" w="243" MESSAGE="Showing Preview" /&gt;
      &lt;block id="1009" type="Carbonite.1_carbonite_runCC" x="786" y="453" w="243" BANK="1" CC="2"  next="ID:1008" /&gt;
      &lt;block id="1008" type="ogscript_debug" x="780" y="578" w="243" MESSAGE="Hiding Preview" /&gt;
      !!*/
      /*!!&lt;checksum&gt;917f769596ef64bae2b3e527ee7b80eb&lt;/checksum&gt;!!*/</task>
         </param>
         <param expand="true" height="78" left="120" oid="GFX_PGM" style="style:toggleButton;" top="158" width="115">
            <task tasktype="ogscript">/*! block id=1012,1010,1014,1015,1020,1017 !*/
      if (params.getValue('GFX_Preview', 0)  ==  0)
      {
      params.setValue('GFX_PGM', 0, 0);
      ogscript.debug("No preview. Cannot show GFX");
      } else {
      rosstalk.sendMessage("192.168.38.150", 7788, "KEYAUTO ME:" + 1 + ":" + 1);
      ogscript.debug("Performing transition");
      }
      /*!!
       &lt;block id="1012" type="if" x="314" y="35" w="268" INPUT1="ID:1010" OPERATION="equals" INPUT2="0" TRUE="ID:1014" FALSE="ID:1020" IGNORE="" /&gt;
      &lt;block id="1010" type="param_GFX Preview (GFX_Preview)[0]" x="40" y="47" w="243" SET="" /&gt;
      &lt;block id="1014" type="param_setvalue" x="647" y="70" w="318" PARAM="[root, Panel Parameters, GFX PGM (GFX_PGM)]" VALUE="0"  next="ID:1015" /&gt;
      &lt;block id="1015" type="ogscript_debug" x="705" y="185" w="243" MESSAGE="No preview. Cannot show GFX" /&gt;
      &lt;block id="1020" type="Carbonite.1_carbonite_keyauto" x="587" y="327" w="243" MESRC="ME" MENUM="1" KEYER="1"  next="ID:1017" /&gt;
      &lt;block id="1017" type="ogscript_debug" x="587" y="480" w="243" MESSAGE="Performing transition" /&gt;
      !!*/
      /*!!&lt;checksum&gt;da6b5583bd090d518e02bf69ae8751f0&lt;/checksum&gt;!!*/</task>
         </param>
      </abs>

    I do know that this might seem overly reduntant for a professional user of a switcher etc, and removes some functionality when it comes to performing a transition with BKGD and Key 1 at the same time. However, some of the guys that will be operating this has next to no technical knowledge. So I am trying to make it as "user friendly" as possible with making sure they SEE the graphics etc before going live, making sure it is correct etc...



  • 2.  RE: Stuck in loop... Set self parameter value on click/toggle.

    Posted 12-14-2017 01:04
    I do get that it probably just fires the task of the button a second time when it sets the parameter of self again, wich in turn fires it over and over...

    But I am running out of ideas on how to solve it.
    And I cant find a "disable" action anywhere. I guess I could hide the button when it's not "ready" but that just... Well... Is a shady way of doing it imo...
    #DashBoard


  • 3.  RE: Stuck in loop... Set self parameter value on click/toggle.

    Posted 12-14-2017 13:56
    So.. Wrapping my head around this yet again today...

    Now I can get it working with buttons (not toggle buttons), by storing the current "state" of wether or not it's showing in preview or program in separate parameters not tied into the buttons itself (as changing the value of self caused the loop yesterday). Not EXACTLY what I was hoping for, but it works.

    Now is there a way to change the state of a toggle button? Like set a specific style or something that gives the appereance of a toggle button?
    When adding a simple button, you can still set the type to be toggle, but I havent found a way to change the state of a toggle button from another button for example...
    #DashBoard


  • 4.  RE: Stuck in loop... Set self parameter value on click/toggle.

    Posted 12-14-2017 17:41

    There is no fantastic way of reading/writing to the state of a non-param toggle button.
    Just looking at your original code though, your infinite loop is caused by the parameter ALWAYS setting itself.

    If you add a check for your preview to only set GFX_Preview to 1 if it isn't already 1, you'll be fine.

    if (params.getValue('GFX_PGM', 0)  ==  1) 
      {
         if (params.getValue('GFX_Preview', 0) != 1)
         {
             params.setValue('GFX_Preview', 0, 1);
             ogscript.debug("GFX Showing. Cannot hide...");
         }
      } else {
          if (params.getValue('GFX_Preview', 0)  ==  1) 
          { 
                rosstalk.sendMessage("192.168.38.150", 7788, "CC " + 1 + ":" + 1);
                ogscript.debug("Showing Preview");
          } else { 
                rosstalk.sendMessage("192.168.38.150", 7788, "CC " + 1 + ":" + 2);
                ogscript.debug("Hiding Preview");
          }
      }

    Same goes for setting GFX_PGM:

    if (params.getValue('GFX_Preview', 0)  ==  0)
      {
         if (params.getValue('GFX_PGM', 0) != 0)
         {
         params.setValue('GFX_PGM', 0, 0);
         ogscript.debug("No preview. Cannot show GFX");
         }
      } else {
      rosstalk.sendMessage("", 7788, "KEYAUTO ME:" + 1 + ":" + 1);
      ogscript.debug("Performing transition");
      }

    If that doesn't achieve what you're looking for, we can discuss other options.

    Cheers.

    James


    #DashBoard


  • 5.  RE: Stuck in loop... Set self parameter value on click/toggle.

    Posted 12-15-2017 08:44
    Ahhhhh, of course... Checking to see what the self value is and only change if it needs changing...
    Makes so much sense now when looking at it of course!

    Guess it's one of those "the more you stare at it, the blinder you get" moments.
    Thanks alot! Good support as allways from you!
    #DashBoard


  • 6.  RE: Stuck in loop... Set self parameter value on click/toggle.

    Posted 12-15-2017 19:56
    Glad to help - we've all been there!

    Cheers.

    James
    #DashBoard


  • 7.  RE: Stuck in loop... Set self parameter value on click/toggle.

    Posted 12-16-2017 12:42
    Now one more thing... Is it possible to change the value of a parameter without triggering the task linked to that parameter?

    I guess I could allways do with a true/false (1/0) parameter that just disables the action of a button parameter if set to false, and just toggle that off when the external button is pressed, and then re-set it back to active when it has done whatever code it had to do... But would be great to have some way of either setting a parameter without having to allways trigger the actions tied to that parameter button as well.

    Just a thought :) (or for all I know, it might just exist allready, just havent found it...)
    #DashBoard