8 #define MAX_ITEM_HISTORY 2048 19 basePath +=
"ComDataBuffer/";
32 for (
size_t i = 0; i <
m_buffers.size(); i++)
34 for (
size_t j = 0; j <
m_buffers[i].size(); j++)
59 if (timestamp != 0.0
f)
65 vector<uint8_t> dataBuffer;
66 dataBuffer.reserve(structSize);
71 for (
size_t i = 0; i < structSize; i++)
73 dataBuffer.push_back(0);
79 for (
size_t i = 0; i < data->
hdr.
offset; i++)
81 dataBuffer.push_back(0);
84 for (
size_t i = 0; i < data->
hdr.
size; i++)
86 dataBuffer.push_back(data->
buf[i]);
89 for (
size_t i = 0; i < structSize - data->
hdr.
size; i++)
91 dataBuffer.push_back(0);
96 size_t written = fwrite(×tamp, 1,
sizeof(
float),
m_timestamps[pHandle][data->
hdr.
id].file);
97 if (written !=
sizeof(
float))
108 written = fwrite(&dataBuffer[0], 1, dataBuffer.size(),
m_buffers[pHandle][data->
hdr.
id].file);
109 if (written != dataBuffer.size())
138 fstat(fileno(file), &buf);
140 fstat(_fileno(file), &buf);
142 long size = buf.st_size;
143 long pos = ftell(file);
144 long afterWriteOffset = size - pos;
151 read += fread(&data[0], 1, afterWriteOffset, file);
157 fseek(file, 0, SEEK_SET);
158 read += fread(&data[afterWriteOffset], 1, pos, file);
167 fseek(file, (
long)
m_buffers[pHandle][dataId].writeOffset, SEEK_SET);
175 while (
m_buffers.size() <= (size_t)pHandle)
178 m_buffers.push_back(vector<buffer_file_t>());
183 string num = out.str();
185 for (uint32_t dataIndex = 1; dataIndex <
DID_COUNT; dataIndex++)
189 string num2 = out2.str();
193 file.
path =
basePath +
"databuffer_" + num +
"_" + num2 + string(
".buf");
197 file.
path =
basePath +
"timebuffer_" + num +
"_" + num2 + string(
".buf");
int ReadData(int pHandle, uint32_t dataId, vector< uint8_t > &data)
vector< vector< buffer_file_t > > m_timestamps
cComDataBuffer g_comDataBuffer
void EnsureBuffers(int pHandle)
static double GetTimestamp(const p_data_hdr_t *hdr, const uint8_t *buf)
FILE * openFile(const char *path, const char *mode)
virtual ~cComDataBuffer()
static uint32_t GetSize(uint32_t dataId)
vector< vector< buffer_file_t > > m_buffers
USBInterfaceDescriptor data
int PushData(int pHandle, const p_data_t *data)
void DeleteDirectory(const std::string &directory, bool recursive)
uint8_t buf[MAX_DATASET_SIZE]