public IEnumerable <double> Interrupt(IEnumerable <double> cableBits)
        {
            int chunks = cableBits.Count();

            var interferencedData = _interference.GetInterference(_frequency, _time);
            int valuesPerChunk    = interferencedData.Length / chunks;

            var splittedData = new List <List <double> >();

            for (int chunk = 0; chunk < chunks; chunk++)
            {
                var singleChunk = new List <double>();
                for (int i = 0; i < valuesPerChunk; i++)
                {
                    singleChunk.Add(interferencedData[chunk * valuesPerChunk + i]);
                }
                splittedData.Add(singleChunk);
            }

            var lastChunk = new List <double>();

            for (int j = (chunks) * valuesPerChunk; j < interferencedData.Length; j++)
            {
                lastChunk.Add(interferencedData[j]);
            }
            if (lastChunk.Count > 0)
            {
                splittedData.Add(lastChunk);
            }

            return(_calculator.Calculate(cableBits, splittedData));
            // TODO Check last bit?
        }
        protected void Send()
        {
            GetTheData();
            string data = _locator.DataToSendViewModel.DataToSend;

            if (String.IsNullOrEmpty(data))
            {
                return;
            }
            var tranlsatedData = _translator.ToBits(data[0].ToString());

            IList <double> bits = new List <double>();

            foreach (var bit in tranlsatedData)
            {
                bits.Add(bit);
            }
            //bits.Add(bits.Last());

            IList <double> bitsInverted = InvertBits(tranlsatedData);

            var interferenceFrequency = _locator.InterferenceViewModel.Frequency;
            var interferenceTime      = _locator.InterferenceViewModel.Time;
            var interferences         = _interference.GetInterference(interferenceFrequency, interferenceTime);

            ClearCharts();

            _locator.BitsChart1ViewModel.Values.AddRange(bits);
            _locator.BitsChart2ViewModel.Values.AddRange(bitsInverted);
            _locator.InterferenceChartViewModel.Values.AddRange(interferences);
            _locator.BitsChartOut1ViewModel.Values.AddRange(
                _distanceSimulator.Simulate(Cable.FIRST, _interferenceSimulator.Interrupt(bits)));
            _locator.BitsChartOut2ViewModel.Values.AddRange(
                _distanceSimulator.Simulate(Cable.SECOND, _interferenceSimulator.Interrupt(bitsInverted)));
            _locator.OutputChartViewModel.Values.AddRange(
                _signalConverter.FromAnalog(bits.Count,
                                            _signalOperator.Add(
                                                _locator.BitsChartOut1ViewModel.Values,
                                                InvertBits(_locator.BitsChartOut2ViewModel.Values))));

            _locator.OutputViewModel.OutData = _translator.FromBits(_locator.OutputChartViewModel.Values.ToIntArray());

            if (_locator.OutputViewModel.OutData.Equals(_locator.DataToSendViewModel.DataToSend))
            {
                _locator.OutputViewModel.SuccessCount++;
            }
            else
            {
                _locator.OutputViewModel.FailCount++;
            }
        }