コード例 #1
0
            /// <summary>Shows all-zero values</summary>
            /// <param name="form">Form holding the data</param>
            public static void ClearAll(TrackerForm form)
            {
                if (!AdvancedConfig.InfoPane)
                {
                    return;
                }

                GpsStatistics st = new GpsStatistics(form, DateTime.Now, new GpsPoint(0, 0, 0));

                st.ShowValues(ValueKind.All);
            }
コード例 #2
0
ファイル: TrackerForm.cs プロジェクト: mendhak/gpstracka
        /// <summary>Called when point is nearly logged</summary>
        /// <param name="time">Logged time</param>
        /// <param name="gpsPoint">Actual position</param>
        /// <param name="logThisPoint">true when point was logged false when it was not</param>
        private void OnPoint(DateTime time, GpsPoint gpsPoint, bool logThisPoint)
        {
            if (continuing && statistic != null)
            {
                statistic.PauseTime = statistic.PauseTime + (time - lastLoggedPointTime);
                //User pause
            }

            if (statistic == null)
            {//Initialize
                statistic = new GpsStatistics(this, time, gpsPoint);
                lastKnownElevation = gpsPoint.Altitude;
                lastLoggedPointTime = time;
                return;
            }
            statistic.CurrentTime = time;

            if (logThisPoint)
            {//This point is logged, count it
                decimal delta = gpsPoint - statistic.CurrentPos;//km
                statistic.SumLength = statistic.SumLength + delta;
                statistic.CurrentPos = gpsPoint;
                statistic.PointsTotal++;
            }
            else
            {//This point is not logged, pause
                statistic.PauseTime = statistic.PauseTime + (time - lastLoggedPointTime);
            }
            lastLoggedPointTime = time;

            if (lastKnownElevation == null)
            {//Initialize altitude if necessary
                lastKnownElevation = gpsPoint.Altitude;
                return;
            }

            if (logThisPoint && gpsPoint.Altitude.HasValue)
            {//Elevation
                decimal delta = gpsPoint.Altitude.Value - lastKnownElevation.Value;
                if (delta < 0)
                {
                    statistic.SumEleMinus = statistic.SumEleMinus - delta;
                }
                else
                {
                    statistic.SumElePlus = statistic.SumElePlus + delta;
                }
                lastKnownElevation = gpsPoint.Altitude;
            }
        }
コード例 #3
0
ファイル: TrackerForm.cs プロジェクト: mendhak/gpstracka
        /// <summary>Performs all the actions necessary to start GPS logging</summary>
        /// <remarks>This method is extracted form <see cref="startMenuItem_Click"/></remarks>
        private void StartGpsLogging()
        {
            try
            {
                if (currentFileName == null || MessageBox.Show(string.Format(Properties.Resources.ContinueInCurrentFile, currentFileName), "GPSTracka", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) != DialogResult.Yes)
                {
                    currentFileName = null;
                    nmeaFileName = null;
                    statistic = null;
                    gpxDocument = null;
                    kmlDocument = null;
                    tickCount = 0;
                }
                if (currentFileName != null)
                {
                    continuing = true;
                }

                invalidPositionCount = 0;
                gpsRunning = true;
                timer1.Interval = Convert.ToInt16(AdvancedConfig.PollingInterval) * 1000;
                afterStart = true;
                //Power requirements
                if (!AdvancedConfig.UseWindowsDriver)
                {
                    powerHandle = SetPowerRequirement(AdvancedConfig.ComPort + ":", (int)DevicePowerState.D0, 1,
                                                      IntPtr.Zero, 0);
                }
                foreach (string device in AdvancedConfig.KeepAwakeList)
                {
                    if (!device.EndsWith(":"))
                    {
                        IntPtr devicePowerHandle = SetPowerRequirement(device + ":", DevicePowerState.D0, 1, IntPtr.Zero, 0);
                        if (PowerHandles.ContainsKey(device))
                        {
                            PowerHandles[device] = devicePowerHandle;
                        }
                        else
                        {
                            PowerHandles.Add(device, devicePowerHandle);
                        }
                    }
                }
                //if (!PowerPolicyNotify(PPN_UNATTENDEDMODE, 1)) {
                //    WriteToTextbox(Properties.Resources.err_PowerPolicyNotifiyFailed);
                //}
                if (!AdvancedConfig.StartImmediatelly)
                {
                    WriteToTextbox(string.Format(Properties.Resources.WillBeginReading,
                                                 AdvancedConfig.PollingInterval));
                }
                Status(Properties.Resources.Starting);
                startMenuItem.Text = Properties.Resources.Stop;
                if (!AdvancedConfig.StartImmediatelly)
                {
                    timer1.Enabled = true;
                    tmrCountDown.Enabled = AdvancedConfig.StatusBar;
                    countDown = timer1.Interval / tmrCountDown.Interval;
                }
                tmrBeep.Enabled = AdvancedConfig.BeepTimer != 0;
                tmrBeep.Interval = AdvancedConfig.BeepTimer * 1000;
                if (statistic == null)
                {
                    GpsStatistics.ClearAll(this);
                }
                else
                {
                    statistic.ShowValues(GpsStatistics.ValueKind.All);
                }
            }
            finally
            {
                mniSatellites.Enabled = gpsRunning;
                settingsMenuItem.Enabled = !gpsRunning;
                if (gpsRunning && AdvancedConfig.StartImmediatelly)
                {
                    timer1_Tick(timer1, EventArgs.Empty);
                }
            }
        }
コード例 #4
0
ファイル: GpsStatistics.cs プロジェクト: mendhak/gpstracka
            /// <summary>Shows all-zero values</summary>
            /// <param name="form">Form holding the data</param>
            public static void ClearAll(TrackerForm form)
            {
                if (!AdvancedConfig.InfoPane)
                {
                    return;
                }

                GpsStatistics st = new GpsStatistics(form, DateTime.Now, new GpsPoint(0, 0, 0));
                st.ShowValues(ValueKind.All);
            }