Init
This commit is contained in:
commit
1c3c03fa38
|
|
@ -0,0 +1,40 @@
|
|||
//
|
||||
// Created by cfif on 07.10.22.
|
||||
//
|
||||
|
||||
#ifndef STORAGES_H
|
||||
#define STORAGES_H
|
||||
|
||||
#include "EraGlonassUveos.h"
|
||||
|
||||
#include "DeviceDataNonVolatile.h"
|
||||
#include "DeviceDataRuntime.h"
|
||||
|
||||
#include "VarsTabDumpObserver.h"
|
||||
|
||||
typedef struct {
|
||||
tLoggerInterface *logger;
|
||||
|
||||
tDeviceDataRuntime runtime;
|
||||
tDeviceDataNonVolatile nvm;
|
||||
|
||||
tVariablesTable publicVariablesTable;
|
||||
|
||||
tVarsTabDumpObserver dumpObserver;
|
||||
|
||||
tEraGlonassUveosDumperInterface uveosDumper;
|
||||
|
||||
struct {
|
||||
tVariableDescriptor vartab[64];
|
||||
} mem;
|
||||
|
||||
} tDeviceStorage;
|
||||
|
||||
bool DeviceStorage_Init(tDeviceStorage *env, tStorageInterface *storageInterface);
|
||||
|
||||
//использоввать только для отладки
|
||||
void DeviceStorage_InitDefaults(tDeviceStorage *env);
|
||||
|
||||
void DeviceStorage_ForceDump(tDeviceStorage *env);
|
||||
|
||||
#endif //STORAGES_H
|
||||
|
|
@ -0,0 +1,73 @@
|
|||
//
|
||||
// Created by cfif on 07.10.22.
|
||||
//
|
||||
|
||||
#include <CmsisRtosThreadUtils.h>
|
||||
#include "DeviceStorage.h"
|
||||
#include "VersionRandID.h"
|
||||
|
||||
#define LOGGER env->logger
|
||||
#define LOG_SIGN "Хран."
|
||||
|
||||
#define VARIABLE_GROUP_UNTRACKED 0
|
||||
#define VARIABLE_GROUP_FLASH (1 << 0)
|
||||
|
||||
void DeviceStorage_InitVariablesTable(tDeviceStorage *env) {
|
||||
|
||||
VariablesTableInitStatic(&env->publicVariablesTable, env->mem.vartab);
|
||||
|
||||
DeviceDataRuntime_InitDefaults(&env->runtime);
|
||||
|
||||
DeviceDataNonVolatile_AddToVarTab(&env->nvm, &env->publicVariablesTable, VARIABLE_GROUP_FLASH);
|
||||
DeviceDataRuntime_AddToVarTab(&env->runtime, &env->publicVariablesTable, VARIABLE_GROUP_UNTRACKED);
|
||||
}
|
||||
|
||||
bool DeviceStorage_LoadNonVolatile(tDeviceStorage *env) {
|
||||
|
||||
if (VarsTabDumpObserver_Load(&env->dumpObserver)) {
|
||||
if (env->nvm.version == DEVICE_DATA_NO_VOLATILE_VERSION) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
DeviceDataNonVolatile_InitDefaults(&env->nvm);
|
||||
|
||||
return VarsTabDumpObserver_Dump(&env->dumpObserver);
|
||||
|
||||
}
|
||||
|
||||
void DeviceStorage_ForceDump(tDeviceStorage *env) {
|
||||
VarsTabDumpObserver_Dump(&env->dumpObserver);
|
||||
}
|
||||
|
||||
void DeviceStorage_InitCommon(tDeviceStorage *env, tStorageInterface *storageInterface) {
|
||||
VarsTabDumpObserver_Init(
|
||||
&env->dumpObserver,
|
||||
storageInterface,
|
||||
5000,
|
||||
&env->nvm,
|
||||
sizeof(env->nvm),
|
||||
&env->publicVariablesTable,
|
||||
VARIABLE_GROUP_FLASH
|
||||
);
|
||||
|
||||
env->uveosDumper = (tEraGlonassUveosDumperInterface) {
|
||||
.env = env,
|
||||
.forceDump = (eraGlonassForceDumpCall) DeviceStorage_ForceDump
|
||||
};
|
||||
|
||||
|
||||
DeviceStorage_InitVariablesTable(env);
|
||||
}
|
||||
|
||||
void DeviceStorage_InitDefaults(tDeviceStorage *env) {
|
||||
DeviceStorage_InitCommon(env, NULL);
|
||||
DeviceDataNonVolatile_InitDefaults(&env->nvm);
|
||||
}
|
||||
|
||||
bool DeviceStorage_Init(tDeviceStorage *env, tStorageInterface *storageInterface) {
|
||||
|
||||
DeviceStorage_InitCommon(env, storageInterface);
|
||||
|
||||
return DeviceStorage_LoadNonVolatile(env);
|
||||
}
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
{
|
||||
"dep": [
|
||||
{
|
||||
"type": "git",
|
||||
"provider": "NAVIGATOR_UVEOS_NATION_TELIT",
|
||||
"repo": "UveosOnNation_VEGA_DataNonVolatile"
|
||||
},
|
||||
{
|
||||
"type": "git",
|
||||
"provider": "NAVIGATOR_UVEOS_NATION_TELIT",
|
||||
"repo": "UveosOnNation_VEGA_DataRuntime"
|
||||
},
|
||||
{
|
||||
"type": "git",
|
||||
"provider": "NAVIGATOR_UVEOS_NATION_TELIT",
|
||||
"repo": "VarTabDumpObserver"
|
||||
},
|
||||
{
|
||||
"type": "git",
|
||||
"provider": "NAVIGATOR_UVEOS_NATION_TELIT",
|
||||
"repo": "VariablesTable"
|
||||
}
|
||||
],
|
||||
"cmake": {
|
||||
"inc_dirs": [
|
||||
"Inc/"
|
||||
],
|
||||
"srcs": [
|
||||
"Src/**.c",
|
||||
"Src_InitDefaults/**.c"
|
||||
]
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue