Esempio n. 1
0
        protected virtual void OnCellGrowthEvent(EventArgs_CellGrowth e)
        {
            EventHandler <EventArgs_CellGrowth> handler = CellGrowthEvent;

            if (handler != null)
            {
                handler(this, e);
            }
        }
Esempio n. 2
0
        //CellGrowthEvent code
        public void RaiseCellGrowthEvent(DateTime when) //tested
        {
            //action within the cell
            List <Dendrite> added = AddDendrites(numDendritesToAddInGrowthEvent, growthEventDendriteTypesList);

            //reset neuron state
            SetNoGrowthState();

            //event
            Console.WriteLine("Neuron raises cell growth event.");
            EventArgs_CellGrowth args = new EventArgs_CellGrowth(when, added);

            OnCellGrowthEvent(args);
        }
        private static void RespondToCellGrowthEvent(object sender, EventArgs_CellGrowth e)
        {
            Console.WriteLine("ProcessManager received cell growth event.");
            List <Dendrite> added = e.DendritesAdded;

            //add Tasks to manipulate dendrites added
            //====================================================================//
            //                             dendrite                               //
            //====================================================================//
            //Consumers to retrieve neurotransmitters from dendrite buffer
            for (int i = 0; i < NUM_DENDRITE_CONSUMERS; i++)
            {
                Task newest = Task.Factory.StartNew((val) =>
                {
                    int id = (int)val;
                    new Task_Dendrite(id, runLength, added[0], neuron.Body, start).Consume();
                }, nextDendriteTaskId++);
                tasks.Add(newest);
            }

            //Producers to send electrical potential to cell body buffer
            for (int i = 0; i < NUM_DENDRITE_PRODUCERS; i++)
            {
                Task newest = Task.Factory.StartNew((val) =>
                {
                    int id = (int)val;
                    new Task_Dendrite(id, runLength, added[0], neuron.Body, start).Produce();
                }, nextDendriteTaskId++);
                tasks.Add(newest);
            }

            //Decayers to decay membrane potential of dendrites
            for (int i = 0; i < NUM_DENDRITE_DECAYERS; i++)
            {
                Task newest = Task.Factory.StartNew((val) =>
                {
                    int id = (int)val;
                    new Task_Dendrite(id, runLength, added[0], neuron.Body, start).Decay();
                }, nextDendriteTaskId++);
                tasks.Add(newest);
            }



            //add Tasks to produce to dendrites added
            //====================================================================//
            //                               input                                //
            //====================================================================//
            //Producers to send neurotransmitters to dendrites
            for (int i = 0; i < NUM_INPUTAXON_PRODUCERS; i++)
            {
                Task newest = Task.Factory.StartNew((val) =>
                {
                    int id         = (int)val;
                    InputAxon axon = new InputAxon(nextInputAxonId++, INPUTAXON_PRODUCTION_FREQUENCY, 0);
                    inputs.Add(axon);
                    new Task_InputAxon(id, runLength, axon, INPUT_MAGNITUDE, start, added[0]).Produce();
                }, nextInputAxonTaskId++);
                tasks.Add(newest);
            }
        }