Now, on another note, Mr. Jimi, sir: I'm doing some work learning to code in XML. I'm trying to start simple. I want to see how the Anti-Skid switch coding looks, ie: How YOU all coded it, but I can't seem to find it. I have a bad feeling that it's in the .dll the plane uses. If it is, I will work on finding code like it someplace else. I just want to, not copy, but look and see, so I can learn to do the same sort of thing. Maybe with light switches, or other type circuits. I am just curious.
Like I say, if it's not available to look at, I'll find something else to work with.
Hey Pat,
First off, copy all you want. This project has definitely taught me a lot and hopefully it will teach you and others as well. Not all of it is my code so just make sure to give credit where it's due.
To monitor a gauge...That being said, there are a few references/sources you will need to code in FSX. The first is the list of Simulation Variables or SIMVARs for short. You can find them in the SDK, or by simply doing a Google search for "FSX SIMVARs" or "P3D SIMVARs". Here's the link:
https://msdn.microsoft.com/en-us/library/cc526981.aspx . From there, a spreadsheet of the variables should show up. These are all of the variables that are being actively monitored within the sim.
In the FSX XML, the standard format for writing a SIMVAR is as follows:
(VAR Type, Actual Variable being monitored, Unit of measurement)
Take the Simvar for Pressure Altitude for example, it would look like this:
(A:PRESSURE ALTITUDE, feet)
A = Indicates SIM Var from the AIRCRAFT. E: is for ENVIRONMENTAL data such as computer, server or sim time etc. P: is for PROGRAM data such as Sim Rate. Most of the time, you will be dealing with "A" Variables.
PRESSURE ALTITUDE = The actual condition that you want to monitor. This is listed in the "Simulation Variable" column of the SIMVAR chart as described above.
feet = The unit of measurement of the variable you are monitoring. For the above, it will display numerical results in feet. The standard unit used for each variable is usually listed next to the listed variable in the "Unit" column of the SIMVAR chart. If you wanted it in meters, simply replace "feet" with "meters". If it's a digital function (on or off), "Bool" (short for Boolean) will work. Your Anti-Skid switch would fall in this category.
So to wrap it all together to monitor your Anti-Skid switch, the code would look like this:
(A:ANTISKID BRAKES ACTIVE, Bool)
Since we're monitoring the variable from the Airplane, "A:" was used, ANTISKID BRAKES ACTIVE and Bool were pulled from the SIMVAR list.
I usually use my "DATA GAUGE" (Shift+8) to monitor the states of certain Simulation Variables while working on certain gauge/functions. The DataGuage.xml can be found in the Panel.Fleet/Gauges folder. There is a lot going on in there if you open it, but basically all of the entries in there are the display parameters for the info on the screen and are paired. The first entry shows the info to display the title of the variable (i.e.
<Gaugestring>Altitude</Gaugestring>
) , and the second grouping shows, the display parameters for the actual data from the simulation variable
<Gaugestring>%((i.e. (A:PRESSURE ALTITUDE, feet))3.1%</Gaugestring>
). To use the gauge, simply find a variable listed that you want to replace with yours, replace it with the variable you want to use, and also replace the title of that variable in the grouping above so you can easily find it. Once you are done, save the file, reload the aircraft in the sim, press Shift+8 and look for your data. For your Antiskid entry, and because it is a Boolean variable, it will return either a "1", indicating that the Antiskid brakes are active, or a "0" showing that they are inactive.
Now, that allows you to MONITOR something..... To get the sim to DO something is a little different....Action items are known as "Key Events" in the sim, and there is a finite list of "doable" things in the sim. That list is contained in another reference, and can be found through Google as well by searching "FSX Event IDs" or "P3D Event IDs". Linked at:
https://msdn.microsoft.com/en-us/library/cc526980.aspx .
The standard for writing an Event ID is as follows:
(Trigger, Event Type, Event ID)
In practicality, it looks like this:
(>K:ANTISKID_BRAKES_TOGGLE)
or
(>K:ANTISKID_BRAKES_TOGGLE)
">" and ">" are the triggers and mean the same thing. They basically tell the gauge to execute/assign what comes after it.
For the sim, "K" will always be used to indicate a key event and you can find the list of Event IDs at the last link provided above.
Tying it all together......Now that you know how to MONITOR something and also to DO something, you can now create basic "IF/THEN" statements in XML. This basically states that "IF all of these things are true, THEN do this action".
Basic structure for an XML IF/THEN Statement is as follows:
(A:Variable 1, unit) parameter
(Variable 2, unit) parameter and
(Variable 3 & so on, unit) parameter and
if{ (>K:Event_ID) } els { (>K:Other Event_ID) }
Few things to note here....
-I put parameter in the example above. This is to define the specifics of your statement. In the case of the previously used Altitude Variable, I might use one of the following to better define parameters for the gauge:
(A:PRESSURE ALTITUDE, feet) 10000 <
=> This means that this IF statement rings "true" if the aircraft's pressure altitude is at 10000 feet and below. "<" translates to "and less than" so literally "10000 feet and less than"
(A:PRESSURE ALTITUDE, feet) 10000 >
=> This means that this IF statement rings "true" if the aircraft's pressure altitude is at 10000 feet and above. ">" translates to "and greater than" so literally "10000 feet and greater than"
(A:PRESSURE ALTITUDE, feet) 10000 ==;
=> This means that this IF statement rings "true" if the aircraft's pressure altitude is equal 10000 feet exactly. "==" translates to "equal to" so literally "10000 feet exactly"
-For Boolean variables, no entry behind the variable indicates that the variable rings "true" if the variable is active, while an exclamation point "!" indicates that the Boolean rings true if the variable is not active. For example, the variable (A:SIM ON GROUND, bool). Simply stating (A:SIM ON GROUND, bool) indicates that this variable rings true if the aircraft is on the ground. (A:SIM ON GROUND, bool) ! indicates that this variable rings true if the aircraft is airborne.
-If you are using more than one variable together to define your if statement, the word "and" or "&&" needs to be included at the end of the second stated variable and every subsequent variable to be included. If it's an "either/or", then the word "or" or "||" needs to be included.
-"Els" or Else statements, are used to indicate something to do be done until all of your "if statements" ring true. An example might be that you want a certain switch to only be activated under certain circumstances, but off under all other circumstances.
So as a final example I will do a basic if/then statement that instructs the sim to TOGGLE THE ANTISKID BRAKES if the sim detects the aircraft to be ON THE GROUND, BELOW 50 KNOTS, and only to toggle the Antiskid Brakes if they aren't already activated.
<Gauge:Example Antiskid Gauge>
<Element>
<Selection>
<Value>
(A:SIM ON GROUND, bool) <!-- Monitors whether the aircraft is on the ground or in the air. Statement is true if the aircraft is on the ground. -->
(A:AIRSPEED INDICATED, knots) 50 < and <!-- Monitors the indicated airspeed of the aircraft. Statement is true if the aircraft is below 50 KIAS. -->
(A:ANTISKID BRAKES ACTIVE, Bool) ! and <!-- Monitors the status of the Antiskid Brakes. Statement is true if Antiskid brakes are OFF/INACTIVE. -->
if{ (>K:ANTISKID_BRAKES_TOGGLE) } <!-- Tells the sim to toggle the antiskid brakes if all of the above statements are all true simultaneously. -->
</Value>
</Selection>
</Element>
</Gauge>
The last reference worth mentioning is the aircraft's "Modeldef". From my understanding, it basically displays all of the variables and event that are "baked" into the 3D model of the jet. Changing them would mean decompiling and recompiling the jet. None the less, very useful reference, especially when trying to tie certain buttons or switches within the cockpit to your gauges for functionality. Here you can see all of the great work that FSDreamTeam put into modeling the F/A-18 Cockpit.
Kinda a lengthy explanation, but that's all I got for now (lunch break is over). That's the basics. Let me know if you have more questions (as I'm sure you do) and I'll try my best to answer them. My best advice is to open an existing gauge, make small changes to them and reload the aircraft to see how things work/change. Once you get used to that, move on to bigger/better things....
-Jimi