public Neuron(DateTime start, List <Task> tasks)
        {
            state      = CellGrowthState.NoGrowth;
            body       = new CellBody(start);
            dendrites  = new List <Dendrite>();
            axons      = new List <Axon>();
            this.start = start;
            main_tasks = tasks;



            //look at the previous 2 seconds
            int      days         = 0;
            int      hours        = 0;
            int      minutes      = 0;
            int      seconds      = 2;
            int      milliseconds = 0;
            TimeSpan window       = new TimeSpan(days, hours, minutes, seconds, milliseconds);

            secondary = new SecondaryMessenger(start, 2, window); //if there are 2 action potentials within the window

            InitializeDendrites();
            InitializeAxons();

            //add event to listen for
            body.ActionPotentialEvent += ReceiveActionPotentialEvent;
        }
        public void Decay(CellBody cb, TimeSpan runLength)
        {
            DateTime start = DateTime.Now;

            //Console.WriteLine("Task_CellBody {0} is working...", Id);
            while (DateTime.Now - start < runLength)
            {
                Thread.Sleep(Frequency);
                cb.DecayMembranePotential();
                //Console.WriteLine("Task_CellBody {0} decayed cell body membrane potential to {1}.", Id, cb.MembranePotential);
            }
            //Console.WriteLine("Task_CellBody {0} is done.", Id);
        }
        public void Consume(CellBody cb, TimeSpan runLength)
        {
            DateTime start = DateTime.Now;

            //Console.WriteLine("Task_CellBody {0} is working...", Id);

            while (DateTime.Now - start < runLength)
            {
                int voltage = cb.TryRemoveFromBuffer();
                //Console.WriteLine("Task_CellBody {0} removed {1} from buffer.", Id, voltage);
            }//end while

            //Console.WriteLine("Task_CellBody {0} is done.", Id);
        }
예제 #4
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);
        }
예제 #5
0
        public void Record(CellBody cb, TimeSpan workDay)
        {
            DateTime start = DateTime.Now;
            DateTime current;
            TimeSpan ts;

            while (DateTime.Now - start < workDay)
            {
                int sleep = (cb.State == 0 ? 5 : 1); //finer grained recording during an action potential
                Thread.Sleep(sleep);
                current = DateTime.Now;
                ts      = current.Subtract(program_start);
                results.Add(new Record(ts, cb.MembranePotential));
            }//end while

            //output results
            OutputResults();
        }