Exemplo n.º 1
0
        public ActivityData(byte[] data, int activityDataLength)
        {
            Items = new List <ActivityDataItem>();

            int length = (int)BinaryHelper.BytesToLong(BinaryHelper.SubByte(data, 1, 2));
            int num2   = (int)BinaryHelper.BytesToLong(BinaryHelper.SubByte(data, 3, 2));

            data = BinaryHelper.SubByte(data, 5, data.Length - 4);
            if (length > 0)
            {
                byte[] buffer  = BinaryHelper.SubByte(data, length + 1, data.Length - length);
                byte[] buffer2 = BinaryHelper.SubByte(data, 1, length);
                data = BinaryHelper.JoinBytes(buffer, buffer2);
            }
            num2 = ((num2 - length) + activityDataLength) % activityDataLength;
            int  num4 = (int)BinaryHelper.BytesToLong(BinaryHelper.SubByte(data, 3, 2));
            int  num5 = 0;
            bool flag = true;

            while (flag & (num4 > 0))
            {
                ActivityDataItem activityDataItem = new ActivityDataItem
                {
                    RecordDate           = BinaryHelper.ToDate(BinaryHelper.SubByte(data, num5 + 5, 4)),
                    DailyPresenceCounter = BinaryHelper.BCDToString(BinaryHelper.SubByte(data, num5 + 9, 2))
                };

                if (activityDataItem.DailyPresenceCounter == BinaryHelper.BCDToString(BinaryHelper.SubByte(data, num2 + 9, 2)))
                {
                    flag = false;
                }

                activityDataItem.DayDistance = BinaryHelper.BytesToLong(BinaryHelper.SubByte(data, num5 + 11, 2));
                activityDataItem.ChangeItems = GetActivityChangeData(BinaryHelper.SubByte(data, num5 + 13, num4 - 12), activityDataItem.DailyPresenceCounter);

                if (flag)
                {
                    num5 += num4;
                    num4  = (int)BinaryHelper.BytesToLong(BinaryHelper.SubByte(data, num5 + 3, 2));
                }

                Items.Add(activityDataItem);
            }
        }