/************************************************************************** * * Copyright (c) 2019-2023 Diality Inc. - All Rights Reserved. * * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. * * @file OperationModes.h * * @author (last) Darren Cox * @date (last) 12-Oct-2022 * * @author (original) Dara Navaei * @date (original) 05-Nov-2019 * ***************************************************************************/ #ifndef __OP_MODES_H__ #define __OP_MODES_H__ #include "HDCommon.h" #include "HDDefs.h" /** * @defgroup HDOperationModes HDOperationModes * @brief Operation Modes module. * * @addtogroup HDOperationModes * @{ */ // ********** public definitions ********** #define NO_SUB_STATE 0xFF ///< value for when submode does not have specific substates and is not applicable. /// Payload record structure for op mode broadcast message typedef struct { U32 opMode; ///< Current operating mode U32 subMode; ///< Current sub-mode of current operating mode } OP_MODE_PAYLOAD_T; /// Payload record structure for operation status events. typedef enum Op_Status_Fields { OPERATION_MODE = 0, ///< Current Operation mode SUB_MODE, ///< Current sub mode SUB_STATE, ///< Current sub state where applicable RESERVED, ///< Reserved 8-bit space used to uphold 32-bit payload sizes. NUM_OF_OP_STATUS_TYPE } OP_STATUS_T; #pragma pack(push, 1) typedef struct { U08 OpStatus[NUM_OF_OP_STATUS_TYPE]; } OP_STATUS_EVENT_PAYLOAD_T; #pragma pack(pop) // ********** public function prototypes ********** void initOperationModes( void ); // Initialize this module void execOperationModes( void ); // Execute the operation modes state machine (scheduled periodic call) void requestNewOperationMode( HD_OP_MODE_T newMode ); // Request a transition to a new operation mode HD_OP_MODE_T getCurrentOperationMode( void ); // Get the current operation mode HD_OP_MODE_T getPreviousOperationMode( void ); // Get the previous operation mode U32 getCurrentSubMode( void ); // Get the current sub-mode void initiateAlarmAction( ALARM_ACTION_T action ); // Initiate an alarm or alarm recovery action according to current op mode CONFIRMATION_REQUEST_STATUS_T getConfirmationRequestStatus( GENERIC_CONFIRM_ID_T request_id ); // Get the current confirmation request status void setConfirmationRequestStatus( GENERIC_CONFIRM_ID_T request_id, CONFIRMATION_REQUEST_STATUS_T status ); // Set the confirmation request status GENERIC_CONFIRM_ID_T addConfirmationRequest( GENERIC_CONFIRM_ID_T request_id, GENERIC_CONFIRM_COMMAND_T request_type, U32 reject_reason ); // Add a new confirmation request void setCurrentSubState( U32 subState ); // Set the current substate. BOOL testSetOperationMode( HD_OP_MODE_T newMode ); // Force transition to a given mode (if allowed) BOOL testSetOpModePublishIntervalOverride( U32 ms ); BOOL testResetOpModePublishIntervalOverride( void ); /**@}*/ #endif