コード例 #1
0
        private void getData()
        {
            try
            {
                myIndicator = JsonSerializer._download_serialized_json_data <indicator>(indicatorsurl);
                myState     = JsonSerializer._download_serialized_json_data <state>(statesurl);



                if (myState.valid == "true")
                {
                    decimal G        = Convert.ToDecimal(myState.Ny, culture);
                    decimal AoA      = Convert.ToDecimal(myState.AoA, culture);
                    decimal Alt      = Convert.ToDecimal(myIndicator.altitude_hour, culture);
                    decimal Vspeed   = Convert.ToDecimal(myState.Vy, culture);
                    int     Fuel     = Convert.ToInt32(myState.Mfuel) * 1000;                                   //MFuel and MFuel0 are given in integers
                    int     FuelFull = Convert.ToInt32(myState.Mfuel0);
                    int     Throttle = Convert.ToInt32(Convert.ToDecimal(myIndicator.throttle, culture) * 100); //TODO throttle variable only avialble in single engine aircraft
                    int     gear     = Convert.ToInt32(myState.gear);
                    int     IAS      = Convert.ToInt32(myState.IAS);                                            //unreliable?
                    int     flaps    = Convert.ToInt32(myState.flaps);
                    label.Content = myIndicator.type;

                    //BINGO FUEL
                    if (Fuel / FuelFull < 103 && Fuel / FuelFull > 100)
                    {
                        System.Media.SoundPlayer myPlayer;
                        myPlayer = new System.Media.SoundPlayer(Properties.Resources.Bingo);
                        myPlayer.PlaySync();
                    }

                    //STALL WARNING
                    if (cbx_a.IsChecked == true)
                    {   //Stall Warning Mandatory pre-definitnions
                        System.Media.SoundPlayer stall1;
                        System.Media.SoundPlayer stall2;
                        stall1 = new System.Media.SoundPlayer(Properties.Resources.AngleOfAttackOverLimit);
                        stall2 = new System.Media.SoundPlayer(Properties.Resources.MaximumAngleOfAttack);

                        if (AoA > User.Default.AoA && AoA < 20 && (myIndicator.gears_lamp == "1" || IAS > 100))
                        {
                            if (AoA < User.Default.AoA + 2)
                            {
                                stall1.Stop();
                                stall2.PlayLooping();
                            }
                            else
                            {
                                stall2.Stop();
                                stall1.PlayLooping();
                            }//multi-layer AoA warnings as a variable-pitch isn't supported by MS's package
                        }
                        else
                        {
                            stall1.Stop(); stall2.Stop();
                        }
                    }

                    //G OVERLOAD
                    if (cbx_g.IsChecked == true)
                    {
                        System.Media.SoundPlayer G1;
                        System.Media.SoundPlayer G2;
                        G1 = new System.Media.SoundPlayer(Properties.Resources.OverG);
                        G2 = new System.Media.SoundPlayer(Properties.Resources.GOverLimit);
                        if (G > User.Default.GForce)
                        {
                            if (G > User.Default.GForce + 4 - User.Default.GForce / (decimal)4)
                            {
                                G1.Stop();
                                G2.PlaySync();
                            }
                            else
                            {
                                G2.Stop();
                                G1.PlaySync();
                            }
                        }
                    }

                    //PULL UP Ground Proximity Warning
                    if (((0 - Vspeed) * ((IAS - 60) / 60 + (decimal)0.5)) > (Alt + 300))
                    {
                        System.Media.SoundPlayer myPlayer;
                        myPlayer = new System.Media.SoundPlayer(Properties.Resources.PullUp);
                        myPlayer.PlaySync();
                    }

                    //=========LOW PRIORITY WARNINGS=======
                    //GEAR UP/DOWN
                    if (User.Default.EnableGear == true && gear == 100 && IAS > User.Default.GearUp && myIndicator.gears_lamp == "0")
                    {
                        System.Media.SoundPlayer myPlayer;
                        myPlayer = new System.Media.SoundPlayer(Properties.Resources.GearUp);
                        myPlayer.PlaySync();
                    }

                    if (User.Default.EnableGear == true && (AoA < 20 || Vspeed > -10) && gear == 0 &&
                        IAS < User.Default.GearDown && IAS > 40 && Throttle < 20 && myIndicator.gears_lamp != "0" /*Alt < 500 && flaps > 20*/)
                    {
                        System.Media.SoundPlayer myPlayer;
                        myPlayer = new System.Media.SoundPlayer(Properties.Resources.GearDown);
                        myPlayer.PlaySync();
                    }
                }
                else
                {
                    dispatcherTimer1.Stop();
                    dispatcherTimer2.Start();
                }
            }
            catch (Exception ex)
            {
                tbx_msgs.Text = ex.Message;
                dispatcherTimer1.Stop();
                dispatcherTimer2.Start();
            }
        }
コード例 #2
0
        /// <summary>
        /// JSON saver
        /// </summary>
        ///

        /*
         * private void saveToJSON()
         * {
         *  //TODO
         *  try
         *  {
         *      myState = JsonSerializer._download_serialized_json_data<state>(statesurl);
         *      if ((myState.valid == "true") && (myIndicator.valid == "true") && (myIndicator.type != "dummy_plane") && (myIndicator.type != null))
         *      {
         *          //using (StreamReader file = File.OpenText(myIndicator.type + ".json"));
         *
         *          //string json = File.ReadAllText("myobjects.json");
         *          //var playerList = JsonConvert.DeserializeObject<List<Player>>(json);
         *
         *          string filePath = Path.GetFullPath(Path.Combine(Environment.CurrentDirectory, @"..\..\..\")) + @"Data\Country.json";
         *
         *          string _countryJson = File.ReadAllText(filePath);
         *
         *          //var _country = JsonConvert.DeserializeObject<List<Country>>(_countryJson);
         *
         *
         *          //save file thing here
         *          //File.WriteAllText("myobjects.json", JsonConvert.SerializeObject(playerList));
         *      }
         *  }
         *  catch (Exception ex)
         *  {
         *      tbx_msgs.Text = ex.Message;
         *      dispatcherTimer1.Stop();
         *      dispatcherTimer2.Start();
         *  }
         * }
         */

        private void getData()
        {
            try
            {
                myIndicator = JsonSerializer._download_serialized_json_data <indicator>(indicatorsurl);
                myState     = JsonSerializer._download_serialized_json_data <state>(statesurl);

                if ((myState.valid == "true") && (myIndicator.valid == "true") && (myIndicator.type != "dummy_plane") && (myIndicator.type != null))
                {
                    decimal G        = Convert.ToDecimal(myState.Ny, culture);
                    decimal AoA      = Convert.ToDecimal(myState.AoA, culture);
                    decimal Vspeed   = Convert.ToDecimal(myState.Vy, culture);
                    int     Fuel     = Convert.ToInt32(myState.Mfuel) * 1000;                                   //MFuel and MFuel0 are given in integers
                    int     FuelFull = Convert.ToInt32(myState.Mfuel0);
                    int     Throttle = Convert.ToInt32(Convert.ToDecimal(myIndicator.throttle, culture) * 100); //TODO throttle variable only avialble in single engine aircraft
                    int     gear     = Convert.ToInt32(myState.gear);
                    int     Alt      = Convert.ToInt32(myState.H, culture);
                    int     IAS      = Convert.ToInt32(myState.IAS);
                    int     flaps    = Convert.ToInt32(myState.flaps);

                    Console.Write(myState.AoS);
                    //tbx_msgs.Text = myState.AoS;
                    decimal AoS = Convert.ToDecimal(myState.AoS);
                    int     TAS = Convert.ToInt32(myState.TAS);
                    label.Content = myIndicator.type;

                    //BINGO FUEL
                    if (cbx_fuel.IsChecked == true && Fuel / FuelFull < 103 && Fuel / FuelFull > 100 && Throttle > 0)
                    {
                        System.Media.SoundPlayer myPlayer;
                        myPlayer = new System.Media.SoundPlayer(Properties.Resources.Bingo);
                        myPlayer.PlaySync();
                    }

                    //STALL WARNING
                    if (cbx_a.IsChecked == true)
                    {   //Stall Warning Mandatory pre-definitnions
                        System.Media.SoundPlayer stall1;
                        System.Media.SoundPlayer stall2;
                        stall1 = new System.Media.SoundPlayer(Properties.Resources.AngleOfAttackOverLimit);
                        stall2 = new System.Media.SoundPlayer(Properties.Resources.MaximumAngleOfAttack);

                        if (AoA > User.Default.AoA * 0.8 && AoA < User.Default.AoA + 10 && (myIndicator.gears_lamp == "1" || IAS > 100))
                        {
                            if (AoA < User.Default.AoA)
                            {
                                stall1.Stop();
                                stall2.PlayLooping();
                            }
                            else
                            {
                                stall2.Stop();
                                stall1.PlayLooping();
                            }//multi-layer AoA warnings as a variable-pitch isn't supported by MS's package
                        }
                        else
                        {
                            stall1.Stop(); stall2.Stop();
                        }
                    }

                    //G OVERLOAD
                    if (cbx_g.IsChecked == true)
                    {
                        System.Media.SoundPlayer G1;
                        System.Media.SoundPlayer G2;
                        G1 = new System.Media.SoundPlayer(Properties.Resources.OverG);
                        G2 = new System.Media.SoundPlayer(Properties.Resources.GOverLimit);
                        if (G > User.Default.GForce || (double)G < -0.4 * User.Default.GForce)
                        {
                            if (G > User.Default.GForce + 3 - User.Default.GForce / (decimal)3)
                            {
                                G1.Stop();
                                G2.PlaySync();
                            }
                            else
                            {
                                G2.Stop();
                                G1.PlaySync();
                            }
                        }
                    }

                    //PULL UP Ground/sea level Proximity Warning
                    //desirable to have about 3 seconds before crash
                    if (cbx_pullup.IsChecked == true && 0 - Vspeed * (2 + (decimal)Math.Pow(IAS / 100, 0.7)) > Alt)
                    {
                        System.Media.SoundPlayer myPlayer;
                        myPlayer = new System.Media.SoundPlayer(Properties.Resources.PullUp);
                        myPlayer.PlaySync();
                    }

                    //Overspeed
                    if (cbx_overSpeed.IsChecked == true && IAS > User.Default.OverSpeed)
                    {
                        System.Media.SoundPlayer myPlayer;
                        myPlayer = new System.Media.SoundPlayer(Properties.Resources.OverSpeed);
                        myPlayer.PlaySync();
                    }

                    //GEAR UP/DOWN
                    if (User.Default.EnableGear == true)
                    {
                        if (gear == 100 && IAS > User.Default.GearUp && myIndicator.gears_lamp == "0")
                        {
                            System.Media.SoundPlayer myPlayer;
                            myPlayer = new System.Media.SoundPlayer(Properties.Resources.GearUp);
                            myPlayer.PlaySync();
                        }

                        if ((AoA < 20 || Vspeed > -10) &&
                            IAS < User.Default.GearDown && IAS > 40 /*Alt < 500 && flaps > 20*/)
                        {
                            float Deg2Rad    = (float)(Math.PI / 180f);
                            float driftSpeed = (float)(TAS * Math.Sin(Deg2Rad * (float)AoS));

                            if (gear == 0 && myIndicator.gears_lamp != "0" && Throttle < 20)
                            {
                                System.Media.SoundPlayer myPlayer;
                                myPlayer = new System.Media.SoundPlayer(Properties.Resources.GearDown);
                                myPlayer.PlaySync();
                            }
                            //Sink rate warning: WT has a global vertical gear speed limit of 10m/s
                            else if (Vspeed < -8 && Throttle < 60)
                            {
                                System.Media.SoundPlayer myPlayer;
                                myPlayer = new System.Media.SoundPlayer(Properties.Resources.SinkRate);
                                myPlayer.PlaySync();
                            }
                            //drift april fools
                            else if (driftSpeed < -50)
                            {
                                tbx_msgs.Text = "ドリフト! ";
                                System.Media.SoundPlayer myPlayer;
                                myPlayer = new System.Media.SoundPlayer(Properties.Resources.Running90s);
                                myPlayer.PlaySync();
                            }
                            else if (driftSpeed > 50)
                            {
                                tbx_msgs.Text = "ドリフト! ";
                                System.Media.SoundPlayer myPlayer;
                                myPlayer = new System.Media.SoundPlayer(Properties.Resources.ManuelGGG);
                                myPlayer.PlaySync();
                            }
                        }
                    }
                }
                else
                {
                    dispatcherTimer1.Stop();
                    dispatcherTimer2.Start();
                }
            }
            catch (Exception ex)
            {
                tbx_msgs.Text = ex.Message;
                dispatcherTimer1.Stop();
                dispatcherTimer2.Start();
            }
        }
コード例 #3
0
        private void getData()
        {
            try
            {
                myIndicator = JsonSerializer._download_serialized_json_data <indicator>(indicatorsurl);
                myState     = JsonSerializer._download_serialized_json_data <state>(statesurl);



                if (myState.valid == "true")
                {
                    decimal G     = Convert.ToDecimal(myState.Ny, culture);
                    decimal AoA   = Convert.ToDecimal(myState.AoA, culture);
                    decimal Alt   = Convert.ToDecimal(myIndicator.altitude_hour, culture);
                    int     gear  = Convert.ToInt32(myState.gear);
                    int     IAS   = Convert.ToInt32(myState.IAS);
                    int     flaps = Convert.ToInt32(myState.flaps);
                    label.Content = myIndicator.type;

                    if (cbx_g.IsChecked == true && G > User.Default.GForce)
                    {
                        System.Media.SoundPlayer myPlayer;
                        myPlayer = new System.Media.SoundPlayer(Properties.Resources.breaths);
                        myPlayer.PlaySync();
                    }



                    if (AoA > User.Default.AoA && myIndicator.gears_lamp == "1" && cbx_a.IsChecked == true)
                    {
                        System.Media.SoundPlayer myPlayer;
                        myPlayer = new System.Media.SoundPlayer(Properties.Resources.carflt_stallhorn02);
                        myPlayer.PlaySync();
                    }
                    if (User.Default.EnableGear == true && gear == 100 && IAS > User.Default.GearUp)
                    {
                        System.Media.SoundPlayer myPlayer;
                        myPlayer = new System.Media.SoundPlayer(Properties.Resources.gearwarn);
                        myPlayer.PlaySync();
                    }

                    if (User.Default.EnableGear == true && gear == 0 && IAS < User.Default.GearDown && Alt < 500 && flaps > 20)
                    {
                        System.Media.SoundPlayer myPlayer;
                        myPlayer = new System.Media.SoundPlayer(Properties.Resources.gearwarn);
                        myPlayer.PlaySync();
                    }
                }
                else
                {
                    dispatcherTimer1.Stop();
                    dispatcherTimer2.Start();
                }
            }
            catch (Exception ex)
            {
                tbx_msgs.Text = ex.Message;
                dispatcherTimer1.Stop();
                dispatcherTimer2.Start();
            }
        }