add flags to var array

This commit is contained in:
pique_n 2021-12-17 16:03:09 +01:00
parent 4ab90de28a
commit d85ece47b7
2 changed files with 25 additions and 12 deletions

View File

@ -77,10 +77,10 @@ typedef struct
// Description: Definition of local variables (visible by this module only).
//=================================================================================================
LOCAL VARH_UVariable m_auVariable[VARH_eNumberOfVariables];
LOCAL StNotification m_astNotifications[VARH_eNumberOfVariables][VARH_eNumberOfNotificationTypes][NUMBER_OF_NOTIFICATIONS] = { 0 };
LOCAL VARH_StVar m_auVariable[VARH_eNumberOfVariables];
LOCAL StNotification m_astNotifications[VARH_eNumberOfVariables][VARH_eNumberOfNotificationTypes][NUMBER_OF_NOTIFICATIONS] = { 0 };
LOCAL osMutexId_t m_pstMutexID = NULL;
LOCAL osMutexId_t m_pstMutexID = NULL;
//=================================================================================================
// Section: LOCAL CONSTANTS
@ -210,9 +210,9 @@ BOOL VARH_boRegisterNotification( U8 u8Variable, VARH_EnNotification enNotificat
VOID VARH_vSetVariableData( U8 u8Variable, VARH_UVariable uData )
{
osMutexAcquire( m_pstMutexID, osWaitForever ); // aquire mutex
VARH_UVariable uOldValue = m_auVariable[u8Variable]; // remember old value
if( boCheckRange( u8Variable, uData ) ) { m_auVariable[u8Variable] = uData; } // store new value
vCallNotifications( u8Variable, uOldValue, m_auVariable[u8Variable] ); // call notifications
VARH_UVariable uOldValue = m_auVariable[u8Variable].uData; // remember old value
if( boCheckRange( u8Variable, uData ) ) { m_auVariable[u8Variable].uData = uData; } // store new value
vCallNotifications( u8Variable, uOldValue, m_auVariable[u8Variable].uData ); // call notifications
osMutexRelease( m_pstMutexID ); // release mutex
}
@ -235,9 +235,9 @@ VOID VARH_vSetVariableDataFromMaster( U8 u8Variable, VARH_UVariable uData )
return;
}
VARH_UVariable uOldValue = m_auVariable[u8Variable]; // remember old value
if( boCheckRange( u8Variable, uData ) ) { m_auVariable[u8Variable] = uData; } // store new value
vCallNotifications( u8Variable, uOldValue, m_auVariable[u8Variable] ); // call notifications
VARH_UVariable uOldValue = m_auVariable[u8Variable].uData; // remember old value
if( boCheckRange( u8Variable, uData ) ) { m_auVariable[u8Variable].uData = uData; } // store new value
vCallNotifications( u8Variable, uOldValue, m_auVariable[u8Variable].uData ); // call notifications
osMutexRelease( m_pstMutexID ); // release mutex
}
@ -250,7 +250,7 @@ VOID VARH_vSetVariableDataFromMaster( U8 u8Variable, VARH_UVariable uData )
VARH_UVariable VARH_uGetVariableData( U8 u8Variable )
{
osMutexAcquire( m_pstMutexID, osWaitForever ); // aquire mutex
VARH_UVariable uVar = m_auVariable[u8Variable];
VARH_UVariable uVar = m_auVariable[u8Variable].uData;
osMutexRelease( m_pstMutexID ); // release mutex
return( uVar );
}

View File

@ -40,12 +40,19 @@ extern "C" {
// Description: Definition of global constants (visible by all modules).
//=================================================================================================
// Flags
// Flags for variable
#define VARH_FLAG_VALID (1<<0) // is data valid
#define VARH_FLAG_OUTOFRANGE (1<<1) // is data out of range
#define VARH_FLAG_MODIFIED (1<<2) // is variable modified (compared to flash)
#define VARH_FLAG_FLASHCORRUPT (1<<3) // data from flash is corrupted
// Flags for variable infos
#define VARH_FLAG_NONE 0 // no flag
#define VARH_FLAG_FLOAT (1<<0) // variable in floating point format
#define VARH_FLAG_SIGNED (1<<1) // variable is signed integer
#define VARH_FLAG_BOOL (1<<2) // variable is boolean
#define VARH_FLAG_READONLY (1<<3) // variable is readonly, master can not set variable
#define VARH_FLAG_FLASH (1<<4) // variable is stored in flash
//=================================================================================================
// Section: MACROS
@ -105,11 +112,17 @@ typedef union {
typedef struct
{
U8 u8Flags; // flags
VARH_UVariable uInitData; // initial Data (data is always 32 bit, at least internal)
VARH_UVariable uInitData; // initial Data (data is always 32 bit)
VARH_UVariable uMinData; // min Value for Data
VARH_UVariable uMaxData; // max Value for Data
} VARH_StVarInfo;
typedef struct
{
VARH_UVariable uData; // Data (data is always 32 bit)
U8 u8Flags; // flags
} VARH_StVar;
//=================================================================================================
// Section: GLOBAL VARIABLES