Ejemplo n.º 1
0
        internal void Read(Stream fitSource, DeveloperDataLookup lookup)
        {
            fitSource.Position = 0;
            EndianBinaryReader br = new EndianBinaryReader(fitSource, false);

            header       = br.ReadByte();
            LocalMesgNum = (byte)(header & Fit.LocalMesgNumMask);

            byte reserved = br.ReadByte();

            architecture   = br.ReadByte();
            br.IsBigEndian = this.IsBigEndian;
            GlobalMesgNum  = br.ReadUInt16();
            NumFields      = br.ReadByte();
            for (int i = 0; i < NumFields; i++)
            {
                byte num  = br.ReadByte();
                byte size = br.ReadByte();
                byte type = br.ReadByte();

                FieldDefinition newField = new FieldDefinition(num, size, type);
                fieldDefs.Add(newField);
            }

            if (ContainsDevData)
            {
                byte devFldCount = br.ReadByte();
                for (int i = 0; i < devFldCount; i++)
                {
                    // Seek to the Size
                    byte num    = br.ReadByte();
                    byte size   = br.ReadByte();
                    byte devIdx = br.ReadByte();
                    DeveloperFieldDefinition defn;
                    var key = new DeveloperDataKey(devIdx, num);
                    Tuple <DeveloperDataIdMesg, FieldDescriptionMesg> tuple = lookup.GetMesgs(key);

                    if (tuple != null)
                    {
                        defn = new DeveloperFieldDefinition(tuple.Item2, tuple.Item1, size);
                    }
                    else
                    {
                        defn = new DeveloperFieldDefinition(num, size, devIdx);
                    }

                    m_devFieldDefs.Add(defn);
                }
            }
        }
Ejemplo n.º 2
0
        public Tuple <DeveloperDataIdMesg, FieldDescriptionMesg> GetMesgs(DeveloperDataKey key)
        {
            DeveloperDataIdMesg  devIdMesg;
            FieldDescriptionMesg descriptionMesg;

            m_developerDataIdMesgs.TryGetValue(key.DeveloperDataIndex, out devIdMesg);
            m_fieldDescriptionMesgs.TryGetValue(key, out descriptionMesg);

            if (devIdMesg != null && descriptionMesg != null)
            {
                return(new Tuple <DeveloperDataIdMesg, FieldDescriptionMesg>(
                           devIdMesg,
                           descriptionMesg));
            }

            return(null);
        }
Ejemplo n.º 3
0
        public Tuple <DeveloperDataIdMessage, FieldDescriptionMessage> GetMessages(DeveloperDataKey key)
        {
            DeveloperDataIdMessage  devIdMessage;
            FieldDescriptionMessage descriptionMessage;

            m_developerDataIdMessages.TryGetValue(key.DeveloperDataIndex, out devIdMessage);
            m_fieldDescriptionMessages.TryGetValue(key, out descriptionMessage);

            if (devIdMessage != null && descriptionMessage != null)
            {
                return(new Tuple <DeveloperDataIdMessage, FieldDescriptionMessage>(
                           devIdMessage,
                           descriptionMessage));
            }

            return(null);
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Determines whether the specified <see cref="T:Dynastream.Fit.DeveloperDataKey"/> is equal to the current <see cref="T:Dynastream.Fit.DeveloperDataKey"/>.
 /// </summary>
 /// <returns>
 /// true if the specified <see cref="T:Dynastream.Fit.DeveloperDataKey"/> is equal to the current <see cref="T:Dynastream.Fit.DeveloperDataKey"/>; otherwise, false.
 /// </returns>
 /// <param name="other">
 /// The <see cref="T:Dynastream.Fit.DeveloperDataKey"/> to compare with the current <see cref="T:Dynastream.Fit.DeveloperDataKey"/>.
 /// </param>
 protected bool Equals(DeveloperDataKey other)
 {
     return((DeveloperDataIndex == other.DeveloperDataIndex) &&
            (FieldDefNum == other.FieldDefNum));
 }
Ejemplo n.º 5
0
        private DeveloperField GetDeveloperField(byte fieldNum, byte developerIndex)
        {
            var devKey = new DeveloperDataKey(developerIndex, fieldNum);

            return(developerFields.ContainsKey(devKey) ? developerFields[devKey] : null);
        }
Ejemplo n.º 6
0
        public void SetDeveloperField(DeveloperField field)
        {
            var devKey = new DeveloperDataKey(field.DeveloperDataIndex, field.Num);

            developerFields[devKey] = field;
        }