View Single Post
  #10  
Old 11-06-2011, 06:20 PM
FST FST is offline
Approved Member
 
Join Date: Oct 2011
Posts: 19
Default

Quote:
Originally Posted by E69_vencejo View Post
Sure I can wait until Sunday ...
Hey Parr

Ok, re-worked the script a little bit for ya. See below

Code:
//-$debug
using System;
using maddox.game;
using maddox.game.world;

public class Mission : AMission
{
    //User Control
    bool do_get = true;
    bool do_log = true;
    bool do_hud = true;

    //Define and Init
    AiAircraft cur_Plane;
    double cur_Time = 0.0;
    bool flag_do_once = false;
    double I_VelocityIAS = 0.0;
    double I_Altitude = 0.0;
    double I_Variometer = 0.0;
    double I_Peilzeiger = 0.0;
    double I_MagneticCompass = 0.0;
    double I_Slip = 0.0;
    double Z_Overload = 0.0;
    double Z_AltitudeAGL = 0.0;
    double Z_AltitudeMSL = 0.0;
    double Z_VelocityIAS = 0.0;
    double Z_VelocityTAS = 0.0;
    double Z_VelocityMach = 0.0;
    double Z_AmbientAirTemperature = 0.0;
    string str_log = "";
    string str_hud = "";
    string str_hdr = "";
    string str_tmp = "";

    //Create Stream
    System.IO.StreamWriter sw;

    //Create Log File
    System.IO.FileInfo fi = new System.IO.FileInfo("C:\\BLACK_BOX_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
            cur_Plane = GamePlay.gpPlayer().Place() as AiAircraft;

            if (cur_Plane != null)
            {
                //Get Data ------------------------------------------------------------------------
                if (do_get)
                {
                    cur_Time                = Time.current();
                    I_MagneticCompass       = cur_Plane.getParameter(part.ParameterTypes.I_MagneticCompass, -1);
                    I_Altitude              = cur_Plane.getParameter(part.ParameterTypes.I_Altitude, -1);
                    I_VelocityIAS           = cur_Plane.getParameter(part.ParameterTypes.I_VelocityIAS, -1);
                    I_Variometer            = cur_Plane.getParameter(part.ParameterTypes.I_Variometer, -1);
                    I_Peilzeiger            = cur_Plane.getParameter(part.ParameterTypes.I_Peilzeiger, -1);
                    I_Slip                  = cur_Plane.getParameter(part.ParameterTypes.I_Slip, -1);
                    Z_Overload              = cur_Plane.getParameter(part.ParameterTypes.Z_Overload, -1);
                    Z_AltitudeAGL           = cur_Plane.getParameter(part.ParameterTypes.Z_AltitudeAGL, -1);
                    Z_AltitudeMSL           = cur_Plane.getParameter(part.ParameterTypes.Z_AltitudeMSL, -1);
                    Z_VelocityIAS           = cur_Plane.getParameter(part.ParameterTypes.Z_VelocityIAS, -1);
                    Z_VelocityTAS           = cur_Plane.getParameter(part.ParameterTypes.Z_VelocityTAS, -1);
                    Z_VelocityMach          = cur_Plane.getParameter(part.ParameterTypes.Z_VelocityMach, -1);
                    Z_AmbientAirTemperature = cur_Plane.getParameter(part.ParameterTypes.Z_AmbientAirTemperature, -1);
                }

                //Display HUD ---------------------------------------------------------------------
                if (do_hud)
                {
                    str_hud = "TIME: " + cur_Time.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
                    GamePlay.gpHUDLogCenter(str_hud);
                }

                //Log Data ------------------------------------------------------------------------
                if (do_log)
                {
                    str_hdr =   "TIME,HDG,ALT,IAS,ROC,PEI,SLIP,OL,AGL,MSL,WIAS,WTAS,WMACH,TEMP";
                    str_log =   cur_Time.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
                                I_Peilzeiger.ToString("0.00") + "," +       //PEI
                                I_Slip.ToString("0.00") + "," +             //SLIP
                                Z_Overload.ToString("0.00") + "," +         //OL
                                Z_AltitudeAGL.ToString("0.00") + "," +      //AGL
                                Z_AltitudeMSL.ToString("0.00") + "," +      //MSL
                                Z_VelocityIAS.ToString("0.00") + "," +      //WIAS
                                Z_VelocityTAS.ToString("0.00") + "," +      //WTAS
                                Z_VelocityMach.ToString("0.00") + "," +     //WMACH
                                Z_AmbientAirTemperature.ToString("0.00");   //TEMP

                    if (flag_do_once == false)
                        str_tmp = str_hdr;
                    else
                        str_tmp = str_log;

                    sw = fi.AppendText();
                    sw.WriteLine(str_tmp);
                    sw.Close();
                }

                //Set Flag
                flag_do_once = true;

            }
        }
    }
}
Note at the top of the script where it says..

Code:
    //User Control
    bool do_get = true;
    bool do_log = true;
    bool do_hud = true;
There you can control what you want to happen.. So delete the code that is in your current 'black_box.cs" file and copy-n-paste this code into your 'black_box.cs' file.

1st TEST

Code:
    //User Control
    bool do_get = true;
    bool do_log = false;
    bool do_hud = true;
Set the values above where data logging is OFF.

Than run the 'black_box.mis'. You should see the HUD but you will not be logging any data..

If you see the HUD, than we have narrowed down our search..

If you don't see the HUD goto next test

2nd TEST

Code:
    //User Control
    bool do_get = true;
    bool do_log = true;
    bool do_hud = false;
Set the values above where HUD display is OFF.

Than run the 'black_box.mis'. You should NOT see the HUD but you should be logging any data..

Let the mission run for a few min, than exit the game, goto the root of your C:\ drive and open the file called 'BLACK_BOX_DATA.CSV' to see if any data was written to the file..

If you see the data in the file, than we have narrowed down our search..

If you don't see data in the file goto next test

3rd TEST

Code:
    //User Control
    bool do_get = false;
    bool do_log = true;
    bool do_hud = true;
Set the values above where get data is OFF.

Than run the 'black_box.mis'. You should see the HUD and you should be logging any data.

Let the mission run for a few min, while it is 'see' if all the HUD values are ZERO (0.0), they should be because we did not 'get' any data thus only the init values are displayed. Than exit the game and goto the root of your C:\ drive and open the file called 'BLACK_BOX_DATA.CSV' to see if any data was written to the file.. All the data should be ZERO (0.00)

If you saw all ZEROS in the HUD display and you see all ZEROS in the log file than we have narrowed down our error to a 'get' issue

If you didn't see the HUD display and the log file is empty.. Than.. well.. shoot Ill have to ponder it some more! ;l

PS before you start each TEST above goto the root of your C:\ drive and delete the file called 'BLACK_BOX_DATA.CSV' if there is one.
Reply With Quote