Esempio n. 1
0
 public void AddReceptor(Receptor.Receptor receptor)
 {
     Receptors.Add(receptor);
     for (int i = 0; i < receptor.Cells.Count; i++)
     {
         Cells.Add(receptor.Cells[i]);
     }
 }
Esempio n. 2
0
        /// <summary>
        /// Returns the list of distinct protocols that each receptor instance in the membrane emits.
        /// </summary>
        public List <string> GetEmittedProtocols()
        {
            List <string> ret = new List <string>();

            Receptors.ForEach(r => ret.AddRange(r.Instance.GetEmittedProtocols().Select(p => p.Protocol)));

            return(ret.Distinct().ToList());
        }
Esempio n. 3
0
        /// <summary>
        ///  Returns the list of distinct protocols that each receptor isntance in the membrane can receive.
        /// </summary>
        /// <returns></returns>
        public List <string> GetListeningProtocols()
        {
            List <string> ret = new List <string>();

            Receptors.ForEach(r => ret.AddRange(r.Instance.GetReceiveProtocols().Select(rp => rp.Protocol)));

            return(ret.Distinct().ToList());
        }
Esempio n. 4
0
        // TODO: Maintain a flat list to avoid this recursion.
        /// <summary>
        /// Recurse through membranes to find the membrane containing the desired receptor.
        /// </summary>
        public Membrane GetMembraneContaining(IReceptor searchFor)
        {
            Membrane ret = null;

            if (Receptors.Contains((Receptor)searchFor))
            {
                ret = this;
            }
            else
            {
                foreach (Membrane childMembrane in Membranes)
                {
                    ret = childMembrane.GetMembraneContaining(searchFor);

                    if (ret != null)
                    {
                        break;
                    }
                }
            }

            return(ret);
        }
Esempio n. 5
0
 /// <summary>
 /// Move the receptors in this membrane to the target membrane.
 /// </summary>
 /// <param name="targetMembrane"></param>
 public void MoveReceptorsToMembrane(IMembrane targetMembrane)
 {
     Receptors.ForEach(r => MoveReceptorToMembrane(r, targetMembrane));
 }
Esempio n. 6
0
 /// <summary>
 /// Remove this membrane, moving its receptors to the parent.
 /// </summary>
 public void Dissolve()
 {
     // TODO: To much conversion.
     MoveReceptorsToMembrane(Receptors.Cast <IReceptor>().ToList(), ParentMembrane);
     ParentMembrane.Membranes.Remove(this);
 }
Esempio n. 7
0
 // TODO: Re-implement by providing methods to add/remove instantiated receptors which
 // would support moving receptors between membranes.  This is a brute force approach
 // for now.
 /// <summary>
 /// Recreates the protocol receptor map from scratch.
 /// </summary>
 public void ReloadProtocolReceptorMap()
 {
     protocolReceptorMap.Clear();
     Receptors.ForEach(r => GatherProtocolReceivers(r));
 }
Esempio n. 8
0
 /// <summary>
 /// Reset the receptor system.  This allows the current carriers to cleanly terminate
 /// and then re-initializes the internal collections to an empty state.
 /// </summary>
 public void Reset()
 {
     Receptors.ForEach(r => r.Instance.Terminate());
     Initialize();
 }