-
Notifications
You must be signed in to change notification settings - Fork 3
/
vecevent.mod
90 lines (80 loc) · 1.32 KB
/
vecevent.mod
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
: Vector stream of events
NEURON {
ARTIFICIAL_CELL VecStim
}
ASSIGNED {
index
etime (ms)
space
}
INITIAL {
index = 0
element()
if (index > 0) {
net_send(etime - t, 1)
}
}
NET_RECEIVE (w) {
if (flag == 1) {
net_event(t)
element()
if (index > 0) {
net_send(etime - t, 1)
}
}
}
VERBATIM
#ifndef NRN_VERSION_GTEQ_8_2_0
extern double* vector_vec();
extern int vector_capacity();
extern void* vector_arg();
#endif
ENDVERBATIM
DESTRUCTOR {
VERBATIM {
IvocVect* vtmp;
IvocVect** vv;
if (ifarg(1)) {
vtmp = (IvocVect*) vector_arg(1);
hoc_obj_ref(*vector_pobj(vtmp));
}
vv = (IvocVect**)(&space);
if (*vv) {
hoc_obj_unref(*vector_pobj(*vv));
}
if (vtmp) { *vv = vtmp; }
}
ENDVERBATIM
}
PROCEDURE element() {
VERBATIM
{ int i, size; double* px;
i = (int)index;
if (i >= 0) {
IvocVect* vv = *((IvocVect**)(&space));
if (vv) {
size = vector_capacity(vv);
px = vector_vec(vv);
if (i < size) {
etime = px[i];
index += 1.;
}else{
index = -1.;
}
}else{
index = -1.;
}
}
}
ENDVERBATIM
}
PROCEDURE play() {
VERBATIM
IvocVect** vv = (IvocVect**)(&space);
*vv = (IvocVect*)0;
if (ifarg(1)) {
*vv = vector_arg(1);
hoc_obj_ref(*vector_pobj(*vv));
}
ENDVERBATIM
}