DeviceLogCSV.h
Go to the documentation of this file.
1 /*
2 MIT LICENSE
3 
4 Copyright (c) 2014-2021 Inertial Sense, Inc. - http://inertialsense.com
5 
6 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions :
7 
8 The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
9 
10 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
11 */
12 
13 #ifndef DEVICE_LOG_CSV_H
14 #define DEVICE_LOG_CSV_H
15 
16 #include <stdio.h>
17 #include <string>
18 #include <vector>
19 #include <map>
20 
21 #include "DataCSV.h"
22 #include "DeviceLog.h"
23 #include "com_manager.h"
24 
25 class cCsvLog
26 {
27 public:
28  cCsvLog() : pFile(NULL), fileCount(0), fileSize(0), dataId(0), orderId(0) { }
29 
30  FILE* pFile;
31  uint32_t fileCount;
32  uint64_t fileSize;
33  uint32_t dataId;
34  uint32_t dataSize;
35  uint64_t orderId;
36  string nextLine;
37  vector<data_info_t> columnHeaders;
38 };
39 
40 
41 class cDeviceLogCSV : public cDeviceLog
42 {
43 public:
44  void InitDeviceForWriting(int pHandle, std::string timestamp, std::string directory, uint64_t maxDiskSpace, uint32_t maxFileSize) OVERRIDE;
45  void InitDeviceForReading() OVERRIDE;
46  bool CloseAllFiles() OVERRIDE;
47  bool SaveData(p_data_hdr_t* dataHdr, const uint8_t* dataBuf) OVERRIDE;
48  p_data_t* ReadData() OVERRIDE;
49  void SetSerialNumber(uint32_t serialNumber) OVERRIDE;
50  std::string LogFileExtention() OVERRIDE { return std::string(".csv"); }
51 
52 private:
53  bool OpenNewFile(cCsvLog& log, bool readOnly);
54  bool GetNextLineForFile(cCsvLog& log);
55 
56  p_data_t* ReadDataFromFile(cCsvLog& log);
57  map<uint32_t, cCsvLog> m_logs;
59  map<uint32_t, vector<string> > m_currentFiles; // all files for each data set
60  map<uint32_t, uint32_t> m_currentFileIndex; // contains the current csv file index for each data set
62  uint64_t m_nextId; // for writing the log, column 0 of csv is an incrementing id. This lets us read the log back in order.
63 };
64 
65 #endif // DEVICE_LOG_CSV_H
uint64_t fileSize
Definition: DeviceLogCSV.h:32
#define OVERRIDE
Definition: ISConstants.h:423
#define NULL
Definition: nm_bsp.h:52
vector< data_info_t > columnHeaders
Definition: DeviceLogCSV.h:37
uint32_t dataId
Definition: DeviceLogCSV.h:33
uint64_t m_nextId
Definition: DeviceLogCSV.h:62
uint64_t orderId
Definition: DeviceLogCSV.h:35
std::string LogFileExtention() OVERRIDE
Definition: DeviceLogCSV.h:50
FILE * pFile
Definition: DeviceLogCSV.h:30
map< uint32_t, cCsvLog > m_logs
Definition: DeviceLogCSV.h:57
p_data_t m_dataBuffer
Definition: DeviceLogCSV.h:61
cDataCSV m_csv
Definition: DeviceLogCSV.h:58
uint32_t fileCount
Definition: DeviceLogCSV.h:31
uint32_t dataSize
Definition: DeviceLogCSV.h:34
map< uint32_t, vector< string > > m_currentFiles
Definition: DeviceLogCSV.h:59
map< uint32_t, uint32_t > m_currentFileIndex
Definition: DeviceLogCSV.h:60
string nextLine
Definition: DeviceLogCSV.h:36


inertial_sense_ros
Author(s):
autogenerated on Sun Feb 28 2021 03:17:57