Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/metadata #2

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 18 additions & 17 deletions ANSIC.lby
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<?AutomationStudio Version=4.3.8.58 SP?>
<Library Version="0.00.7" xmlns="http://br-automation.co.at/AS/Library">
<Files>
<File>VersionHistory.txt</File>
<File Description="Exported data types">Persist.typ</File>
<File Description="Exported constants">Persist.var</File>
<File Description="Exported functions and function blocks">Persist.fun</File>
<File Description="Copy values from persistent memory to working memory">PersistFn_Init.c</File>
<File Description="Copy values from working memory to persistent memory">PersistFn_Cyclic.c</File>
<File Description="Internal function to determine memory addresses">persistInternalMapMemory.c</File>
<File Description="Internal: Backup to persistent memory">persistInternalBackup.c</File>
<File Description="Internal: Restore from persistent memory">persistInternalRestore.c</File>
</Files>
<Dependencies>
<Dependency ObjectName="sys_lib" />
</Dependencies>
<?xml version="1.0" encoding="utf-8"?>
<?AutomationStudio FileVersion="4.9"?>
<Library Version="0.00.7" SubType="ANSIC" xmlns="http://br-automation.co.at/AS/Library">
<Files>
<File>VersionHistory.txt</File>
<File Description="Exported data types">Persist.typ</File>
<File Description="Exported constants">Persist.var</File>
<File Description="Exported functions and function blocks">Persist.fun</File>
<File Description="Copy values from persistent memory to working memory">PersistFn_Init.c</File>
<File Description="Copy values from working memory to persistent memory">PersistFn_Cyclic.c</File>
<File Description="Internal function to determine memory addresses">persistInternalMapMemory.c</File>
<File Description="Internal: Backup to persistent memory">persistInternalBackup.c</File>
<File Description="Internal: Restore from persistent memory">persistInternalRestore.c</File>
</Files>
<Dependencies>
<Dependency ObjectName="sys_lib" />
<Dependency ObjectName="astime" />
</Dependencies>
</Library>
86 changes: 46 additions & 40 deletions Persist.fun
Original file line number Diff line number Diff line change
@@ -1,40 +1,46 @@
(********************************************************************
* COPYRIGHT --
********************************************************************
* Library: Persist
* File: Persist.fun
* Author: davidblackburn
* Created: October 04, 2013
********************************************************************
* Functions and function blocks of library Persist
********************************************************************)

FUNCTION PersistFn_Init : UINT (*Copy values from persistent memory to working memory*) (*$GROUP=User*)
VAR_IN_OUT
Persistence : Persistence_typ;
END_VAR
END_FUNCTION

FUNCTION PersistFn_Cyclic : UINT (*Copy values from working memory to persistent memory*) (*$GROUP=User*)
VAR_IN_OUT
Persistence : Persistence_typ;
END_VAR
END_FUNCTION

FUNCTION persistInternalMapMemory : UINT (*Internal: Determine memory addresses*) (*$GROUP=User*)
VAR_IN_OUT
Persistence : Persistence_typ;
END_VAR
END_FUNCTION

FUNCTION persistInternalBackup : UINT (*Internal: Backup to persistent memory*) (*$GROUP=User*)
VAR_IN_OUT
Persistence : Persistence_typ;
END_VAR
END_FUNCTION

FUNCTION persistInternalRestore : UINT (*Internal: Restore from persistent memory*) (*$GROUP=User*)
VAR_IN_OUT
Persistence : Persistence_typ;
END_VAR
END_FUNCTION
(********************************************************************
* COPYRIGHT --
********************************************************************
* Library: Persist
* File: Persist.fun
* Author: davidblackburn
* Created: October 04, 2013
********************************************************************
* Functions and function blocks of library Persist
********************************************************************)

FUNCTION PersistFn_Init : UINT (*Copy values from persistent memory to working memory*) (*$GROUP=User*)
VAR_IN_OUT
Persistence : Persistence_typ;
END_VAR
END_FUNCTION

FUNCTION PersistFn_Cyclic : UINT (*Copy values from working memory to persistent memory*) (*$GROUP=User*)
VAR_IN_OUT
Persistence : Persistence_typ;
END_VAR
END_FUNCTION

FUNCTION persistInternalMapMemory : UINT (*Internal: Determine memory addresses*) (*$GROUP=User*)
VAR_IN_OUT
Persistence : Persistence_typ;
END_VAR
END_FUNCTION

FUNCTION persistInternalBackup : UINT (*Internal: Backup to persistent memory*) (*$GROUP=User*)
VAR_IN_OUT
Persistence : Persistence_typ;
END_VAR
END_FUNCTION

FUNCTION persistInternalRestore : UINT (*Internal: Restore from persistent memory*) (*$GROUP=User*)
VAR_IN_OUT
Persistence : Persistence_typ;
END_VAR
END_FUNCTION

FUNCTION persistUpdateMetadata : UINT
VAR_INPUT
Persistence : Persistence_typ;
END_VAR
END_FUNCTION
112 changes: 60 additions & 52 deletions Persist.typ
Original file line number Diff line number Diff line change
@@ -1,52 +1,60 @@
(********************************************************************
* COPYRIGHT --
********************************************************************
* Library: Persist
* File: Persist.typ
* Author: davidblackburn
* Created: October 04, 2013
********************************************************************
* Data types of library Persist
********************************************************************)
(*Public types*)

TYPE
PERSIST_ERR_enum :
(
PERSIST_ERR_INVALIDINPUT := 50000,
PERSIST_ERR_OUTOFMEMORY,
PERSIST_ERR_DATAMOVED_CHANGED
);
Persistence_Int_VarInfo_typ : STRUCT
pWorkingVariable : UDINT;
sizeofWorkingVariable : UDINT;
pPersistentMemory : UDINT;
END_STRUCT;
Persistence_Internal_typ : STRUCT
WorkingVariableInfo : ARRAY[0..PERSIST_MAI_VARLIST]OF Persistence_Int_VarInfo_typ;
ValidWorkingVariable : Persistence_Int_VarInfo_typ;
iVariable : USINT;
DataValid : BOOL;
END_STRUCT;
Persistence_OUT_STAT_typ : STRUCT
RequiredMemory : UDINT; (*Number of bytes required to store every variable in WorkingVariableList*)
Initialized : BOOL;
Error : BOOL;
ErrorID : UINT;
ErrorString : STRING[PERSIST_STRLEN_ERRORSTRING];
END_STRUCT;
Persistence_OUT_typ : STRUCT
STAT : Persistence_OUT_STAT_typ;
END_STRUCT;
Persistence_IN_typ : STRUCT
pPersistentVariable : UDINT; (*Address of the persistent variable*)
sizeofPersistentVariable : UDINT; (*Size of the persistent variable*)
pDataValid : UDINT; (*Address of the DataValid variable. If *pDataValid == TRUE, then persistent memory is copied to working memory on startup. If *pDataValid == FALSE, then persistent memory is NOT copied to working memory*)
WorkingVariableList : ARRAY[0..PERSIST_MAI_VARLIST]OF STRING[PERSIST_STRLEN_VARNAME]; (*List of working variables to be managed*)
END_STRUCT;
Persistence_typ : STRUCT
IN : Persistence_IN_typ;
OUT : Persistence_OUT_typ;
Internal : Persistence_Internal_typ;
END_STRUCT;
END_TYPE
(********************************************************************
* COPYRIGHT --
********************************************************************
* Library: Persist
* File: Persist.typ
* Author: davidblackburn
* Created: October 04, 2013
********************************************************************
* Data types of library Persist
********************************************************************)
(*Public types*)

TYPE
PERSIST_ERR_enum :
(
PERSIST_ERR_INVALIDINPUT := 50000,
PERSIST_ERR_OUTOFMEMORY,
PERSIST_ERR_DATAMOVED_CHANGED
);
Persistence_Var_Metadata : STRUCT
workingVariable : STRING[80];
variableSize : UDINT;
lastFileBackupTime : DATE_AND_TIME;
dataChanged : BOOL;
pSelf : UDINT;
END_STRUCT;
Persistence_Int_VarInfo_typ : STRUCT
pMetadata : REFERENCE TO Persistence_Var_Metadata;
pWorkingVariable : UDINT;
sizeofWorkingVariable : UDINT;
pPersistentMemory : UDINT;
END_STRUCT;
Persistence_Internal_typ : STRUCT
WorkingVariableInfo : ARRAY[0..PERSIST_MAI_VARLIST]OF Persistence_Int_VarInfo_typ;
ValidWorkingVariable : Persistence_Int_VarInfo_typ;
iVariable : USINT;
DataValid : BOOL;
END_STRUCT;
Persistence_OUT_STAT_typ : STRUCT
RequiredMemory : UDINT; (*Number of bytes required to store every variable in WorkingVariableList*)
Initialized : BOOL;
Error : BOOL;
ErrorID : UINT;
ErrorString : STRING[PERSIST_STRLEN_ERRORSTRING];
END_STRUCT;
Persistence_OUT_typ : STRUCT
STAT : Persistence_OUT_STAT_typ;
END_STRUCT;
Persistence_IN_typ : STRUCT
pPersistentVariable : UDINT; (*Address of the persistent variable*)
sizeofPersistentVariable : UDINT; (*Size of the persistent variable*)
pDataValid : UDINT; (*Address of the DataValid variable. If *pDataValid == TRUE, then persistent memory is copied to working memory on startup. If *pDataValid == FALSE, then persistent memory is NOT copied to working memory*)
WorkingVariableList : ARRAY[0..PERSIST_MAI_VARLIST]OF STRING[PERSIST_STRLEN_VARNAME]; (*List of working variables to be managed*)
END_STRUCT;
Persistence_typ : STRUCT
IN : Persistence_IN_typ;
OUT : Persistence_OUT_typ;
Internal : Persistence_Internal_typ;
END_STRUCT;
END_TYPE
Loading