{load_file("init-rgc-121203.hoc")}
{load_file("util.hoc")}
objref shapePlot


/////////////////////////////////////////////////////////////////////

strdef fName
proc runPosition() {
    // parameters: stimX stimY stimAmp tstop filePrefix
    stimX = $1
    stimY = $2
    stimAmp = $3
    setelec(stimX, stimY, stimZ)
    setstim(stimDel, stimDur, stimAmp)
    
    tstop = $4
    tstop_changed()

    run()
    sprint(fName, "./output/latencyShape-10_%s_%.3f.ps", $s5, $4)
    shapePlot.printfile(fName)
}

proc setPosition() { local time
    if ($1 == 1) {
        for case (&time, 10.1, 10.5, 11.0, 12.0) {
            runPosition(10, 60, -0.00516, time, "10_60")
        }
    } else if ($1 == 2) {
        for case (&time, 10.1, 10.5, 11.0, 12.0) {
            runPosition(0, 0, -0.00516, time, "0_0")
        }
    } else if ($1 == 3) {
        for case (&time, 10.5, 11, 13, 14) {
            runPosition(110, -40, -0.02672, time, "110_-40")
        }
    } else if ($1 == 4) {
        for case (&time, 11, 13, 15.4, 16.6) {
            runPosition(20, -90, -0.01406, time, "20_-90")
        }
    }
}


/////////////////////////////////////////////////////////////////////

elecRad = 10  // electrode radius (um)
stimZ = -40   // um

screen_update_invl = 0.025
tstop = 50
tstop_changed()

shapePlot = new PlotShape(0)
shapePlot.variable("v")
shapePlot.view(-100, -70, 220, 220, 400, 450, 200, 200)
shapePlot.exec_menu("Shape Plot")
fast_flush_list.append(shapePlot)
{doNotify()}

print "INFO: set stim position with setPosition(1~4)"
setPosition(1)
setPosition(3)
setPosition(4)