-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathachpublisher.cpp
37 lines (29 loc) · 998 Bytes
/
achpublisher.cpp
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
#include "achshm.h"
#include "timer.h"
cshmPublisher::cshmPublisher(const char* channel_name, int _total_frames, size_t _frame_size) {
shm = new cshm(channel_name, _total_frames, _frame_size);
}
cshm_error cshmPublisher::open() {
return shm->Open();
}
cshm_error cshmPublisher::set(void* buffer, size_t buffer_size) {
double c_time = Timer::getCurrentTime();
return shm->Write(buffer, buffer_size, c_time);
}
cshmPublisher::~cshmPublisher() {
delete shm;
}
cshmVirtualPublisher::cshmVirtualPublisher(const char* channel_name, int _total_frames, size_t _frame_size) {
shm = new cshm(channel_name, _total_frames, _frame_size);
}
cshm_error cshmVirtualPublisher::open() {
return shm->Open();
}
// Read time from the buffer info, instead of the current time
cshm_error cshmVirtualPublisher::set(void* buffer, cshm_buffer_info_t *info) {
double c_time = info->time;
return shm->Write(buffer, info->size_written, c_time);
}
cshmVirtualPublisher::~cshmVirtualPublisher() {
delete shm;
}