View Single Post
  #1  
Old 11-02-2011, 03:17 AM
FST FST is offline
Approved Member
 
Join Date: Oct 2011
Posts: 19
Default black box in-flight data recorder

Howdy all

Figured I would post my 'black box' script and corresponding mission file. It is a basic flight test data recorder, nothing fancy, nothing new just took a few different examples and put them into one script file. I made if for those who are into testing, but might not be into C# programing. The script does two things; one it displays to the screen (HUD) the time, heading, altitude, speed, and air temp, and two it logs this data to a csv file on the root of your C drive called 'FLIGHT_TEST_DATA.CSV'. If ya have MS EXCEL you can open er up and do all sorts of stuff with it.

Here is the script code
Code:
//-$debug
using System;
using System.Threading;
using System.Collections.Generic;
using maddox.game;
using maddox.game.world;
using maddox.GP;


public class Mission : AMission
{
    //flag
    bool done = false;

    //Create Stream
    System.IO.StreamWriter sw;

    //Log Line
    string str_log = System.String.Empty;

    //Create Log File
    System.IO.FileInfo fi = new System.IO.FileInfo("C:\\FLIGHT_TEST_DATA.CSV");

    //Script Main
    public override void OnTickGame()
    {
        //Init Ticker
        base.OnTickGame();

        //loop rate set to ~1/30th of a second, i.e. 30 ticks = ~1 second
        if (Time.tickCounter() % 30 == 1)
        {
            //Get player aircraft
            AiAircraft curPlane = GamePlay.gpPlayer().Place() as AiAircraft;

            if (curPlane != null)
            {
                //Instrumentation - Machine Spatial
                double I_VelocityIAS = curPlane.getParameter(part.ParameterTypes.I_VelocityIAS, -1);
                double I_Altitude = curPlane.getParameter(part.ParameterTypes.I_Altitude, -1);
                double I_Variometer = curPlane.getParameter(part.ParameterTypes.I_Variometer, -1);
                double I_MagneticCompass = curPlane.getParameter(part.ParameterTypes.I_MagneticCompass, -1);

                //Parameters - Machine Spatial
                double Z_Overload = curPlane.getParameter(part.ParameterTypes.Z_Overload, -1);
                double Z_AltitudeAGL = curPlane.getParameter(part.ParameterTypes.Z_AltitudeAGL, -1);
                double Z_AltitudeMSL = curPlane.getParameter(part.ParameterTypes.Z_AltitudeMSL, -1);
                double Z_VelocityIAS = curPlane.getParameter(part.ParameterTypes.Z_VelocityIAS, -1);
                double Z_VelocityTAS = curPlane.getParameter(part.ParameterTypes.Z_VelocityTAS, -1);
                double Z_VelocityMach = curPlane.getParameter(part.ParameterTypes.Z_VelocityMach, -1);
                double Z_AmbientAirTemperature = curPlane.getParameter(part.ParameterTypes.Z_AmbientAirTemperature, -1);

                //Game Time
                double dtime = Time.current();

                //Log Header
                if (done == false)
                {
                    //Write Header
                    sw = fi.AppendText();
                    sw.WriteLine("TIME,HDG,ALT,IAS,ROC,TEMP");
                    sw.Close();
                    done = true;
                }

                //Log Data
                str_log =   dtime.ToString("0.00") + ","                //TIME
                            I_MagneticCompass.ToString("0.00") +  ","   //HDG
                            I_Altitude.ToString("0.00") +  ","          //ALT
                            I_VelocityIAS.ToString("0.00") +  ","       //IAS
                            I_Variometer.ToString("0.00") +  ","        //ROC
                            Z_AmbientAirTemperature.ToString("0.00");   //TEMP

                sw = fi.AppendText();
                sw.WriteLine(str_log);
                sw.Close();

                //Display HUD
                GamePlay.gpHUDLogCenter("TIME: " + dtime.ToString("0.00") +                         //TIME
                                        "    HDG: " + I_MagneticCompass.ToString("0.00") +          //HDG
                                        "    ALT: " + I_Altitude.ToString("0.00") +                 //ALT
                                        "    IAS: " + I_VelocityIAS.ToString("0.00") +              //IAS
                                        "    ROC: " + I_Variometer.ToString("0.00") +               //ROC
                                        "   TEMP: " + Z_AmbientAirTemperature.ToString("0.00"));    //TEMP
            }
        }
    }
}
Here is the mission code
Code:
[PARTS]
  core.100
  bob.100
[MAIN]
  MAP Land$English_Channel_1940
  BattleArea 150000 100000 100000 150000 1000
  TIME 12
  WeatherIndex 0
  CloudsHeight 1000
  BreezeActivity 10
  ThermalActivity 10
  player BoB_RAF_F_FatCat_Early.000
[GlobalWind_0]
  Power 3.000 0.000 0.000
  BottomBound 0.00
  TopBound 1500.00
  GustPower 5
  GustAngle 45
[splines]
[AirGroups]
  BoB_RAF_F_FatCat_Early.01
[BoB_RAF_F_FatCat_Early.01]
  Flight0  1
  Class Aircraft.SpitfireMkIIa
  Formation VIC3
  CallSign 28
  Fuel 100
  Weapons 1
  SetOnPark 1
  Skill 1 1 1 1 1 1 1 1
[BoB_RAF_F_FatCat_Early.01_Way]
  TAKEOFF 141594.60 233985.67 0 0
  NORMFLY 140789.51 233939.32 10000.00 300.00
[CustomChiefs]
[Stationary]
[Buildings]
[BuildingsLinks]
To use it just copy the 'black_box.mis' and 'black_box.cs' files into your 'USER' single folder

C:\Users\<YOUR NAME HERE>\Documents\1C SoftClub\il-2 sturmovik cliffs of dover\missions\Single

Than from the FMB open the 'black_box.mis' file and select 'Play Mission'! When yer done, goto the root of your C drive and there you will find the 'FLIGHT_TEST_DATA.CSV'. Note after each run, you should rename this file, because each time you run the mission it just keeps adding to (append) this file

Also keep in mind parr.. The HUD display and log file have some tumble weed looking values while the plane is on the ground, once she gets up in the blue the values seem to be fine, Also note the ROC value in the script is the indicated value, that is to say it is the value used to drive the cockpit gauges. Now on the spit, the gauge has a max of 4000fpm, and thus the indicated value is limited to that value, even though the ROC is higher than that. When I tested a 109E4 the ROC value was stuck at zero.. So there are some issues, but, there are other values you can use for ROC, but I have not had enough time to ponder over them to figure out them thar units yet. That's all I can recollect fer now, try er out and let me know what ya think.

That's about it parr, good luck!

Oh, if yah are lazy like me, below is an attached zip file you can dl that has all the above code and an example track
Attached Images
File Type: jpg airborn_cockpit.jpg (19.2 KB, 93 views)
File Type: jpg airborn_external.jpg (16.4 KB, 75 views)
Attached Files
File Type: zip black_box.zip (400.5 KB, 38 views)

Last edited by FST; 11-02-2011 at 01:47 PM.
Reply With Quote