Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
plugin-GUI
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
yehaojie
plugin-GUI
Commits
41c0c6bd
Commit
41c0c6bd
authored
13 years ago
by
Stuart Layton
Browse files
Options
Downloads
Patches
Plain Diff
fixed bug in SpikeObject that was causing a buffer over run when spikes were generated
parent
dcef9e7a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Source/Processors/Visualization/SpikeObject.cpp
+42
-48
42 additions, 48 deletions
Source/Processors/Visualization/SpikeObject.cpp
Source/Processors/Visualization/SpikeObject.h
+1
-1
1 addition, 1 deletion
Source/Processors/Visualization/SpikeObject.h
with
43 additions
and
49 deletions
Source/Processors/Visualization/SpikeObject.cpp
+
42
−
48
View file @
41c0c6bd
...
...
@@ -89,9 +89,7 @@ bool unpackSpike(SpikeObject *s, char* buffer, int bufferSize){
if
(
idx
>=
bufferSize
)
std
::
cout
<<
"Buffer Overrun! More data extracted than was given!"
<<
std
::
endl
;
}
// Checks the validity of the buffer, this should be run before unpacking and after packing the buffer
...
...
@@ -135,60 +133,56 @@ void makeBufferValid(char *buffer, int bufferSize){
}
SpikeObject
generateSimulatedSpike
(
uint64_t
timestamp
,
int
noise
,
bool
sineWave
)
void
generateSimulatedSpike
(
SpikeObject
*
s
,
uint64_t
timestamp
,
int
noise
)
{
uint16_t
realSpikeWave
[
32
]
=
uint16_t
trace
[
32
]
=
{
1880
,
1900
,
1940
,
2040
,
2290
,
2790
,
3475
,
3995
,
4110
,
3890
,
3505
,
3090
,
2720
,
2410
,
2155
,
1945
,
1775
,
1635
,
1520
,
1420
,
1340
,
1265
,
1205
,
1155
,
1115
,
1080
,
1050
,
1034
,
1010
,
1001
,
1000
,
1000
};
uint16_t
sineSpikeWave
[
32
]
=
{
78
,
90
,
101
,
111
,
120
,
126
,
129
,
130
,
129
,
126
,
120
,
111
,
101
,
90
,
78
,
65
,
52
,
40
,
29
,
19
,
11
,
5
,
2
,
1
,
2
,
5
,
11
,
19
,
29
,
40
,
52
,
65
};
uint16_t
*
trace
;
uint16_t
gain
;
if
(
sineWave
){
trace
=
sineSpikeWave
;
gain
=
100
;
}
else
{
trace
=
realSpikeWave
;
gain
=
5
;
}
SpikeObject
s
;
s
.
timestamp
=
timestamp
;
s
.
source
=
0
;
s
.
nChannels
=
4
;
s
.
nSamples
=
32
;
// uint16_t sineSpikeWave[32] =
// { 78, 90, 101, 111, 120, 126, 129, 130,
// 129, 126, 120, 111, 101, 90, 78, 65,
// 52, 40, 29, 19, 11, 5, 2, 1,
// 2, 5, 11, 19, 29, 40, 52, 65};
// uint16_t trace[32] = {0};
uint16_t
gain
=
5
;
// if(sineWave){
// memcpy(trace, sineSpikeWave, 64);
// gain = 100;
// }
// else{
// memcpy(trace, realSpikeWave, 64);
// gain = 5;
// }
s
->
timestamp
=
timestamp
;
s
->
source
=
0
;
s
->
nChannels
=
4
;
s
->
nSamples
=
32
;
int
idx
=
0
;
for
(
int
i
=
0
;
i
<
s
.
nSamples
;
i
++
)
for
(
int
i
=
0
;
i
<
4
;
i
++
)
{
s
.
gain
[
i
]
=
gain
;
s
.
threshold
[
i
]
=
12000
;
for
(
int
j
=
0
;
j
<
s
.
nChannels
;
j
++
){
int
n
=
0
;
if
(
noise
>
0
){
n
=
rand
()
%
noise
-
noise
/
2
;
}
s
.
data
[
idx
++
]
=
(
trace
[
i
]
*
gain
)
+
n
;
}
s
->
gain
[
i
]
=
gain
;
s
->
threshold
[
i
]
=
12000
;
for
(
int
j
=
0
;
j
<
32
;
j
++
){
int
n
=
0
;
if
(
noise
>
0
){
n
=
rand
()
%
noise
-
noise
/
2
;
}
s
->
data
[
idx
]
=
(
trace
[
j
]
+
n
)
*
gain
;
idx
=
idx
+
1
;
}
}
return
s
;
}
...
...
This diff is collapsed.
Click to expand it.
Source/Processors/Visualization/SpikeObject.h
+
1
−
1
View file @
41c0c6bd
...
...
@@ -71,7 +71,7 @@ void makeBufferValid(char *buffer, int bufferLength);
// Help function for generating fake spikes in the absence of a real spike source.
// Can be used to generate a sign wave with a fixed Frequency of 1000 hz or a basic spike waveform
// Additionally noise can be added to the waveform for help in diagnosing projection plots
SpikeObject
generateSimulatedSpike
(
uint64_t
timestamp
,
int
noise
,
bool
sineWave
);
void
generateSimulatedSpike
(
SpikeObject
*
s
,
uint64_t
timestamp
,
int
noise
);
// Define the << operator for the SpikeObject
// std::ostream& operator<<(std::ostream &strm, const SpikeObject s);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment