amp = 1.7
del = 50
dur = 2.5

// ***** Place synapses, electrodes or other point processes *****
for CELLINDEX = 0,cellList.count-1 {
	cellList.o(CELLINDEX).soma[0] {
		pp = new IClamp(0.500000)
		pp.amp = amp
		pp.del = del
		pp.dur = dur
	}
	io = ppList.append(pp)
	objref pp
}

proc updateIClamp() {
	for p = 0,ppList.count-1 {
		ppList.o[p].amp = amp
		ppList.o[p].del = del
		ppList.o[p].dur = dur
	}
}

io = xpanel("Current injection")
io = xvalue("Amplitude [nA]","amp", 1,"updateIClamp()", 1, 1 )
io = xvalue("Delay [ms]","del", 1 ,"updateIClamp()", 1, 1 )
io = xvalue("Duration [ms]","dur", 1 ,"updateIClamp()", 1, 1 )
io = xpanel(250,650)
pwmexppanel = PWManager[0].count

{
io = xpanel("RunControl")
io = xvalue("Init","v_init", 1,"init()", 1, 1 )
io = xbutton("Init & Run","{init() run()}")
io = xbutton("Stop","stoprun=1")
io = xvalue("Continue til","runStopAt", 1,"{continuerun(runStopAt) stoprun=1}", 1, 1 )
io = xvalue("Continue for","runStopIn", 1,"{continuerun(t + runStopIn) stoprun=1}", 1, 1 )
io = xbutton("Single Step","steprun()")
io = xvalue("t","t", 2 )
io = xvalue("Tstop","tstop", 1,"tstop_changed()", 0, 1 )
io = xvalue("dt","dt", 1,"setdt()" )
io = xstatebutton("Variable dt",&cv ,"setcvode()")
io = xvalue("Points plotted/ms","steps_per_ms", 1,"setdt()", 0, 1 )
io = xvalue("Real Time","realtime", 0,"", 0, 1 )
io = xpanel(250,150)
}
pwmrctrl = PWManager[0].count


	g = new PlotShape(0)
	{g.view(-100, -100, 1000, 1000, 550, 150, 500, 500)}
	io = g.show(0)
	io = g.variable("v")
	io = fast_flush_list.append(g)
	io = g.flush()
	io = g.exec_menu("View = plot")
	io = g.exec_menu("Shape Plot")

pwmgraph.x(0) = PWManager[0].count

{
g = new Graph(0)
io = g.size(0,1000,-80,40)
{g.view(0, 0, tstop, 0.1, 550, 900, 300, 200)}
io = graphList[0].append(g)
gind = graphList[0].count

for CELLINDEX = 0,cellList.count-1 {
	sprint(tmpstr,"cellList.o[%d].adendMML[0].%s(.5)",CELLINDEX,caname)
	sprint(tmpstr2,"Cell%d: Ca2+ in MML [mM]",CELLINDEX)
	g.addexpr(tmpstr2,tmpstr, CELLINDEX%9+1,CELLINDEX/9+1)  // avoid white color
	}
}
pwmgraph.x(1) = PWManager[0].count