public Dendrite AddDendrite(DendriteType type)
        {
            Dendrite d = new Dendrite(nextDendriteId++, type);

            dendrites.Add(d);
            return(d);
        }
Пример #2
0
        public void Decay(Dendrite dt, TimeSpan runLength)
        {
            DateTime start = DateTime.Now;

            //Console.WriteLine("Task_Dendrite {0} is working...", Id);
            while (DateTime.Now - start < runLength)
            {
                Thread.Sleep(Frequency);
                dt.DecayMembranePotential();
                //Console.WriteLine("Task_Dendrite {0} decayed dendrite membrane potential to {1}.", Id, dt.MembranePotential);
            }
            //Console.WriteLine("Task_Dendrite {0} is done.", Id);
        }
Пример #3
0
        public void Consume(Dendrite dt, TimeSpan runLength)
        {
            DateTime start = DateTime.Now;

            //Console.WriteLine("Task_Dendrite {0} is working...", Id);
            while (DateTime.Now - start < runLength)
            {
                int voltage = dt.TryRemoveFromBuffer();
                //Console.WriteLine("Task_Dendrite {0} consumed {1} from buffer.", Id, voltage);
            }//end while

            //Console.WriteLine("Task_Dendrite {0} is done.", Id);
        }
Пример #4
0
        public void Produce(Dendrite dt, TimeSpan runLength)
        {
            DateTime start = DateTime.Now;

            //Console.WriteLine("Task_Input {0} is working...", Id);
            while (DateTime.Now - start < runLength)
            {
                Thread.Sleep(Frequency);
                Neurotransmitter newest = new Neurotransmitter(true);
                dt.AddToBuffer(newest);

                //Console.WriteLine("Task_Input {0} added {1} to dendrite {2} buffer.", Id, newest.ElectricalPotential, dt.Id);
            }//end while

            //Console.WriteLine("Task_Input {0} is done.", Id);
        }//end Work()
Пример #5
0
        public void Produce(Dendrite dt, CellBody cb, TimeSpan runLength)
        {
            DateTime start = DateTime.Now;

            //Console.WriteLine("Task_Dendrite {0} is working...", Id);
            while (DateTime.Now - start < runLength)
            {
                Thread.Sleep(Frequency);
                int currentMembranePotential = dt.MembranePotential;
                int difference = (currentMembranePotential - RESTING_POTENTIAL);
                cb.AddToBuffer(difference);

                //Console.WriteLine("Task_Dendrite {0} produced {1} to cell body buffer.", Id, difference);
            }//end while

            //Console.WriteLine("Task_Dendrite {0} is done.", Id);
        }
        }//end Main()

        public static void main_CellGrowthTriggered(object sender, CellGrowthEventArgs e)
        {
            Neuron       n         = e.neuron;
            DendriteType type      = e.type;
            TimeSpan     runLength = e.timespan;
            List <Task>  tasks     = e.tasks;

            Console.WriteLine("Triggered.");



            Dendrite d = n.AddDendrite(type);

            //Consumer to consume neurotransmitters from dendrite buffer
            for (int i = 0; i < 1; i++)
            {
                Task newest = Task.Factory.StartNew((val) =>
                {
                    int id = (int)val;
                    new Task_Dendrite(id, 10).Consume(d, runLength);
                }, i);
                tasks.Add(newest);
            }

            //Producers to send electrical potential to cell body buffer
            for (int i = 0; i < 1; i++)
            {
                Task newest = Task.Factory.StartNew((val) =>
                {
                    int id = (int)val;
                    new Task_Dendrite(id, 10).Produce(d, n.Body, runLength);
                }, i);
                tasks.Add(newest);
            }

            ////Decayers to decay membrane potential of dendrites
            for (int i = 0; i < 1; i++)
            {
                Task newest = Task.Factory.StartNew((val) =>
                {
                    int id = (int)val;
                    new Task_Dendrite(id, 10).Decay(d, runLength);
                }, i);
                tasks.Add(newest);
            }
            //Console.WriteLine("Added.");

            //reset Token so system waits for new tasks too
            //do
            //{
            //try
            //{
            //    cts = new CancellationTokenSource();
            //    Task.WaitAll(tasks.ToArray(), cts.Token);
            //}
            //catch (OperationCanceledException)
            //{
            //    // start over and wait for new tasks
            //}
            //}
            //while (cts.IsCancellationRequested);
        }//end BuildDendrite()
        private void InitializeDendrites()
        {
            Dendrite d1 = new Dendrite(nextDendriteId++, DendriteType.Proximal);

            dendrites.Add(d1);
        }