-
Notifications
You must be signed in to change notification settings - Fork 21
/
NaviDataStore.cpp
93 lines (86 loc) · 1.64 KB
/
NaviDataStore.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#include "pch.h"
#include "NaviDataStore.h"
NaviDataStore::NaviDataStore()
{
}
//NaviDataStore::~NaviDataStore()
//{
// if (wfpS != NULL)
// fclose(wfpS);
// if (wfpN != NULL)
// fclose(wfpN);
// if (wfpG != NULL)
// fclose(wfpG);
// if (wfpR != NULL)
// fclose(wfpR);
//}
void NaviDataStore::createDirectory(SYSTEMTIME* st)
{
sprintf_s(datetime, "%4d%02d%02d%02d%02d%02d", st->wYear, st->wMonth, st->wDay, st->wHour, st->wMinute, st->wSecond);
datapath += datetime;
if (!PathIsDirectory(datapath))
{
CreateDirectory(datapath,0);
}
}
void NaviDataStore::closeFile(DataType dt)
{
if (dt == COM)
{
if (wfpS != NULL)
fclose(wfpS);
}
else if (dt == IMU)
{
if (wfpN != NULL)
fclose(wfpN);
}
else if (dt == GPS)
{
if (wfpG != NULL)
fclose(wfpG);
}
else if (dt == RES)
{
if (wfpG != NULL)
fclose(wfpR);
}
}
void NaviDataStore::createFile(SYSTEMTIME* st, DataType dt)
{
if (dt == COM)
{
fopen_s(&wfpS, "COM_Data.bin", "wb"); // bin Serial
}
else if (dt == IMU)
{
fopen_s(&wfpN, "IMU_Data.bin", "wb"); // bin imu+gps
}
else if (dt == GPS)
{
fopen_s(&wfpG, "GNSS_Data.bin", "w"); // GPSÎı¾¡¡¡¡GPGGA BESTVELA
}
else if (dt == RES)
{
fopen_s(&wfpR, "RESS_DATA.bin", "w");
}
}
void NaviDataStore::saveData(DataType dt, void* data)
{
if (dt == COM)
{
fwrite((double*)data, sizeof(double), 15, wfpS);
}
else if (dt == IMU)
{
fwrite((double*)data, sizeof(double), 15, wfpN);
}
else if (dt == GPS)
{
fprintf_s(wfpG, (char*)data);
}
else if (dt == RES)
{
fwrite((double*)data, sizeof(double), 9, wfpR);
}
}