-
Notifications
You must be signed in to change notification settings - Fork 1
/
vecevent.mod
154 lines (137 loc) · 2.62 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
: Vector stream of events
NEURON {
THREADSAFE
ARTIFICIAL_CELL VecStim
BBCOREPOINTER ptr
RANGE xpos, ypos, zpos, gid, randi
}
PARAMETER {
xpos = 0
ypos = 0
zpos = 0
randi = 0
gid = 0
}
ASSIGNED {
index
etime (ms)
ptr
}
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)
}
}
}
FUNCTION is_art() {
is_art=1
}
PROCEDURE position(a, b, c) {
xpos = a
ypos = b
zpos = c
}
DESTRUCTOR {
VERBATIM
void* vv = (void*)(_p_ptr);
if (vv) {
hoc_obj_unref(*vector_pobj(vv));
}
ENDVERBATIM
}
VERBATIM
#include <stdint.h>
#if NRNBBCORE
#include "coreneuron/nrniv/ivocvect.h"
#endif
ENDVERBATIM
PROCEDURE element() {
VERBATIM
{ void* vv; int i, size; double* px;
i = (int)index;
if (i >= 0) {
vv = (void*)(_p_ptr);
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
#if !NRNBBCORE
void** pv;
void* ptmp = NULL;
if (ifarg(1)) {
ptmp = vector_arg(1);
hoc_obj_ref(*vector_pobj(ptmp));
}
pv = (void**)(&_p_ptr);
if (*pv) {
hoc_obj_unref(*vector_pobj(*pv));
}
*pv = ptmp;
#endif
ENDVERBATIM
}
VERBATIM
#if !NRNBBCORE
static void bbcore_write(double* dArray, int* iArray, int* doffset, int* ioffset, _threadargsproto_) {
uint32_t dsize = 0;
if (_p_ptr) {
dsize = (uint32_t)vector_capacity(_p_ptr);
}
if (iArray) {
uint32_t* ia = ((uint32_t*)iArray) + *ioffset;
void* vec = _p_ptr;
ia[0] = dsize;
double *da = dArray + *doffset;
double *dv;
if(dsize) {
dv = vector_vec(vec);
}
int iInt;
for (iInt = 0; iInt < dsize; ++iInt) {
da[iInt] = dv[iInt];
}
}
*ioffset += 1;
*doffset += dsize;
}
#endif
static void bbcore_read(double* dArray, int* iArray, int* doffset, int* ioffset, _threadargsproto_) {
assert(!_p_ptr);
uint32_t* ia = ((uint32_t*)iArray) + *ioffset;
int dsize = ia[0];
*ioffset += 1;
double *da = dArray + *doffset;
_p_ptr = vector_new1(dsize); /* works for dsize=0 */
double *dv = vector_vec(_p_ptr);
int iInt;
for (iInt = 0; iInt < dsize; ++iInt)
{
dv[iInt] = da[iInt];
}
*doffset += dsize;
}
ENDVERBATIM