コード例 #1
0
		//
		//Show the user selected icon for the gps device on the WorldView
		public void ShowOverlay(GPSRenderInformation renderInformation)
		{
            lock ("RenderAccess")
			{
				if (renderInformation.gpsTrack!=null)
				{
                    //Resize array if necessary
                    if (renderInformation.iIndex >= m_uTrackResize)
                    {
                        m_uTrackResize = (uint)renderInformation.iIndex+1;
                        Array.Resize(ref m_gpsTrack, (int)m_uTrackResize);
                    }

					if (m_gpsTrack[renderInformation.iIndex]==null)
                        m_gpsTrack[renderInformation.iIndex] = new GPSTrackLine(ParentApplication.WorldWindow.CurrentWorld, renderInformation.sDescription);
                    m_gpsTrack[renderInformation.iIndex].Initialize(this.drawArgs);
                    m_gpsTrack[renderInformation.iIndex].SetTrack(this, renderInformation.gpsTrack, renderInformation.sDescription, renderInformation.colorTrack, renderInformation.sIcon, renderInformation.bShowInfo);
					Add(m_gpsTrack[renderInformation.iIndex]);
				}
				else
				{
					if (renderInformation.bPOI==false)
					{
						
						int iIndex;
						for (iIndex=0; iIndex<m_iGpsIconIndex; iIndex++)
							if (renderInformation.sDescription==m_gpsIcons[iIndex].m_RenderInfo.sDescription)
								break;

						if (iIndex==m_iGpsIconIndex)
						{
                            //Resize array if necessary
                            if (m_iGpsIconIndex>=m_uIconResize)
                            {
                                m_uIconResize+=5;
                                Array.Resize(ref m_gpsIcons, (int)m_uIconResize);
                            }

							m_gpsIcons[iIndex] = new GPSIcon(this, renderInformation, ParentApplication.WorldWindow.CurrentWorld);
							m_gpsIcons[iIndex].Initialize(this.drawArgs);
							Add(m_gpsIcons[iIndex]);
							m_iGpsIconIndex++;
						}

						if (m_gpsIcons[iIndex].m_bTrack)
							Plugin.pluginWorldWindowGotoLatLonHeading(renderInformation.fLat,renderInformation.fLon,renderInformation.fHeading,renderInformation.iStartAltitud);

						m_gpsIcons[iIndex].SetGpsData(drawArgs, renderInformation);
					}
					else
					{
                        //Resize array if necessary
                        if (m_iGpsPOIIndex >= m_uPOIResize)
                        {
                            m_uPOIResize += 5;
                            Array.Resize(ref m_gpsPOI, (int)m_uPOIResize);
                        }

						if (m_gpsPOI[m_iGpsPOIIndex]==null)
						{
							m_gpsPOI[m_iGpsPOIIndex] = new GPSIcon(this, renderInformation.iIndex,renderInformation, ParentApplication.WorldWindow.CurrentWorld);
							m_gpsPOI[m_iGpsPOIIndex].Initialize(this.drawArgs);
							Add(m_gpsPOI[m_iGpsPOIIndex]);
						}
						m_iGpsPOIIndex++;
					}
				}
			}
		}
コード例 #2
0
		//Show the user selected icon for the gps device on the WorldView
		public void pluginShowOverlay(GPSRenderInformation renderInformation)
		{
			renderInformation.iActiveTrack=gpsTracker.GetActiveTrack();
			gpsOverlay.ShowOverlay(renderInformation);
		}
コード例 #3
0
		//Update the icon position from the latest gps data
		public void SetGpsData(DrawArgs drawArgs, GPSRenderInformation renderInformation)
		{

			this.m_RenderInfo=renderInformation;
			if (m_bSignalDistance)
			{
				for (int i=0; i<m_gpsTrackerOverlay.m_iGpsPOIIndex; i++)
				{
					m_gpsTrackerOverlay.m_gpsPOI[i].m_fLatitudeFrom=m_RenderInfo.fLat;
					m_gpsTrackerOverlay.m_gpsPOI[i].m_fLongitudeFrom=m_RenderInfo.fLon;
					m_gpsTrackerOverlay.m_gpsPOI[i].m_sDescriptionFrom=m_RenderInfo.sDescription;
				}
			}
		
			if (renderInformation.bRestartTrack)
			{
				m_uVerticesCount=0;
				m_uPointCount=0;
				m_uTotalPointCount=0;
				m_fTotalDistance=0;
			}
			else
			if (m_fVerticalExaggeration != World.Settings.VerticalExaggeration)
			{
				//There was a change in vertical exaggeration, recalculate track
				uint uPoint;
				if (m_uVerticesCount==0)
					uPoint=m_uPointCount;
				else
					uPoint=50000;
				for (uint uVertices=0; uVertices<=m_uVerticesCount; uVertices++)
				{
					for (uint uP=0; uP<uPoint; uP++)
					{
						float elevation = (float)(m_parentWorld.TerrainAccessor.GetElevationAt(this.vertices[uVertices].fLat[uP], this.vertices[uVertices].fLon[uP], (double)241));
						if (this.vertices[m_uVerticesCount].fAlt[uP] < elevation)
							this.vertices[m_uVerticesCount].fAlt[uP] = elevation;
						Vector3 v=MathEngine.SphericalToCartesian(this.vertices[uVertices].fLat[uP], this.vertices[uVertices].fLon[uP], this.m_parentWorld.EquatorialRadius + (this.vertices[uVertices].fAlt[uP] * World.Settings.VerticalExaggeration));

						this.vertices[uVertices].vertices[uP].X = v.X;
						this.vertices[uVertices].vertices[uP].Y = v.Y;
						this.vertices[uVertices].vertices[uP].Z = v.Z;
					}
					if (uVertices == m_uVerticesCount)
						uPoint = m_uPointCount;
				}
				m_fVerticalExaggeration = World.Settings.VerticalExaggeration;
			}

			if (m_uPointCount>=50000)
			{
				m_uVerticesCount++;
				m_uPointCount=0;
			}

			if (m_uPointCount==0)
			{
				this.vertices[m_uVerticesCount] = new GPSTrackVertices();
				this.vertices[m_uVerticesCount].vertices = new CustomVertex.PositionColored[50000];
				this.vertices[m_uVerticesCount].fLat = new double[50000];
				this.vertices[m_uVerticesCount].fLon = new double[50000];
				this.vertices[m_uVerticesCount].fAlt = new double[50000];
			}

			float elev = (float)(m_parentWorld.TerrainAccessor.GetElevationAt(renderInformation.fLat, renderInformation.fLon, (double)241));
			if (renderInformation.fAlt < elev)
				renderInformation.fAlt = elev;
			Vector3 vTrack=MathEngine.SphericalToCartesian(renderInformation.fLat, renderInformation.fLon, this.m_parentWorld.EquatorialRadius + (renderInformation.fAlt * World.Settings.VerticalExaggeration));

			this.vertices[m_uVerticesCount].vertices[m_uPointCount].X = vTrack.X;
			this.vertices[m_uVerticesCount].vertices[m_uPointCount].Y = vTrack.Y;
			this.vertices[m_uVerticesCount].vertices[m_uPointCount].Z = vTrack.Z;
			this.vertices[m_uVerticesCount].vertices[m_uPointCount].Color =m_RenderInfo.colorTrack.ToArgb();
			this.vertices[m_uVerticesCount].fLat[m_uPointCount] = renderInformation.fLat;
			this.vertices[m_uVerticesCount].fLon[m_uPointCount] = renderInformation.fLon;
			this.vertices[m_uVerticesCount].fAlt[m_uPointCount] = renderInformation.fAlt;
			m_uPointCount++;
			if (m_uTotalPointCount>0)
			{
                double dDistance = CalculateDistance(m_fLatFrom, m_fLonFrom, renderInformation.fLat, renderInformation.fLon);
				if (double.IsNaN(dDistance)==false)
					m_fTotalDistance=m_fTotalDistance+(float)dDistance;
				}

			m_fLatFrom=renderInformation.fLat;
			m_fLonFrom=renderInformation.fLon;
			m_uTotalPointCount++;
			
		}
コード例 #4
0
        //static int VK_RCONTROL = 0xA3;
        //static int VK_LALT = 0xA4;
        //static int VK_RALT = 0xA5;

		//float fFeetToMeter = 31F/100F;

		public GPSIcon(
			GPSTrackerOverlay gpsTrackerOverlay,
			int iIndex, 
			GPSRenderInformation renderInformation,
			World parentWorld)
			: base(renderInformation.sDescription, parentWorld.Position, Quaternion.RotationYawPitchRoll(0,0,0)) 
		{
			m_fVerticalExaggeration = World.Settings.VerticalExaggeration;
			m_RenderInfo=renderInformation;
			m_RenderInfo.bPOI=true;
			this.m_gpsTrackerOverlay=gpsTrackerOverlay;
			m_RenderInfo.iIndex=iIndex;
			this.m_parentWorld = parentWorld;
			this.m_textureFileName = m_RenderInfo.sIcon;
			this.m_iTextureWidth = 32;
			this.m_iTextureHeight = 32;
			this.m_iIconWidth = 32;
			this.m_iIconHeight = 32;
			this.m_iIconWidthHalf = m_iIconWidth/2;
			this.m_iIconHeightHalf = m_iIconHeight/2;
			this.m_bTrack=renderInformation.fTrack;
			m_bShowInfo = m_RenderInfo.bShowInfo;

			m_fLatitudeFrom=1000F;
			m_fLongitudeFrom=1000F;
			m_sDescriptionFrom="";
			m_bSignalDistance=false;

			m_uVerticesCount=0;
			m_uPointCount=0;
			m_fTotalDistance=0;
			m_uTotalPointCount=0;

			this.RenderPriority = RenderPriority.Icons;
		}
コード例 #5
0
		public GPSIcon(
			GPSTrackerOverlay gpsTrackerOverlay,
			GPSRenderInformation renderInformation,
			World parentWorld)
			: base(renderInformation.sDescription, parentWorld.Position, Quaternion.RotationYawPitchRoll(0,0,0)) 
		{
			m_fVerticalExaggeration = World.Settings.VerticalExaggeration;
			m_RenderInfo=renderInformation;
			m_RenderInfo.bPOI=false;
			this.m_gpsTrackerOverlay=gpsTrackerOverlay;
			this.m_parentWorld = parentWorld;
			this.m_textureFileName = m_RenderInfo.sIcon;
			this.m_iTextureWidth = 32;
			this.m_iTextureHeight = 32;
			this.m_iIconWidth = 32;
			this.m_iIconHeight = 32;
			this.m_iIconWidthHalf = m_iIconWidth/2;
			this.m_iIconHeightHalf = m_iIconHeight/2;
			m_bSignalDistance=false;
			this.m_bTrack=renderInformation.fTrack;
			m_bShowInfo = m_RenderInfo.bShowInfo;
            m_bTrackLine = m_RenderInfo.bTrackLine;
            m_bTrackHeading = gpsTrackerOverlay.Plugin.gpsTracker.m_bTrackHeading;

			m_fLastAlt=-1000000F;
			m_fLastRoll=-1000F;
			m_fLastDepth=-1000000F;
			m_fLastPitch=-1000F;
			m_fLastSpeed=-1F;
			m_fLastESpeed=-1000000F;
			m_fLastNSpeed=-1000000F;
			m_fLastVSpeed=-1000000F;
			m_fLastHeading=-1F;
			m_iLastHour=-1;
			m_iLastMin=-1;
			m_fLastSec=(float)-1;
			m_iLastDay=-1;
			m_iLastMonth=-1;
			m_iLastYear=-1;
			m_fLatitudeFrom=1000F;
			m_fLongitudeFrom=1000F;
			m_sDescriptionFrom="";

			m_uVerticesCount=0;
			m_uPointCount=0;
			m_fTotalDistance=0;
			m_uTotalPointCount=0;

			for (int i=0; i<m_gpsTrackerOverlay.m_iGpsIconIndex; i++)
				if (m_gpsTrackerOverlay.m_gpsIcons[i].m_RenderInfo.iIndex==m_RenderInfo.iIndex && 
					m_gpsTrackerOverlay.m_gpsIcons[i].m_bTrack &&
					m_bTrack)
					m_bTrack=false;

			this.RenderPriority = RenderPriority.Icons;
		}
コード例 #6
0
        public void threadStartFile()
        {
            int       iIndex     = Int32.Parse(Thread.CurrentThread.Name);
            GPSSource gpsSource  = (GPSSource)m_GpsTracker.m_gpsSourceList[iIndex];
            bool      bShowError = true;

            while (m_GpsTracker.m_fCloseThreads == false)
            {
                gpsSource.GpsPos.m_gpsTrack = null;

                try
                {
                    string sFileName = "";
                    lock ("threadStartFile")
                    {
                        m_GpsTracker.m_gpsTrackerPlugin.pluginShowFixInfo("GPSTracker: Downloading " + gpsSource.sFileName);

                        WebClient myWebClient = new WebClient();
                        sFileName = GpsTrackerPlugin.m_sPluginDirectory + "\\DownloadedFile" + Convert.ToString(iIndex) + ".gpsTracker";
                        if (File.Exists(sFileName))
                        {
                            File.Delete(sFileName);
                        }
                        string sWebReload = "";
                        if (!File.Exists(gpsSource.sFileName))
                        {
                            sWebReload = "?r=" + System.Guid.NewGuid().ToString();
                        }

                        myWebClient.DownloadFile(gpsSource.sFileName + sWebReload, sFileName);
                    }

                    if (File.Exists(sFileName))
                    {
                        gpsSource.bBabelNMEA = false;
                        lock ("threadStartFile")
                        {
                            //Convert files to a known format
                            switch (gpsSource.saGpsBabelFormat[0])
                            {
                            case "nasabaloon":
                                if (m_GpsTracker.m_NMEA.CheckConvertNasaBaloon(sFileName, gpsSource.sFileName))
                                {
                                    sFileName = sFileName + ".NMEAText";
                                }
                                break;

                            case "aprs":
                            case "nmea":
                            case "GpsTracker":
                            case "Unknown":
                                //Nothing to convert
                                break;

                            default:
                                //Use GpsBabel
                                string sBabelCommandLine;
                                if (gpsSource.bWaypoints)
                                {
                                    sBabelCommandLine = "-w;";
                                }
                                else
                                {
                                    sBabelCommandLine = "-t;-r;";
                                }
                                sBabelCommandLine += "-i;" + gpsSource.saGpsBabelFormat[0] + ";";
                                sBabelCommandLine += "-f;" + sFileName + ";";
                                if (gpsSource.bWaypoints)
                                {
                                    sBabelCommandLine += "-o;csv;-F;" + sFileName + ".WaypointsCSV;";
                                    if (File.Exists(sFileName + ".WaypointsCSV"))
                                    {
                                        File.Delete(sFileName + ".WaypointsCSV");
                                    }
                                }
                                else
                                {
                                    sBabelCommandLine += "-o;nmea;-F;" + sFileName + ".NMEAText;";
                                    if (File.Exists(sFileName + ".NMEAText"))
                                    {
                                        File.Delete(sFileName + ".NMEAText");
                                    }
                                }
                                m_GpsBabel.Execute(sBabelCommandLine);

                                if (gpsSource.bWaypoints && File.Exists(sFileName + ".WaypointsCSV"))
                                {
                                    FileInfo fInfo = new FileInfo(sFileName + ".WaypointsCSV");
                                    if (fInfo.Length > 0)
                                    {
                                        sFileName += ".WaypointsCSV";
                                    }
                                }
                                else
                                if (gpsSource.bWaypoints == false && File.Exists(sFileName + ".NMEAText"))
                                {
                                    FileInfo fInfo = new FileInfo(sFileName + ".NMEAText");
                                    if (fInfo.Length > 0)
                                    {
                                        sFileName           += ".NMEAText";
                                        gpsSource.bBabelNMEA = true;
                                    }
                                }
                                break;
                            }
                        }

                        if (gpsSource.bTrackAtOnce != true && !m_GpsTracker.m_File.IsTrackAtOnce(sFileName))
                        {
                            if (!gpsSource.bWaypoints)
                            {
                                m_GpsTracker.m_gpsTrackerPlugin.pluginShowFixInfo("");
                                m_GpsTracker.m_gpsTrackerPlugin.pluginShowFixInfo("GPSTracker: Active");

                                gpsSource.sFileNameSession = sFileName;
                                gpsSource.iFilePlaySpeed   = gpsSource.iPlaySpeed;
                                threadFile();
                            }
                            else
                            {
                                m_GpsTracker.m_gpsTrackerPlugin.pluginShowFixInfo("");
                                m_GpsTracker.m_gpsTrackerPlugin.pluginShowFixInfo("GPSTracker: Active");

                                ArrayList    listWaypoints = new ArrayList();
                                StreamReader sReader       = null;
                                try
                                {
                                    sReader = File.OpenText(sFileName);
                                    string sLine;
                                    do
                                    {
                                        sLine = sReader.ReadLine();
                                        if (sLine != null)
                                        {
                                            listWaypoints.Add(sLine);
                                        }
                                    } while(sLine != null);
                                }
                                catch (Exception)
                                {
                                }
                                if (sReader != null)
                                {
                                    sReader.Close();
                                }

                                if (listWaypoints.Count > 0)
                                {
                                    char [] cSep   = { ',' };
                                    bool    bTrack = gpsSource.bTrack;
                                    for (int i = 0; i < listWaypoints.Count; i++)
                                    {
                                        string    sFormat = (string)listWaypoints[i];
                                        string [] sWaypointData;
                                        sWaypointData = sFormat.Split(cSep);
                                        if (sWaypointData.Length == 3)
                                        {
                                            try
                                            {
                                                m_GpsTracker.AddPOI(sWaypointData[2], Convert.ToDouble(sWaypointData[0]), Convert.ToDouble(sWaypointData[1]), false, gpsSource);
                                                if (gpsSource.bTrack)
                                                {
                                                    gpsSource.bTrack = false;
                                                }
                                            }
                                            catch (Exception)
                                            {
                                                Thread.Sleep(200);
                                            }
                                        }
                                    }
                                    gpsSource.bTrack = bTrack;
                                }
                            }
                        }
                        else
                        {
                            if (gpsSource.iReload > 0 && File.Exists(sFileName + ".TrackAtOnce"))
                            {
                                File.Delete(sFileName + ".TrackAtOnce");
                            }

                            lock ("threadStartFile")
                            {
                                //track at once
                                m_GpsTracker.m_File.PreprocessFile(iIndex, sFileName, gpsSource.sFileName, false, gpsSource.bForcePreprocessing);
                            }

                            GPSRenderInformation renderInfo = new GPSRenderInformation();
                            renderInfo.bPOI          = false;
                            renderInfo.iIndex        = iIndex;
                            renderInfo.sDescription  = gpsSource.sDescription;
                            renderInfo.fFix          = false;
                            renderInfo.bShowInfo     = m_GpsTracker.m_bInfoText;
                            renderInfo.bTrackLine    = false;
                            renderInfo.gpsTrack      = gpsSource.GpsPos.m_gpsTrack;
                            renderInfo.bRestartTrack = false;
                            renderInfo.iDay          = gpsSource.GpsPos.m_iDay;
                            renderInfo.iMonth        = gpsSource.GpsPos.m_iMonth;
                            renderInfo.iYear         = gpsSource.GpsPos.m_iYear;
                            renderInfo.colorTrack    = gpsSource.colorTrack;
                            renderInfo.sIcon         = gpsSource.sIconPath;
//                            while (m_GpsTracker.m_fCloseThreads == false)
//                            {
                            m_GpsTracker.m_gpsTrackerPlugin.pluginShowOverlay(renderInfo);
                            if (gpsSource.bTrack == true)
                            {
                                m_GpsTracker.m_gpsTrackerPlugin.pluginWorldWindowGotoLatLonHeading(gpsSource.GpsPos.m_gpsTrack.m_fLat[0], gpsSource.GpsPos.m_gpsTrack.m_fLon[0], -1F, gpsSource.iStartAltitud);
                            }
                            if (gpsSource.iStartAltitud > 0)
                            {
                                gpsSource.iStartAltitud = 0;
                            }

//                                Thread.Sleep(3000);
//                            }
                        }
                    }

                    if (gpsSource.iReload == 0 || m_GpsTracker.m_fCloseThreads == true)
                    {
                        break;
                    }
                    else
                    {
                        for (int i = 0; i < gpsSource.iReload && m_GpsTracker.m_fCloseThreads == false; i++)
                        {
                            Thread.Sleep(1000);
                        }
                    }
                }
                catch (Exception)
                {
                    if (bShowError)
                    {
                        lock ("threadStartFile")
                        {
                            bShowError = false;
                            m_GpsTracker.m_gpsTrackerPlugin.pluginShowFixInfo("GPSTracker: Unable to Download " + gpsSource.sFileName + ". Retrying in the background.");
                            for (int i = 0; i < 5 && m_GpsTracker.m_fCloseThreads == false; i++)
                            {
                                Thread.Sleep(1000);
                            }
                            m_GpsTracker.m_gpsTrackerPlugin.pluginShowFixInfo("");
                            m_GpsTracker.m_gpsTrackerPlugin.pluginShowFixInfo("GPSTracker: Active");
                        }
                        for (int i = 0; i < 60 && m_GpsTracker.m_fCloseThreads == false; i++)
                        {
                            Thread.Sleep(1000);
                        }
                    }
                    else
                    {
                        m_GpsTracker.m_gpsTrackerPlugin.pluginShowFixInfo("");
                        m_GpsTracker.m_gpsTrackerPlugin.pluginShowFixInfo("GPSTracker: Active");
                        for (int i = 0; i < 60 && m_GpsTracker.m_fCloseThreads == false; i++)
                        {
                            Thread.Sleep(1000);
                        }
                    }
                }
            }

            gpsSource.eventThreadSync.Set();
        }
コード例 #7
0
ファイル: GPSTracker.cs プロジェクト: jpespartero/WorldWind
		private void threadPOI()
		{
            try
            {
                bool bStartAltitud = false;
                Thread.Sleep(500);
                while (!m_fCloseThreads)
                {
                    lock (LockPOI)
                    {
                        for (int i = 0; i < m_gpsSourceList.Count; i++)
                        {
                            GPSSource gpsSource = (GPSSource)m_gpsSourceList[i];
                            Thread.Sleep(100);

                            if (!gpsSource.bSetup)
                                continue;

                            if (gpsSource.sType == "POI" && gpsSource.bPOISet == false) //Point of interest
                            {
                                gpsSource.bPOISet = true;

                                GPSRenderInformation renderInfo = new GPSRenderInformation();
                                renderInfo.bPOI = true;
                                renderInfo.iIndex = i;
							    renderInfo.sDescription=gpsSource.sDescription.Trim();
                                renderInfo.fFix = false;
                                renderInfo.fLat = gpsSource.fLat;
                                renderInfo.fLon = gpsSource.fLon;
                                renderInfo.sIcon = gpsSource.sIconPath;
                                renderInfo.bShowInfo = m_bInfoText;
                                renderInfo.bTrackLine = m_bTrackLine;
                                renderInfo.gpsTrack = gpsSource.GpsPos.m_gpsTrack;
                                renderInfo.bRestartTrack = false;
                                renderInfo.iDay = gpsSource.GpsPos.m_iDay;
                                renderInfo.iMonth = gpsSource.GpsPos.m_iMonth;
                                renderInfo.iYear = gpsSource.GpsPos.m_iYear;
                                renderInfo.colorTrack = gpsSource.colorTrack;
                                m_gpsTrackerPlugin.pluginShowOverlay(renderInfo);
                                if (gpsSource.bTrack)
                                {
                                    if (bStartAltitud == true)
                                        gpsSource.iStartAltitud = 0;
                                    m_gpsTrackerPlugin.pluginWorldWindowGotoLatLonHeading(Convert.ToSingle(gpsSource.fLat), Convert.ToSingle(gpsSource.fLon), -1F, gpsSource.iStartAltitud);
                                }

                            }
                            else
                                if (gpsSource.sType == "POI" && gpsSource.bTrack)
                                {
                                    if (bStartAltitud == true)
                                        gpsSource.iStartAltitud = 0;
                                    m_gpsTrackerPlugin.pluginWorldWindowGotoLatLonHeading(Convert.ToSingle(gpsSource.fLat), Convert.ToSingle(gpsSource.fLon), -1F, gpsSource.iStartAltitud);
                                }
                            if (gpsSource.iStartAltitud > 0 && bStartAltitud==false)
                            {
                                Thread.Sleep(3000);
                                bStartAltitud = true;
                                gpsSource.iStartAltitud = 0;
                            }


                            if (m_fCloseThreads)
                                break;
                        }


                    }

                    if (!m_fCloseThreads)
                        Thread.Sleep(1000);
                }
                m_eventPOIThreadSync.Set();
            }
            catch (Exception)
            {
            }
		}
コード例 #8
0
ファイル: GPSTracker.cs プロジェクト: jpespartero/WorldWind
		//Show the GPS icon in he World View
		public bool ShowGPSIcon(char [] cNMEAMessage, int iMsgLength, bool fCheck, int iIndex, bool bRestartTrack, bool bParse)
		{
			bool bRet=false;

			lock(LockShowIcon)
			{
				GPSSource gpsSource = (GPSSource)m_gpsSourceList[iIndex];

#if !DEBUG
			try
#endif
			{
				if (bParse)
					bRet=m_NMEA.ParseGPSMessage(cNMEAMessage,iMsgLength,fCheck,iIndex);
				else
					bRet=true;
			
				if (bRet==true && m_fInitialized==true)
				{
					if(m_swRecorder!=null)
					{
						String sMsg = new String(cNMEAMessage);
						char [] cAny = new char[3];	cAny[0]='\r'; cAny[1]='\n';	cAny[2]='\0';
						int iEnd=sMsg.IndexOfAny(cAny);
						if (iEnd>0)
							sMsg=sMsg.Substring(0,iEnd);
						sMsg = Convert.ToString(iIndex) + "," + sMsg;
						m_swRecorder.WriteLine(sMsg);
					}

                    string sNMEAMsg = "";
                    if (gpsSource.bNMEAExport)
                        sNMEAMsg = m_NMEA.ConvertToGPGGA(gpsSource.GpsPos);

                    //Export to a raw NMEA file is selected
                    if (gpsSource.bNMEAExport && sNMEAMsg != "")
                    {
                        if (gpsSource.swExport == null)
                        {
                            try
                            {
                                string sPath = textBoxNMEAExportPath.Text;
                                if (sPath == "")
                                    sPath = GpsTrackerPlugin.m_sPluginDirectory + "\\NMEAExport\\" + gpsSource.sDescription + ".txt";
                                else
                                {
                                    if (sPath.EndsWith("\\"))
                                        sPath = sPath + gpsSource.sDescription + ".txt";
                                    else
                                        sPath = sPath + "\\" + gpsSource.sDescription + ".txt";
                                }
                                gpsSource.swExport = File.CreateText(sPath);
                            }
                            catch (Exception)
                            {
                                gpsSource.swExport = null;
                            }
                        }

                        try
                        {
                            if (gpsSource.swExport != null)
                            {
                                gpsSource.swExport.WriteLine(sNMEAMsg);
                                gpsSource.swExport.Flush();
                            }
                        }
                        catch (Exception)
                        {
                        }
                    }

					m_gpsTrackerPlugin.pluginLocked(true);
								
					//Show the user selected icon for the gps device on the WorldView
					string sPortInfo=gpsSource.sType;
					switch (sPortInfo)
					{
						case "UDP":
							sPortInfo += ": Port " + Convert.ToString(gpsSource.iUDPPort);
							break;
						case "COM":
							sPortInfo += ": Port " + Convert.ToString(gpsSource.iCOMPort);
							break;
						case "USB":
							sPortInfo += ": USB Device " + gpsSource.sUSBDevice;
							break;
						case "TCP":
							sPortInfo += ": IP:Port " + gpsSource.sTCPAddress + ":" + Convert.ToString(gpsSource.iTCPPort);
							break;
						case "File":
							//Do not display port info for an IXSEA file.
							string sFileName=gpsSource.sFileName;
							int iIndexName = sFileName.LastIndexOf('\\');
							if (iIndexName>=0 && iIndexName<sFileName.Length-1)
								sFileName=sFileName.Substring(iIndexName+1);

							sPortInfo += ": " + sFileName;
							break;

					}

					if (m_fInitialized==true)
					{
						GPSRenderInformation renderInfo = new GPSRenderInformation();
						renderInfo.fTrack=gpsSource.bTrack;
						renderInfo.bPOI=false;
						renderInfo.iIndex=iIndex;
                        if (gpsSource.GpsPos.m_sName != "")
                            renderInfo.sDescription = gpsSource.GpsPos.m_sName;
						else
							renderInfo.sDescription=gpsSource.sDescription;
                        renderInfo.sComment = gpsSource.GpsPos.m_sComment;
                        renderInfo.iAPRSIconTable = gpsSource.GpsPos.m_iAPRSIconTable;
                        renderInfo.iAPRSIconCode = gpsSource.GpsPos.m_iAPRSIconCode;
						renderInfo.fFix=true;
                        renderInfo.fLat = gpsSource.GpsPos.m_fLat;
                        renderInfo.fLon = gpsSource.GpsPos.m_fLon;
                        renderInfo.fAlt = gpsSource.GpsPos.m_fAlt;
                        renderInfo.fRoll = gpsSource.GpsPos.m_fRoll;
                        renderInfo.fPitch = gpsSource.GpsPos.m_fPitch;
                        renderInfo.fDepth = gpsSource.GpsPos.m_fDepth;
                        renderInfo.sAltUnit = gpsSource.GpsPos.m_sAltUnit;
                        renderInfo.sSpeedUnit = gpsSource.GpsPos.m_sSpeedUnit;
                        renderInfo.fSpeed = gpsSource.GpsPos.m_fSpeed;
                        renderInfo.fESpeed = gpsSource.GpsPos.m_fESpeed;
                        renderInfo.fNSpeed = gpsSource.GpsPos.m_fNSpeed;
                        renderInfo.fVSpeed = gpsSource.GpsPos.m_fVSpeed;
                        renderInfo.fHeading = gpsSource.GpsPos.m_fHeading;

                        if (gpsSource.GpsPos.m_iAPRSIconCode >= 0 && gpsSource.GpsPos.m_iAPRSIconTable >= 0)
						{
							string sPath="";
                            if (gpsSource.GpsPos.m_iAPRSIconTable == Convert.ToInt32('/'))
                                sPath = GpsTrackerPlugin.m_sPluginDirectory + "\\aprs\\primary";
                            if (gpsSource.GpsPos.m_iAPRSIconTable == Convert.ToInt32('\\'))
                                sPath = GpsTrackerPlugin.m_sPluginDirectory + "\\aprs\\secondary";

							if (sPath!="")
							{
                                string sFileName = String.Format("{0:000}", gpsSource.GpsPos.m_iAPRSIconCode) + ".png";
								if (File.Exists(sPath + "\\" + sFileName))
									sPath=sPath + "\\" + sFileName;
								else
									sPath=gpsSource.sIconPath;
							}
							else
								sPath=gpsSource.sIconPath;
							
							renderInfo.sIcon=sPath;

						}
						else
							renderInfo.sIcon=gpsSource.sIconPath;

						renderInfo.iStartAltitud=gpsSource.iStartAltitud;
						renderInfo.sPortInfo=sPortInfo;
                        renderInfo.iHour = gpsSource.GpsPos.m_iHour;
                        renderInfo.iMin = gpsSource.GpsPos.m_iMin;
                        renderInfo.fSec = gpsSource.GpsPos.m_iSec;
						renderInfo.bShowInfo=m_bInfoText;
						renderInfo.bTrackLine=m_bTrackLine;
                        renderInfo.gpsTrack = gpsSource.GpsPos.m_gpsTrack;
						renderInfo.bRestartTrack=bRestartTrack;
                        renderInfo.iDay = gpsSource.GpsPos.m_iDay;
                        renderInfo.iMonth = gpsSource.GpsPos.m_iMonth;
                        renderInfo.iYear = gpsSource.GpsPos.m_iYear;
						renderInfo.colorTrack=gpsSource.colorTrack;
						m_gpsTrackerPlugin.pluginShowOverlay(renderInfo);

                        //GeoFence Check
                        lock ("GeoFenceAccess")
                        {
                            for (int iFence = 0; iFence < m_gpsSourceList.Count; iFence++)
                            {
                                GPSSource gpsSourceFence = (GPSSource)m_gpsSourceList[iFence];
                                if (gpsSourceFence.sType == "GeoFence" &&
                                    (gpsSourceFence.GeoFence.sSource == gpsSource.sDescription ||
                                    gpsSourceFence.GeoFence.sSource == "All Gps Sources"))
                                {
                                    bool bSourceIn = false;
                                    int i = 0;
                                    int j = 0;
                                    for (i = 0; i < gpsSourceFence.GeoFence.arrayLat.Count; i++)
                                    {
                                        j++;
                                        if (j == gpsSourceFence.GeoFence.arrayLat.Count)
                                            j = 0;
                                        if ((float)gpsSourceFence.GeoFence.arrayLat[i] < gpsSource.GpsPos.m_fLat && (float)gpsSourceFence.GeoFence.arrayLat[j] >= gpsSource.GpsPos.m_fLat ||
                                            (float)gpsSourceFence.GeoFence.arrayLat[j] < gpsSource.GpsPos.m_fLat && (float)gpsSourceFence.GeoFence.arrayLat[i] >= gpsSource.GpsPos.m_fLat)
                                        {
                                            if ((float)gpsSourceFence.GeoFence.arrayLon[i] + (gpsSource.GpsPos.m_fLat - (float)gpsSourceFence.GeoFence.arrayLat[i]) / ((float)gpsSourceFence.GeoFence.arrayLat[j] - (float)gpsSourceFence.GeoFence.arrayLat[i]) * ((float)gpsSourceFence.GeoFence.arrayLon[j] - (float)gpsSourceFence.GeoFence.arrayLon[i]) < gpsSource.GpsPos.m_fLon)
                                                bSourceIn = !bSourceIn;
                                        }

                                    }

                                    for (i = 0; i < gpsSourceFence.GeoFence.SourcesIn.Count; i++)
                                    {
                                        string sSourceIn = (string)gpsSourceFence.GeoFence.SourcesIn[i];
                                        if (sSourceIn == gpsSource.sDescription && bSourceIn == false)
                                        {
                                            gpsSourceFence.GeoFence.SourcesIn.RemoveAt(i);
                                            gpsSourceFence.GeoFence.SourcesOut.Add(gpsSource.sDescription);
                                            // Signal current source is going OUT
                                            SignalGeoFence(false, gpsSourceFence.GeoFence, gpsSource);
                                            break;
                                        }
                                    }

                                    for (i = 0; i < gpsSourceFence.GeoFence.SourcesOut.Count; i++)
                                    {
                                        string sSourceOut = (string)gpsSourceFence.GeoFence.SourcesOut[i];
                                        if (sSourceOut == gpsSource.sDescription && bSourceIn == true)
                                        {
                                            gpsSourceFence.GeoFence.SourcesOut.RemoveAt(i);
                                            gpsSourceFence.GeoFence.SourcesIn.Add(gpsSource.sDescription);
                                            // Signal current source is going IN
                                            SignalGeoFence(true, gpsSourceFence.GeoFence, gpsSource);
                                            break;
                                        }
                                    }

                                    if (gpsSourceFence.GeoFence.SourcesIn.Count == 0 && bSourceIn == true)
                                    {
                                        gpsSourceFence.GeoFence.SourcesIn.Add(gpsSource.sDescription);
                                        // Signal current source is going IN
                                        SignalGeoFence(true, gpsSourceFence.GeoFence, gpsSource);
                                    }
                                    else
                                        if (gpsSourceFence.GeoFence.SourcesOut.Count == 0 && bSourceIn == false)
                                    {
                                        gpsSourceFence.GeoFence.SourcesOut.Add(gpsSource.sDescription);
                                        // Signal current source is going OUT
                                        SignalGeoFence(false, gpsSourceFence.GeoFence, gpsSource);
                                    }
                                }
                            }
                        }
                        

						if (gpsSource.iStartAltitud>0)
						{
							Thread.Sleep(3000);
							gpsSource.iStartAltitud=0;
						}
					}
					m_iLocked++;

				}

						//Display Message in Message Monitor
				try
				{
					if (m_MessageMonitor!=null && bRet)
							m_MessageMonitor.AddMessage(cNMEAMessage, iMsgLength);
				}
				catch (Exception)
				{
					m_MessageMonitor=null;
				}

						
					}
#if !DEBUG
			catch (Exception)
			{
			}
#endif

			}
			return bRet;
		}
コード例 #9
0
ファイル: GPSTracker.cs プロジェクト: jpespartero/WorldWind
        //
		//Start all the necessary threads for processing all the selected gps sources
		private bool Start()
		{
			bool fRet=false;
			GPSSource gpsSource;

			if (m_fInitialized)
			{
				progressBarSetup.Visible=false;
				labelSettingup.Visible=false;

				m_iLocked=0;
				m_iPrevLocked=0;
			
				m_fCloseThreads=false;

				m_fVerticalExaggeration=World.Settings.VerticalExaggeration;
				if (checkBoxVExaggeration.Checked==true)
					World.Settings.VerticalExaggeration=0F;

				labelSettingup.Visible=true;
				labelSettingup.Update();
				progressBarSetup.Visible=true;
				progressBarSetup.Update();
				progressBarSetup.Maximum=m_gpsSourceList.Count+1;
				if (m_fPlayback==false)
				{
					for (int i=0; i<m_gpsSourceList.Count; i++)
					{
						gpsSource=(GPSSource)m_gpsSourceList[i];
						gpsSource.datePosition = new DateTime(1771,6,9);

						if (checkBoxSetAltitud.Checked && gpsSource.bTrack)
							gpsSource.iStartAltitud = Convert.ToInt32(numericUpDownAltitud.Value);
						else
							gpsSource.iStartAltitud=0;

						if (!gpsSource.bSetup)
							continue;

                        gpsSource.GpsPos.m_gpsTrack = null;
                        if (gpsSource.bSave && (i + 1 <= progressBarSetup.Maximum))
						    progressBarSetup.Value=i+1;

                        if (gpsSource.sType == "COM" && gpsSource.GpsCOM.IsOpen)
                            gpsSource.GpsCOM.StartRx();
						else
						if (gpsSource.sType=="POI") //Point of interest
						{
							if (m_hPOIThread==null)
							{
                                m_eventPOIThreadSync = new AutoResetEvent(false);
								m_hPOIThread = new Thread(new ThreadStart(this.threadPOI));
								m_hPOIThread.IsBackground = true;
								m_hPOIThread.Priority = System.Threading.ThreadPriority.Normal; 
								m_hPOIThread.Start();
							}
						}
						else
						{
							if (gpsSource.sType=="TCP")
							{
								SecurityOptions options;
								if (gpsSource.bSecureSocket)
									options = new SecurityOptions(
										SecureProtocol.Ssl3 | SecureProtocol.Tls1,	// use SSL3 or TLS1
										null,										// do not use client authentication
										ConnectionEnd.Client,						// this is the client side
										CredentialVerification.None,				// do not check the certificate -- this should not be used in a real-life application :-)
										null,										// not used with automatic certificate verification
										gpsSource.sTCPAddress,						// this is the common name of the Microsoft web server
										SecurityFlags.Default,						// use the default security flags
										SslAlgorithms.SECURE_CIPHERS,				// only use secure ciphers
										null);
								else
									options = new SecurityOptions(SecureProtocol.None, null, ConnectionEnd.Client);
								SecureSocket socketTCP = new SecureSocket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp, options);
								
								IPHostEntry IPHost = Dns.GetHostEntry(gpsSource.sTCPAddress); 
								IPEndPoint ipEndPoint	= new IPEndPoint(IPHost.AddressList[0], gpsSource.iTCPPort);
								socketTCP.Blocking = true ;
								AsyncCallback callbackProc	= new AsyncCallback(m_UDPTCP.TcpConnectCallback);
                                gpsSource.tcpSockets = new TCPSockets();
                                gpsSource.tcpSockets.sStream = "";
                                gpsSource.tcpSockets.socket = socketTCP;
                                gpsSource.tcpSockets.iDeviceIndex = i;
                                gpsSource.tcpSockets.byTcpBuffer = new byte[1024];
                                gpsSource.tcpSockets.socket.BeginConnect(ipEndPoint, callbackProc, gpsSource.tcpSockets);	
							}
							else
							if (gpsSource.sType=="UDP")
							{
                                //
                                //This thread starts the UDP lisenter
                                gpsSource.eventThreadSync = new AutoResetEvent(false);
                                gpsSource.fileThread = new Thread(new ThreadStart(threadUDP));
                                gpsSource.fileThread.IsBackground = true;
                                gpsSource.fileThread.Priority = System.Threading.ThreadPriority.Normal;
                                gpsSource.fileThread.Name = i.ToString();
                                gpsSource.fileThread.Start(); 
                                 
							}
							else
							if (gpsSource.sType=="File")
							{
                                gpsSource.eventThreadSync = new AutoResetEvent(false);
								gpsSource.fileThread = new Thread(new ThreadStart(m_File.threadStartFile));
								gpsSource.fileThread.IsBackground = true;
								gpsSource.fileThread.Priority = System.Threading.ThreadPriority.Normal; 
								gpsSource.fileThread.Name= i.ToString(); 
								gpsSource.fileThread.Start();
							}
							else
							if (gpsSource.sType=="APRS Internet")
							{
                                gpsSource.eventThreadSync = new AutoResetEvent(false);
                                gpsSource.aprsThread = new Thread(new ThreadStart(m_APRS.threadAPRSIS));
                                gpsSource.aprsThread.IsBackground = true;
                                gpsSource.aprsThread.Name = i.ToString();
                                gpsSource.aprsThread.Start();
							}
							else
							if (gpsSource.sType=="USB")
							{
                                gpsSource.eventThreadSync = new AutoResetEvent(false);
								gpsSource.usbThread = new Thread(new ThreadStart(m_File.threadStartUSB));
								gpsSource.usbThread.IsBackground = true;
								gpsSource.usbThread.Priority = System.Threading.ThreadPriority.Normal; 
								gpsSource.usbThread.Name= i.ToString(); 
								gpsSource.usbThread.Start();
							}
                            else
							if (gpsSource.sType=="GeoFence")
							{
                                gpsSource.GeoFence.sName = gpsSource.sDescription;
                                gpsSource.GeoFence.bShowInfo = checkBoxInformationText.Checked;
                                m_gpsTrackerPlugin.pluginAddGeoFence(gpsSource.GeoFence);
                            }
						}
					}
				}
				else
				{
					
					for (int i=0; i<m_gpsSourceList.Count; i++)
					{
						gpsSource=(GPSSource)m_gpsSourceList[i];
						gpsSource.iReload=0;
						gpsSource.datePosition = new DateTime(1771,6,9);

						if (checkBoxSetAltitud.Checked && gpsSource.bTrack)
							gpsSource.iStartAltitud = Convert.ToInt32(numericUpDownAltitud.Value);
						else
							gpsSource.iStartAltitud=0;

						if (!gpsSource.bSetup)
							continue;

                        gpsSource.GpsPos.m_gpsTrack = null;
                        if ((i + 1 <= progressBarSetup.Maximum))
						    progressBarSetup.Value=i+1;
						if (gpsSource.sType=="POI") //Point of interest
						{
							if (m_hPOIThread==null)
							{
                                m_eventPOIThreadSync = new AutoResetEvent(false);
								m_hPOIThread = new Thread(new ThreadStart(this.threadPOI));
								m_hPOIThread.IsBackground = true;
								m_hPOIThread.Priority = System.Threading.ThreadPriority.Normal; 
								m_hPOIThread.Start();
							}
						}
						else
						{
							if (gpsSource.bTrackAtOnce!=true)
							{
                                gpsSource.eventThreadSync = new AutoResetEvent(false);
                                gpsSource.fileThread = new Thread(new ThreadStart(m_File.threadFile));
                                gpsSource.fileThread.IsBackground = true;
                                gpsSource.fileThread.Priority = System.Threading.ThreadPriority.Normal;
                                gpsSource.fileThread.Name = i.ToString(); 
								gpsSource.sFileNameSession=m_sPlaybackFile;
								if (gpsSource.sType=="File")
									gpsSource.iFilePlaySpeed=gpsSource.iPlaySpeed;
								else
									gpsSource.iFilePlaySpeed=1;
                                gpsSource.fileThread.Start();
							}
							else
							{
								gpsSource.sFileName=gpsSource.sFileName.Replace("*PLUGINDIR*",GpsTrackerPlugin.m_sPluginDirectory);
								if (File.Exists(gpsSource.sFileName))
								{
									//track at once
									m_File.PreprocessFile(i,gpsSource.sFileName,gpsSource.sFileName,true,gpsSource.bForcePreprocessing);

									GPSRenderInformation renderInfo = new GPSRenderInformation();
									renderInfo.bPOI=false;
									renderInfo.iIndex=i;
									renderInfo.sDescription=gpsSource.sDescription;
									renderInfo.fFix=false;
									renderInfo.bShowInfo=m_bInfoText;
									renderInfo.bTrackLine=false;
                                    renderInfo.gpsTrack = gpsSource.GpsPos.m_gpsTrack;
									renderInfo.bRestartTrack=false;
                                    renderInfo.iDay = gpsSource.GpsPos.m_iDay;
                                    renderInfo.iMonth = gpsSource.GpsPos.m_iMonth;
                                    renderInfo.iYear = gpsSource.GpsPos.m_iYear;
									renderInfo.colorTrack=gpsSource.colorTrack;
									m_gpsTrackerPlugin.pluginShowOverlay(renderInfo);

									if (gpsSource.bTrack==true)
                                        m_gpsTrackerPlugin.pluginWorldWindowGotoLatLonHeading(gpsSource.GpsPos.m_gpsTrack.m_fLat[0], gpsSource.GpsPos.m_gpsTrack.m_fLat[0], -1F, gpsSource.iStartAltitud);
									if (gpsSource.iStartAltitud>0)
									{
										Thread.Sleep(3000);
										gpsSource.iStartAltitud=0;
									}

								}
							}
						}
					}
				}
                if (m_gpsSourceList.Count + 1 <= progressBarSetup.Maximum)
				    progressBarSetup.Value=m_gpsSourceList.Count+1;

				if (m_timerLocked==null)
					m_timerLocked = new System.Threading.Timer(new TimerCallback(timerCallbackLocked),0, 500, 5000);
			
				fRet=true;
			}

			return fRet;
		}
コード例 #10
0
		public void threadStartFile()
		{
			int iIndex= Int32.Parse(Thread.CurrentThread.Name); 
			GPSSource gpsSource = (GPSSource)m_GpsTracker.m_gpsSourceList[iIndex];
			bool bShowError=true;

			while(m_GpsTracker.m_fCloseThreads==false)
			{
				gpsSource.GpsPos.m_gpsTrack = null;

				try
				{
					string sFileName="";
					lock("threadStartFile")
					{
						m_GpsTracker.m_gpsTrackerPlugin.pluginShowFixInfo("GPSTracker: Downloading " + gpsSource.sFileName);

						WebClient myWebClient = new WebClient();
                        sFileName = GpsTrackerPlugin.m_sPluginDirectory + "\\DownloadedFile" + Convert.ToString(iIndex) + ".gpsTracker";
						if (File.Exists(sFileName))
							File.Delete(sFileName);
						string sWebReload="";
						if (!File.Exists(gpsSource.sFileName))
							sWebReload="?r=" + System.Guid.NewGuid().ToString();

						myWebClient.DownloadFile(gpsSource.sFileName + sWebReload, sFileName); 
					}

					if (File.Exists(sFileName))
					{
						gpsSource.bBabelNMEA=false;
						lock("threadStartFile")
						{
							//Convert files to a known format
							switch (gpsSource.saGpsBabelFormat[0])
							{
								case "nasabaloon":
									if (m_GpsTracker.m_NMEA.CheckConvertNasaBaloon(sFileName, gpsSource.sFileName))
										sFileName=sFileName + ".NMEAText";
									break;
								case "aprs":
								case "nmea":
								case "GpsTracker":
								case "Unknown":
									//Nothing to convert
									break;
								default:
									//Use GpsBabel
									string sBabelCommandLine;
									if (gpsSource.bWaypoints)
										sBabelCommandLine = "-w;";
									else
										sBabelCommandLine = "-t;-r;";
									sBabelCommandLine+="-i;" + gpsSource.saGpsBabelFormat[0] + ";";
									sBabelCommandLine+="-f;" + sFileName + ";";
									if (gpsSource.bWaypoints)
									{
										sBabelCommandLine+="-o;csv;-F;" + sFileName + ".WaypointsCSV;";
										if (File.Exists(sFileName + ".WaypointsCSV"))
											File.Delete(sFileName + ".WaypointsCSV");
									}
									else
									{
										sBabelCommandLine+="-o;nmea;-F;" + sFileName + ".NMEAText;";
										if (File.Exists(sFileName + ".NMEAText"))
											File.Delete(sFileName + ".NMEAText");
									}
									m_GpsBabel.Execute(sBabelCommandLine);

									if (gpsSource.bWaypoints && File.Exists(sFileName + ".WaypointsCSV"))
									{
										FileInfo fInfo = new FileInfo(sFileName + ".WaypointsCSV");
										if (fInfo.Length>0)
											sFileName+=".WaypointsCSV";
									}
									else
										if (gpsSource.bWaypoints==false && File.Exists(sFileName + ".NMEAText"))
									{
										FileInfo fInfo = new FileInfo(sFileName + ".NMEAText");
										if (fInfo.Length>0)
						{
											sFileName+=".NMEAText";
											gpsSource.bBabelNMEA=true;
						}
									}
									break;

							}
						}

						if (gpsSource.bTrackAtOnce!=true && !m_GpsTracker.m_File.IsTrackAtOnce(sFileName))
						{
							if (!gpsSource.bWaypoints)
							{
								m_GpsTracker.m_gpsTrackerPlugin.pluginShowFixInfo("");
								m_GpsTracker.m_gpsTrackerPlugin.pluginShowFixInfo("GPSTracker: Active");

							gpsSource.sFileNameSession=sFileName;
							gpsSource.iFilePlaySpeed=gpsSource.iPlaySpeed;
							threadFile();
						}
						else
						{
								m_GpsTracker.m_gpsTrackerPlugin.pluginShowFixInfo("");
								m_GpsTracker.m_gpsTrackerPlugin.pluginShowFixInfo("GPSTracker: Active");
	
								ArrayList listWaypoints = new ArrayList();
								StreamReader sReader = null;
								try
								{
									sReader = File.OpenText(sFileName);
									string sLine;
									do
									{
										sLine=sReader.ReadLine();
										if (sLine!=null)
											listWaypoints.Add(sLine);
									} while(sLine!=null);
								}
								catch(Exception)
								{
								}
								if (sReader!=null)
									sReader.Close();

								if (listWaypoints.Count>0)
								{
									char [] cSep = { ',' };
									bool bTrack = gpsSource.bTrack;
									for (int i=0; i<listWaypoints.Count; i++)
									{
										string sFormat = (string)listWaypoints[i];
										string [] sWaypointData;
										sWaypointData = sFormat.Split(cSep);
										if (sWaypointData.Length == 3)
										{
											try
											{
												m_GpsTracker.AddPOI(sWaypointData[2], Convert.ToDouble(sWaypointData[0]), Convert.ToDouble(sWaypointData[1]), false, gpsSource);
												if (gpsSource.bTrack)
													gpsSource.bTrack=false;
											}
											catch(Exception)
											{
												Thread.Sleep(200);
											}
										}
									}
									gpsSource.bTrack = bTrack;
								}
							}
						}
						else
						{
							if (gpsSource.iReload>0 && File.Exists(sFileName + ".TrackAtOnce"))
								File.Delete(sFileName + ".TrackAtOnce");

							lock("threadStartFile")
							{
								//track at once
								m_GpsTracker.m_File.PreprocessFile(iIndex,sFileName,gpsSource.sFileName,false,gpsSource.bForcePreprocessing);
							}

							GPSRenderInformation renderInfo = new GPSRenderInformation();
							renderInfo.bPOI=false;
							renderInfo.iIndex=iIndex;
							renderInfo.sDescription=gpsSource.sDescription;
							renderInfo.fFix=false;
							renderInfo.bShowInfo=m_GpsTracker.m_bInfoText;
							renderInfo.bTrackLine=false;
							renderInfo.gpsTrack=gpsSource.GpsPos.m_gpsTrack;
							renderInfo.bRestartTrack=false;
							renderInfo.iDay=gpsSource.GpsPos.m_iDay;
							renderInfo.iMonth=gpsSource.GpsPos.m_iMonth;
							renderInfo.iYear=gpsSource.GpsPos.m_iYear;
							renderInfo.colorTrack=gpsSource.colorTrack;
                            renderInfo.sIcon = gpsSource.sIconPath;
//                            while (m_GpsTracker.m_fCloseThreads == false)
//                            {
                                m_GpsTracker.m_gpsTrackerPlugin.pluginShowOverlay(renderInfo);
                                if (gpsSource.bTrack == true)
                                    m_GpsTracker.m_gpsTrackerPlugin.pluginWorldWindowGotoLatLonHeading(gpsSource.GpsPos.m_gpsTrack.m_fLat[0], gpsSource.GpsPos.m_gpsTrack.m_fLon[0], -1F, gpsSource.iStartAltitud);
                                if (gpsSource.iStartAltitud > 0)
                                    gpsSource.iStartAltitud = 0;
                                
//                                Thread.Sleep(3000);
//                            }
						}
					}

					if (gpsSource.iReload==0 || m_GpsTracker.m_fCloseThreads==true)
						break;
					else
					{
						for (int i=0; i<gpsSource.iReload && m_GpsTracker.m_fCloseThreads==false; i++)
							Thread.Sleep(1000);

					}
				}
				catch(Exception)
				{
					if (bShowError)
					{
						lock("threadStartFile")
						{
							bShowError=false;
							m_GpsTracker.m_gpsTrackerPlugin.pluginShowFixInfo("GPSTracker: Unable to Download " + gpsSource.sFileName + ". Retrying in the background.");
							for (int i=0; i<5 && m_GpsTracker.m_fCloseThreads==false; i++)
								Thread.Sleep(1000);
							m_GpsTracker.m_gpsTrackerPlugin.pluginShowFixInfo("");
							m_GpsTracker.m_gpsTrackerPlugin.pluginShowFixInfo("GPSTracker: Active");
						}
						for (int i=0; i<60 && m_GpsTracker.m_fCloseThreads==false; i++)
							Thread.Sleep(1000);
					}
					else
					{
						m_GpsTracker.m_gpsTrackerPlugin.pluginShowFixInfo("");
						m_GpsTracker.m_gpsTrackerPlugin.pluginShowFixInfo("GPSTracker: Active");
						for (int i=0; i<60 && m_GpsTracker.m_fCloseThreads==false; i++)
							Thread.Sleep(1000);
					}
				}
			}

            gpsSource.eventThreadSync.Set();
		}