Jump to content
Sign in to follow this  
Bam2000

Simbrief read Wind Information

Recommended Posts

Posted (edited)

Hi, 

i cannot find Wind Information from Simbrief. Is there any chance to get the following Numbers from the Simbrief FB as a Variable to use on Streamdeck?

jb287xas.png

Edited by Bam2000

Share this post


Link to post
Share on other sites
Posted (edited)

Is this information part of the Simbrief API / webservice? They you should be able to query it. 

Edited by Lorby_SI

LORBY-SI

Share this post


Link to post
Share on other sites
Posted (edited)

Ok, so this data is present in the API. in fact, the entire navlog is part of the download, and every "fix" in the navlog has weather data attached, among dozens of other information items. 

My advice woould be that you write a JScript or VBScript program in AAO that queries the SimBrief API and then parses the desired information from the returned XML or Json string. This is not something that can be done "generically" in AAO with the existing mechanism. Well, it could, but doing that would create thousands of (useless) LVars, that AAO would have to wade through every single time that you want to query any LVars at all. Which will lead to a massive loss of app performance.

This is JUST the structure for the TOC. As noted, the navlog contains the entire flight plan - and many other things on top. My download for a flight from EDDM to LIRF has 17448 lines of XML code (yes, that is seventeen thousand)

    <fix>
      <ident>TOC</ident>
      <name>TOP OF CLIMB</name>
      <type>ltlg</type>
      <icao_region/>
      <frequency/>
      <pos_lat>47.298883</pos_lat>
      <pos_long>11.913664</pos_long>
      <stage>CLB</stage>
      <via_airway>Y107</via_airway>
      <is_sid_star>0</is_sid_star>
      <distance>8</distance>
      <track_true>187</track_true>
      <track_mag>184</track_mag>
      <heading_true>190</heading_true>
      <heading_mag>186</heading_mag>
      <altitude_feet>31000</altitude_feet>
      <ind_airspeed>289</ind_airspeed>
      <true_airspeed>452</true_airspeed>
      <mach>0.78</mach>
      <mach_thousandths>0.78</mach_thousandths>
      <wind_component>-16</wind_component>
      <groundspeed>436</groundspeed>
      <time_leg>62</time_leg>
      <time_total>900</time_total>
      <fuel_flow>5822</fuel_flow>
      <fuel_leg>59</fuel_leg>
      <fuel_totalused>1229</fuel_totalused>
      <fuel_min_onboard>4887</fuel_min_onboard>
      <fuel_plan_onboard>5558</fuel_plan_onboard>
      <oat>-52</oat>
      <oat_isa_dev>-5</oat_isa_dev>
      <wind_dir>240</wind_dir>
      <wind_spd>26</wind_spd>
      <shear>1</shear>
      <tropopause_feet>37200</tropopause_feet>
      <ground_height>6969</ground_height>
      <mora>10500</mora>
      <fir>LOVV</fir>
      <fir_units>N,F</fir_units>
      <fir_valid_levels>2000,4000,6000,8000,10000,12000,14000,16000,18000,20000,22000,24000,26000,28000,30000,32000,34000,36000,38000,40000,43000,47000,51000,55000,59000,63000,67000</fir_valid_levels>
      <wind_data>
        <level>
          <altitude>0</altitude>
          <wind_dir>16</wind_dir>
          <wind_spd>3</wind_spd>
          <oat>14</oat>
        </level>
        <level>
          <altitude>5000</altitude>
          <wind_dir>16</wind_dir>
          <wind_spd>3</wind_spd>
          <oat>5</oat>
        </level>
        <level>
          <altitude>10000</altitude>
          <wind_dir>101</wind_dir>
          <wind_spd>1</wind_spd>
          <oat>-5</oat>
        </level>
        <level>
          <altitude>14000</altitude>
          <wind_dir>241</wind_dir>
          <wind_spd>6</wind_spd>
          <oat>-13</oat>
        </level>
        <level>
          <altitude>18000</altitude>
          <wind_dir>271</wind_dir>
          <wind_spd>9</wind_spd>
          <oat>-22</oat>
        </level>
        <level>
          <altitude>24000</altitude>
          <wind_dir>238</wind_dir>
          <wind_spd>12</wind_spd>
          <oat>-36</oat>
        </level>
        <level>
          <altitude>30000</altitude>
          <wind_dir>240</wind_dir>
          <wind_spd>24</wind_spd>
          <oat>-50</oat>
        </level>
        <level>
          <altitude>34000</altitude>
          <wind_dir>238</wind_dir>
          <wind_spd>30</wind_spd>
          <oat>-58</oat>
        </level>
        <level>
          <altitude>39000</altitude>
          <wind_dir>248</wind_dir>
          <wind_spd>30</wind_spd>
          <oat>-63</oat>
        </level>
        <level>
          <altitude>45000</altitude>
          <wind_dir>278</wind_dir>
          <wind_spd>29</wind_spd>
          <oat>-57</oat>
        </level>
      </wind_data>
      <fir_crossing/>
    </fix>

 

Edited by Lorby_SI

LORBY-SI

Share this post


Link to post
Share on other sites
Posted (edited)

For anyone interested, here is how you would query simbrief and extract the wind data at a specific point of your flight plan

Initialization script:

'yoursimbriefuser'·(>L:simbrief_user,·String)·
'TOC'·(>L:fix_icao,·String)·
1·(>K:Test-SimBriefWinds)

Query script (using a JScript in AAO, which in this case is a script in the group "Test" with the title "SimBriefWinds" - see >K: call above)

(WSH:jscript|AaoEntry)

function AaoEntry(){
  var sbuser = (L:simbrief_user, String);
  var fix_icao = (L:fix_icao, String);
  (STRARR:sbwinds).clear();
  var xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");   
  var commandStr = "https://www.simbrief.com/api/xml.fetcher.php?username=" + sbuser;
  xmlHttpReq.open("POST", commandStr, false);
  xmlHttpReq.send();
  var content = xmlHttpReq.responseText;
  var dom = new ActiveXObject("msxml2.DOMDocument.6.0");
  dom.async = false;
  dom.loadXML(content); 
  var objNodeList = dom.documentElement.selectNodes("navlog/fix");
  for (var i = 0; i < objNodeList.length; i++){
    var chkFix = objNodeList[i].getElementsByTagName("ident")[0].text;
    if (chkFix === fix_icao ){
       var winds = objNodeList[i].getElementsByTagName("wind_data");
       if (winds && winds.length > 0){
         var levels = winds[0].getElementsByTagName("level");
         for (var l = 0; l < levels.length; l++){ 
             var alt = levels[l].getElementsByTagName("altitude")[0].text;
             var dir = levels[l].getElementsByTagName("wind_dir")[0].text;
             var spd = levels[l].getElementsByTagName("wind_spd")[0].text;
             var oat = levels[l].getElementsByTagName("oat")[0].text;
	         var windinf = "" + alt + " " + dir + "/" + spd + " " + oat + "C";
             (STRARR:sbwinds).push(windinf);
             // var script = "\'" + dir + "/" + spd + " " + oat + "\'"; 
             // script = script + " (>L:wind_" + alt + ", String)";
             // AaoCmd.exec(script); 
         }
       }
       break;
    }
  }
}

The result is a string array that contains the wind information for the various altitudes that were in the SimBrief report
"0 16/3 14C"
"5000 16/3 5C"
"10000 101/1 -5C"
"14000 241/6 -13C"

etc.

The values in the array can be read with "(STRARR:sbwinds) <index> get" - see AAO manual.
You can change "windinf" every which way you like. You could also filter out specific altitudes - or whatever. JScript is similar enough to Javascript that this shouldn't be a problem.

Alternatively, you can use the LVars that I've commented out (the red lines). Or you could use a HASHMAP which might be convenient too.

Edited by Lorby_SI

LORBY-SI

Share this post


Link to post
Share on other sites
On 3/15/2024 at 3:57 PM, Bam2000 said:

Hi, 

i cannot find Wind Information from Simbrief. Is there any chance to get the following Numbers from the Simbrief FB as a Variable to use on Streamdeck?

 

So - did you use my script above? Did it do what you wanted? Should it be doing something else?

What is the use case here? Isn't that value just a prediction, outdated once you actually get to that point? 


LORBY-SI

Share this post


Link to post
Share on other sites
On 3/17/2024 at 9:12 AM, Lorby_SI said:

So - did you use my script above? Did it do what you wanted? Should it be doing something else?

What is the use case here? Isn't that value just a prediction, outdated once you actually get to that point? 

hey, sorry did not receive any notification for this message, so did not test yet. Will do in the evening. Thanks for the Guide 🙂

Share this post


Link to post
Share on other sites

A few additional helpful AAO scripts:

This opens SimBrief ready to input a new flight

(EXEC:https://dispatch.simbrief.com/options/new)

This downloads the entire OFP package from SimBrief into a file "ofp.xml" on your desktop. This can be opened and read with any text editor.

(WSH:jscript|AaoEntry)

function AaoEntry(){
  // your SimBrief user name goes here
  var sbuser = '<yoursimbriefnamehere>';
  // query SimBrief
  var xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");   
  var commandStr = "https://www.simbrief.com/api/xml.fetcher.php?username=" + sbuser;
  xmlHttpReq.open("POST", commandStr, false);
  xmlHttpReq.send();
  var content = xmlHttpReq.responseText;
  var fso = new ActiveXObject("Scripting.FileSystemObject");
  // your Windows user name goes here
  var outFile = fso.OpenTextFile("C:\\Users\\<yourusername>\\Desktop\\ofp.xml", 2, true, -1);
  outFile.Write(content);
  outFile.Close();
}

 

  • Like 1

LORBY-SI

Share this post


Link to post
Share on other sites
Posted (edited)
On 3/15/2024 at 9:12 PM, Lorby_SI said:

For anyone interested, here is how you would query simbrief and extract the wind data at a specific point of your flight plan

Initialization script:


'yoursimbriefuser'·(>L:simbrief_user,·String)·
'TOC'·(>L:fix_icao,·String)·
1·(>K:Test-SimBriefWinds)

Query script (using a JScript in AAO, which in this case is a script in the group "Test" with the title "SimBriefWinds" - see >K: call above)


(WSH:jscript|AaoEntry)

function AaoEntry(){
  var sbuser = (L:simbrief_user, String);
  var fix_icao = (L:fix_icao, String);
  (STRARR:sbwinds).clear();
  var xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");   
  var commandStr = "https://www.simbrief.com/api/xml.fetcher.php?username=" + sbuser;
  xmlHttpReq.open("POST", commandStr, false);
  xmlHttpReq.send();
  var content = xmlHttpReq.responseText;
  var dom = new ActiveXObject("msxml2.DOMDocument.6.0");
  dom.async = false;
  dom.loadXML(content); 
  var objNodeList = dom.documentElement.selectNodes("navlog/fix");
  for (var i = 0; i < objNodeList.length; i++){
    var chkFix = objNodeList[i].getElementsByTagName("ident")[0].text;
    if (chkFix === fix_icao ){
       var winds = objNodeList[i].getElementsByTagName("wind_data");
       if (winds && winds.length > 0){
         var levels = winds[0].getElementsByTagName("level");
         for (var l = 0; l < levels.length; l++){ 
             var alt = levels[l].getElementsByTagName("altitude")[0].text;
             var dir = levels[l].getElementsByTagName("wind_dir")[0].text;
             var spd = levels[l].getElementsByTagName("wind_spd")[0].text;
             var oat = levels[l].getElementsByTagName("oat")[0].text;
	         var windinf = "" + alt + " " + dir + "/" + spd + " " + oat + "C";
             (STRARR:sbwinds).push(windinf);
             // var script = "\'" + dir + "/" + spd + " " + oat + "\'"; 
             // script = script + " (>L:wind_" + alt + ", String)";
             // AaoCmd.exec(script); 
         }
       }
       break;
    }
  }
}

The result is a string array that contains the wind information for the various altitudes that were in the SimBrief report
"0 16/3 14C"
"5000 16/3 5C"
"10000 101/1 -5C"
"14000 241/6 -13C"

etc.

 

If i execute the Script should i recveice the 

"0 16/3 14C"
"5000 16/3 5C"
"10000 101/1 -5C"
"14000 241/6 -13C"

etc.

as an output? or should i just see the JSCript inside the "Debug Window" ?

because i don't really now how to access the data after executing the JScript 😞I'm sorry but iam a complety noob in regards of Script Languages

EDIT: i commented also the red part out by removing the // and executed it. Then i tried to read the L:wind_ variable but it just gives me a "0" 

 

I need the data for some Airline SOP that require me to enter these OAT for the TOC inside the FMS of the 737. And i have created a Streamdeck profile that shows me all the relevant information from the Simbrief Briefing file so its easier and faster to enter 🙂

Edited by Bam2000

Share this post


Link to post
Share on other sites
Posted (edited)
53 minutes ago, Bam2000 said:

as an output? or should i just see the JSCript inside the "Debug Window" ?

See my post above:

The values in the array can be read with "(STRARR:sbwinds) <index> get" - see AAO manual.

I'd suggest using the "Watch simulator variables" Dialog. Once the script has been run, the array is in the second group from the top.

Edited by Lorby_SI

LORBY-SI

Share this post


Link to post
Share on other sites
Posted (edited)
56 minutes ago, Bam2000 said:

Then i tried to read the L:wind_ variable but it just gives me a "0" 

This is not one LVar, it is a String LVar for each flight level.

Again, use the "Watch simulator variables" dialog, after the script has been run the variables are in the first group

Edited by Lorby_SI

LORBY-SI

Share this post


Link to post
Share on other sites
Posted (edited)

okay understand now i see some values in the AAO RPN Script Processing. Sadly these doesn't match my Simbrief values for the TOC

49wvupao.png

Edited by Bam2000

Share this post


Link to post
Share on other sites
Posted (edited)
54 minutes ago, Bam2000 said:

Sadly these doesn't match my Simbrief values for the TOC

Believe it or not, but they are the SimBrief values for TOC in person, taken from the actual SimBrief download. The table in your screenshot is also in the OFP package (=in the same download), a bit further down. But it is a lot harder to get to programmatically, because it is just a big mass of text. Not impossible, but hard to do. The values in the LVars are actual data fields for each waypoint of your SimBrief route - check my initial screenshot of the XML structure.

You would have to ask SimBrief why they have two different wind tables in the same OFP package...

Edited by Lorby_SI

LORBY-SI

Share this post


Link to post
Share on other sites
53 minutes ago, Bam2000 said:

i see some values in the AAO RPN Script Processing

That is not the correct place to look for them.


LORBY-SI

Share this post


Link to post
Share on other sites
Posted (edited)

This script will return the table your screenshot shows and write it into "(L:tocwinds, String)"
Make sure to supply your actual SimBrief user name.

(WSH:jscript|AaoEntry)

function AaoEntry(){
  var sbuser = "<yoursimbriefusername>";
  var xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");   
  var commandStr = "https://www.simbrief.com/api/xml.fetcher.php?username=" + sbuser;
  xmlHttpReq.open("POST", commandStr, false);
  xmlHttpReq.send();
  var content = xmlHttpReq.responseText;
  var dom = new ActiveXObject("msxml2.DOMDocument.6.0");
  dom.async = false;
  dom.loadXML(content); 
  var objNodeList = dom.documentElement.selectNodes("text/plan_html");
  if (objNodeList && objNodeList.length > 0){
    var htm = objNodeList[0].text;
    var lines = htm.split("\n");
    for (var i = 0; i < lines.length; i++){
       var tocPos = lines[i].indexOf("T O C"); 
       if (tocPos > 0){
          var res = "";
          for (var j = 0; j < 5 ;j++){
            res = res + lines[1 + i  +j].substr(tocPos, 16) + "| ";
          }
          res = res.substr(0, res.length  -2);
          (L:tocwinds, String) = res;
          break;
       }
    }
  }
}

 

Edited by Lorby_SI
  • Like 1

LORBY-SI

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Tom Allensworth,
    Founder of AVSIM Online


  • Flight Simulation's Premier Resource!

    AVSIM is a free service to the flight simulation community. AVSIM is staffed completely by volunteers and all funds donated to AVSIM go directly back to supporting the community. Your donation here helps to pay our bandwidth costs, emergency funding, and other general costs that crop up from time to time. Thank you for your support!

    Click here for more information and to see all donations year to date.
×
×
  • Create New...