public void AddValue(DateTime timestamp, PollItemValue pollItemValue)
 {
     if (_hashtableItemValues.Count >= _maxValueCount)
         DeleteFirstKey();
     _hashtableItemValues.Add(timestamp, pollItemValue);
     _lastTimestamp = timestamp;
     OnValueUpdatedInThread(pollItemValue);
 }
 protected void OnValueUpdatedInThread(PollItemValue newPollItemValue)
 {
     System.Threading.Thread updateValueThread = new System.Threading.Thread(OnValueUpdated);
     updateValueThread.IsBackground = true;
     updateValueThread.Start(newPollItemValue);
 }
 public PollItemValueUpdatedEventArgs(PollItemValue pollItemValue)
 {
     _pollItemValue = pollItemValue;
 }
        /// <summary>
        /// Unpack poll item. Save value into buffer. Save item in result list 
        /// </summary>
        /// <param name="currentPollItem">poll item</param>
        /// <param name="currentItemValue">poll item value</param>
        /// <param name="resultItemList">result updated poll item list</param>
        private void UnpackAndSaveSubItems(
            CommonDataContract.PollItem currentPollItem, 
            CommonDataContract.PollItemValue currentItemValue,
            List<CommonDataContract.PollItem> resultItemList)
        {
            Int64 intValue = Convert.ToInt64(currentItemValue.Value);
            bool[] fullBits = new bool[currentPollItem.PackLength];
            char[] bits = Convert.ToString(intValue, 2).ToCharArray();
            for (int i = 1; i <= bits.Length; i++) {
                if (bits[bits.Length-i] == '1')
                    fullBits[fullBits.Length - i] = true;
            }

            CommonDataContract.PollItemValue newPollItemValue;
            int lastIndex = fullBits.Length - 1;
            foreach (var subItem in currentPollItem.SubItems) {
                newPollItemValue = new CommonDataContract.PollItemValue();
                newPollItemValue.ItemID = subItem.ItemName;
                newPollItemValue.Timestamp = currentItemValue.Timestamp;
                /// Берем смещение от конца массива (т.е. при offset = 0 надо взять последний элемент)
                newPollItemValue.Value = fullBits[lastIndex - subItem.BitOffset];
                subItem.AddValue(newPollItemValue.Timestamp, newPollItemValue);
                resultItemList.Add(subItem);
            }
        }