예제 #1
0
        public void RecordTelemetry(PacketDecoder packet)
        {
            if (packet.GetType().Name == "TimingsDataDecoder")
            {
                var decoder = (TimingsDataDecoder)packet;

                var item = new TrackData
                {
                    worldposx  = decoder.participants.ParticipantInfoArray(0).worldPosition.Int(0),
                    worldposy  = decoder.participants.ParticipantInfoArray(0).worldPosition.Int(1),
                    worldposz  = decoder.participants.ParticipantInfoArray(0).worldPosition.Int(2),
                    currentLap = decoder.participants.ParticipantInfoArray(0).currentLap.Int()
                };

                recordedData.trackDatas.Add(item);
            }
        }
예제 #2
0
        public void DisplayTelemetry(IRecord record)
        {
            var recordedData = record.RecordedData();

            int lap = 0;

            if (recordedData.trackDatas.Count > 0)
            {
                lap = recordedData.trackDatas[0].currentLap;
            }

            List <TrackPosData> laps = new List <TrackPosData>();
            TrackPosData        data = new TrackPosData();

            foreach (var item in recordedData.trackDatas)
            {
                var trackData = new TrackData
                {
                    worldposx = item.worldposx,
                    worldposy = item.worldposy,
                    worldposz = item.worldposz
                };

                data.trackData.Add(trackData);

                if (lap != item.currentLap)
                {
                    laps.Add(data);
                    data.trackData.Clear();
                    lap = item.currentLap;
                }
            }

            if (laps.Count > 0)
            {
                Stream          SaveFileStream = File.Create(fileName);
                BinaryFormatter serializer     = new BinaryFormatter();
                serializer.Serialize(SaveFileStream, laps);
                SaveFileStream.Close();
            }
        }
        public void Process()
        {
            var    laps     = GetLaps();
            string fileName = "./Tracks/" + laps.GetTrackName() + ".bin";

            // temp get laps x y z;
            TrackData        trackData = new TrackData();
            List <TrackData> tracks    = new List <TrackData>();

            for (int i = 1; i < laps.Size(); i = (i + 2))
            {
                // skip out lap and them get every second lap
                // 1 = outside
                // 3 = raceline
                // 5 = inside
                for (int j = 0; j < laps.GetLaps()[i].Size(); ++j)
                {
                    if (laps.GetLaps()[i].GetPackets()[j].GetType().Name == "TimingsDataDecoder")
                    {
                        TimingsDataDecoder timings = (TimingsDataDecoder)laps.GetLaps()[i].GetPackets()[j];;

                        trackData = new TrackData
                        {
                            worldposx  = timings.participants.ParticipantInfoArray(timings.localParticipantIndex.Int()).worldPosition.Int(0),
                            worldposy  = timings.participants.ParticipantInfoArray(timings.localParticipantIndex.Int()).worldPosition.Int(1),
                            worldposz  = timings.participants.ParticipantInfoArray(timings.localParticipantIndex.Int()).worldPosition.Int(2),
                            currentLap = i
                        };
                        tracks.Add(trackData);
                    }
                }
            }

            if (tracks.Count != 0)
            {
                FileStream stream = new FileStream(fileName);
                stream.Save(tracks);
            }

            laps.EraseLaps();
        }