• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

FSX XML coding help needed - array?

Messages
43
Country
germany
Hi folks,
I have managed to get an XML gauge to work that uses the fs9gps TrafficInfo to retrieve AI positions. All it needs to do is to write bearing, distance, altitude to L: Vars. The gauge has no visible output.
Can anybody tell me how I can modify the code to allow for e.g. 15 aircraft to be polled (without paste & copy), I'm thinking of an array.
It seems arrays are a difficult topic in XML?
Thanks!

Code:
<Gauge Name="TrafficInfoTW" Version="1.0">
<Size X="400" Y="300" />
        <Update Frequency="2" Hidden="No">
                16 (&gt;C:ITrafficInfo:Filter, enum)  <!-- Bit 4: TRAFFIC_FILTER_IN_AIR
-->
                15 (&gt;C:ITrafficInfo:Radius,nmiles)
                20 (>C:ITrafficInfo:MaxVehicles)
                0 d (&gt;C:ITrafficInfo:CurrentVehicle,enum)
                    (&gt;C:ITrafficInfo:SelectedVehicle,enum) 

                (A:PLANE LATITUDE,degrees) (&gt;C:fs9gps:GeoCalcLatitude1,degrees) 
                (A:PLANE LONGITUDE,degrees) (&gt;C:fs9gps:GeoCalcLongitude1,degrees) 
                (C:ITrafficInfo:S:PLANE LATITUDE,degrees)  (&gt;L:temp_lat,degrees) 
                (L:temp_lat) (&gt;C:fs9gps:GeoCalcLatitude2,degrees) 
                (C:ITrafficInfo:S:PLANE LONGITUDE,degrees) (&gt;L:temp_lon,degrees) 
                (L:temp_lon,degrees) (&gt;C:fs9gps:GeoCalcLongitude2,degrees) 
                (C:fs9gps:GeoCalcBearing,degrees) (&gt;L:TCAS_bearing_0,degrees)
                (C:fs9gps:GeoCalcDistance,nmiles) (&gt;L:TCAS_distance_0,nmiles)
                (C:ITrafficInfo:S:PLANE ALTITUDE, feet) (&gt;L:TCAS_altitude_0, feet)                       
            
        </Update>
 </Gauge>
 
Use Tom's XMLTools (available here in the library).
Great for using tables/arrays in XML gauges ...

Rob
 
I agree with Rob's recommendation to use XMLTools (specifically, the XMLVars class) to create your arrays for ITraffic information.

As an additional reference, you might take a look at the ExampleMovingMap1.xml gauge bundled with FSMAP Guidebook. Download the Example XML Map Gauges.zip file.

Among other things, it contains a fully functional XML TCAS gauge that uses XMLVars for the necessary AI Traffic info arrays. It will also provide some insight as to use of the ITrafficInfo variable SelectedVehicleID to keep track of specific AI Traffic as you cycle through CurrentVehicle. Actually, as currently written, your Update section doesn't loop through 20 vehicles, but, instead, returns information only on the closest traffic, CurrentVehicle 0.

Hope this helps,

Bob
 
Thanks for your tips. I will look into it.

FYI the actual gauge will be "stupid". It must only provide the altitude, bearing and distance of AI in LVars. These will be accessed through Air Manager where the actual TCAS functionality will be programmed.
 
A few items regarding TCAS simulation:

1. An ItrafficInfo search returns traffic in ascending distance from the reference (the User's) aircraft. In one Update cycle, the order may be Aircraft A, Aircraft B, Aircraft C, Aircraft D. The next Update cycle, it could be Aircraft B, Aircraft A, Aircraft C, Aircraft D. TCAS calculations are aircraft specific, not distance from the reference aircraft specific. Therefore, one must pass information to a TCAS calculator based on specific aircraft, and that is done using SelectedVehicleID as part of the information array.

2. TCAS alarm thresholds are based on time separation, not distance. That forces you to keep track of a specific traffic aircraft from one Update cycle to the next, so that rate of change information can be determined. Again, that aircraft's order in the ItrafficInfo search output often changes from one cycle to the next, so keep track of the aircraft's SelectedVehicleID, not its CurrentVehicle order.

3. You are correct to view this as an array issue. I use XMLVars to create the aircraft-specific arrays in my TCAS alarm calculations, but bear in mind that XMLVar variables are C:Vars, not L:Vars. If, for some reason, your TCAS manager program cannot read C:Vars, then you may be in trouble. And, you can't assign your XMLVar array into say, 15 L:Vars because you will lose the aircraft-specific information that TCAS relies on.


Regards,

Bob
 
Back
Top