from neuron import h
from cell import Cell

h.load_file('stdrun.hoc')

NUM_CELLS = 2
RED = 2  # see https://www.neuron.yale.edu/neuron/static/py_doc/visualization/graph.html?highlight=graph%20color#Graph.color

my_cells = [Cell(i) for i in range(NUM_CELLS)]

ns = h.NetStim()
ns.number = 1
ns.start = 4  # ms

nc = h.NetCon(ns, my_cells[0].syn)
nc.delay = 1  # ms
nc.weight[0] = 0.01

nc1 = h.NetCon(my_cells[0].soma(0.5)._ref_v, my_cells[1].syn, sec=my_cells[0].soma)
nc1.delay = 5  # ms
nc1.weight[0] = 0.01


h.tstop = 50

ps = h.PlotShape()
ps.show(0)

g = h.Graph()
g.addvar('Cell[0].soma(0.5).v', my_cells[0].soma(0.5)._ref_v)
g.color(RED)
g.addvar('Cell[1].soma(0.5).v', my_cells[1].soma(0.5)._ref_v)
g.size(0, 50, -80, 50)
h.graphList[0].append(g)

print('running the new version')

h.finitialize(-65)
h.continuerun(h.tstop)
