public int TryRemoveFromBuffer() //tested { Neurotransmitter removed = buffer.Take(); int charge = removed.Charge; int oldMembranePotential = membranePotential; //affect local membrane potential int currentMembranePotential = Interlocked.Add(ref membranePotential, charge); //decide whether change was significant enough to add to SecondaryMessenger if (Math.Abs(currentMembranePotential - oldMembranePotential) > significantVoltageChange) { messenger.AddEvent(DateTime.Now); //check whether dendrite growth state threshold reached if (state == 0 && messenger.IsGrowthStateTriggered(DateTime.Now)) { SetGrowthState(); } } return(charge); }
public void Produce() //tested { if (dendrite == null) { Console.WriteLine("Dendrite is NULL."); return; //nothing to produce to } Console.WriteLine("Task_InputAxon {0} is producing...", Id); while (DateTime.Now - start < runLength) { Thread.Sleep(axon.ProductionFrequency); Neurotransmitter newest = new Neurotransmitter(neurotransmitterMagnitude); dendrite.AddToBuffer(newest); //Console.WriteLine("Task_InputAxon {0} added {1} to dendrite {2} buffer.", Id, newest.Charge, dendrite.Id); }//end while Console.WriteLine("Task_InputAxon {0} is done.", Id); }
//public methods public void AddToBuffer(Neurotransmitter nt) { buffer.Add(nt); }