Beispiel #1
0
        // function is called from the retrieval of information from the simconnect and in this case stores it in the database based
        // on prefrences
        public void UseData(MSFS2020_SimConnectIntergration.SimPlaneDataStructure simPlaneData)
        {
            if (AutomaticLoggingCB.Checked == true)
            {
                // if user wanted automatic logging and ground speed is > LoggingThresholdGroundVelTB and they hadn't stoppeed logging before manaually then turn logging on and write aircraft to start flight
                if (simPlaneData.ground_velocity >= Convert.ToInt32(LoggingThresholdGroundVelTB.Text))
                {
                    if ((bLoggingEnabled == false) && (bStoppedLoggingDueToSpeed == true))
                    {
                        StartLoggingBtn.PerformClick();
                        bStartedLoggingDueToSpeed = true;
                    }
                }
                else
                {
                    if (bLoggingEnabled == true)
                    {
                        // if ground speed is < LoggingThresholdGroundVelTB and user wanted automatic logging and logging was on due to speed then turn it off
                        if (bStartedLoggingDueToSpeed == true)
                        {
                            StopLoggingAction();
                        }
                    }
                    bStoppedLoggingDueToSpeed = true;
                }
            }

            if (bLoggingEnabled == true)
            {
                // if we don't have flight header information then ask for it and don't write out this data point
                if (nCurrentFlightID == 0)
                {
                    simConnectIntegration.GetSimEnvInfo();
                }
                else
                {
                    System.TimeSpan tsDiffRecords = DateTime.Now - dtLastDataRecord;

                    // if altitude above ground is greater or equal threshold and it has been threshold amount of time or
                    //    altitude is below threshold
                    if (((simPlaneData.altitude_above_ground >= Convert.ToInt32(ThresholdMinAltTB.Text)) &&
                         (tsDiffRecords.TotalSeconds >= Convert.ToDouble(ThresholdLogWriteFreqTB.Text))) ||
                        (simPlaneData.altitude_above_ground < Convert.ToInt32(ThresholdMinAltTB.Text)))
                    {
                        int FlightSampleID;

                        FlightSampleID = FlightPathDB.WriteFlightPoint(nCurrentFlightID, simPlaneData.latitude, simPlaneData.longitude, simPlaneData.altitude);
                        FlightPathDB.WriteFlightPointDetails(FlightSampleID, simPlaneData.altitude_above_ground, simPlaneData.engine1rpm, simPlaneData.engine2rpm, simPlaneData.engine3rpm,
                                                             simPlaneData.engine4rpm, simPlaneData.lightsmask, simPlaneData.ground_velocity, simPlaneData.plane_pitch, simPlaneData.plane_bank, simPlaneData.plane_heading_true,
                                                             simPlaneData.plane_heading_magnetic, simPlaneData.plane_airspeed_indicated, simPlaneData.airspeed_true, simPlaneData.vertical_speed,
                                                             simPlaneData.heading_indicator, simPlaneData.flaps_handle_position, simPlaneData.spoilers_handle_position,
                                                             simPlaneData.gear_handle_position, simPlaneData.ambient_wind_velocity, simPlaneData.ambient_wind_direction, simPlaneData.ambient_temperature,
                                                             simPlaneData.stall_warning, simPlaneData.overspeed_warning, simPlaneData.is_gear_retractable, simPlaneData.spoiler_available, simPlaneData.sim_on_ground);
                        dtLastDataRecord = DateTime.Now;
                    }
                    flightPlan.AddFlightPlanWaypoint(new FlightWaypointData(simPlaneData.gps_wp_prev_latitude, simPlaneData.gps_wp_prev_longitude, simPlaneData.gps_wp_prev_altitude, simPlaneData.gps_wp_prev_id),
                                                     new FlightWaypointData(simPlaneData.gps_wp_next_latitude, simPlaneData.gps_wp_next_longitude, simPlaneData.gps_wp_next_altitude, simPlaneData.gps_wp_next_id),
                                                     simPlaneData.gps_flight_plan_wp_index, simPlaneData.gps_flight_plan_wp_count);
                }
            }
        }