Garmin Fleet Management Controller  2.19.0
AobrdEventLogConverter.cpp File Reference
#include "AobrdEventLogConverter.h"
#include "CsvWriter.h"
#include "util.h"
#include <stdlib.h>
#include <fstream>
#include <map>
#include "pack_begin.h"

Go to the source code of this file.

Classes

struct  evt_log_header_fixed
 

Functions

static void checkFieldHeaders (uint32 &field_flags, int start, int end, vector< string > &record, uint16 &fieldIdx)
 
static void convertTimeTypeToString (time_type aTimestamp, char *full, int fullSize)
 
static void decodeDegreeFields (uint32 &, int start, int end, ofstream &rawFile, vector< string > &record, uint16 &fieldIdx, char *format="%f")
 Convert degrees into 4 byte signed int. More...
 
static void decodeStringFields (uint32 &field_flags, int start, int end, ofstream &rawFile, vector< string > &record, uint16 &fieldIdx)
 Convert CSV fields into 1 byte length and character stream. More...
 
static void decodeTimestampFields (uint32 &, int start, int end, ofstream &rawFile, vector< string > &record, uint16 &fieldIdx)
 Convert human-readable formatted timestamp into seconds. More...
 
static void decodeUint16Fields (uint32 &, int start, int end, ofstream &rawFile, vector< string > &record, uint16 &fieldIdx, char *format="%x")
 Convert 6 byte hex string into 2 byte unsigned int. More...
 
static void decodeUint32Fields (uint32 &, int start, int end, ofstream &rawFile, vector< string > &record, uint16 &fieldIdx, char *format="%x")
 Convert 10 byte hex string into 4 byte unsigned int. More...
 
static void encodeDegreeFields (uint32 field_flags, int start, int end, ifstream &rawFile, CsvWriter &csvWriter, char *format="%08.6f")
 Convert 4 byte signed int into degrees. More...
 
static void encodeStringFields (uint32 field_flags, int start, int end, ifstream &rawFile, CsvWriter &csvWriter)
 Convert 1 byte length and character stream into CSV cell. More...
 
static time_type encodeTimestampField (uint32 field_flags, int start, ifstream &rawFile, CsvWriter &csvWriter)
 
static void encodeTimestampFields (uint32 field_flags, int start, int end, ifstream &rawFile, CsvWriter &csvWriter)
 Convert time_type into human-readable formatted timestamp. More...
 
static void encodeUint16Fields (uint32 field_flags, int start, int end, ifstream &rawFile, CsvWriter &csvWriter, char *format="0x%.4x")
 Convert 2 byte unsigned int into 6 byte hex string. More...
 
static void encodeUint32Fields (uint32 field_flags, int start, int end, ifstream &rawFile, CsvWriter &csvWriter, char *format="0x%.8x")
 Convert 4 byte unsigned int into 10 byte hex string. More...
 
bool locateEventBeingVerified (void *key, vector< string > &record)
 callback for finding a Driver Status Change event in CSV file More...
 
static void modifyStatusChangeRecord (bool(*locator)(void *key, vector< string > &record), void *key, void(*updater)(void *val, vector< string > &record), void *val, const char *source)
 Function for finding and updating a record. More...
 
static time_type parseDateTime (std::string cellValue)
 Convert date-time string to UTC timestamp. More...
 
static uint16 readCSVRecord (ifstream &fstream, vector< string > &record, char delimiter= ',')
 Convert CSV record into vector of strings. More...
 
void updateEventBeingVerified (void *val, vector< string > &record)
 callback for updating a verified Driver Status Change event More...
 

Function Documentation

static void checkFieldHeaders ( uint32 field_flags,
int  start,
int  end,
vector< string > &  record,
uint16 fieldIdx 
)
static

Definition at line 754 of file AobrdEventLogConverter.cpp.

Referenced by AobrdEventLogConverter::convertToRaw().

static void decodeDegreeFields ( uint32 field_flags,
int  start,
int  end,
ofstream &  rawFile,
vector< string > &  record,
uint16 fieldIdx,
char *  format = "%f" 
)
static

Convert degrees into 4 byte signed int.

Definition at line 671 of file AobrdEventLogConverter.cpp.

References UTIL_convert_degrees_to_semicircles().

Referenced by AobrdEventLogConverter::convertToRaw().

static void decodeStringFields ( uint32 field_flags,
int  start,
int  end,
ofstream &  rawFile,
vector< string > &  record,
uint16 fieldIdx 
)
static

Convert CSV fields into 1 byte length and character stream.

Definition at line 642 of file AobrdEventLogConverter.cpp.

Referenced by AobrdEventLogConverter::convertToRaw().

static void decodeTimestampFields ( uint32 field_flags,
int  start,
int  end,
ofstream &  rawFile,
vector< string > &  record,
uint16 fieldIdx 
)
static

Convert human-readable formatted timestamp into seconds.

Definition at line 736 of file AobrdEventLogConverter.cpp.

References parseDateTime().

Referenced by AobrdEventLogConverter::convertToRaw().

static void decodeUint16Fields ( uint32 field_flags,
int  start,
int  end,
ofstream &  rawFile,
vector< string > &  record,
uint16 fieldIdx,
char *  format = "%x" 
)
static

Convert 6 byte hex string into 2 byte unsigned int.

Definition at line 716 of file AobrdEventLogConverter.cpp.

Referenced by AobrdEventLogConverter::convertToRaw().

static void decodeUint32Fields ( uint32 field_flags,
int  start,
int  end,
ofstream &  rawFile,
vector< string > &  record,
uint16 fieldIdx,
char *  format = "%x" 
)
static

Convert 10 byte hex string into 4 byte unsigned int.

Definition at line 691 of file AobrdEventLogConverter.cpp.

Referenced by AobrdEventLogConverter::convertToRaw().

static void encodeDegreeFields ( uint32  field_flags,
int  start,
int  end,
ifstream &  rawFile,
CsvWriter csvWriter,
char *  format = "%08.6f" 
)
static

Convert 4 byte signed int into degrees.

Definition at line 156 of file AobrdEventLogConverter.cpp.

References UTIL_convert_semicircles_to_degrees(), and CsvWriter::WriteValue().

Referenced by AobrdEventLogConverter::convertToCsv().

static void encodeStringFields ( uint32  field_flags,
int  start,
int  end,
ifstream &  rawFile,
CsvWriter csvWriter 
)
static

Convert 1 byte length and character stream into CSV cell.

Definition at line 63 of file AobrdEventLogConverter.cpp.

References CsvWriter::WriteValue().

Referenced by AobrdEventLogConverter::convertToCsv().

static time_type encodeTimestampField ( uint32  field_flags,
int  start,
ifstream &  rawFile,
CsvWriter csvWriter 
)
static
static void encodeTimestampFields ( uint32  field_flags,
int  start,
int  end,
ifstream &  rawFile,
CsvWriter csvWriter 
)
static

Convert time_type into human-readable formatted timestamp.

Definition at line 102 of file AobrdEventLogConverter.cpp.

References convertTimeTypeToString(), and CsvWriter::WriteValue().

Referenced by AobrdEventLogConverter::convertToCsv().

static void encodeUint16Fields ( uint32  field_flags,
int  start,
int  end,
ifstream &  rawFile,
CsvWriter csvWriter,
char *  format = "0x%.4x" 
)
static

Convert 2 byte unsigned int into 6 byte hex string.

Definition at line 202 of file AobrdEventLogConverter.cpp.

References CsvWriter::WriteValue().

Referenced by AobrdEventLogConverter::convertToCsv().

static void encodeUint32Fields ( uint32  field_flags,
int  start,
int  end,
ifstream &  rawFile,
CsvWriter csvWriter,
char *  format = "0x%.8x" 
)
static

Convert 4 byte unsigned int into 10 byte hex string.

Definition at line 180 of file AobrdEventLogConverter.cpp.

References CsvWriter::WriteValue().

Referenced by AobrdEventLogConverter::convertToCsv().

bool locateEventBeingVerified ( void *  key,
vector< string > &  record 
)

callback for finding a Driver Status Change event in CSV file

Definition at line 284 of file AobrdEventLogConverter.cpp.

Referenced by AobrdEventLogConverter::convertToCsv().

static void modifyStatusChangeRecord ( bool(*)(void *key, vector< string > &record)  locator,
void *  key,
void(*)(void *val, vector< string > &record)  updater,
void *  val,
const char *  source 
)
static

Function for finding and updating a record.

Definition at line 300 of file AobrdEventLogConverter.cpp.

References cnt_of_array, CsvWriter::NewLine(), readCSVRecord(), and CsvWriter::WriteValue().

Referenced by AobrdEventLogConverter::convertToCsv().

static uint16 readCSVRecord ( ifstream &  fstream,
vector< string > &  record,
char  delimiter = ',' 
)
static

Convert CSV record into vector of strings.

Returns
the number of 'cells' in the record

Definition at line 225 of file AobrdEventLogConverter.cpp.

Referenced by AobrdEventLogConverter::convertToRaw(), AobrdEventLogConverter::countRecords(), AobrdEventLogConverter::findRecordAt(), and modifyStatusChangeRecord().

void updateEventBeingVerified ( void *  val,
vector< string > &  record 
)

callback for updating a verified Driver Status Change event

Definition at line 292 of file AobrdEventLogConverter.cpp.

Referenced by AobrdEventLogConverter::convertToCsv().