示例#1
0
        public IList <Gh625Packet.TrackFileHeader625M> ReadTrackHeaders(IJobMonitor monitor)
        {
            monitor.PercentComplete = 0;
            monitor.StatusText      = CommonResources.Text.Devices.ImportJob_Status_OpeningDevice;

            Int16[] tracks = new Int16[2];

            GlobalsatPacket getHeadersPacket = PacketFactory.GetTrackFileHeaders();
            Gh625Packet     response         = (Gh625Packet)SendPacket(getHeadersPacket);

            return(response.UnpackTrackHeaders());
        }
示例#2
0
        public IList <Gh625Packet.TrackFileSection625M> ReadTracks(IList <Gh625Packet.TrackFileHeader625M> tracks, IJobMonitor monitor)
        {
            if (tracks.Count == 0)
            {
                return(new Gh625Packet.TrackFileSection625M[0]);
            }

            float         totalPoints  = 0;
            IList <Int16> trackIndexes = new List <Int16>();

            foreach (Gh625Packet.TrackFileHeader625M header in tracks)
            {
                totalPoints += header.TrackPointCount;
                trackIndexes.Add(header.TrackPointIndex);
            }
            float pointsRead = 0;

            IList <Gh625Packet.TrackFileSection625M> trackSections = new List <Gh625Packet.TrackFileSection625M>();
            GlobalsatPacket getFilesPacket = PacketFactory.GetTrackFileSections(trackIndexes);
            GlobalsatPacket getNextPacket  = PacketFactory.GetNextTrackSection();
            Gh625Packet     response       = (Gh625Packet)SendPacket(getFilesPacket);

            monitor.PercentComplete = 0;

            Gh625Packet.TrackFileSection625M trackSection;
            int numInCurrentTrain  = 0;
            int readInCurrentTrain = 0;

            do
            {
                if (numInCurrentTrain == 0)
                {
                    // The section is a laps section (the first of the section)
                    trackSection = response.UnpackTrackSectionLaps();
                    if (trackSection != null)
                    {
                        numInCurrentTrain  = trackSection.TrackPointCount;
                        readInCurrentTrain = 0;
                    }
                }
                else
                {
                    // The section is a GPS/HRM detail section
                    trackSection = response.UnpackTrackSection();
                    if (trackSection != null)
                    {
                        int pointsInThisSection = trackSection.EndPointIndex - trackSection.StartPointIndex + 1;
                        readInCurrentTrain += pointsInThisSection;
                        pointsRead         += pointsInThisSection;

                        DateTime time           = trackSection.StartTime.ToLocalTime();
                        string   statusProgress = time.ToShortDateString() + " " + time.ToShortTimeString();
                        monitor.StatusText      = String.Format(CommonResources.Text.Devices.ImportJob_Status_Reading, statusProgress);
                        monitor.PercentComplete = pointsRead / totalPoints;

                        if (readInCurrentTrain >= numInCurrentTrain)
                        {
                            numInCurrentTrain = 0;
                        }
                    }
                }
                if (trackSection != null)
                {
                    trackSections.Add(trackSection);
                    response = (Gh625Packet)SendPacket(getNextPacket);
                }
            } while (trackSection != null);

            monitor.PercentComplete = 1;
            return(trackSections);
        }