Esempio n. 1
0
 public GPSSource()
 {
     GpsPos              = new GPSPositionVariables();
     GeoFence            = new GPSGeoFenceData();
     GeoFence.arrayLat   = new ArrayList();
     GeoFence.arrayLon   = new ArrayList();
     GeoFence.SourcesIn  = new ArrayList();
     GeoFence.SourcesOut = new ArrayList();
     GeoFence.sEmail     = "";
     GeoFence.sName      = "";
     GeoFence.sSound     = GpsTrackerPlugin.m_sPluginDirectory + "\\GeoFence.wav";
     GeoFence.sSoundOut  = GpsTrackerPlugin.m_sPluginDirectory + "\\GeoFenceOut.wav";
     GeoFence.bEmailIn   = false;
     GeoFence.bEmailOut  = false;
     GeoFence.bMsgBoxIn  = false;
     GeoFence.bMsgBoxOut = false;
     GeoFence.bSoundIn   = true;
     GeoFence.bSoundOut  = true;
     bShowCircles        = false;
     iCirclesCount       = 3;
     dCirclesEvery       = 2;
     iLinesEvery         = 45;
     bKms                   = true;
     colorCircle            = System.Drawing.Color.Yellow;
     bShowName              = true;
     bShowPosition          = true;
     bShowSpeed             = true;
     bShowHeading           = true;
     bShowTimeDate          = true;
     bShowTrackDistance     = true;
     bShowComment           = true;
     bShowReferenceDistance = true;
     bShowReferenceAngles   = true;
     iInformationFontSize   = 0;
     colorInformation       = System.Drawing.Color.Yellow;
     bShowGrid              = false;
     iSquareCount           = 5;
     dSquareSize            = 2;
     bGridKms               = true;
     colorGrid              = System.Drawing.Color.Yellow;
     bUpdateLineNumber      = false;
     bPlay                  = true;
 }
Esempio n. 2
0
        public string ConvertToGPGGA(GPSPositionVariables gpsPos)
        {
            string sGPGGA = "";

            try
            {
                sGPGGA  = "$GPGGA,";                                                                                                                       //GpGGA
                sGPGGA += String.Format("{0:00}", gpsPos.m_iHour) + String.Format("{0:00}", gpsPos.m_iMin) + String.Format("{0:00}", gpsPos.m_iSec) + ","; //Time of fix

                String sLat = Convert.ToString(gpsPos.m_fLat);
                String sNMEALat;
                String sNMEALatMin;
                String sNMEALatNS;
                int    iIndex1 = sLat.IndexOf(CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator);
                if (iIndex1 == -1)
                {
                    sLat = sLat + CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator + "0";
                }
                iIndex1 = sLat.IndexOf(CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator);
                if (sLat.StartsWith("-"))
                {
                    sNMEALatNS = "S";
                    sNMEALat   = sLat.Substring(1, iIndex1 - 1);
                }
                else
                {
                    sNMEALatNS = "N";
                    sNMEALat   = sLat.Substring(0, iIndex1);
                }
                if (sNMEALat.Length == 1)
                {
                    sNMEALat = "0" + sNMEALat;
                }
                else
                if (sNMEALat.Length == 0)
                {
                    sNMEALat = "00";
                }
                double dLatMin = Convert.ToDouble(sLat.Substring(iIndex1)) * 60;
                sNMEALatMin = Convert.ToString(decimal.Round(Convert.ToDecimal(dLatMin), 3));
                iIndex1     = sNMEALatMin.IndexOf(CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator);
                if (iIndex1 == -1)
                {
                    sNMEALatMin = sNMEALatMin + ".0";
                }
                iIndex1 = sNMEALatMin.IndexOf(CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator);
                if (iIndex1 == 1)
                {
                    sNMEALatMin = "0" + sNMEALatMin;
                }
                sNMEALatMin = sNMEALatMin.Replace(Convert.ToChar(CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator), '.');
                sNMEALat   += sNMEALatMin;

                sGPGGA += sNMEALat + "," + sNMEALatNS + ","; //Lat

                String sLon = Convert.ToString(gpsPos.m_fLon);
                String sNMEALon;
                String sNMEALonMin;
                String sNMEALonEW;
                iIndex1 = sLon.IndexOf(CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator);
                if (iIndex1 == -1)
                {
                    sLon = sLon + CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator + "0";
                }
                iIndex1 = sLon.IndexOf(CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator);
                if (sLon.StartsWith("-"))
                {
                    sNMEALonEW = "W";
                    sNMEALon   = sLon.Substring(1, iIndex1 - 1);
                }
                else
                {
                    sNMEALonEW = "E";
                    sNMEALon   = sLon.Substring(0, iIndex1);
                }
                if (sNMEALon.Length == 1)
                {
                    sNMEALon = "00" + sNMEALon;
                }
                else
                if (sNMEALon.Length == 2)
                {
                    sNMEALon = "0" + sNMEALon;
                }
                else
                if (sNMEALon.Length == 0)
                {
                    sNMEALon = "000";
                }
                double dLonMin = Convert.ToDouble(sLon.Substring(iIndex1)) * 60;
                sNMEALonMin = Convert.ToString(decimal.Round(Convert.ToDecimal(dLonMin), 3));
                iIndex1     = sNMEALonMin.IndexOf(CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator);
                if (iIndex1 == -1)
                {
                    sNMEALonMin = sNMEALonMin + ".0";
                }
                iIndex1 = sNMEALonMin.IndexOf(CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator);
                if (iIndex1 == 1)
                {
                    sNMEALonMin = "0" + sNMEALonMin;
                }
                sNMEALonMin = sNMEALonMin.Replace(Convert.ToChar(CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator), '.');
                sNMEALon   += sNMEALonMin;

                sGPGGA += sNMEALon + "," + sNMEALonEW + ",";                  //Lon

                sGPGGA += "1,";                                               //Gps Fix
                sGPGGA += "12,";                                              //satellites in view
                sGPGGA += "0.5,";                                             //Horizontal Dilution of Precision, 0.5 to 99.9

                sGPGGA += String.Format("{0:0000.0}", gpsPos.m_fAlt) + ",M,"; //altitud

                sGPGGA += "0,M,";
                sGPGGA += ",,,";
                //Checksum
                int iChecksum = Convert.ToByte(sGPGGA[1]);
                for (int iGPGGA = 2; iGPGGA < sGPGGA.Length; iGPGGA++)
                {
                    iChecksum ^= Convert.ToByte(sGPGGA[iGPGGA]);
                }

                sGPGGA += "*" + iChecksum.ToString("X2");
            }
            catch (Exception)
            {
                sGPGGA = "";
            }

            return(sGPGGA);
        }