Facility Control

 View Only
  • 1.  DashBoard Visual Logic Ands & Ors

    Posted 01-11-2023 22:56
    I'm working on some visual logic for a DashBoard panel button to roll the correct newscast open depending upon time of day and day of week.

    I am much more familiar with visual logic in Xpression, but DashBoard doesn't have all the same blocks.

    I've been trying to come up with a way to make an "and" condition, but either fail or start an approach that will be very cumbersome.

    Below is the latest attempt, but I worry about how complex it would need to be to cover all days and dayparts.


    I considered making each time its own task, but thought that might introduce some delays, if I had fifty tasks stacked up in a button.

    I've started looking at the ogScript version of tasks I built with visual logic, but although I am capable of stringing together some coherent thoughts in VBScript for Xpression, ogScript is escaping me.

    Am I close? Am I missing something?

    Thanks,
    James.

    #DashBoard
    #CarboniteBlack
    #XPression
    ------------------------------
    James Hessler
    WAAY (HEARTLAND MEDIA)
    ------------------------------
    ​​​​


  • 2.  RE: DashBoard Visual Logic Ands & Ors

    Posted 01-16-2023 15:53
    If you want to learn how to code, the scrips in DashBoard is JavaScript based, and not that hard to get into.

    As for the visual logic you need, I never solved that one in VL myself.

    ------------------------------
    Aleksander Stalsberg
    Inland Norway University of Applied Sciences/Lillehammer Icehockey Club
    Norway
    ------------------------------



  • 3.  RE: DashBoard Visual Logic Ands & Ors

    Posted 01-16-2023 16:21
    I have working visual logic to decide which open rolls depending upon the day and time that isn't alarmingly bulky.



    My problem is that I have five tasks; which open?,  pause, clear some Xpression layers, another pause, and cut ME3

    If the opens are different lengths, this bites me on the undercut.

    I've read about Async.Exec scripts (adding a dealy between tasks) but can't figure out where they would go, much less be able to write them.

    I'm only assuming the Async.Exec would apply since I want it all to happen within one task.

    Could I add your sample to a custom code block and have it do what I need?

    I remember reading about a problem with more than one Async.Exec, so I'm not sure about how to address that...include that script snippet in another Custom Code block.

    But where? at the beginning of my visual logic?

    I want to exit the visual logic when it fires an open and does all the other steps---does a return block on the out side of my last function do that?

    I know---so many questions---is there any hope?

    Aside from being wary of the time needed to become proficient at JavaScript and therefore hopefully ogScript, I need this to be visual so that coworkers have a better chance of understanding what it does and be able to make changes down the road.

    Thanks,
    James.

    ------------------------------
    James Hessler
    WAAY (HEARTLAND MEDIA)
    ------------------------------



  • 4.  RE: DashBoard Visual Logic Ands & Ors

    Posted 01-18-2023 10:04
    Hi James
    asyncExec does not have a visual logic control block but you can use the "custom code" block to execute it.  It takes a function name (and an optional delay) as arguments so you would put your main task body in a function and call it.



    You would also use custom code to trigger a pause - it takes a number of milliseconds as its argument.

    <abs contexttype="opengear" keepalive="true">
       <button buttontype="push" height="111" left="47" name="Async Exec" top="81" width="232">
          <task tasktype="ogscript">
    function MyExec() {
    
    
    
    
    	/*! block id=1005,1004,1006,1007,1008,1009,1013,1014,1010,1011,1012 !*/
    	switch (	new Date().getDay())
    	{
    		case 0:
    			ogscript.debug("Sunday");
    			break;
    		case 1:
    			ogscript.debug("Monday");
    			break;
    		case 2:
    			ogscript.debug("Tuesday");
    			break;
    		case 3:
    			ogscript.debug("Wednesday");
    				ogscript.pause(1000);
    				ogscript.debug("Yes... definitely Wednesday");
    			break;
    		case 4:
    			ogscript.debug("Thursday");
    			break;
    		case 5:
    			ogscript.debug("Friday");
    			break;
    		case 6:
    			ogscript.debug("Saturday");
    			break;
    	}
    	/*!!
     	&lt;block id="1005" type="switch" x="244" y="230" w="268" VALUE="ID:1004" STATEMENT="ID:1006" statementtag_STATEMENT="0" STATEMENT_0="ID:1007" statementtag_STATEMENT_0="1" STATEMENT_1="ID:1008" statementtag_STATEMENT_1="2" STATEMENT_2="ID:1009" statementtag_STATEMENT_2="3" STATEMENT_3="ID:1010" statementtag_STATEMENT_3="4" STATEMENT_4="ID:1011" statementtag_STATEMENT_4="5" STATEMENT_5="ID:1012" statementtag_STATEMENT_5="6" STATEMENT_6="" /&gt;
    	&lt;block id="1004" type="getCurrentDay" x="10" y="10" w="243" empty2="" /&gt;
    	&lt;block id="1006" type="ogscript_debug" x="564" y="8" w="243" MESSAGE="Sunday" /&gt;
    	&lt;block id="1007" type="ogscript_debug" x="563" y="75" w="243" MESSAGE="Monday" /&gt;
    	&lt;block id="1008" type="ogscript_debug" x="564" y="143" w="243" MESSAGE="Tuesday" /&gt;
    	&lt;block id="1009" type="ogscript_debug" x="566" y="212" w="243" MESSAGE="Wednesday"  next="ID:1013" /&gt;
    	&lt;block id="1013" type="customcode" x="817" y="277" w="343" CODE="ogscript.pause(1000);"  next="ID:1014" /&gt;
    	&lt;block id="1014" type="ogscript_debug" x="844" y="439" w="243" MESSAGE="Yes... definitely Wednesday" /&gt;
    	&lt;block id="1010" type="ogscript_debug" x="576" y="426" w="243" MESSAGE="Thursday" /&gt;
    	&lt;block id="1011" type="ogscript_debug" x="575" y="508" w="243" MESSAGE="Friday" /&gt;
    	&lt;block id="1012" type="ogscript_debug" x="569" y="587" w="243" MESSAGE="Saturday" /&gt;
    	!!*/
    }
    
    
    
    
    /*! block id=1001 !*/
    ogscript.asyncExec(MyExec);
    /*!!
     &lt;block id="1001" type="customcode" x="185" y="136" w="343" CODE="ogscript.asyncExec(MyExec);" /&gt;
    !!*/
    /*!!&lt;checksum&gt;28faf98de753390b0fcfc9464c2e5eb2&lt;/checksum&gt;!!*/</task>
       </button>
    </abs>
    ​


    ------------------------------
    James Peltzer
    Ross Video
    ------------------------------



  • 5.  RE: DashBoard Visual Logic Ands & Ors

    Posted 01-19-2023 15:58
    Hey James,

    Thank you so much.

    It will be a little while before I can digest all this and work it into my button---but the fact that what I need to do is possible is great!

    Thanks,
    James.

    ------------------------------
    James Hessler
    WAAY (HEARTLAND MEDIA)
    ------------------------------



  • 6.  RE: DashBoard Visual Logic Ands & Ors

    Posted 01-19-2023 22:26
    James,

    I got to it sooner than I thought.

    I made the asyncExec as a function


    and one day/time case for my open as a function



    or alternately as


    and fired the two functions in the main body of my task


    It played the open I wanted because the day is neither Sunday nor Saturday, and the time was between 8pm &  9pm, but I didn't get to see about it clearing the Xpression layers I need to clear because the pauses don't happen.

    Does anything jump out at you? 

    I realize in my experimenting, I didn't try putting the asyncExec function into my open function---would that have been closer?

    Thanks,
    James.

    This is the ogScript:

    function MyExec() {




    /*! block id=1444 !*/
    ogscript.asyncExec(MyExec);
    /*!!
    <block id="1444" type="customcode" x="8" y="18" w="343" CODE="ogscript.asyncExec(MyExec);" />
    !!*/
    }


    function open() {




    /*! block id=1445,1446,1447,1448,1449,1450,1451,1452 !*/
    if (new Date().getDay() == 0)
    {
    if (new Date().getTime() > new Date(new Date().getFullYear(),new Date().getMonth(),new Date().getDate(),20,00,0,0).getTime() && new Date().getTime() < new Date(new Date().getFullYear(),new Date().getMonth(),new Date().getDate(),21,00,0,0).getTime()) { rosstalk.sendMessage("10.253.10.107", 7788, "TAKE " + 1798 + ":" + (1 -1) + ":" + 10);
    } else {
    } } else { if (new Date().getDay() == 6) { if (new Date().getTime() > new Date(new Date().getFullYear(),new Date().getMonth(),new Date().getDate(),20,00,0,0).getTime() && new Date().getTime() < new Date(new Date().getFullYear(),new Date().getMonth(),new Date().getDate(),21,00,0,0).getTime()) { rosstalk.sendMessage("10.253.10.107", 7788, "TAKE " + 1798 + ":" + (1 -1) + ":" + 10);
    } else { } } else { if (new Date().getTime() > new Date(new Date().getFullYear(),new Date().getMonth(),new Date().getDate(),20,00,0,0).getTime() && new Date().getTime() < new Date(new Date().getFullYear(),new Date().getMonth(),new Date().getDate(),21,00,0,0).getTime()) { rosstalk.sendMessage("10.253.10.107", 7788, "TAKE " + 1798 + ":" + (1 -1) + ":" + 10);
    } else { } }
    }
    /*! block id=1461 !*/
    ogscript.pause(2250);
    /*! block id=1462 !*/
    rosstalk.sendMessage("10.253.10.107", 7788, "CLFB " + (1 - 1) + ":" + 0);
    /*! block id=1463 !*/
    rosstalk.sendMessage("10.253.10.107", 7788, "CLFB " + (1 - 1) + ":" + 1);
    /*! block id=1464 !*/
    rosstalk.sendMessage("10.253.10.107", 7788, "CLFB " + (1 - 1) + ":" + 2);
    /*! block id=1465 !*/
    rosstalk.sendMessage("10.253.10.107", 7788, "CLFB " + (1 - 1) + ":" + 3);
    /*! block id=1466 !*/
    rosstalk.sendMessage("10.253.10.107", 7788, "CLFB " + (1 - 1) + ":" + 4);
    /*! block id=1467 !*/
    rosstalk.sendMessage("10.253.10.107", 7788, "CLFB " + (1 - 1) + ":" + 5);
    /*! block id=1468 !*/
    rosstalk.sendMessage("10.253.10.107", 7788, "CLFB " + (1 - 1) + ":" + 6);
    /*! block id=1469 !*/
    ogscript.pause(3000);
    /*! block id=1470 !*/
    rosstalk.sendMessage("10.253.10.88", 7788, "MECUT ME:" + 3);
    /*!!
    <block id="1445" type="if_dayofweek" x="107" y="17" w="243" DAY="Sunday" TRUE="ID:1446" FALSE="ID:1448" next="ID:1461" />
    <block id="1446" type="if_currenttimebetween" x="515" y="44" w="268" TIME1="20:00" TIME2="21:00" TRUE="ID:1447" FALSE="" />
    <block id="1447" type="XPression.1_xpression_take" x="770" y="45" w="257" color="#ffc857" TAKEID="1798" BUFFER="1" LAYER="10" />
    <block id="1448" type="if_dayofweek" x="284" y="118" w="243" DAY="Saturday" TRUE="ID:1449" FALSE="ID:1451" />
    <block id="1449" type="if_currenttimebetween" x="499" y="151" w="268" TIME1="20:00" TIME2="21:00" TRUE="ID:1450" FALSE="" />
    <block id="1450" type="XPression.1_xpression_take" x="765" y="168" w="262" color="#ffc857" TAKEID="1798" BUFFER="1" LAYER="10" />
    <block id="1451" type="if_currenttimebetween" x="472" y="271" w="268" TIME1="20:00" TIME2="21:00" TRUE="ID:1452" FALSE="" />
    <block id="1452" type="XPression.1_xpression_take" x="763" y="290" w="267" color="#ffc857" TAKEID="1798" BUFFER="1" LAYER="10" />
    <block id="1461" type="customcode" x="119" y="267" w="343" CODE="ogscript.pause(2250);" next="ID:1462" />
    <block id="1462" type="XPression.1_xpression_clearlayer" x="44" y="448" w="243" color="#ffc857" BUFFER="1" LAYER="0" next="ID:1463" />
    <block id="1463" type="XPression.1_xpression_clearlayer" x="251" y="451" w="243" color="#ffc857" BUFFER="1" LAYER="1" next="ID:1464" />
    <block id="1464" type="XPression.1_xpression_clearlayer" x="457" y="450" w="243" color="#ffc857" BUFFER="1" LAYER="2" next="ID:1465" />
    <block id="1465" type="XPression.1_xpression_clearlayer" x="666" y="448" w="243" color="#ffc857" BUFFER="1" LAYER="3" next="ID:1466" />
    <block id="1466" type="XPression.1_xpression_clearlayer" x="40" y="566" w="243" color="#ffc857" BUFFER="1" LAYER="4" next="ID:1467" />
    <block id="1467" type="XPression.1_xpression_clearlayer" x="257" y="572" w="243" color="#ffc857" BUFFER="1" LAYER="5" next="ID:1468" />
    <block id="1468" type="XPression.1_xpression_clearlayer" x="470" y="574" w="243" color="#ffc857" BUFFER="1" LAYER="6" next="ID:1469" />
    <block id="1469" type="customcode" x="87" y="675" w="343" CODE="ogscript.pause(3000);" next="ID:1470" />
    <block id="1470" type="Carbonite 00:0F:9B:03:D3:AF&lt;br&gt;Slot 0&lt;br&gt;Carbonite_carbonite_cut" x="531" y="687" w="243" MESRC="ME" MENUM="3" />
    !!*/
    }




    /*! block id=1481 !*/
    MyExec()
    /*! block id=1480 !*/
    open()
    /*!!
    <block id="1481" type="function_MyExec" x="76" y="30" w="243" next="ID:1480" />
    <block id="1480" type="function_open" x="68" y="107" w="243" />
    !!*/
    /*!!<checksum>b01a18e66e00fcd0f4bbda0a54782296</checksum>!!*/

    ------------------------------
    James Hessler
    WAAY (HEARTLAND MEDIA)
    ------------------------------



  • 7.  RE: DashBoard Visual Logic Ands & Ors

    Posted 01-20-2023 09:51
    The "Main" tab is the one that should be calling asyncExec and passing-in the function name ("MyExec" in my example or "open" in yours).  Your call to asyncExec is in MyExec and is just re-executing itself (probably eventually causing a stack overflow and definitely).  Your call to "open" is directly in main so it is executing in the UI thread instead of the asyncExec thread and, due to this, will have pauses disabled.

    ------------------------------
    James Peltzer
    Ross Video
    ------------------------------



  • 8.  RE: DashBoard Visual Logic Ands & Ors

    Posted 01-20-2023 13:55
    Hey James,

    I had a feeling it was something dumb...hope the stack overflow wasn't too dangerous.

    I'll work on it again this afternoon and evening.

    By the way, I have dug and dug and can't find a way to copy and paste DashBoard visual logic blocks---is this even possible?

    I tried jiggling the handle in the keyboard shortcuts dialog disabling/re-enabling (I think?) and changing where the action applied, but nothing made them work. 

    Thanks, James.

    ------------------------------
    James Hessler
    WAAY (HEARTLAND MEDIA)
    ------------------------------



  • 9.  RE: DashBoard Visual Logic Ands & Ors

    Posted 01-20-2023 22:25
    Hey James!

    I've got part of it working---my first day/time case works: says it isn't Sunday, and it isn't Saturday and between 8:38pm and 8:39pm, it took takeID 1798, paused three seconds and cut Carbonite ME3.

    However, it didn't quite hold up for the next case: between 8:39pm & 8:45pm, it took takeID 1790, but never cut.

    Is there a limit on the number of pauses allowed?

    Visual logic for all the time cases I want to cover in a twenty-four hour period will get pretty bulky...I considered whether I might need to try creating a function for each time case.

    By the way, three seconds is not enough and I think I may have found that longer than three seconds didn't work either, but maybe I was making the second pause the long one.

    At some point, I closed and reopened DashBoard, but never rebooted the PC.

    Can you think of anything else that would cause this behavior?

    Thanks,
    James.




    ------------------------------
    James Hessler
    WAAY (HEARTLAND MEDIA)
    ------------------------------



  • 10.  RE: DashBoard Visual Logic Ands & Ors

    Posted 01-23-2023 10:02
    Hi James
    No, there is no limit on the number or duration of pauses provided that you're running in the asyncExec thread. If you script isn't executing all the way through, I would look whether anything was written to the debug output.

    I would suggest starting with some debug statements to make sure your conditional paths and pauses are working as expected before adding your actual takes and transitions - it might make it easier to debug.  

    If possible, post the generated ogScript and we can see if there is anything obviously wrong in what Visual Logic generated from your blocks.



    ------------------------------
    James Peltzer
    Ross Video
    ------------------------------