Facility Control

 View Only
  • 1.  Using XML in DahBoard

    Posted 11-11-2024 20:55

    I'm trying to use this XML  file in DashBoard that reflects some columns in my show rundowns

    <?xml version="1.0" encoding="UTF-8"?>
    <runningorders>
    <ro slug="MONDAY 4PM" roid="ENPSxxxx3;P_xxxxNEWS\W;05A26EF1-BE61-4376-996F2427960F18FC"/>
    <ro slug="MONDAY 5PM" roid="ENPSxxxx3;P_xxxxNEWS\W;6500BEB3-AE0F-4FEB-ADBA034619DA341E"/>
    <ro slug="MONDAY 6PM" roid="ENPSxxxx3;P_xxxxNEWS\W;A8F44DA3-08AF-4A79-80FCD787F8C51A96">
    <story id="ENPSxxxx3;P_xxxxNEWS\W\R_A8F44DA3-08AF-4A79-80FCD787F8C51A96;0898E8CB-715D-4D00-B26851F8E81D21FE" slug="HL: HOMECOMING FOR LIMESTONE COUNTY WOMAN-LIVE" headline="friday" qualifier="thunderstorms" status="PLAY"/>
    <story id="ENPSxxxx3;P_xxxxNEWS\W\R_A8F44DA3-08AF-4A79-80FCD787F8C51A96;AE6D78FD-1B6D-492E-A111EF9128C2D632" slug="HL: DEADLY TWIN PEAKS SHOOTING FOLO-LIVE" headline="saturday" qualifier="snow" status="STOP"/>
    <story id="ENPSxxxx3;P_xxxxNEWS\W\R_A8F44DA3-08AF-4A79-80FCD787F8C51A96;1B2B26AF-5652-476A-89E32A3438355DEE" slug="HL: FREE HAIRCUTS FOR VETERANS-SOTVO" headline="sunday" qualifier="sunny" status="STOP"/>
    </ro>
    <ro slug="MONDAY 10PM" roid="ENPSxxxx3;P_xxxxNEWS\W;96A0FC71-CA20-4A79-AC4B8340AE86C4BE"/>
    <ro slug="BGFN Week 12" roid="ENPSxxxx3;P_xxxxNEWS\W;860C881A-98BA-4430-9E952F3B645BC1B8"/>
    </runningorders>

    I also need to be able to select which rundown I'm looking at from the text file RunningOrderList.txt which contains:

    MONDAY 4PM
    MONDAY 5PM
    MONDAY 6PM
    MONDAY 10PM
    BGFN Week 12

    I'm basing this on a tutorial file that populates a table with data and with some help from a programmer who is unfamiliar with ogScript, I have this script.

    var xmlDocument = ogscript.parseXML('RunningOrders.xml');   //Parse the XML
    var nodeList = xmlDocument.getElementsByTagName("ro");      //Get the tags we want to include in the constraint
    
    var colData0 = [];   //Placeholder for the new constraint data
    var colData1 = [];   //Placeholder for the new constraint data
    var colData2 = [];   //Placeholder for the new constraint data
    var colData3 = [];   //Placeholder for the new constraint data
    
    for (var i = 0; i < nodeList.getLength(); i++)              //Loop through each tag we found
    {
       var ronode = nodeList.item(i);                           //Get the node
       var storyList = ronode.getElementsByTagName("story");    //get story nodes, if any inside the ro
       if( storyList.getLength() == 0 ) {
         colData0.push(parseInt(node.getAttribute("slug")));
         colData1.push(node.getAttribute("headline"));
         colData2.push(node.getAttribute("qualifier"));
         colData3.push(node.getAttribute("status"));
       } else {
         for (var j = 0; j < storyList.getLength(); j++) {
            colData0.push(parseInt(node.getAttribute("slug")));
            colData1.push(node.getAttribute("headline"));
            var story = storyList.item(j);
            colData2.push(story.getAttribute("qualifier"));
            colData3.push(story.getAttribute("status"));
         }
       }
    }
    
    
    params.setAllValues('cols.0', colData0);
    params.setAllValues('cols.1', colData1);
    params.setAllValues('cols.2', colData2);
    params.setAllValues('cols.3', colData3);

    I am getting  no data to my table---can anybody see what I have done wrong?

    Am I even close to something that works?

    Thanks,

    James. 



    ------------------------------
    James Hessler
    WAAY TV (ALLEN MEDIA BROADCASTING)
    ------------------------------


  • 2.  RE: Using XML in DahBoard

    Posted 11-12-2024 16:26

    Hi James,

    The only thing that I could point out is that you are trying to get the attributes on the variable called "node" when your node is called "ronode". Here is a custom panel example which uses struct parameters to load the XML data and set it into a struct array. 

    <abs contexttype="opengear" id="_top" keepalive="false">
       <meta>
          <params>
             <param access="1" constrainttype="STRUCT" name="story_template" oid="story_template" type="STRUCT" widget="table">
                <value>
                   <subparam access="1" maxlength="0" name="Id" suboid="id" type="STRING" value="" widget="default"/>
                   <subparam access="1" maxlength="0" name="Slug" suboid="slug" type="STRING" value="" widget="default"/>
                   <subparam access="1" maxlength="0" name="Headline" suboid="headline" type="STRING" value="" widget="default"/>
                   <subparam access="1" maxlength="0" name="Qualifier" suboid="qualifier" type="STRING" value="" widget="default"/>
                   <subparam access="1" maxlength="0" name="Status" suboid="status" type="STRING" value="" widget="default"/>
                </value>
             </param>
             <param access="1" constrainttype="STRUCT" name="ro_template" oid="ro_template" type="STRUCT" widget="table">
                <value>
                   <subparam access="1" maxlength="0" name="Id" suboid="id" type="STRING" value="" widget="default"/>
                   <subparam access="1" maxlength="0" name="Slug" suboid="slug" type="STRING" value="" widget="default"/>
                   <subparam access="1" maxlength="0" name="Stories" suboid="stories" templateoid="story_template" type="STRUCT_ARRAY" value="" widget="table"/>
                </value>
             </param>
             <param access="1" constrainttype="STRUCT" name="running_orders" oid="running_orders" templateoid="ro_template" type="STRUCT_ARRAY" widget="table">            
             </param>
          </params>
          <ogscript/>
       </meta>
       <meta>
          <api immediate="true">function initXMLData(){
                var document = ogscript.parseXML("orders.xml");
                var running_orders = document.getElementsByTagName("ro");
    
                for(var i = 0; i &lt; running_orders.getLength(); i++) {
                   var ro_node = running_orders.item(i);
                   if(ro_node != null)
                   {
                      var roid = ro_node.getAttribute("roid");
                      var ro_slug = ro_node.getAttribute("slug");                  
                      var stories = ro_node.getElementsByTagName("story");
                      var stories_data = [];
                      if(stories.getLength() &gt; 0)
                      {
                         for(var j = 0; j &lt; stories.getLength(); j++) {
                            var story = stories.item(j);
                            if(story != null)
                            {
                               var data = {
                                  id: story.getAttribute("id"),
                                  slug: story.getAttribute("story_slug"),
                                  headline: story.getAttribute("headline"),
                                  qualifier: story.getAttribute("qualifier"),
                                  status: story.getAttribute("status")
                               };
                               stories_data.push(data);
                            }
                         }
                      }
                      var new_ro = {
                         roid: roid,
                         slug: ro_slug,
                         stories: stories_data
                      };
                      params.setValue("running_orders", i, new_ro);
                   }
                   
                }
    
             }
             initXMLData();</api>
       </meta>
       <param expand="true" height="913" left="61" oid="running_orders" showlabel="false" top="41" width="1419"/>
    </abs>
    


    Let me know if that answers your question,



    ------------------------------
    Aury Rukazana
    Senior Software Developer
    Ross Video
    ------------------------------



  • 3.  RE: Using XML in DahBoard

    Posted 30 days ago

    Hey Aury,

    Wow! That was so quick!

    I've just started looking at it and will try to find time this evening to see what I can decipher of it.

    These are the columns that populate:

    ...but story slug, headline, qualifier, and status don't populate although I can see them listed as parameters.

    I'll let you know where I get with it.

    Thanks so much,

    James.



    ------------------------------
    James Hessler
    WAAY TV (ALLEN MEDIA BROADCASTING)
    ------------------------------



  • 4.  RE: Using XML in DahBoard

    Posted 30 days ago

    Hey Aury,

    I've been able to spend some time in DashBoard and made a table that references the stories in running order 0, or running order 1, basically by index and so on.

    I'd like a way to have the xml update automatically without refreshing/reloading, but I'm not sure that is possible at all.

    I'm working on being able to chose the rundown by name as the index scares me---what if somebody created a new rundown or disabled running order 0---I'm thinking that the indices would shuffle and I'd be lost or suddenly in another rundown.

    I'm out of time tonight, so I'll look again tomorrow.

    Thanks again, James.



    ------------------------------
    James Hessler
    WAAY TV (ALLEN MEDIA BROADCASTING)
    ------------------------------



  • 5.  RE: Using XML in DahBoard

    Posted 29 days ago

    Hey James,

    Can you clarify further on the xml updating automatically? You want to have the xml on your local machine be updated? Or the xml that has already been loaded by DashBoard? You can load the xml and create an object that references it and make updates to the object as needed. 

    var runningOrdersObject= ogscript.parseXML('runningorders.xml'); // read the xml 
    ogscript.putObject('orders',myObject); // store the xml in a an object
    var myStoredObject= ogscript.getObject('orders'); // read the object



    ------------------------------
    Cheers,

    Aury Rukazana
    Senior Software Developer
    Ross Video
    ------------------------------



  • 6.  RE: Using XML in DahBoard

    Posted 29 days ago

    Hey Aury, 

    I think I would like DashBoard to reload the XML each time the source updates.

    I also see that there might be a benefit to updating manually...any insight here would be appreciated.

    I look at what your code does when I get in this afternoon.

    Thanks,

    James.



    ------------------------------
    James Hessler
    WAAY TV (ALLEN MEDIA BROADCASTING)
    ------------------------------



  • 7.  RE: Using XML in DahBoard

    Posted 17 days ago

    Hey Aury,

    I didn't have any luck with your latest snippet, but I have been making good progress otherwise.

    There are two problems I've encountered that have worried me.

    The story slug doesn't populate in DashBoard in any way, although it shows up correctly in the XML file itself.

    The other is the run order list---your templates reference the run orders by index, but I haven't been able to convert the run order list to include the index of each run order---what I'm hoping for is a pulldown where I can select run order by name and then reference its index in the script to make the selection.

    I've found posts in the community that I thought might point me in the right direction, but I haven't been able to make them work.

    Any ideas what happens to the slug? Is it too long? I'm not at work yet, but it might be a concatenation of two columns separated by a hyphen--- would that explain it?

    Is the run order pulldown possible?

    Thanks,

    James.



    ------------------------------
    James Hessler
    WAAY TV (ALLEN MEDIA BROADCASTING)
    ------------------------------