コード例 #1
0
ファイル: MainForm.cs プロジェクト: ucnl/RedGTR_VLBL
        private void exportTracksBtn_Click(object sender, EventArgs e)
        {
            using (SaveFileDialog sDialog = new SaveFileDialog())
            {
                sDialog.Title      = "Exporting tracks...";
                sDialog.Filter     = "Google KML (*.kml)|*.kml";
                sDialog.FileName   = string.Format("{0}.kml", StrUtils.GetHMSString());
                sDialog.DefaultExt = "kml";

                if (sDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    SaveTracks(sDialog.FileName);
                }
            }
        }
コード例 #2
0
ファイル: MainForm.cs プロジェクト: ucnl/RedGTR_VLBL
        private void SaveFullSnapshot()
        {
            Bitmap target = new Bitmap(this.Width, this.Height);

            this.DrawToBitmap(target, this.DisplayRectangle);

            try
            {
                if (!Directory.Exists(snapshotsPath))
                {
                    Directory.CreateDirectory(snapshotsPath);
                }

                target.Save(Path.Combine(snapshotsPath, string.Format("{0}.{1}", StrUtils.GetHMSString(), ImageFormat.Png)));
            }
            catch
            {
                //
            }
        }
コード例 #3
0
ファイル: MainForm.cs プロジェクト: ucnl/RedGTR_VLBL
        public MainForm()
        {
            InitializeComponent();

            this.Text = string.Format("{0}", Application.ProductName);

            #region file names & paths

            DateTime startTime = DateTime.Now;
            settingsFileName = Path.ChangeExtension(Application.ExecutablePath, "settings");
            logPath          = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "LOG");
            logFileName      = StrUtils.GetTimeDirTreeFileName(startTime, Application.ExecutablePath, "LOG", "log", true);
            snapshotsPath    = StrUtils.GetTimeDirTree(startTime, Application.ExecutablePath, "SNAPSHOTS", false);

            #endregion

            #region logger

            loggerTextAddedEventHandler = new EventHandler <TextAddedEventArgs>(logger_TextAdded);

            logger = new TSLogProvider(logFileName);
            logger.TextAddedEvent += loggerTextAddedEventHandler;
            logger.WriteStart();

            #endregion

            #region settings

            logger.Write("Loading settings...");
            settingsProvider = new SettingsProviderXML <SettingsContainer>();
            settingsProvider.isSwallowExceptions = false;

            try
            {
                settingsProvider.Load(settingsFileName);
            }
            catch (Exception ex)
            {
                ProcessException(ex, true);
            }

            logger.Write(settingsProvider.Data.ToString());

            gtr_RemoteTimeout_S = Convert.ToInt32((GTR.MIN_REM_TOUT_MS / 1000) + 2 * (double)settingsProvider.Data.MaxDistance / 1500) + 1;

            #endregion

            #region NMEA

            NMEAParser.AddManufacturerToProprietarySentencesBase(ManufacturerCodes.TNT);
            NMEAParser.AddProprietarySentenceDescription(ManufacturerCodes.TNT, "0", "x");
            NMEAParser.AddProprietarySentenceDescription(ManufacturerCodes.TNT, "1", "x,x");
            NMEAParser.AddProprietarySentenceDescription(ManufacturerCodes.TNT, "2", "x,x");
            NMEAParser.AddProprietarySentenceDescription(ManufacturerCodes.TNT, "3", "x,x");
            NMEAParser.AddProprietarySentenceDescription(ManufacturerCodes.TNT, "4", "x,x");
            NMEAParser.AddProprietarySentenceDescription(ManufacturerCodes.TNT, "5", "x,x.x");
            NMEAParser.AddProprietarySentenceDescription(ManufacturerCodes.TNT, "6", "x,x");
            NMEAParser.AddProprietarySentenceDescription(ManufacturerCodes.TNT, "7", "x,x.x");
            NMEAParser.AddProprietarySentenceDescription(ManufacturerCodes.TNT, "8", "x,x");
            NMEAParser.AddProprietarySentenceDescription(ManufacturerCodes.TNT, "9", "x,x.x,x.x");
            NMEAParser.AddProprietarySentenceDescription(ManufacturerCodes.TNT, "A", "x,x");
            NMEAParser.AddProprietarySentenceDescription(ManufacturerCodes.TNT, "B", "x");
            NMEAParser.AddProprietarySentenceDescription(ManufacturerCodes.TNT, "C", "x,x.x,x.x,x.x,x.x,x.x,x.x");
            NMEAParser.AddProprietarySentenceDescription(ManufacturerCodes.TNT, "D", "x,x,x.x,x.x,x.x,x.x,x.x,x.x,x.x");
            NMEAParser.AddProprietarySentenceDescription(ManufacturerCodes.TNT, "E", "x,x,x");
            NMEAParser.AddProprietarySentenceDescription(ManufacturerCodes.TNT, "!", "c--c,x,c--c,x,x,c--c");
            NMEAParser.AddProprietarySentenceDescription(ManufacturerCodes.TNT, "O", "x.x,x.x");
            NMEAParser.AddProprietarySentenceDescription(ManufacturerCodes.TNT, "P", "x,x.x");

            /*
             #define IC_D2H_ACK              '0'        // $PTNT0,errCode
             #define IC_H2D_FLD_GET          '1'        // $PTNT1,fldID,reserved
             #define IC_H2D_FLD_SET          '2'        // $PTNT2,fldID,fldNewValue
             #define IC_D2H_FLD_VAL          '3'        // $PTNT3,fldID,fldValue
             #define IC_H2D_LOC_DATA_GET     '4'        // $PTNT4,locDataID,reserved
             #define IC_D2H_LOC_DATA_VAL     '5'        // $PTNT5,locDataID,locDataValue
             #define IC_H2D_ACT_INVOKE       '6'        // $PTNT6,actionID,reserved
             #define IC_H2D_LOC_DATA_SET     '7'        // $PTNT7,locDataID,locDataValue
             #define IC_H2D_REM_SEND         '8'        // $PTNT8,targetAddr,codeMsg
             #define IC_D2H_REM_RECEIVED     '9'        // $PTNT9,codeMsg,snrd,dpl
             #define IC_H2D_REM_PING         'A'        // $PTNTA,targetAddr,timeoutMs
             #define IC_D2H_REM_TOUT         'B'        // $PTNTB,targetAddr
             #define IC_D2H_REM_PONG         'C'        // $PTNTC,requestedAddr,snrd,dpl,pTime,[dst],[dpt],[tmp]
             #define IC_D2H_REM_PONGEX       'D'        // $PTNTD,requestedAddr,requestedCmd,receivedValue_decoded,snrd,dpl,pTime,[dst],[dpt],[tmp]
             #define IC_H2D_REM_PINGEX       'E'        // $PTNTE,targetAddr,requestedCmd,timeoutMs
             #define IC_D2H_DEV_INFO_VAL     '!'        // $PTNT!,sys_moniker,sys_ver,dev_type,core_moniker,core_ver,dev_serial_num
             #define IC_D2H_PRETMP_VAL       'O'        // $PTNTO,pressure_mbar,temp_deg_c
             #define IC_H2D_SETVAL           'P'        // $PTNTP,valueID,value
             */

            #endregion

            #region other

            gtrPortErrorEventHandler          = new EventHandler <SerialErrorReceivedEventArgs>(gtrPort_Error);
            gtrPortNewNMEAMessageEventHandler = new EventHandler <NewNMEAMessageEventArgs>(gtrPort_NewNMEAMessage);

            gtrPort = new NMEASerialPort(new SerialPortSettings(settingsProvider.Data.GTRPortName, BaudRate.baudRate9600,
                                                                System.IO.Ports.Parity.None, DataBits.dataBits8, System.IO.Ports.StopBits.One, System.IO.Ports.Handshake.None));

            gtrPort.IsRawModeOnly = false;

            timerTickHandler = new EventHandler(timer_Tick);

            timer        = new PrecisionTimer();
            timer.Mode   = Mode.Periodic;
            timer.Period = 1000;

            timer.Tick += timerTickHandler;
            timer.Start();


            if (settingsProvider.Data.IsGNSSEmulator)
            {
                gnssEmulatorPort = new NMEASerialPort(new SerialPortSettings(settingsProvider.Data.GNSSEmulatorPortName, BaudRate.baudRate9600,
                                                                             Parity.None, DataBits.dataBits8, StopBits.One, Handshake.None));
            }

            measurements = new Measurements(settingsProvider.Data.MeasurementsFIFOSize, settingsProvider.Data.BaseSize);

            bLatitude    = new AgingDouble("F06", "°");
            bLongitude   = new AgingDouble("F06", "°");
            bTemperature = new AgingDouble("F01", "°C");
            bDepth       = new AgingDouble("F03", " m");
            tTemperature = new AgingDouble("F01", "°C");
            tDepth       = new AgingDouble("F02", " m");

            tLatitude    = new AgingDouble("F06", "°");
            tLongitude   = new AgingDouble("F06", "°");
            tRadialError = new AgingDouble("F03", " m");

            tLocation = new List <GeoPoint3DWE>();
            bLocation = new List <GeoPoint>();

            tBestLocation             = new GeoPoint3DWE();
            tBestLocation.Latitude    = double.NaN;
            tBestLocation.Longitude   = double.NaN;
            tBestLocation.RadialError = double.NaN;

            marinePlot.InitTracks(settingsProvider.Data.MeasurementsFIFOSize);
            marinePlot.AddTrack("BOAT GNSS", Color.Blue, 2.0f, 2, settingsProvider.Data.MeasurementsFIFOSize, true);
            marinePlot.AddTrack("BASE", Color.Salmon, 2.0f, 8, settingsProvider.Data.BaseSize, false);
            marinePlot.AddTrack("MEASUREMENTS", Color.Green, 2.0f, 4, settingsProvider.Data.MeasurementsFIFOSize, false);
            marinePlot.AddTrack("TARGET", Color.Black, 2.0f, 4, settingsProvider.Data.MeasurementsFIFOSize, false);
            marinePlot.AddTrack("BEST", Color.Red, 2.0f, 8, 1, false);

            #endregion
        }