w1 = 0
w2 = 0
w3 = 0
tc1 = 0
tc2 = 0
tc3 = 0
strdef fname

proc readsyn() {localobj synfile
	synfile = new File()
	synfile.ropen($s1)
	

	$o2.G1_weight = synfile.scanvar()
	$o2.G1_eRev = synfile.scanvar()
	$o2.G1_opentc = synfile.scanvar()
	$o2.G1_closetc = synfile.scanvar()

	$o2.G2_weight = synfile.scanvar()
	$o2.G2_eRev = synfile.scanvar()
	$o2.G2_opentc = synfile.scanvar()
	$o2.G2_closetc = synfile.scanvar()

	$o2.G3_weight = synfile.scanvar()
	$o2.G3_eRev = synfile.scanvar()
	$o2.G3_opentc = synfile.scanvar()
	$o2.G3_closetc = synfile.scanvar()


}

proc savesyn() {
	w1 = $o1.G1_weight 
	tc1 = $o1.G1_closetc 
	
	w2 = $o1.G2_weight 
	tc2 = $o1.G2_closetc 

	w3 = $o1.G3_weight 
	tc3 = $o1.G3_closetc 
}

load_file("nrngui.hoc")

// chdir("c:/sims/nfrost")

// chdir("mods")
// nrn_load_dll("nrnmech.dll")
// chdir("..")

load_file("celltypes/C2Type.hoc") 
load_file("celltypes/DSIType.hoc")
load_file("celltypes/VSIType.hoc")
load_file("celltypes/IFType.hoc")
load_file("celltypes/DRIType.hoc")



objref TestCell, IF, DRI, C2
IF = new IFType()
DRI = new DRIType()
//C2 = new C2Type()

/*  change here */
TestCell = new DSIType()

objectvar IF_Ts, IF_Tnc, T_Ts, T_Tnc, IF_DRIs, IF_DRInc, DRI_Ts, DRI_Tnc, C2_DRIs, C2_DRInc, DSI_C2nc, DSI_C2s, C2_DSIs, C2_DSInc

TestCell.soma {IF_Ts = new tholdsyn(0.5)}
access IF.soma
IF_Tnc = new NetCon(&v(0.5), IF_Ts, 0, 0, 1)

TestCell.soma {T_Ts = new tholdsyn(0.5)}
access TestCell.soma
T_Tnc = new NetCon(&v(0.5), T_Ts, 0, 0, 1)

TestCell.soma {DRI_Ts = new tholdsyn(0.5)}
access DRI.soma
DRI_Tnc = new NetCon(&v(0.5), DRI_Ts, 0, 0, 1)

DRI.soma {IF_DRIs = new tholdsyn(0.5)}
access IF.soma
IF_DRInc = new NetCon(&v(0.5), IF_DRIs, 0, 0, 1)

//DRI.soma {C2_DRIs = new tholdsyn(0.5)}
//access C2.soma
//C2_DRInc = new NetCon(&v(0.5), C2_DRIs, 0, 0, 1)

//C2.soma {DSI_C2s = new tholdsyn(0.5)}
//access TestCell.soma
//DSI_C2nc = new NetCon(&v(0.5), DSI_C2s, 0, 0, 1)

//TestCell.soma {C2_DSIs = new tholdsyn(0.5)}
//access C2.soma
//C2_DSInc = new NetCon(&v(0.5), C2_DSIs, 0, 0, 1)

/* change here */
readsyn("syndefs/DSI_DSI.txt", T_Ts)
readsyn("syndefs/nosyn.txt", IF_Ts)
readsyn("syndefs/RAMP_DRI.txt", IF_DRIs)
readsyn("syndefs/DRI_DSI.txt", DRI_Ts)
//readsyn("syndefs/C2_DRI.txt", C2_DRIs)
//readsyn("syndefs/DSI_C2.txt", DSI_C2s)
//readsyn("syndefs/C2_DSI.txt", C2_DSIs)

//savesyn(IF_Ts)
//savesyn(DRI_Ts)
savesyn(IF_DRIs)

synscale = 1
tcscale = 1
ifrate = 100
ifstart = 45000

access TestCell.soma
objref etrode
etrode = new IClamp(0.5)
etrode.dur = 900000
etrode.del = 0
etrode.amp = 1.9

objref ifreq
ifreq = new Vector()
ifreq.record(&TestCell.sthold.freq)

tstop = 45000+60000

load_file("fp.ses")

proc init() {

			finitialize(v_init)
			fcurrent()

			TestCell.soma.v = TestCell.ileak.vrest

			for(x = 0; x < 1000; x = x + ifrate) {
				//IF_Tnc.event(ifstart + x)
				IF_DRInc.event(ifstart+x)
			}			
			
			//DRI_Ts.G1_weight = w1 * synscale
			//DRI_Ts.G2_weight = w2 * synscale
			//DRI_Ts.G3_weight = w3 * synscale
			//DRI_Ts.G1_closetc = tc1 * tcscale
			//DRI_Ts.G2_closetc = tc2 * tcscale
			//DRI_Ts.G3_closetc = tc3 * tcscale

			IF_DRIs.G1_weight = w1 * synscale
			IF_DRIs.G2_weight = w2 * synscale
			IF_DRIs.G3_weight = w3 * synscale
			IF_DRIs.G1_closetc = tc1 * tcscale
			IF_DRIs.G2_closetc = tc2 * tcscale
			IF_DRIs.G3_closetc = tc3 * tcscale

			//IF_Ts.G1_weight = w1 * synscale
			//IF_Ts.G2_weight = w2 * synscale
			//IF_Ts.G3_weight = w3 * synscale
			//IF_Ts.G1_closetc = tc1 * tcscale
			//IF_Ts.G2_closetc = tc2 * tcscale
			//IF_Ts.G3_closetc = tc3 * tcscale
		}


proc savefreq() {local x localobj outfile
	outfile = new File()
	outfile.wopen($s1)

	outfile.printf("label:%s\n", "ifreq")
	outfile.printf("%o\n", ifreq.size())

	for(x =0; x < ifreq.size(); x = x + 1) {
			outfile.printf("%f	%f\n", x*dt, ifreq.x[x])
		}
	outfile.close()

}