public override void GetInputDataSync() //Diastole
        {
            PatternToSendInOutputChannels = string.Empty;

            var activeChannels = ListOfInputChannels.Where(inputChannel => inputChannel.IsActive).OrderBy(inputChannel => inputChannel.XCellOrigin.Id).ToList();
            var activeChannelsWithoutXCellDestiny = activeChannels.Where(activeChannel => activeChannel.XCellDestiny == null).ToList();

            foreach (var activeChannelWithoutXCellDestiny in activeChannelsWithoutXCellDestiny)
            {
                var xCellDP_I = new XCellDP_I(activeChannelWithoutXCellDestiny.XCellOrigin.Id, this);
                activeChannelWithoutXCellDestiny.XCellDestiny = xCellDP_I;
                xCellDP_I.ListOfInputChannels.Add(activeChannelWithoutXCellDestiny);
                ListOfXCellsDPI.Add(xCellDP_I);
            }

            foreach (var xCellDPI in ListOfXCellsDPI)
            {
                xCellDPI.GetInputData();
                xCellDPI.SendOutputData();
            }

            foreach (var xCellDPI in ListOfXCellsDPI.Where(xCelldpI => xCelldpI.ListOfOutputChannels[0].IsActive).OrderBy(xCelldpI => xCelldpI.ListOfOutputChannels[0].PatternToSendToAnXCell).ToList())
            {
                PatternToSendInOutputChannels = $"{PatternToSendInOutputChannels}{xCellDPI.ListOfOutputChannels[0].PatternToSendToAnXCell}&";
            }
            PatternToSendInOutputChannels = PatternToSendInOutputChannels.TrimEnd('&');

            var c1 = activeChannels.Count();
            var c2 = activeChannelsWithoutXCellDestiny.Count();

            if (c1 == c2 && c1 > 0)
            {
                if (!string.IsNullOrEmpty(PatternToSendInOutputChannels))
                {
                    var xCellAND = ((ANDLayer)LayerUp).CreateAnXCellANDGivenItsID(PatternToSendInOutputChannels);
                    //Crear una XCellAND con los canales de entrada igual a los canales de salida de las XCellDP_I creadas
                    foreach (var activeChannelWithoutXCell in activeChannelsWithoutXCellDestiny)
                    {
                        xCellAND.ListOfInputChannels.Add(activeChannelWithoutXCell.XCellDestiny.ListOfOutputChannels[0]);
                    }
                }
            }

            foreach (var xCellDPI in ListOfXCellsDPI)
            {
                xCellDPI.GetInputData();
            }

            foreach (var xCellDPI in ListOfXCellsDPI)
            {
                xCellDPI.ListOfInputChannels[0].PatternToSendToAnXCell = null;
                xCellDPI.ListOfInputChannels[0].Aij      = double.NaN;
                xCellDPI.ListOfInputChannels[0].IsActive = false;
            }
        }
        //public override void GetInputDataSync() //Diastole
        //{
        //    PatternToSendInOutputChannels = string.Empty;

        //    var activeChannels = ListOfInputChannels.Where(inputChannel => inputChannel.IsActive).OrderBy(inputChannel => inputChannel.XCellOrigin.Id).ToList();
        //    var activeChannelsWithoutXCellDestiny = activeChannels.Where(activeChannel => activeChannel.XCellDestiny == null).ToList();

        //    //if (activeChannels != null)
        //    //{
        //    //    foreach (var activeChannel in activeChannels)
        //    //    {
        //    //        PatternToSendInOutputChannels = $"{PatternToSendInOutputChannels}{activeChannel.PatternToSendToAnXCell}&";
        //    //    }
        //    //    PatternToSendInOutputChannels = PatternToSendInOutputChannels.TrimEnd('&');
        //    //}

        //    foreach (var activeChannelWithoutXCellDestiny in activeChannelsWithoutXCellDestiny)
        //    {
        //        var xCellDP_I = new XCellDP_I(activeChannelWithoutXCellDestiny.XCellOrigin.Id, this);
        //        activeChannelWithoutXCellDestiny.XCellDestiny = xCellDP_I;
        //        xCellDP_I.ListOfInputChannels.Add(activeChannelWithoutXCellDestiny);
        //        ListOfXCellsDPI.Add(xCellDP_I);
        //    }

        //    foreach (var xCellDPI in ListOfXCellsDPI)
        //    {
        //        xCellDPI.GetInputData();
        //        xCellDPI.SendOutputData();
        //    }

        //    foreach (var xCellDPI in ListOfXCellsDPI.Where(xCelldpI => xCelldpI.ListOfOutputChannels[0].IsActive).OrderBy(xCelldpI => xCelldpI.ListOfOutputChannels[0].PatternToSendToAnXCell).ToList())
        //    {
        //        PatternToSendInOutputChannels = $"{PatternToSendInOutputChannels}{xCellDPI.ListOfOutputChannels[0].PatternToSendToAnXCell}&";
        //        //xCellDPI.ListOfOutputChannels[0].PatternToSendToAnXCell = null;
        //        //xCellDPI.ListOfOutputChannels[0].Aij = double.NaN;
        //        //xCellDPI.ListOfOutputChannels[0].IsActive = false;
        //    }
        //    PatternToSendInOutputChannels = PatternToSendInOutputChannels.TrimEnd('&');

        //    //var c1 = activeChannels.Count();
        //    //var c2 = activeChannelsWithoutXCellDestiny.Count();

        //    //if (c1 == c2 && c1>0)
        //    //{
        //    //    if(!string.IsNullOrEmpty(PatternToSendInOutputChannels))
        //    //    {
        //    //        var xCellAND = ((ANDLayer)LayerUp).CreateAnXCellANDGivenItsID(PatternToSendInOutputChannels);
        //    //        //Crear una XCellAND con los canales de entrada igual a los canales de salida de las XCellDP_I creadas
        //    //        foreach (var activeChannelWithoutXCell in activeChannelsWithoutXCellDestiny)
        //    //        {
        //    //            xCellAND.ListOfInputChannels.Add(activeChannelWithoutXCell.XCellDestiny.ListOfOutputChannels[0]);
        //    //        }
        //    //    }
        //    //}

        //    //foreach(var xCellDPI in ListOfXCellsDPI)
        //    //{
        //    //    xCellDPI.GetInputData();
        //    //}

        //    //foreach (var xCellDPI in ListOfXCellsDPI)
        //    //{
        //    //    xCellDPI.ListOfInputChannels[0].PatternToSendToAnXCell = null;
        //    //    xCellDPI.ListOfInputChannels[0].Aij = double.NaN;
        //    //    xCellDPI.ListOfInputChannels[0].IsActive = false;
        //    //}
        //}

        public override void SendOutputDataSync() //Systole
        {
            //foreach (var outputChannel in ListOfOutputChannels.OrderBy(inputChannel => inputChannel.XCellOrigin.Id))
            //{
            //    foreach (var channelToXCellAnd in outputChannel.XCellDestiny.ListOfOutputChannels)
            //    {
            //        channelToXCellAnd.PatternToSendToAnXCell = PatternToSendInOutputChannels;
            //    }
            //}

            foreach (var xCellDPI in ListOfXCellsDPI.OrderBy(xCellDpI => xCellDpI.Id).ToList())
            {
                xCellDPI.SendOutputData();
            }


            foreach (var xCellDPI in ListOfXCellsDPI)
            {
                xCellDPI.ListOfInputChannels[0].PatternToSendToAnXCell = null;
                xCellDPI.ListOfInputChannels[0].Aij      = double.NaN;
                xCellDPI.ListOfInputChannels[0].IsActive = false;
            }
        }
 public override ICollection <XCell> GetListOfXCells()
 {
     return(ListOfXCellsDPI.Cast <XCell>().ToList());
 }