Index: firmware/App/Controllers/ConcentratePumps.c =================================================================== diff -u -r0803f828b81e046166457564650acf6a9bbd3cc6 -rbb7a4629cc96d96b6d1749c924e77886e0d64bcb --- firmware/App/Controllers/ConcentratePumps.c (.../ConcentratePumps.c) (revision 0803f828b81e046166457564650acf6a9bbd3cc6) +++ firmware/App/Controllers/ConcentratePumps.c (.../ConcentratePumps.c) (revision bb7a4629cc96d96b6d1749c924e77886e0d64bcb) @@ -303,7 +303,7 @@ { if ( pumpId < NUM_OF_CONCENTRATE_PUMPS ) { -#ifndef _RLEASE_ +#ifndef _RELEASE_ if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_CONC_PUMPS ) != SW_CONFIG_ENABLE_VALUE ) #endif { Index: firmware/App/Controllers/DialysateFlow.c =================================================================== diff -u -r0803f828b81e046166457564650acf6a9bbd3cc6 -rbb7a4629cc96d96b6d1749c924e77886e0d64bcb --- firmware/App/Controllers/DialysateFlow.c (.../DialysateFlow.c) (revision 0803f828b81e046166457564650acf6a9bbd3cc6) +++ firmware/App/Controllers/DialysateFlow.c (.../DialysateFlow.c) (revision bb7a4629cc96d96b6d1749c924e77886e0d64bcb) @@ -89,10 +89,9 @@ SELF_TEST_STATUS_T execDialysateFlowMeterSelfTest( void ) { SELF_TEST_STATUS_T result = SELF_TEST_STATUS_IN_PROGRESS; + BOOL calStatus = getNVRecord2Driver( GET_CAL_FLOW_SENSORS, (U08*)&flowSensorsCalRecord, sizeof( DG_FLOW_SENSORS_CAL_RECORD_T ), + NUM_OF_CAL_DATA_FLOW_SENSORS, ALARM_ID_DG_FLOW_SENSORS_INVALID_CAL_RECORD ); - BOOL calStatus = getNVRecord2Driver( GET_CAL_FLOW_SENSORS, (U08*)&flowSensorsCalRecord, sizeof( DG_FLOW_SENSORS_CAL_RECORD_T ), - NUM_OF_CAL_DATA_FLOW_SENSORS, ALARM_ID_DG_FLOW_SENSORS_INVALID_CAL_RECORD ); - if ( TRUE == calStatus ) { result = SELF_TEST_STATUS_PASSED; Index: firmware/App/Controllers/Pressures.c =================================================================== diff -u -r0803f828b81e046166457564650acf6a9bbd3cc6 -rbb7a4629cc96d96b6d1749c924e77886e0d64bcb --- firmware/App/Controllers/Pressures.c (.../Pressures.c) (revision 0803f828b81e046166457564650acf6a9bbd3cc6) +++ firmware/App/Controllers/Pressures.c (.../Pressures.c) (revision bb7a4629cc96d96b6d1749c924e77886e0d64bcb) @@ -273,8 +273,7 @@ S32 measuredPressureReadingsRaw[ NUM_OF_PRESSURE_SENSORS ]; U32 sensorID; F32 pressureReading; - BOOL isPressureOutOfRange; - + BOOL isPressureOutOfRange; PRESSURE_STATE_T result = PRESSURE_CONTINUOUS_READ_STATE; // get latest raw pressure readings Index: firmware/App/Controllers/ROPump.c =================================================================== diff -u -rbcb768dd6a13286e028533394916a9f69c9f254f -rbb7a4629cc96d96b6d1749c924e77886e0d64bcb --- firmware/App/Controllers/ROPump.c (.../ROPump.c) (revision bcb768dd6a13286e028533394916a9f69c9f254f) +++ firmware/App/Controllers/ROPump.c (.../ROPump.c) (revision bb7a4629cc96d96b6d1749c924e77886e0d64bcb) @@ -339,14 +339,14 @@ { U32 roFlowReading = (U32)getFPGAROPumpFlowRate(); F32 roFeedbackVoltage = getIntADCVoltageConverted( INT_ADC_RO_PUMP_FEEDBACK_DUTY_CYCLE ); - - // Update sum for flow average calculation - measuredFlowReadingsSum += (S32)roFlowReading; - // Read the pressure at the sensor. The pump cannot be more that the maximum allowed pressure // to make sure the hardware (especially the ROF) is not damaged. If it is the case, we need to stop immediately F32 actualPressure = getMeasuredDGPressure( PRESSURE_SENSOR_RO_PUMP_OUTLET ); BOOL isPressureMax = ( actualPressure >= MAX_ALLOWED_MEASURED_PRESSURE_PSI ? TRUE : FALSE ); + + // Update sum for flow average calculation + measuredFlowReadingsSum += (S32)roFlowReading; + checkPersistentAlarm( ALARM_ID_RO_PUMP_PRESSURE_OUT_OF_RANGE, isPressureMax, actualPressure, MAX_ALLOWED_MEASURED_PRESSURE_PSI ); // Check if a new calibration is available @@ -643,17 +643,15 @@ RO_PUMP_STATE_T state = RO_PUMP_RAMP_UP_TO_TARGET_FLOW_STATE; // Get the current pressure from the sensor - F32 actualPressure = getMeasuredDGPressure( PRESSURE_SENSOR_RO_PUMP_OUTLET ); - F32 targetFlowRate = getTargetROPumpFlowRate(); - F32 actualFlowRate = (F32)getMeasuredROFlowRateLPM(); - + F32 actualPressure = getMeasuredDGPressure( PRESSURE_SENSOR_RO_PUMP_OUTLET ); + F32 targetFlowRate = getTargetROPumpFlowRate(); + F32 actualFlowRate = (F32)getMeasuredROFlowRateLPM(); F32 flowRateDeviation = fabs( targetFlowRate - actualFlowRate ) / targetFlowRate; BOOL isFlowOutOfRange = flowRateDeviation > ROP_FLOW_TARGET_TOLERANCE; + F32 targetPressure = getTargetROPumpPressure(); if ( ++roControlTimerCounter >= ROP_RAMP_UP_CONTROL_INTERVAL ) { - F32 targetPressure = getTargetROPumpPressure(); - // If the actual pressure is greater than the target pressure or it is within the tolerance of the maximum pressure, move to set // to target pressure straight. At the beginning the maximum pressure is set in the targetROPumpPressure override variable. // If the flow rate was reached without reaching to maximum pressure, the pressure that was set to targetROPumpPressure override will Index: firmware/App/Controllers/Switches.c =================================================================== diff -u -r9df576f7d1962f640d8d8a4b56403431c67a8639 -rbb7a4629cc96d96b6d1749c924e77886e0d64bcb --- firmware/App/Controllers/Switches.c (.../Switches.c) (revision 9df576f7d1962f640d8d8a4b56403431c67a8639) +++ firmware/App/Controllers/Switches.c (.../Switches.c) (revision bb7a4629cc96d96b6d1749c924e77886e0d64bcb) @@ -15,7 +15,6 @@ * ***************************************************************************/ - #include "FPGA.h" #include "MessageSupport.h" #include "Switches.h" Index: firmware/App/Services/SystemCommMessages.c =================================================================== diff -u -r0803f828b81e046166457564650acf6a9bbd3cc6 -rbb7a4629cc96d96b6d1749c924e77886e0d64bcb --- firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 0803f828b81e046166457564650acf6a9bbd3cc6) +++ firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision bb7a4629cc96d96b6d1749c924e77886e0d64bcb) @@ -870,6 +870,41 @@ } /*********************************************************************//** +* @brief +* The handleStartStopDGFlush function handles a request to start or stop +* DG flush mode. +* @details Inputs: none +* @details Outputs: message handled +* @param message a pointer to the message to handle +* @return none +*************************************************************************/ +BOOL handleStartStopDGFlush( MESSAGE_T *message ) +{ + BOOL result = FALSE; + + if ( message->hdr.payloadLen == sizeof(U32) ) + { + BOOL startingDGFlush; + + memcpy( &startingDGFlush, message->payload, sizeof(U32) ); + + if ( TRUE == startingDGFlush ) + { + result = startDGFlush(); + } + else + { + result = stopDGFlush(); + } + } + + // Respond to request + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_DG_2_HD, result ); + + return result; +} + +/*********************************************************************//** * @brief * The sendCommandResponseMsg function constructs a command response to HD * and queues the msg for transmit on the appropriate CAN channel. @@ -893,10 +928,6 @@ serializeMessage( msg, COMM_BUFFER_OUT_CAN_DG_2_HD, ACK_REQUIRED ); } -// *********************************************************************** -// **************** Message Handling Helper Functions ******************** -// *********************************************************************** - /*********************************************************************//** * @brief * The handleSwitchReservoirCmd function handles a switch reservoirs command @@ -1121,8 +1152,120 @@ sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } +/************************************************************************* + * @brief + * The handleStartStopDGHeatDisinfect function handles a request start or + * stop DG heat disifect mode. + * @details Inputs: none + * @details Outputs: message handled + * @param message: a pointer to the message to handle + * @return result + *************************************************************************/ +BOOL handleStartStopDGHeatDisinfect( MESSAGE_T *message ) +{ + BOOL status = FALSE; + + if ( message->hdr.payloadLen == sizeof(U32) ) + { + BOOL startingDGHeatDisinfect; + + memcpy( &startingDGHeatDisinfect, message->payload, sizeof(U32) ); + + if ( TRUE == startingDGHeatDisinfect ) + { + status = startDGHeatDisinfect(); + } + else + { + status = stopDGHeatDisinfect(); + } + } + + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_DG_2_HD, status ); + + return status; +} + /*********************************************************************//** * @brief + * The handleUIClockSyncRequest function handles a UI clock sync message. + * @details Inputs: none + * @details Outputs: message handled, response constructed and queued for transmit. + * @param messagePtr pointer to the message to handle. + * @return none + *************************************************************************/ +void handleUIClockSyncRequest( MESSAGE_T *message ) +{ + BOOL result = FALSE; + U32 rejReason = REQUEST_REJECT_REASON_NONE; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + if ( message->hdr.payloadLen == sizeof( U32 ) ) + { + U32 epoch; + + memcpy( &epoch, message->payload, sizeof( U32 ) ); + result = setRTCEpoch( epoch ); + if ( FALSE == result ) + { + rejReason = REQUEST_REJECT_REASON_INVALID_DATE_OR_TIME; + } + } + else + { + rejReason = REQUEST_REJECT_REASON_INVALID_REQUEST_FORMAT; + } + + // Create a response message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_DG_UI_SET_RTC_RESPONSE; + msg.hdr.payloadLen = sizeof( BOOL ) + sizeof( U32 ); + memcpy( payloadPtr, &result, sizeof( BOOL ) ); + payloadPtr += sizeof( BOOL ); + memcpy( payloadPtr, &rejReason, sizeof( U32 ) ); + + // 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_DG_2_UI, ACK_REQUIRED ); + + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_DG_2_UI, result ); +} + +/*********************************************************************//** +* @brief +* The handleDGPOSTResultRequest function handles a request to report DG +* POST results. +* @details Inputs: none +* @details Outputs: message handled +* @param message a pointer to the message to handle +* @return none +*************************************************************************/ +void handleDGPOSTResultRequest( MESSAGE_T *message ) +{ + BOOL status = FALSE; + BOOL result = FALSE; + + if ( 0 == message->hdr.payloadLen ) + { + if ( TRUE == isPOSTCompleted() ) + { + status = TRUE; + if ( TRUE == isPOSTPassed() ) + { + result = TRUE; + } + sendPOSTFinalResult( result ); + } + } + // If can't respond to request, NAK the message + if ( status != TRUE ) + { + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, status ); + } +} + +/*********************************************************************//** + * @brief * The handleStartStopPrimaryHeater function handles a request start or * stop the primary heater * @details Inputs: none @@ -1156,7 +1299,77 @@ return result; } +/*********************************************************************//** +* @brief +* The handleStartStopDGChemicalDisinfect function handles a request to start +* or stop DG chemical disinfect mode. +* @details Inputs: none +* @details Outputs: message handled +* @param message a pointer to the message to handle +* @return none +*************************************************************************/ +BOOL handleStartStopDGChemicalDisinfect( MESSAGE_T *message ) +{ + BOOL result = FALSE; + if ( message->hdr.payloadLen == sizeof(U32) ) + { + BOOL startingDGChemicalDisinfect; + + memcpy( &startingDGChemicalDisinfect, message->payload, sizeof(U32) ); + + if ( TRUE == startingDGChemicalDisinfect ) + { + result = startDGChemicalDisinfect(); + } + else + { + result = stopChemicalDisinfect(); + } + } + + // Respond to request + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_DG_2_HD, result ); + + return result; +} + +/*********************************************************************//** + * @brief + * The handleSetHDOperationMode function receives the HD operation modes data + * publish message. + * @details Inputs: none + * @details Outputs: none + * @param message a pointer to the message to handle + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL handleSetHDOperationMode( MESSAGE_T *message ) +{ + BOOL status = FALSE; + U08* payloadPtr = message->payload; + + // HD mode broadcast is operations mode and submode so 8 bytes + if ( message->hdr.payloadLen == sizeof( U32 ) + sizeof( U32 ) ) + { + U32 mode; + + // NOTE: the HD operations modes broadcast message contains the mode and submode states + // In this case, only the mode is needed. The mode is received to check if HD is in treatment + // and therefore, DG can void the last disinfect. + memcpy( payloadPtr, &mode, sizeof( U32 ) ); + setHDOperationMode( mode ); + status = TRUE; + } + + return status; +} + + +// *********************************************************************** +// **************** Message Handling Helper Functions ******************** +// *********************************************************************** + + /************************************************************************* * TEST SUPPORT FUNCTIONS *************************************************************************/ @@ -2640,120 +2853,8 @@ sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } -/************************************************************************* - * @brief - * The handleStartStopDGHeatDisinfect function handles a request start or - * stop DG heat disifect mode. - * @details Inputs: none - * @details Outputs: message handled - * @param message: a pointer to the message to handle - * @return result - *************************************************************************/ -BOOL handleStartStopDGHeatDisinfect( MESSAGE_T *message ) -{ - BOOL status = FALSE; - - if ( message->hdr.payloadLen == sizeof(U32) ) - { - BOOL startingDGHeatDisinfect; - - memcpy( &startingDGHeatDisinfect, message->payload, sizeof(U32) ); - - if ( TRUE == startingDGHeatDisinfect ) - { - status = startDGHeatDisinfect(); - } - else - { - status = stopDGHeatDisinfect(); - } - } - - sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_DG_2_HD, status ); - - return status; -} - /*********************************************************************//** - * @brief - * The handleUIClockSyncRequest function handles a UI clock sync message. - * @details Inputs: none - * @details Outputs: message handled, response constructed and queued for transmit. - * @param messagePtr pointer to the message to handle. - * @return none - *************************************************************************/ -void handleUIClockSyncRequest( MESSAGE_T *message ) -{ - BOOL result = FALSE; - U32 rejReason = REQUEST_REJECT_REASON_NONE; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - if ( message->hdr.payloadLen == sizeof( U32 ) ) - { - U32 epoch; - - memcpy( &epoch, message->payload, sizeof( U32 ) ); - result = setRTCEpoch( epoch ); - if ( FALSE == result ) - { - rejReason = REQUEST_REJECT_REASON_INVALID_DATE_OR_TIME; - } - } - else - { - rejReason = REQUEST_REJECT_REASON_INVALID_REQUEST_FORMAT; - } - - // Create a response message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_DG_UI_SET_RTC_RESPONSE; - msg.hdr.payloadLen = sizeof( BOOL ) + sizeof( U32 ); - memcpy( payloadPtr, &result, sizeof( BOOL ) ); - payloadPtr += sizeof( BOOL ); - memcpy( payloadPtr, &rejReason, sizeof( U32 ) ); - - // 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_DG_2_UI, ACK_REQUIRED ); - - sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_DG_2_UI, result ); -} - -/*********************************************************************//** * @brief -* The handleDGPOSTResultRequest function handles a request to report DG -* POST results. -* @details Inputs: none -* @details Outputs: message handled -* @param message a pointer to the message to handle -* @return none -*************************************************************************/ -void handleDGPOSTResultRequest( MESSAGE_T *message ) -{ - BOOL status = FALSE; - BOOL result = FALSE; - - if ( 0 == message->hdr.payloadLen ) - { - if ( TRUE == isPOSTCompleted() ) - { - status = TRUE; - if ( TRUE == isPOSTPassed() ) - { - result = TRUE; - } - sendPOSTFinalResult( result ); - } - } - // If can't respond to request, NAK the message - if ( status != TRUE ) - { - sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, status ); - } -} - -/*********************************************************************//** -* @brief * The handleSetDGCalibrationRecord function handles a request to set the DG * calibration data record. * @details Inputs: none @@ -2784,41 +2885,8 @@ sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, status ); } -/*********************************************************************//** -* @brief -* The handleStartStopDGFlush function handles a request to start or stop -* DG flush mode. -* @details Inputs: none -* @details Outputs: message handled -* @param message a pointer to the message to handle -* @return none -*************************************************************************/ -BOOL handleStartStopDGFlush( MESSAGE_T *message ) -{ - BOOL result = FALSE; - if ( message->hdr.payloadLen == sizeof(U32) ) - { - BOOL startingDGFlush; - memcpy( &startingDGFlush, message->payload, sizeof(U32) ); - - if ( TRUE == startingDGFlush ) - { - result = startDGFlush(); - } - else - { - result = stopDGFlush(); - } - } - - // Respond to request - sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_DG_2_HD, result ); - - return result; -} - /*********************************************************************//** * @brief * The handleGetDGCalibrationRecord function handles a request to get the DG @@ -3140,41 +3208,6 @@ } /*********************************************************************//** -* @brief -* The handleStartStopDGChemicalDisinfect function handles a request to start -* or stop DG chemical disinfect mode. -* @details Inputs: none -* @details Outputs: message handled -* @param message a pointer to the message to handle -* @return none -*************************************************************************/ -BOOL handleStartStopDGChemicalDisinfect( MESSAGE_T *message ) -{ - BOOL result = FALSE; - - if ( message->hdr.payloadLen == sizeof(U32) ) - { - BOOL startingDGChemicalDisinfect; - - memcpy( &startingDGChemicalDisinfect, message->payload, sizeof(U32) ); - - if ( TRUE == startingDGChemicalDisinfect ) - { - result = startDGChemicalDisinfect(); - } - else - { - result = stopChemicalDisinfect(); - } - } - - // Respond to request - sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_DG_2_HD, result ); - - return result; -} - -/*********************************************************************//** * @brief * The handleTestBlockMessagesRequest function handles a request to * block transmission of specific message(s). @@ -3577,34 +3610,4 @@ return result; } -/*********************************************************************//** - * @brief - * The handleSetHDOperationMode function receives the HD operation modes data - * publish message. - * @details Inputs: none - * @details Outputs: none - * @param message a pointer to the message to handle - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL handleSetHDOperationMode( MESSAGE_T *message ) -{ - BOOL status = FALSE; - U08* payloadPtr = message->payload; - - // HD mode broadcast is operations mode and submode so 8 bytes - if ( message->hdr.payloadLen == sizeof( U32 ) + sizeof( U32 ) ) - { - U32 mode; - - // NOTE: the HD operations modes broadcast message contains the mode and submode states - // In this case, only the mode is needed. The mode is received to check if HD is in treatment - // and therefore, DG can void the last disinfect. - memcpy( payloadPtr, &mode, sizeof( U32 ) ); - setHDOperationMode( mode ); - status = TRUE; - } - - return status; -} - /**@}*/ Index: firmware/App/Services/SystemCommMessages.h =================================================================== diff -u -r1e22b6ff6f42ddc57ad6c17e56057ab8a3765680 -rbb7a4629cc96d96b6d1749c924e77886e0d64bcb --- firmware/App/Services/SystemCommMessages.h (.../SystemCommMessages.h) (revision 1e22b6ff6f42ddc57ad6c17e56057ab8a3765680) +++ firmware/App/Services/SystemCommMessages.h (.../SystemCommMessages.h) (revision bb7a4629cc96d96b6d1749c924e77886e0d64bcb) @@ -116,6 +116,9 @@ // MSG_ID_DG_SAMPLE_WATER_CMD void handleSampleWaterCmd( MESSAGE_T *message ); +// MSG_ID_SET_RTC_TIMESTAMP +void handleSetRTCTimestamp( MESSAGE_T *message ); + // MSG_ID_START_STOP_PRIMARY_HEATER BOOL handleStartStopPrimaryHeater( MESSAGE_T * message ); @@ -176,9 +179,6 @@ // MSG_ID_PUBLSIH_HEATERS_DATA_OVERRIDE void handleTestHeatersDataPublishOverrideRequest ( MESSAGE_T *message ); -// MSG_ID_SET_RTC_TIMESTAMP -void handleSetRTCTimestamp( MESSAGE_T *message ); - // MSG_ID_PRESSURE_OVERRIDE: void handleTestPressureSensorOverrideRequest( MESSAGE_T *message );