Index: firmware/App/Modes/OperationModes.c =================================================================== diff -u -r4d7d40a27130dc813d653f044cbb856b1b7d8481 -r0bf1c0824844ed4c227eef0323238daedf505dc7 --- firmware/App/Modes/OperationModes.c (.../OperationModes.c) (revision 4d7d40a27130dc813d653f044cbb856b1b7d8481) +++ firmware/App/Modes/OperationModes.c (.../OperationModes.c) (revision 0bf1c0824844ed4c227eef0323238daedf505dc7) @@ -17,9 +17,6 @@ #include "gio.h" -#include "SystemCommMessages.h" -#include "TaskGeneral.h" -#include "OperationModes.h" #include "ModeChemicalDisinfect.h" #include "ModeDrain.h" #include "ModeFault.h" @@ -31,6 +28,9 @@ #include "ModeService.h" #include "ModeSolo.h" #include "ModeStandby.h" +#include "OperationModes.h" +#include "SystemCommMessages.h" +#include "TaskGeneral.h" /** * @addtogroup DGOperationModes @@ -39,18 +39,17 @@ // ********** private definitions ********** -#define BROADCAST_DG_OP_MODE_INTERVAL ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) ///< interval (ms/task time) at which the op mode is published on the CAN bus. +#define BROADCAST_DG_OP_MODE_INTERVAL ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) ///< interval (ms/task time) at which the operation mode is published on the CAN bus. // ********** private data ********** -static volatile BOOL modeRequest[NUM_OF_DG_MODES - 1]; ///< Array of mode request flags. +static volatile BOOL modeRequest[ NUM_OF_DG_MODES - 1 ]; ///< Array of mode request flags. static DG_OP_MODE_T currentMode = DG_MODE_INIT; ///< The currently active mode. static U32 currentSubMode = 0; ///< The currently active state of the active mode. -static U32 broadcastModeIntervalCtr = 11; ///< Interval counter used to determine when to broadcase operation mode. Initialize to 11 to stagger broadcast. -static U32 dgOpModePublicationTimerCounter = 0; ///< Timer counter for DG operation mode publication +static U32 broadcastModeIntervalCtr = 11; ///< Interval counter used to determine when to broadcast operation mode. Initialize to 11 to stagger broadcast. /// This matrix determines legal transitions from one mode to another. -static const DG_OP_MODE_T MODE_TRANSITION_TABLE[NUM_OF_DG_MODES - 1][NUM_OF_DG_MODES - 1] = +static const DG_OP_MODE_T MODE_TRANSITION_TABLE[ NUM_OF_DG_MODES - 1 ][ NUM_OF_DG_MODES - 1 ] = { // from to-> FAULT SERVICE INIT STANBY STBY-SOLO RE-CIRC FILL DRAIN FLUSH HEAT DIS CHEM DIS /* FAUL */{ DG_MODE_FAUL, DG_MODE_SERV, DG_MODE_NLEG, DG_MODE_NLEG, DG_MODE_NLEG, DG_MODE_NLEG, DG_MODE_NLEG, DG_MODE_NLEG, DG_MODE_NLEG, DG_MODE_NLEG, DG_MODE_NLEG }, @@ -107,9 +106,6 @@ initFlushMode(); initHeatDisinfectMode(); initChemicalDisinfectMode(); - - // initialize broadcast timer counter - dgOpModePublicationTimerCounter = 0; } /*********************************************************************//** @@ -125,7 +121,7 @@ // any new mode requests? newMode = arbitrateModeRequest(); // will return current mode if no pending requests - newMode = MODE_TRANSITION_TABLE[currentMode][newMode]; + newMode = MODE_TRANSITION_TABLE[ currentMode ][ newMode ]; // is requested new mode valid and legal at this time? if ( newMode >= DG_MODE_NLEG ) @@ -194,7 +190,7 @@ currentMode = DG_MODE_FAUL; currentSubMode = 0; break; - } // end switch + } // publish op mode on interval broadcastOperationMode(); Index: firmware/App/Services/SystemComm.c =================================================================== diff -u -r32d22b41c0297166bf2c89e59c968d69828d5025 -r0bf1c0824844ed4c227eef0323238daedf505dc7 --- firmware/App/Services/SystemComm.c (.../SystemComm.c) (revision 32d22b41c0297166bf2c89e59c968d69828d5025) +++ firmware/App/Services/SystemComm.c (.../SystemComm.c) (revision 0bf1c0824844ed4c227eef0323238daedf505dc7) @@ -1148,6 +1148,10 @@ handleDGSoftwareResetRequest( message ); break; + case MSG_ID_DG_OPERATION_MODE_REQUEST: + handleDGOperationModeRequest( message ); + break; + case MSG_ID_CONCENTRATE_PUMP_TARGET_SPEED_OVERRIDE: handleSetConcentratePumpTargetSpeed( message ); break; Index: firmware/App/Services/SystemCommMessages.c =================================================================== diff -u -r32d22b41c0297166bf2c89e59c968d69828d5025 -r0bf1c0824844ed4c227eef0323238daedf505dc7 --- firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 32d22b41c0297166bf2c89e59c968d69828d5025) +++ firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 0bf1c0824844ed4c227eef0323238daedf505dc7) @@ -1900,6 +1900,35 @@ /*********************************************************************//** * @brief + * The handleDGOperationModeRequest function handles a request to change + * DG operation mode. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleDGOperationModeRequest( MESSAGE_T *message ) +{ + BOOL result = FALSE; + DG_OP_MODE_T mode; + + // verify payload length + if ( sizeof( DG_OP_MODE_T ) == message->hdr.payloadLen ) + { + if ( TRUE == isTestingActivated() ) + { + memcpy( &mode, message->payload, sizeof( DG_OP_MODE_T ) ); + requestNewOperationMode( mode ); + result = mode < DG_MODE_NLEG; + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief * The handleSetConcentratePumpTargetSpeed function handles a request to * override a concentrate pump's target speed value. * @details Inputs: none Index: firmware/App/Services/SystemCommMessages.h =================================================================== diff -u -r32d22b41c0297166bf2c89e59c968d69828d5025 -r0bf1c0824844ed4c227eef0323238daedf505dc7 --- firmware/App/Services/SystemCommMessages.h (.../SystemCommMessages.h) (revision 32d22b41c0297166bf2c89e59c968d69828d5025) +++ firmware/App/Services/SystemCommMessages.h (.../SystemCommMessages.h) (revision 0bf1c0824844ed4c227eef0323238daedf505dc7) @@ -200,6 +200,9 @@ // MSG_ID_DG_SOFTWARE_RESET_REQUEST void handleDGSoftwareResetRequest( MESSAGE_T *message); +// MSG_ID_DG_OPERATION_MODE_REQUEST +void handleDGOperationModeRequest( MESSAGE_T *message); + // MSG_ID_CONCENTRATE_PUMP_TARGET_SPEED_OVERRIDE void handleSetConcentratePumpTargetSpeed( MESSAGE_T *message );