Index: firmware/App/Modes/OperationModes.c =================================================================== diff -u -r21d37cf60ade3de697371d2b71b2e7c652e55bd9 -rcd5be724d5a3ba7457e761191d82f278654d7f5c --- firmware/App/Modes/OperationModes.c (.../OperationModes.c) (revision 21d37cf60ade3de697371d2b71b2e7c652e55bd9) +++ firmware/App/Modes/OperationModes.c (.../OperationModes.c) (revision cd5be724d5a3ba7457e761191d82f278654d7f5c) @@ -1,14 +1,14 @@ /************************************************************************** * -* Copyright (c) 2019-2023 Diality Inc. - All Rights Reserved. +* Copyright (c) 2019-2024 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.c * -* @author (last) Michael Garthwaite -* @date (last) 14-Jun-2023 +* @author (last) Dara Navaei +* @date (last) 12-Oct-2023 * * @author (original) Dara Navaei * @date (original) 05-Nov-2019 @@ -62,6 +62,7 @@ static U32 broadcastModeIntervalCtr; ///< Interval counter used to determine when to broadcast operation mode. Initialize to 11 to stagger broadcast. static U32 currentSubState; ///< current sub state. static U32 current4thLevelState; ///< current 4th level state. + /// Interval (in task intervals) at which to publish operation mode data to CAN bus. static OVERRIDE_U32_T opModePublishInterval = { BROADCAST_HD_OP_MODE_INTERVAL, BROADCAST_HD_OP_MODE_INTERVAL, BROADCAST_HD_OP_MODE_INTERVAL, 0 }; /// Local structure init for saving confirmation requests @@ -139,7 +140,6 @@ HD_OP_MODE_T newMode; U32 priorSubMode = currentSubMode; U32 priorSubState = currentSubState; - U32 priorOpMode = (U32)currentMode; U32 prior4thLevelState = current4thLevelState; // Any new mode requests? @@ -165,7 +165,7 @@ transitionToNewOperationMode( newMode ); currentMode = newMode; - if ( ( MODE_TREA == lastMode ) && ( currentMode != MODE_TREA ) ) + if ( MODE_TREA == lastMode ) { // If the last mode is treatment but the new mode is not treatment // it means the treatment is done. Get the elapsed time since the beginning of the treatment and convert it to hours to be written @@ -174,6 +174,7 @@ // Write the treatment hours and set the service to be false so the treatment hours is not reset setTxTimeHours( txElapsedTimeHrs ); } + sendOperationStatusEvent(); } // Mode specific processing to be done continuously @@ -218,9 +219,10 @@ break; } // End switch +#ifndef _VECTORCAST_ // Send operation status event when appropriate - if ( priorOpMode != currentMode || priorSubMode != currentSubMode || - priorSubState != currentSubState || prior4thLevelState != current4thLevelState ) + if ( ( priorSubMode != currentSubMode ) || ( priorSubState != currentSubState ) || ( prior4thLevelState != current4thLevelState ) ) +#endif { sendOperationStatusEvent(); SEND_EVENT_WITH_2_U32_DATA( HD_EVENT_SUB_MODE_CHANGE, priorSubMode, currentSubMode ) @@ -536,24 +538,40 @@ *************************************************************************/ GENERIC_CONFIRM_ID_T addConfirmationRequest( GENERIC_CONFIRM_ID_T requestID, GENERIC_CONFIRM_COMMAND_T requestType, U32 rejectReason ) { - U32 i; + U32 i; + BOOL confirmAlreadyPending = FALSE; GENERIC_CONFIRM_ID_T newID = GENERIC_CONFIRM_ID_NONE; + // Check to make sure specified confirmation is not already pending for ( i = 0; i < MAX_PENDING_CONFIRM_REQUESTS; i++ ) { - if ( CONFIRMATION_REQUEST_STATUS_UNUSED == confirmRequests[ i ].status ) + if ( ( confirmRequests[ i ].requestID == requestID ) && + ( confirmRequests[ i ].status != CONFIRMATION_REQUEST_STATUS_UNUSED ) ) { - // Save the confirmation request info - confirmRequests[ i ].requestID = requestID; - confirmRequests[ i ].requestType = requestType; - confirmRequests[ i ].timeStamp = getMSTimerCount(); - confirmRequests[ i ].status = CONFIRMATION_REQUEST_STATUS_PENDING; - newID = requestID; - sendConfirmationRequest( requestID, requestType, rejectReason ); + confirmAlreadyPending = TRUE; break; } } + // If not already pending, add confirmation to list of pending confirmations and send to UI to be displayed + if ( confirmAlreadyPending != TRUE ) + { + for ( i = 0; i < MAX_PENDING_CONFIRM_REQUESTS; i++ ) + { + if ( CONFIRMATION_REQUEST_STATUS_UNUSED == confirmRequests[ i ].status ) + { + // Save the confirmation request info + confirmRequests[ i ].requestID = requestID; + confirmRequests[ i ].requestType = requestType; + confirmRequests[ i ].timeStamp = getMSTimerCount(); + confirmRequests[ i ].status = CONFIRMATION_REQUEST_STATUS_PENDING; + newID = requestID; + sendConfirmationRequest( requestID, requestType, rejectReason ); + break; + } + } + } + return newID; }