//	AlphaSyn.cxx

#include "AlphaSyn.h"
#include <math.h>

void AlphaSyn::Step( const real dt )
{
	// first, check the presynaptic voltage
	// but ONLY if we're not already releasing
	
	if (t == 0 || t > pulseTime) {
		if (itsComp->GetV() > Vthresh) t = dt;
	}
	
	// if we're not spiking -- i.e., t == 0 -- then return
	if (t==0) return;
	
	// set conductance G according to the alpha function
	
	if (tau1 == tau2)
		G = MaxG * (t/tau1) * exp(1 - t/tau1);
	else
		G = MaxG * ( exp(-t/tau1) - exp(-t/tau2) ) / ( tau1 - tau2 );
		
	t += dt;
	
	// if G has gotten ridiculously small, reset t
	if (t > pulseTime && G < 0.0001) {
		G = 0;
		t = 0;
	}

}
