-
Notifications
You must be signed in to change notification settings - Fork 0
/
DeviceConfig_0003.h
48 lines (39 loc) · 1.65 KB
/
DeviceConfig_0003.h
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
#pragma once
#include "DeviceConfig.h"
#include "MigrateAnyData/MigrateAnyData.h"
#include "MigrateDeviceConfig.h"
namespace MigrateDeviceConfig {
namespace V00000003 {
inline int GetSizeOfCurrentData();
inline void MigrateUp(void *pCurr, void *pPrev);
inline void MigrateDown(void *pCurr, void *pPrev);
const TDataMigrate DataMigrate = {0x00000003, MigrateUp, MigrateDown, GetSizeOfCurrentData};
typedef V00000002::Snapshot::TDeviceConfig TDeviceConfig_prev, *PTDeviceConfig_prev;
namespace Snapshot {
typedef struct {
char Name[16];
uint16_t RestartCount;
uint32_t CommunicationTimeout;
uint32_t spare[4];
} TDeviceConfig, *PTDeviceConfig;
} // namespace Snapshot
inline int GetSizeOfCurrentData() {
return sizeof(Snapshot::TDeviceConfig);
}
inline void MigrateUp(void *pCurr, void *pPrev) {
auto pCurrConfig = (Snapshot::PTDeviceConfig)pCurr;
auto pPrevConfig = (PTDeviceConfig_prev)pPrev;
strncpy(pCurrConfig->Name, pPrevConfig->Name, sizeof(pCurrConfig->Name) - 1);
pCurrConfig->RestartCount = 0;
pCurrConfig->CommunicationTimeout = 1500;
memset(pCurrConfig->spare, 0, sizeof(pCurrConfig->spare));
fprintf(stdout, "DeviceConfig. MigrateUp to %04X\n", DataMigrate.Version);
}
inline void MigrateDown(void *pCurr, void *pPrev) {
auto pCurrConfig = (Snapshot::PTDeviceConfig)pCurr;
auto pPrevConfig = (PTDeviceConfig_prev)pPrev;
strncpy(pPrevConfig->Name, pCurrConfig->Name, sizeof(pPrevConfig->Name) - 1);
fprintf(stdout, "DeviceConfig. MigrateDown from %04X\n", DataMigrate.Version);
}
} // namespace V00000003
} // namespace MigrateDeviceConfig