Index: firmware/App/Services/SystemCommMessages.c =================================================================== diff -u -rc52bfbc3f41fecde11bbec3eb71dc812154fc760 -rafa9d4924d55ac4fc98270a012e92dd1f6ee65d0 --- firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision c52bfbc3f41fecde11bbec3eb71dc812154fc760) +++ firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision afa9d4924d55ac4fc98270a012e92dd1f6ee65d0) @@ -570,8 +570,33 @@ result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_REQUIRED ); return result; -} +} + +/*********************************************************************//** + * @brief + * The sendTreatmentPeriodicDataToUI function constructs a treatment periodic + * data message to the UI and queues the msg for transmit on the appropriate CAN channel. + * @details Inputs: none + * @details Outputs: Treatment parameter ranges msg constructed and queued. + * @param periodDataPtr treatment log period data record pointer + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendTreatmentPeriodicDataToUI( TREATMENT_LOG_DATA_PERIODIC_T * periodDataPtr ) +{ + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_HD_TREATMENT_LOG_PERIODIC_DATA; + msg.hdr.payloadLen = sizeof( TREATMENT_LOG_DATA_PERIODIC_T ); + + memcpy( payloadPtr, periodDataPtr, sizeof( TREATMENT_LOG_DATA_PERIODIC_T ) ); + + // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + return serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_REQUIRED ); +} + /*********************************************************************//**  * @brief  * The handlePatientDisconnectionConfirmCmd function handles user confirms @@ -587,8 +612,10 @@ { signalUserConfirmPatientDisconnection(); } - - sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); + else + { + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); + } } /*********************************************************************//** @@ -606,8 +633,10 @@ { signalUserConfirmDisposableRemoval(); } - - sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); + else + { + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); + } } /*********************************************************************//** @@ -638,10 +667,12 @@ { if ( 0 == message->hdr.payloadLen ) { - handleTreatmentLogDataRequest(); + sendTreatmentLogDataToUI(); } - - sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); + else + { + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); + } } /*********************************************************************//** @@ -650,6 +681,8 @@ * for UI and queues the msg for transmit on the appropriate CAN channel. * @details Inputs: none * @details Outputs: Treatment log data msg constructed and queued. + * @param accepted T/F - was treatment log request accepted? + * @param reason reason why request was rejected (or zero if accepted) * @param logDataPtr treatment log data record pointer * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ @@ -672,9 +705,296 @@ // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer return serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_REQUIRED ); } - + /*********************************************************************//** * @brief + * The handleUIDisinfectRequest function handles a disinfect/flush user + * action command message from the UI. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleUIDisinfectRequest( MESSAGE_T *message ) +{ + BOOL result = FALSE; + + if ( message->hdr.payloadLen == sizeof(U32) ) + { + U32 cmd; + + memcpy( &cmd, message->payload, sizeof(U32) ); + + if ( 0 == cmd ) // Command 0 = Flush + { + result = signalUserInitiateFlushMode(); + } + else if ( 1 == cmd ) // Command 1 = Heat disinfect + { + result = signalUserInitiateHeatDisinfectMode(); + } + else if ( 2 == cmd ) // Command 2 = chemical disinfect + { + result = signalUserInitiateChemicalDisinfectMode(); + } + } + + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, result ); +} + +/*********************************************************************//** + * @brief + * The sendDisinfectConfirmResponse function constructs a disinfect or flush + * confirm user action response to the UI and queues the msg for + * transmit on the appropriate CAN channel. + * @details Inputs: none + * @details Outputs: Disposable removal confirm response msg constructed + * and queued. + * @param accepted T/F - was disinfect or flush confirm request accepted? + * @param reason reason why request was rejected (or zero if accepted) + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendDisinfectConfirmResponse( BOOL accepted, U32 reason ) +{ + return sendUIResponseMsg( MSG_ID_HD_DISINFECT_RESPONSE, accepted, reason ); +} + +/*********************************************************************//** + * @brief + * The handleSetHDStandbyDisinfectSubmode function handles setting the + * standby submode to wait for disisnfect state. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleSetHDStandbyDisinfectSubmodeRequest( MESSAGE_T *message ) +{ + BOOL result = FALSE; + + // The payload should be 0 in this case because there is mode in this command + if ( 0 == message->hdr.payloadLen ) + { + signalInitiateStandbyDisinfectSubmode(); + } + + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, result ); +} + +/*********************************************************************//** + * @brief + * The handleSetHDStandbyDisinfectSubmodeResponse function constructs a + * standby submode change to wait for disinfect confirm user action response + * to the UI and queues the msg for transmit on the appropriate CAN channel. + * @details Inputs: none + * @details Outputs: Disposable removal confirm response msg constructed + * and queued. + * @param accepted T/F - was set standby submode confirm request accepted? + * @param reason reason why request was rejected (or zero if accepted) + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL handleSetHDStandbyDisinfectSubmodeResponse( BOOL accepted, U32 reason ) +{ + return sendUIResponseMsg( MSG_ID_HD_SET_STANDBY_DISINFECT_SUB_MODE_RESPONSE, accepted, reason ); +} + +/*********************************************************************//** + * @brief + * The handleFlushUIStateReadingFromDG function handles the readings of DG + * flush mode. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleFlushUIStateReadingFromDG( MESSAGE_T *message ) +{ + if ( message->hdr.payloadLen == sizeof(MODE_FLUSH_DATA_T) ) + { + MODE_FLUSH_DATA_T payload; + DG_DISINFECT_UI_STATES_T uiStates; + + memcpy( &payload, message->payload, sizeof(MODE_FLUSH_DATA_T) ); + + uiStates.heatDisinfectUIState = 0; + uiStates.chemDisinfectUIState = 0; + uiStates.flushUIState = payload.flushUIState; + + setDGDisinfectsStates( uiStates ); + } +} + +/*********************************************************************//** + * @brief + * The handleHeatDisinfectUIStateReadingFromDG function handles the readings + * of DG heat disinfect mode. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleHeatDisinfectUIStateReadingFromDG( MESSAGE_T *message ) +{ + if ( message->hdr.payloadLen == sizeof(MODE_HEAT_DISINFECT_DATA_T) ) + { + MODE_HEAT_DISINFECT_DATA_T payload; + DG_DISINFECT_UI_STATES_T uiStates; + + memcpy( &payload, message->payload, sizeof(MODE_HEAT_DISINFECT_DATA_T) ); + + uiStates.heatDisinfectUIState = payload.heatDisinfectUIState; + uiStates.chemDisinfectUIState = 0; + uiStates.flushUIState = 0; + + setDGDisinfectsStates( uiStates ); + } +} + +/*********************************************************************//** + * @brief + * The handleUIActiveAlarmsListRequest function handles UI active alarms list request. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none. + *************************************************************************/ +void handleUIActiveAlarmsListRequest( MESSAGE_T *message ) +{ + if ( 0 == message->hdr.payloadLen ) + { + handleActiveAlarmListRequest(); + } + else + { + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); + } +} + +/*********************************************************************//** + * @brief + * The handleChemDisinfectUIStateReadingFromDG function handles the readings + * of DG chemical disinfect mode. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleChemDisinfectUIStateReadingFromDG( MESSAGE_T *message ) +{ + if ( message->hdr.payloadLen == sizeof(MODE_CHEMICAL_DISINFECT_DATA_T) ) + { + MODE_CHEMICAL_DISINFECT_DATA_T payload; + DG_DISINFECT_UI_STATES_T uiStates; + + memcpy( &payload, message->payload, sizeof(MODE_CHEMICAL_DISINFECT_DATA_T) ); + + uiStates.heatDisinfectUIState = 0; + uiStates.chemDisinfectUIState = payload.chemDisinfectUIState; + uiStates.flushUIState = 0; + + setDGDisinfectsStates( uiStates ); + } +} + +/*********************************************************************//** + * The sendActiveAlarmsList function constructs a treatment log data message + * for UI and queues the msg for transmit on the appropriate CAN channel. + * @details Inputs: none + * @details Outputs: Treatment log data msg constructed and queued. + * @details Outputs: Treatment log data msg constructed and queued. + * @param accepted T/F - was treatment log request accepted? + * @param alarmList pointer to active alarms list record + * @param size the size of active alarms list + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendActiveAlarmsList( BOOL accepted, U32 reason, U32 *alarmList, U32 size ) +{ + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_HD_ACTIVE_ALARMS_LIST_REQUEST_RESPONSE; + msg.hdr.payloadLen = sizeof( BOOL ) + sizeof( U32 ) + size; + + memcpy( payloadPtr, &accepted, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + memcpy( payloadPtr, &reason, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + memcpy( payloadPtr, alarmList, size ); + + // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + return serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_REQUIRED ); +} + +/*********************************************************************//** + * @brief + * The sendTreatmentLogAlarmEventData function constructs a treatment log + * alarm event data message for UI and queues the msg for transmit on the + * appropriate CAN channel. + * @details Inputs: none + * @details Outputs: Treatment log alarm event data msg constructed and queued. + * @param alarmID ID of the occurred alarm + * @param almData1 data associates with the alarm + * @param almData1 data associates with the alarm + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendTreatmentLogAlarmEventData( ALARM_ID_T alarmID, ALARM_DATA_T almData1, ALARM_DATA_T almData2 ) +{ + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + U32 id = (U32)alarmID; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_HD_TREATMENT_LOG_ALARM_EVENT; + msg.hdr.payloadLen = sizeof( ALARM_ID_T ) + 3 * sizeof( F32 ); + + memcpy( payloadPtr, &id, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + memcpy( payloadPtr, &almData1.data, sizeof( F32 ) ); + payloadPtr += sizeof( F32 ); + memcpy( payloadPtr, &almData2.data, sizeof( F32 ) ); + + // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + return serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_REQUIRED ); +} + +/*********************************************************************//** + * @brief + * The sendTreatmentLogEventData function constructs a treatment log parameter + * change event data message for UI and queues the msg for transmit on the + * appropriate CAN channel. + * @details Inputs: none + * @details Outputs: Treatment log event data msg constructed and queued. + * @param event ID of parameter change event + * @param oldValue parameter change event old data value + * @param newValue parameter change event new data value + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendTreatmentLogEventData( EVENT_ID_T event, F32 oldValue, F32 newValue ) +{ + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + U32 eventID = (U32)event; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_HD_TREATMENT_LOG_EVENT; + msg.hdr.payloadLen = sizeof( EVENT_ID_T ) + 3 * sizeof( F32 ); + + memcpy( payloadPtr, &eventID, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + memcpy( payloadPtr, &oldValue, sizeof( F32 ) ); + payloadPtr += sizeof( F32 ); + memcpy( payloadPtr, &newValue, sizeof( F32 ) ); + + // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + return serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_REQUIRED ); +} + +/*********************************************************************//** + * @brief * The handleSampleWaterCmd function handles a sample water user action command * message from the UI. * @details Inputs: none @@ -691,8 +1011,10 @@ memcpy( &cmd, &message->payload[0], sizeof( U32 ) ); signalSampleWaterUserAction( (REQUESTED_SAMPLE_WATER_USER_ACTIONS_T)cmd ); } - - sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); + else + { + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); + } } /*********************************************************************//** @@ -727,8 +1049,10 @@ memcpy( &result, &message->payload[0], sizeof( U32 ) ); setSampleWaterResult( (BOOL) result ); } - - sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); + else + { + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); + } } /*********************************************************************//** @@ -746,8 +1070,10 @@ { signalUserConfirmConsumableInstall(); } - - sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); + else + { + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); + } } /*********************************************************************//** @@ -765,8 +1091,10 @@ { signalUserConfirmInstallation(); } - - sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); + else + { + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); + } } /*********************************************************************//** @@ -784,8 +1112,10 @@ { signalStartPrime(); } - - sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); + else + { + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); + } } /*********************************************************************//** @@ -818,8 +1148,10 @@ { signalUserContinueToTreatment(); } - - sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); + else + { + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); + } } /*********************************************************************//** @@ -852,8 +1184,10 @@ { signalUserConfirmPatientConnection(); } - - sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); + else + { + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); + } } /*********************************************************************//** @@ -885,8 +1219,10 @@ { signalUserStartTreatment(); } - - sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); + else + { + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); + } } /*********************************************************************//** @@ -1232,6 +1568,92 @@ /*********************************************************************//** * @brief + * The sendDGStartFlushModeCommand function constructs a DG start/stop + * flush mode command message and queues the msg for transmit on the + * appropriate CAN channel. + * @details Inputs: none + * @details Outputs: DG start flush mode command msg constructed and queued. + * @param start TRUE indicates start flush mode + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendDGStartFlushModeCommand( BOOL start ) +{ + BOOL result; + MESSAGE_T msg; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_DG_START_STOP_FLUSH; + msg.hdr.payloadLen = sizeof( BOOL ); + + memcpy( msg.payload, &start, sizeof( BOOL ) ); + + // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_DG, ACK_REQUIRED ); + + return result; +} + +/*********************************************************************//** + * @brief + * The sendDGStartHeatDisinfectModeCommand function constructs a DG start/stop + * heat disinfect mode command message and queues the msg for transmit on + * the appropriate CAN channel. + * @details Inputs: none + * @details Outputs: DG start heat disinfect mode command msg constructed + * and queued. + * @param start TRUE indicates start heat disinfect mode + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendDGStartHeatDisinfectModeCommand( BOOL start ) +{ + BOOL result; + MESSAGE_T msg; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_DG_START_STOP_HEAT_DISINFECT; + msg.hdr.payloadLen = sizeof( BOOL ); + + memcpy( msg.payload, &start, sizeof( BOOL ) ); + + // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_DG, ACK_REQUIRED ); + + return result; +} + +/*********************************************************************//** + * @brief + * The sendDGStartChemicalDisinfectModeCommand function constructs a DG + * start/stop chemical disinfect mode command message and queues the msg + * for transmit on the appropriate CAN channel. + * @details Inputs: none + * @details Outputs: DG start chemical disinfect mode command msg + * constructed and queued. + * @param start TRUE indicates start chemical disinfect mode + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendDGStartChemicalDisinfectModeCommand( BOOL start ) +{ + BOOL result; + MESSAGE_T msg; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_DG_START_STOP_CHEM_DISINFECT; + msg.hdr.payloadLen = sizeof( BOOL ); + + memcpy( msg.payload, &start, sizeof( BOOL ) ); + + // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_DG, ACK_REQUIRED ); + + return result; +} + +/*********************************************************************//** + * @brief * The broadcastAccelData function constructs an accelerometer data msg to * be broadcast and queues the msg for transmit on the appropriate CAN channel. * @details Inputs: none @@ -2350,6 +2772,33 @@ return result; } +/*********************************************************************//** + * @brief + * The broadcastDisinfectsData function sends out the disinfects data. + * @details Inputs: none + * @details Outputs: disinfects data msg constructed and queued + * @param disinfectsData which is disinfects msg constructed and queued + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL broadcastDisinfectsData( DISINFECTS_DATA_T *disinfectsData ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_HD_DISINFECT_STANDBY_DATA; + msg.hdr.payloadLen = sizeof( DISINFECTS_DATA_T ); + + memcpy( payloadPtr, disinfectsData, sizeof( DISINFECTS_DATA_T ) ); + + // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_BROADCAST, ACK_NOT_REQUIRED ); + + return result; +} + #ifdef EMC_TEST_BUILD BOOL broadcastCANErrorCount( U32 count ) { @@ -2684,12 +3133,12 @@ *************************************************************************/ void handleDGTemperatureData( MESSAGE_T *message ) { - if ( message->hdr.payloadLen == sizeof(DG_TEMPERATURES_T) ) + if ( message->hdr.payloadLen == sizeof( TEMPERATURE_SENSORS_DATA_T ) ) { - DG_TEMPERATURES_T payload; - - memcpy( &payload, message->payload, sizeof(DG_TEMPERATURES_T) ); - setDialysateTemperatureReadings( payload.TDi, payload.TRo ); + TEMPERATURE_SENSORS_DATA_T payload; + + memcpy( &payload, message->payload, sizeof( TEMPERATURE_SENSORS_DATA_T ) ); + setDialysateTemperatureReadings( payload.inletDialysate, payload.outletRedundant ); } // TODO - what to do if invalid payload length? // TODO - how to know if DG stops sending these? @@ -5245,13 +5694,13 @@ *************************************************************************/ void handleSetFluidLeakStateOverrideRequest( MESSAGE_T *message ) { - TEST_OVERRIDE_ARRAY_PAYLOAD_T payload; + TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; // Verify payload length - if ( sizeof( TEST_OVERRIDE_ARRAY_PAYLOAD_T ) == message->hdr.payloadLen ) + if ( sizeof( TEST_OVERRIDE_PAYLOAD_T ) == message->hdr.payloadLen ) { - memcpy( &payload, message->payload, sizeof( TEST_OVERRIDE_ARRAY_PAYLOAD_T ) ); + memcpy( &payload, message->payload, sizeof( TEST_OVERRIDE_PAYLOAD_T ) ); if ( FALSE == payload.reset ) { result = testSetFluidLeakStateOverride( ( FLUID_LEAK_STATES_T)( payload.state.u32 ) ); @@ -6082,13 +6531,46 @@ /*********************************************************************//** * @brief - * The handleTestMonitoredVoltagesSendIntervalOverrideRequest function handles a - * request to override the monitored HD voltages data publication interval. + * The handleTestValvesCurrentOverrideRequest function handles a + * request to override HD valves' current. * @details Inputs: none * @details Outputs: message handled * @param message : a pointer to the message to handle * @return none *************************************************************************/ +void handleTestValvesCurrentOverrideRequest( MESSAGE_T *message ) +{ + TEST_OVERRIDE_ARRAY_PAYLOAD_T payload; + BOOL result = FALSE; + + // Verify payload length + if ( sizeof(TEST_OVERRIDE_ARRAY_PAYLOAD_T) == message->hdr.payloadLen ) + { + memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_ARRAY_PAYLOAD_T) ); + if ( FALSE == payload.reset ) + { + result = testSetValvesCurrentOverride( payload.index, payload.state.f32 ); + } + else + { + result = testResetValvesCurrentOverride( payload.index ); + } + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleTestMonitoredVoltagesSendIntervalOverrideRequest function + * handles a request to override the monitored HD voltages data + * publication interval. + * @details Inputs: none + * @details Outputs: message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ void handleTestMonitoredVoltagesSendIntervalOverrideRequest( MESSAGE_T *message ) { TEST_OVERRIDE_PAYLOAD_T payload; @@ -6114,6 +6596,38 @@ /*********************************************************************//** * @brief + * The handleTestValvesPositionCountOverrideRequest function handles a + * request to override HD valves' position in counts. + * @details Inputs: none + * @details Outputs: message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestValvesPositionCountOverrideRequest( MESSAGE_T *message ) +{ + TEST_OVERRIDE_ARRAY_PAYLOAD_T payload; + BOOL result = FALSE; + + // Verify payload length + if ( sizeof(TEST_OVERRIDE_ARRAY_PAYLOAD_T) == message->hdr.payloadLen ) + { + memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_ARRAY_PAYLOAD_T) ); + if ( FALSE == payload.reset ) + { + result = testSetValvesPositionCountOverride( payload.index, payload.state.u32 ); + } + else + { + result = testResetValvesPositionCountOverride( payload.index ); + } + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief * The handleTestMonitoredVoltageOverrideRequest function handles a * request to override the monitored HD voltage override. * @details Inputs: none