added and changed the variable Handler
This commit is contained in:
@ -19,7 +19,7 @@
|
||||
//
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
//
|
||||
// Description: This source file contains all functions dealing with variables
|
||||
// Description: This source file contains all functions dealing with global variables
|
||||
//
|
||||
//=================================================================================================
|
||||
|
||||
@ -34,7 +34,6 @@
|
||||
#include "VARH_VariableHandler.h"
|
||||
|
||||
// Toolbox
|
||||
#include "../Toolbox/ASRT_Assert.h"
|
||||
#include "../Toolbox/UTIL_Utility.h"
|
||||
|
||||
#include "cmsis_os2.h"
|
||||
@ -45,7 +44,7 @@
|
||||
//=================================================================================================
|
||||
|
||||
// define the number of notifications according the need
|
||||
#define NUMBER_OF_NOTIFICATOINS 1
|
||||
#define NUMBER_OF_NOTIFICATIONS 2
|
||||
|
||||
|
||||
//=================================================================================================
|
||||
@ -73,20 +72,13 @@ typedef struct
|
||||
PVOID pvArgument;
|
||||
} StNotification;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
VARH_pfnRangeCheck pfnCallback;
|
||||
PVOID pvArgument;
|
||||
} StRangeCheck;
|
||||
|
||||
//=================================================================================================
|
||||
// Section: LOCAL VARIABLES
|
||||
// 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_NOTIFICATOINS] = { 0 };
|
||||
LOCAL StRangeCheck m_astRangeCheck[VARH_eNumberOfVariables] = { 0 };
|
||||
LOCAL VARH_UVariable m_auVariable[VARH_eNumberOfVariables];
|
||||
LOCAL StNotification m_astNotifications[VARH_eNumberOfVariables][VARH_eNumberOfNotificationTypes][NUMBER_OF_NOTIFICATIONS] = { 0 };
|
||||
|
||||
LOCAL osMutexId_t m_pstMutexID = NULL;
|
||||
|
||||
@ -98,23 +90,9 @@ LOCAL osMutexId_t m_pstMutexID = NULL;
|
||||
|
||||
LOCAL CONST VARH_StVarInfo m_astVarInfo[VARH_eNumberOfVariables] =
|
||||
{
|
||||
{"Status", VARH_FLAG_READONLY, VARH_eUnitByte, VARH_ePrefixNone, (VARH_UVariable)TRUE}, // VARH_eEnable,
|
||||
|
||||
{"VoltageRef En", VARH_FLAG_NONE, VARH_eUnitBoolean, VARH_ePrefixNone, (VARH_UVariable)FALSE}, // VARH_eSetMode,
|
||||
|
||||
{"Status G", VARH_FLAG_NONE, VARH_eUnitBoolean, VARH_ePrefixNone, (VARH_UVariable)FALSE}, // VARH_eInvertA,
|
||||
{"Status R", VARH_FLAG_NONE, VARH_eUnitBoolean, VARH_ePrefixNone, (VARH_UVariable)FALSE}, // VARH_eInvertB,
|
||||
{"Enabled G", VARH_FLAG_NONE, VARH_eUnitBoolean, VARH_ePrefixNone, (VARH_UVariable)FALSE}, // VARH_eInvertA,
|
||||
{"Enabled R", VARH_FLAG_NONE, VARH_eUnitBoolean, VARH_ePrefixNone, (VARH_UVariable)FALSE}, // VARH_eInvertB,
|
||||
{"Inverted G", VARH_FLAG_NONE, VARH_eUnitBoolean, VARH_ePrefixNone, (VARH_UVariable)FALSE}, // VARH_eInvertA,
|
||||
{"Inverted R", VARH_FLAG_NONE, VARH_eUnitBoolean, VARH_ePrefixNone, (VARH_UVariable)FALSE}, // VARH_eInvertB,
|
||||
{"Spare G", VARH_FLAG_NONE, VARH_eUnitBoolean, VARH_ePrefixNone, (VARH_UVariable)FALSE}, // VARH_eInvertA,
|
||||
{"Spare R", VARH_FLAG_NONE, VARH_eUnitBoolean, VARH_ePrefixNone, (VARH_UVariable)FALSE}, // VARH_eInvertB,
|
||||
|
||||
{"Temp HeatSink", VARH_FLAG_FLOAT | VARH_FLAG_READONLY, VARH_eUnitCelsius, VARH_ePrefixNone, (VARH_UVariable)0.0f}, // VARH_eTempCS,
|
||||
{"Temp Shunt", VARH_FLAG_FLOAT | VARH_FLAG_READONLY, VARH_eUnitCelsius, VARH_ePrefixNone, (VARH_UVariable)0.0f}, // VARH_eTempRef,
|
||||
{"Temp VoltageRef", VARH_FLAG_FLOAT | VARH_FLAG_READONLY, VARH_eUnitCelsius, VARH_ePrefixNone, (VARH_UVariable)0.0f}, // VARH_eTempShunt,
|
||||
{"Temp CurrentSrc", VARH_FLAG_FLOAT | VARH_FLAG_READONLY, VARH_eUnitCelsius, VARH_ePrefixNone, (VARH_UVariable)0.0f}, // VARH_eTempShunt,
|
||||
{ VARH_FLAG_READONLY | VARH_FLAG_FLOAT, (VARH_UVariable)0.0f, (VARH_UVariable)-60.0f, (VARH_UVariable)100.0f }, // VARH_eTemp_H,
|
||||
{ VARH_FLAG_READONLY | VARH_FLAG_FLOAT, (VARH_UVariable)0.0f, (VARH_UVariable)-60.0f, (VARH_UVariable)100.0f }, // VARH_eTemp_C,
|
||||
{ VARH_FLAG_READONLY | VARH_FLAG_FLOAT, (VARH_UVariable)0.0f, (VARH_UVariable)-50.0f, (VARH_UVariable)70.0f }, // VARH_eTemp_Diff,
|
||||
|
||||
};
|
||||
|
||||
@ -132,15 +110,18 @@ LOCAL CONST osMutexAttr_t m_stMutexAttr =
|
||||
// Description: Definition of local functions (visible by this module only).
|
||||
//=================================================================================================
|
||||
|
||||
|
||||
PRIVATE VOID vSetVariablesToInitDataCallback( PVOID pvData );
|
||||
|
||||
// notification functions
|
||||
PRIVATE VOID vCallNotifications( U8 u8Variable, VARH_UVariable uOldData, VARH_UVariable uNewData );
|
||||
|
||||
PRIVATE BOOL boNewValue( VARH_UVariable uOldData, VARH_UVariable uNewData );
|
||||
|
||||
// check functions
|
||||
PRIVATE BOOL boCheckRange( U8 u8Variable, VARH_UVariable uNewData );
|
||||
|
||||
PRIVATE BOOL boRising( U8 u8Variable, VARH_UVariable uOldData, VARH_UVariable uNewData );
|
||||
PRIVATE BOOL boFalling( U8 u8Variable, VARH_UVariable uOldData, VARH_UVariable uNewData );
|
||||
PRIVATE BOOL boNewValue( U8 u8Variable, VARH_UVariable uOldData, VARH_UVariable uNewData );
|
||||
PRIVATE BOOL boBooleanVarCheck( U32 u32NewValue );
|
||||
PRIVATE BOOL boU32VarCheck( U8 u8Variable, U32 u32NewValue );
|
||||
PRIVATE BOOL boS32VarCheck( U8 u8Variable, S32 s32NewValue );
|
||||
PRIVATE BOOL boFloatVarCheck( U8 u8Variable, FLOAT flNewValue );
|
||||
|
||||
//=================================================================================================
|
||||
// Section: EXTERNAL FUNCTIONS
|
||||
@ -167,20 +148,15 @@ PRIVATE BOOL boNewValue( U8 u8Variable, VARH_UVariable uOldData, VARH_UVariable
|
||||
// Parameters: BOOL boInitConfig
|
||||
// Returns: Boolean TRUE if successful
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
BOOL VARH_boInitializeModule( BOOL boInitConfig )
|
||||
BOOL VARH_boInitializeModule( VOID )
|
||||
{
|
||||
ASRT_STATIC_ASSERT( VARH_eNumberOfVariables <= 255 );
|
||||
BOOL boOK = TRUE;
|
||||
|
||||
boOK &= ((m_pstMutexID = osMutexNew( &m_stMutexAttr )) == NULL) ? FALSE : TRUE;
|
||||
|
||||
memset( &m_astNotifications, 0, sizeof(m_astNotifications) ); // reset the notifications
|
||||
memset( &m_astRangeCheck, 0, sizeof(m_astRangeCheck) ); // reset the function pointers
|
||||
|
||||
if( boInitConfig )
|
||||
{
|
||||
VARH_vSetAllVariablesToInitData();
|
||||
}
|
||||
VARH_vSetAllVariablesToInitData();
|
||||
|
||||
return( boOK );
|
||||
}
|
||||
@ -197,14 +173,12 @@ BOOL VARH_boInitializeModule( BOOL boInitConfig )
|
||||
BOOL VARH_boRegisterNotification( U8 u8Variable, VARH_EnNotification enNotification, VARH_pfnNotification pfnCallback, PVOID pvCallbackArgument )
|
||||
{
|
||||
// check parameters
|
||||
#if defined(PDEF_FUNCTION_PARAMETER_CHECK_ENABLED) && PDEF_FUNCTION_PARAMETER_CHECK_ENABLED == TRUE
|
||||
if( enNotification >= VARH_eNumberOfNotificationTypes || pfnCallback == NULL)
|
||||
{
|
||||
return( FALSE );
|
||||
}
|
||||
#endif
|
||||
|
||||
for( U8 u8Notification = 0; u8Notification < NUMBER_OF_NOTIFICATOINS; u8Notification++ )
|
||||
for( U8 u8Notification = 0; u8Notification < NUMBER_OF_NOTIFICATIONS; u8Notification++ )
|
||||
{
|
||||
if( m_astNotifications[u8Variable][enNotification][u8Notification].pfnCallback == NULL )
|
||||
{
|
||||
@ -217,30 +191,11 @@ BOOL VARH_boRegisterNotification( U8 u8Variable, VARH_EnNotification enNotificat
|
||||
return( FALSE ); // registration not successful
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
// Function: VARH_boRegisterRangeCheck
|
||||
// Description: Registers the range check function
|
||||
// Parameters: U8 u8Variable
|
||||
// VARH_pfnRangeCheck pfnCallback
|
||||
// PVOID pvCallbackArgument
|
||||
// Returns: Boolean TRUE if register of Callback was successful, otherwise FALSE
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
BOOL VARH_boRegisterRangeCheck( U8 u8Variable, VARH_pfnRangeCheck pfnCallback, PVOID pvCallbackArgument )
|
||||
{
|
||||
if( m_astRangeCheck[u8Variable].pfnCallback == NULL )
|
||||
{
|
||||
m_astRangeCheck[u8Variable].pfnCallback = pfnCallback;
|
||||
m_astRangeCheck[u8Variable].pvArgument = pvCallbackArgument;
|
||||
return( TRUE );
|
||||
}
|
||||
|
||||
return( FALSE );
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
// Function: VARH_vSetVariableData
|
||||
// Description: Sets the Variable Data
|
||||
// Parameters: VARH_EnVariables enVariable
|
||||
// Parameters: U8 u8Variable
|
||||
// VARH_UVariable uData
|
||||
// Returns: None
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
@ -252,77 +207,17 @@ VOID VARH_vSetVariableData( U8 u8Variable, VARH_UVariable uData )
|
||||
vCallNotifications( u8Variable, uOldValue, m_auVariable[u8Variable] ); // call notifications
|
||||
osMutexRelease( m_pstMutexID ); // release mutex
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
// Function: VARH_vSetBit
|
||||
// Description: Sets the bit specified with the bitmask in the specified variable
|
||||
// Parameters: U8 u8Variable
|
||||
// U32 u32BitMask
|
||||
// Returns: None
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
VOID VARH_vSetBit( U8 u8Variable, U32 u32BitMask )
|
||||
{
|
||||
osMutexAcquire( m_pstMutexID, osWaitForever ); // aquire mutex
|
||||
U32 u32Data = m_auVariable[u8Variable].u32Val; // read
|
||||
UTIL_SET_BIT( &u32Data, u32BitMask ); // modify
|
||||
VARH_vSetVariableData( u8Variable, (VARH_UVariable) u32Data ); // write
|
||||
osMutexRelease( m_pstMutexID ); // release mutex
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
// Function: VARH_vClearBit
|
||||
// Description: Clears the bit specified with the bitmask in the specified variable
|
||||
// Function: VARH_vSetVariableDataFromMaster
|
||||
// Description: Sets the Variable Data from Master Protocol.
|
||||
// Only use this function from Master interpreter
|
||||
// Parameters: U8 u8Variable
|
||||
// U32 u32BitMask
|
||||
// VARH_UVariable uData
|
||||
// Returns: None
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
VOID VARH_vClearBit( U8 u8Variable, U32 u32BitMask )
|
||||
{
|
||||
osMutexAcquire( m_pstMutexID, osWaitForever ); // aquire mutex
|
||||
U32 u32Data = m_auVariable[u8Variable].u32Val; // read
|
||||
UTIL_CLEAR_BIT( &u32Data, u32BitMask ); // modify
|
||||
VARH_vSetVariableData( u8Variable, (VARH_UVariable) u32Data ); // write
|
||||
osMutexRelease( m_pstMutexID ); // release mutex
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
// Function: VARH_u32GetBit
|
||||
// Description: Gets the bits specified with the bitmask in the specified variable
|
||||
// Parameters: U8 u8Variable
|
||||
// U32 u32BitMask
|
||||
// Returns: None
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
U32 VARH_u32GetBit( U8 u8Variable, U32 u32BitMask )
|
||||
{
|
||||
osMutexAcquire( m_pstMutexID, osWaitForever ); // aquire mutex
|
||||
U32 u32Ret = m_auVariable[u8Variable].u32Val & u32BitMask;
|
||||
osMutexRelease( m_pstMutexID ); // release mutex
|
||||
return( u32Ret );
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
// Function: VARH_vIncrement
|
||||
// Description: Increments the specifiend variable
|
||||
// Parameters: U8 u8Variable
|
||||
// Returns: None
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
VOID VARH_vIncrement( U8 u8Variable )
|
||||
{
|
||||
osMutexAcquire( m_pstMutexID, osWaitForever ); // aquire mutex
|
||||
VARH_vSetVariableData( u8Variable, (VARH_UVariable) m_auVariable[u8Variable].u32Val++ );
|
||||
osMutexRelease( m_pstMutexID ); // release mutex
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
// Function: VARH_vSetVariableDataFromClient
|
||||
// Description: Sets the Variable Data from Client Protocol.
|
||||
// Only use this function from Client interpreter
|
||||
// Parameters: U8 u8Variable
|
||||
// PVOID pvData
|
||||
// SDEF_EnByteOrder enByteOrder
|
||||
// Returns: None
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
VOID VARH_vSetVariableDataFromClient( U8 u8Variable, VARH_UVariable uData )
|
||||
VOID VARH_vSetVariableDataFromMaster( U8 u8Variable, VARH_UVariable uData )
|
||||
{
|
||||
osMutexAcquire( m_pstMutexID, osWaitForever ); // aquire mutex
|
||||
|
||||
@ -353,15 +248,13 @@ VARH_UVariable VARH_uGetVariableData( U8 u8Variable )
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
// Function: VARH_u32GetVariableDataFromMSCB
|
||||
// Description: Gets the Variable Data from MSCB Protocol
|
||||
// Only use this function from MSCB interpreter
|
||||
// Function: VARH_u32GetVariableDataFromMaster
|
||||
// Description: Gets the Variable Data from Master Protocol
|
||||
// Only use this function from Master interpreter
|
||||
// Parameters: U8 u8Variable
|
||||
// PVOID pvData
|
||||
// SDEF_EnByteOrder enByteOrder
|
||||
// Returns: Number of elements copied
|
||||
// Returns: VARH_UVariable
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
VARH_UVariable VARH_u32GetVariableDataFromClient( U8 u8Variable )
|
||||
VARH_UVariable VARH_u32GetVariableDataFromMaster( U8 u8Variable )
|
||||
{
|
||||
|
||||
osMutexAcquire( m_pstMutexID, osWaitForever ); // aquire mutex
|
||||
@ -371,17 +264,6 @@ VARH_UVariable VARH_u32GetVariableDataFromClient( U8 u8Variable )
|
||||
return( uVar );
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
// Function: VARH_pstGetVariableInfo
|
||||
// Description: Gets the Variable Info
|
||||
// Parameters: U8 u8Variable
|
||||
// Returns: VARH_StVarInfo*
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
CONST VARH_StVarInfo* VARH_pstGetVariableInfo( U8 u8Variable )
|
||||
{
|
||||
return( (CONST VARH_StVarInfo*)&m_astVarInfo[u8Variable] );
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
// Function: VARH_vSetVariableToInitData
|
||||
// Description: Sets the variable to its initial data
|
||||
@ -409,35 +291,61 @@ VOID VARH_vSetAllVariablesToInitData( VOID )
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
// Function: VARH_vGetNumberOfVariables
|
||||
// Description: Gets the number of used variables
|
||||
// Parameters: None
|
||||
// Returns: U8 number of used variables
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
U8 VARH_u8GetNumberOfVariables( VOID )
|
||||
{
|
||||
return( VARH_eNumberOfVariables );
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
// Function: VARH_boBooleanVarCheck
|
||||
// Description: Checks the range of a boolean
|
||||
// Parameters: PVOID pvCallbackData
|
||||
// VARH_UVariable uNewValue
|
||||
// Returns: TRUE, the variable can be written
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
BOOL VARH_boBooleanVarCheck( PVOID pvCallbackData, VARH_UVariable uNewValue )
|
||||
{
|
||||
UNUSED( pvCallbackData );
|
||||
return( uNewValue.u32Val > 1 ? FALSE : TRUE );
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
// Section: LOCAL FUNCTIONS
|
||||
// Descriptionn: Definition (implementation) of local functions.
|
||||
//=================================================================================================
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
// Function: boBooleanVarCheck
|
||||
// Description: Checks the range of a boolean
|
||||
// Parameters: U32 u32NewValue
|
||||
// Returns: TRUE, the variable can be written
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
PRIVATE BOOL boBooleanVarCheck( U32 u32NewValue )
|
||||
{
|
||||
return( u32NewValue > 1 ? FALSE : TRUE );
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
// Function: boU32VarCheck
|
||||
// Description: Checks the range of a U32
|
||||
// Parameters: U8 u8Variable
|
||||
// U32 u32NewValue
|
||||
// Returns: TRUE, the variable can be written
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
PRIVATE BOOL boU32VarCheck( U8 u8Variable, U32 u32NewValue )
|
||||
{
|
||||
return( m_astVarInfo[u8Variable].uMinData.u32Val < u32NewValue < m_astVarInfo[u8Variable].uMaxData.u32Val ? TRUE : FALSE );
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
// Function: boS32VarCheck
|
||||
// Description: Checks the range of a S32
|
||||
// Parameters: U8 u8Variable
|
||||
// S32 s32NewValue
|
||||
// Returns: TRUE, the variable can be written
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
PRIVATE BOOL boS32VarCheck( U8 u8Variable, S32 s32NewValue )
|
||||
{
|
||||
return( m_astVarInfo[u8Variable].uMinData.s32Val < s32NewValue < m_astVarInfo[u8Variable].uMaxData.s32Val ? TRUE : FALSE );
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
// Function: boFloatVarCheck
|
||||
// Description: Checks the range of a Float
|
||||
// Parameters: U8 u8Variable
|
||||
// FLOAT flNewValue
|
||||
// Returns: TRUE, the variable can be written
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
PRIVATE BOOL boFloatVarCheck( U8 u8Variable, FLOAT flNewValue )
|
||||
{
|
||||
return( m_astVarInfo[u8Variable].uMinData.flVal < flNewValue < m_astVarInfo[u8Variable].uMaxData.flVal ? TRUE : FALSE );
|
||||
}
|
||||
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
// Function: vCallNotifications
|
||||
// Description: Calls the notification callback functions
|
||||
@ -448,36 +356,21 @@ BOOL VARH_boBooleanVarCheck( PVOID pvCallbackData, VARH_UVariable uNewValue )
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
PRIVATE VOID vCallNotifications( U8 u8Variable, VARH_UVariable uOldData, VARH_UVariable uNewData )
|
||||
{
|
||||
for( U8 u8Notification = 0; u8Notification < NUMBER_OF_NOTIFICATOINS; u8Notification++ )
|
||||
for( U8 u8Notification = 0; u8Notification < NUMBER_OF_NOTIFICATIONS; u8Notification++ )
|
||||
{
|
||||
if( m_astNotifications[u8Variable][VARH_eWrite][u8Notification].pfnCallback != NULL )
|
||||
{
|
||||
m_astNotifications[u8Variable][VARH_eWrite][u8Notification].pfnCallback( m_astNotifications[u8Variable][VARH_eWrite][u8Notification].pvArgument );
|
||||
}
|
||||
|
||||
if( boNewValue( u8Variable, uOldData, uNewData ) )
|
||||
if( boNewValue( uOldData, uNewData ) )
|
||||
{
|
||||
if( m_astNotifications[u8Variable][VARH_eNewValue][u8Notification].pfnCallback != NULL )
|
||||
{
|
||||
m_astNotifications[u8Variable][VARH_eNewValue][u8Notification].pfnCallback( m_astNotifications[u8Variable][VARH_eNewValue][u8Notification].pvArgument );
|
||||
}
|
||||
}
|
||||
|
||||
if( boRising( u8Variable, uOldData, uNewData ) )
|
||||
{
|
||||
if( m_astNotifications[u8Variable][VARH_eRising][u8Notification].pfnCallback != NULL )
|
||||
{
|
||||
m_astNotifications[u8Variable][VARH_eRising][u8Notification].pfnCallback( m_astNotifications[u8Variable][VARH_eRising][u8Notification].pvArgument );
|
||||
}
|
||||
}
|
||||
|
||||
if( boFalling( u8Variable, uOldData, uNewData ) )
|
||||
{
|
||||
if( m_astNotifications[u8Variable][VARH_eFalling][u8Notification].pfnCallback != NULL )
|
||||
{
|
||||
m_astNotifications[u8Variable][VARH_eFalling][u8Notification].pfnCallback( m_astNotifications[u8Variable][VARH_eFalling][u8Notification].pvArgument );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -490,37 +383,20 @@ PRIVATE VOID vCallNotifications( U8 u8Variable, VARH_UVariable uOldData, VARH_U
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
PRIVATE BOOL boCheckRange( U8 u8Variable, VARH_UVariable uNewData )
|
||||
{
|
||||
if( m_astRangeCheck[u8Variable].pfnCallback == NULL )
|
||||
if( m_astVarInfo[u8Variable].u8Flags & VARH_FLAG_FLOAT )
|
||||
{
|
||||
return( TRUE );
|
||||
return( boFloatVarCheck(u8Variable, uNewData.flVal ) );
|
||||
} else if( m_astVarInfo[u8Variable].u8Flags & VARH_FLAG_SIGNED )
|
||||
{
|
||||
return( boS32VarCheck(u8Variable, uNewData.s32Val ) );
|
||||
} else if( m_astVarInfo[u8Variable].u8Flags & VARH_FLAG_BOOL )
|
||||
{
|
||||
return( boBooleanVarCheck( uNewData.s32Val ) );
|
||||
} else
|
||||
{
|
||||
return( boU32VarCheck(u8Variable, uNewData.u32Val ) );
|
||||
}
|
||||
return( m_astRangeCheck[u8Variable].pfnCallback( m_astRangeCheck[u8Variable].pvArgument, uNewData ) );
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
// Function: boRising
|
||||
// Description: returns True, if there is a rising edge on this variable (only for boolean types)
|
||||
// Parameters: U8 u8Variable
|
||||
// VARH_UVariable uOldData
|
||||
// VARH_UVariable uNewData
|
||||
// Returns: None
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
PRIVATE BOOL boRising( U8 u8Variable, VARH_UVariable uOldData, VARH_UVariable uNewData )
|
||||
{
|
||||
return( uOldData.u32Val == 0 && uNewData.u32Val == 1 ? TRUE : FALSE );
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
// Function: boFalling
|
||||
// Description: returns True, if there is a falling edge on this variable (only for boolean types)
|
||||
// Parameters: U8 u8Variable
|
||||
// VARH_UVariable uOldData
|
||||
// VARH_UVariable uNewData
|
||||
// Returns: None
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
PRIVATE BOOL boFalling( U8 u8Variable, VARH_UVariable uOldData, VARH_UVariable uNewData )
|
||||
{
|
||||
return( uOldData.u32Val == 1 && uNewData.u32Val == 0 ? TRUE : FALSE );
|
||||
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
@ -531,8 +407,7 @@ PRIVATE BOOL boFalling( U8 u8Variable, VARH_UVariable uOldData, VARH_UVariable u
|
||||
// VARH_UVariable uNewData
|
||||
// Returns: None
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
PRIVATE BOOL boNewValue( U8 u8Variable, VARH_UVariable uOldData, VARH_UVariable uNewData )
|
||||
PRIVATE BOOL boNewValue( VARH_UVariable uOldData, VARH_UVariable uNewData )
|
||||
{
|
||||
UNUSED( u8Variable );
|
||||
return( uNewData.u32Val != uOldData.u32Val ? TRUE : FALSE);
|
||||
}
|
||||
|
Reference in New Issue
Block a user