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
502f5322
Commit
502f5322
authored
8 years ago
by
Josh Siegle
Committed by
GitHub
8 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #47 from beOn/development
addToBuffer with >1 item
parents
2b94695d
c408fc40
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Source/Processors/DataThreads/DataBuffer.cpp
+29
-15
29 additions, 15 deletions
Source/Processors/DataThreads/DataBuffer.cpp
Source/Processors/DataThreads/DataBuffer.h
+11
-2
11 additions, 2 deletions
Source/Processors/DataThreads/DataBuffer.h
with
40 additions
and
17 deletions
Source/Processors/DataThreads/DataBuffer.cpp
+
29
−
15
View file @
502f5322
...
...
@@ -49,25 +49,39 @@ void DataBuffer::resize(int chans, int size)
numChans
=
chans
;
}
void
DataBuffer
::
addToBuffer
(
float
*
data
,
int64
*
timestamps
,
uint64
*
eventCodes
,
int
numItems
)
int
DataBuffer
::
addToBuffer
(
float
*
data
,
int64
*
timestamps
,
uint64
*
eventCodes
,
int
numItems
,
int
chunkSize
)
{
// writes one sample for all channels
int
startIndex1
,
blockSize1
,
startIndex2
,
blockSize2
;
abstractFifo
.
prepareToWrite
(
numItems
,
startIndex1
,
blockSize1
,
startIndex2
,
blockSize2
);
for
(
int
chan
=
0
;
chan
<
numChans
;
chan
++
)
{
buffer
.
copyFrom
(
chan
,
// int destChannel
startIndex1
,
// int destStartSample
data
+
chan
,
// const float* source
1
);
// int num samples
int
bs
[
3
]
=
{
blockSize1
,
blockSize2
,
0
};
int
si
[
2
]
=
{
startIndex1
,
startIndex2
};
int
cSize
=
0
;
int
idx
=
0
;
int
blkIdx
;
for
(
int
i
=
0
;
bs
[
i
]
!=
0
;
i
++
)
{
// for each of the dest blocks we can write to...
blkIdx
=
0
;
for
(
int
j
=
0
;
j
<
bs
[
i
];
j
+=
chunkSize
)
{
// for each chunk...
cSize
=
chunkSize
<=
bs
[
i
]
-
j
?
chunkSize
:
bs
[
i
]
-
j
;
// ...figure our how much you can write
for
(
int
chan
=
0
;
chan
<
numChans
;
chan
++
)
{
// ...write that much, per channel
buffer
.
copyFrom
(
chan
,
// (int destChannel)
si
[
i
]
+
j
,
// (int destStartSample)
data
+
(
idx
*
numChans
)
+
chan
,
// (const float* source)
cSize
);
// (int num samples)
}
for
(
int
k
=
0
;
k
<
cSize
;
k
++
)
{
timestampBuffer
[
si
[
i
]
+
blkIdx
+
k
]
=
timestamps
[
idx
+
k
];
eventCodeBuffer
[
si
[
i
]
+
blkIdx
+
k
]
=
eventCodes
[
idx
+
k
];
}
idx
+=
cSize
;
blkIdx
+=
cSize
;
}
}
*
(
timestampBuffer
+
startIndex1
)
=
*
timestamps
;
*
(
eventCodeBuffer
+
startIndex1
)
=
*
eventCodes
;
abstractFifo
.
finishedWrite
(
numItems
)
;
// finish write
abstractFifo
.
finishedWrite
(
idx
)
;
return
idx
;
}
int
DataBuffer
::
getNumSamples
()
...
...
This diff is collapsed.
Click to expand it.
Source/Processors/DataThreads/DataBuffer.h
+
11
−
2
View file @
502f5322
...
...
@@ -45,8 +45,17 @@ public:
/** Clears the buffer.*/
void
clear
();
/** Add an array of floats to the buffer.*/
void
addToBuffer
(
float
*
data
,
int64
*
ts
,
uint64
*
eventCodes
,
int
numItems
);
/** Add an array of floats to the buffer.
@param data The data.
@param timestamps Array of timestamps. Same length as numItems.
@param eventCodes Array of event codes. Same length as numItems.
@param numItems Total number of samples per channel.
@param chunkSize Number of consecutive samples per channel per chunk.
1 by default. Typically 1 or numItems.
@return The number of items actually written. May be less than numItems if
the buffer doesn't have space.
*/
int
addToBuffer
(
float
*
data
,
int64
*
timestamps
,
uint64
*
eventCodes
,
int
numItems
,
int
chunkSize
=
1
);
/** Returns the number of samples currently available in the buffer.*/
int
getNumSamples
();
...
...
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