Index: firmware/App/Controllers/PresOccl.c =================================================================== diff -u -r6419179374edcd65da462de84e8aeaefb7e20320 -r5d13922ee2e8c851bc5db67ef4d0120b47de6f07 --- firmware/App/Controllers/PresOccl.c (.../PresOccl.c) (revision 6419179374edcd65da462de84e8aeaefb7e20320) +++ firmware/App/Controllers/PresOccl.c (.../PresOccl.c) (revision 5d13922ee2e8c851bc5db67ef4d0120b47de6f07) @@ -147,8 +147,7 @@ U32 diOccl = getMeasuredDialInPumpOcclusion(); U32 doOccl = getMeasuredDialOutPumpOcclusion(); - if ( ( bpOccl >= CARTRIDGE_LOADED_THRESHOLD ) && - ( diOccl >= CARTRIDGE_LOADED_THRESHOLD ) && + if ( ( bpOccl >= CARTRIDGE_LOADED_THRESHOLD ) && ( diOccl >= CARTRIDGE_LOADED_THRESHOLD ) && ( doOccl >= CARTRIDGE_LOADED_THRESHOLD ) ) { result = TRUE; @@ -159,6 +158,23 @@ /*********************************************************************//** * @brief + * The isCartridgeUnloaded function determines if a cartridge has been + * unloaded by looking at the 3 occlusion pressure sensors. + * @details Inputs: occlusion pressures for the pumps + * @details Outputs: none + * @return TRUE if all 3 occlusion sensors read below loaded threshold, FALSE if not. + *************************************************************************/ +BOOL isCartridgeUnloaded( void ) +{ + BOOL const bpOcclBelowLoadedThreshold = getMeasuredBloodPumpOcclusion() <= CARTRIDGE_LOADED_THRESHOLD; + BOOL const diOcclBelowLoadedThreshold = getMeasuredDialInPumpOcclusion() <= CARTRIDGE_LOADED_THRESHOLD; + BOOL const doOcclBelowLoadedThreshold = getMeasuredDialOutPumpOcclusion() <= CARTRIDGE_LOADED_THRESHOLD; + + return ( bpOcclBelowLoadedThreshold && diOcclBelowLoadedThreshold && doOcclBelowLoadedThreshold ); +} + +/*********************************************************************//** + * @brief * The isSalineBagEmpty function determines whether the saline bag is empty. * It is assumed that this function will only be called from mode handling * (General Task) when pumping (BP) from the saline bag. Index: firmware/App/Controllers/PresOccl.h =================================================================== diff -u -r7010cc605d12e424828fabb567102e4494901e70 -r5d13922ee2e8c851bc5db67ef4d0120b47de6f07 --- firmware/App/Controllers/PresOccl.h (.../PresOccl.h) (revision 7010cc605d12e424828fabb567102e4494901e70) +++ firmware/App/Controllers/PresOccl.h (.../PresOccl.h) (revision 5d13922ee2e8c851bc5db67ef4d0120b47de6f07) @@ -63,7 +63,7 @@ void initPresOccl( void ); void execPresOccl( void ); -SELF_TEST_STATUS_T execPresOcclTest( void ); +void execPresOcclTest( void ); SELF_TEST_STATUS_T execPresOcclDryTest( void ); F32 getMeasuredArterialPressure( void ); Index: firmware/App/HDCommon.h =================================================================== diff -u -r6419179374edcd65da462de84e8aeaefb7e20320 -r5d13922ee2e8c851bc5db67ef4d0120b47de6f07 --- firmware/App/HDCommon.h (.../HDCommon.h) (revision 6419179374edcd65da462de84e8aeaefb7e20320) +++ firmware/App/HDCommon.h (.../HDCommon.h) (revision 5d13922ee2e8c851bc5db67ef4d0120b47de6f07) @@ -32,7 +32,7 @@ // TODO - remove build switches before release #ifndef _RELEASE_ #ifndef _VECTORCAST_ - #define BOARD_WITH_NO_HARDWARE 1 +// #define BOARD_WITH_NO_HARDWARE 1 // #define RUN_WITHOUT_DG 1 // Run HD w/o DG // #define SIMULATE_UI 1 // Build w/o requirement that UI be there // #define TASK_TIMING_OUTPUT_ENABLED 1 // Re-purposes alarm lamp pins for task timing @@ -53,7 +53,7 @@ #define DISABLE_PRESSURE_CHECKS 1 // Do not error on HD pressure checks // #define DISABLE_UF_ALARMS 1 // Do not error on HD ultrafiltration checks #define DISABLE_VALVE_ALARMS 1 // Do not error on HD valve position -// #define DISABLE_CAL_CHECK 1 + #define DISABLE_CAL_CHECK 1 // #define RUN_PUMPS_OPEN_LOOP 1 // BP and DPi pumps will be run open loop (no flow sensor feedback) // #define RAW_FLOW_SENSOR_DATA 1 // Test build will not filter flow sensor data // #define READ_FPGA_ASYNC_DATA 1 // Test build reads non-priority register page every other time @@ -69,6 +69,7 @@ // #define DISABLE_BATT_COMM 1 // Disable battery communication. #define SKIP_AIR_BUBBLE_CHECK 1 // Skip air bubble detector self-test. #define DISABLE_OCCLUSION_SELF_TEST 1 // Skip occlusion sensor self-test. + #define SKIP_CARTRIDGE_REMOVAL 1 // Skip cartridge removal check #include #include Index: firmware/App/Services/SystemComm.c =================================================================== diff -u -r6419179374edcd65da462de84e8aeaefb7e20320 -r5d13922ee2e8c851bc5db67ef4d0120b47de6f07 --- firmware/App/Services/SystemComm.c (.../SystemComm.c) (revision 6419179374edcd65da462de84e8aeaefb7e20320) +++ firmware/App/Services/SystemComm.c (.../SystemComm.c) (revision 5d13922ee2e8c851bc5db67ef4d0120b47de6f07) @@ -1255,6 +1255,18 @@ handleTreatmentEndCmd( message ); break; + case MSG_ID_UI_PATIENT_DISCONNECTION_CONFIRM: + handlePatientDisconnectionConfirmCmd( message ); + break; + + case MSG_ID_UI_DISPOSABLE_REMOVAL_CONFIRM: + handleDisposableRemovalConfirmCmd( message ); + break; + + case MSG_ID_UI_TREATMENT_LOG_DATA_REQUEST: + handleUITreatmentLogDataRequest( message ); + break; + case MSG_ID_DG_COMMAND_RESPONSE: handleDGCmdResp( message ); break; Index: firmware/App/Services/SystemCommMessages.c =================================================================== diff -u -r6419179374edcd65da462de84e8aeaefb7e20320 -r5d13922ee2e8c851bc5db67ef4d0120b47de6f07 --- firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 6419179374edcd65da462de84e8aeaefb7e20320) +++ firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 5d13922ee2e8c851bc5db67ef4d0120b47de6f07) @@ -25,6 +25,7 @@ #include "ConsumableSelfTest.h" #include "DGInterface.h" #include "FPGA.h" +#include "ModePostTreat.h" #include "ModePreTreat.h" #include "ModeStandby.h" #include "ModeTreatment.h" @@ -543,7 +544,108 @@ result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_REQUIRED ); return result; +} + +/*********************************************************************//** + * @brief + * The handlePatientDisconnectionConfirmCmd function handles user confirms + * patient disconnection. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none. + *************************************************************************/ +void handlePatientDisconnectionConfirmCmd( MESSAGE_T *message ) +{ + if ( 0 == message->hdr.payloadLen ) + { + signalUserConfirmPatientDisconnection(); + } + + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); } + +/*********************************************************************//** + * @brief + * The handleDisposableRemovalConfirmCmd function handles user confirms + * disposable removal. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none. + *************************************************************************/ +void handleDisposableRemovalConfirmCmd( MESSAGE_T *message ) +{ + if ( 0 == message->hdr.payloadLen ) + { + signalUserConfirmDisposableRemoval(); + } + + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); +} + +/*********************************************************************//** + * @brief + * The sendDisposableRemovalConfirmResponse function constructs a disposable + * removal 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 disposable removal 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 sendDisposableRemovalConfirmResponse( BOOL accepted, U32 reason ) +{ + return sendUIResponseMsg( MSG_ID_HD_DISPOSABLE_REMOVAL_CONFIRM_RESPONSE, accepted, reason ); +} + +/*********************************************************************//** + * @brief + * The handleUITreatmentLogDataRequest function handles UI treatment log data request. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none. + *************************************************************************/ +void handleUITreatmentLogDataRequest( MESSAGE_T *message ) +{ + if ( 0 == message->hdr.payloadLen ) + { + handleTreatmentLogDataRequest(); + } + + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); +} + +/*********************************************************************//** + * @brief + * The sendTreatmentLogData 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. + * @param logDataPtr treatment log data record pointer + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendTreatmentLogData( BOOL accepted, U32 reason, TREATMENT_LOG_DATA_PAYLOAD_T *logDataPtr ) +{ + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_HD_TREATMENT_LOG_DATA_RESPONSE; + msg.hdr.payloadLen = sizeof( BOOL ) + sizeof( U32 ) + sizeof( TREATMENT_LOG_DATA_PAYLOAD_T ); + + memcpy( payloadPtr, &accepted, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + memcpy( payloadPtr, &reason, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + memcpy( payloadPtr, logDataPtr, sizeof( TREATMENT_LOG_DATA_PAYLOAD_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 @@ -1505,6 +1607,30 @@ /*********************************************************************//** * @brief + * The broadcastPostTreatmentState function constructs a post treatment state msg + * to be broadcast and queues the msg for transmit on the appropriate CAN channel. + * @details Inputs: none + * @details Outputs: post-treatment state msg constructed and queued + * @param postTreatmentSubMode post-treatment state sub-mode + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL broadcastPostTreatmentState( U32 postTreatmentSubMode ) +{ + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_HD_POST_TREATMENT_STATE; + msg.hdr.payloadLen = sizeof( U32 ); + + memcpy( payloadPtr, &postTreatmentSubMode, sizeof( U32 ) ); + + // 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_BROADCAST, ACK_NOT_REQUIRED ); +} + +/*********************************************************************//** + * @brief * The broadcastPreTreatmentState function constructs a pre-treatment state msg to * be broadcast and queues the msg for transmit on the appropriate CAN channel. * @details Inputs: none @@ -3048,7 +3174,6 @@ /*********************************************************************//** * @brief * The sendDebugDataToUI function sends debug string to the UI for logging. - * @details * @details Inputs: none * @details Outputs: Message constructed and queued for transmit * @param str Pointer to debug string Index: firmware/App/Services/SystemCommMessages.h =================================================================== diff -u -r6419179374edcd65da462de84e8aeaefb7e20320 -r5d13922ee2e8c851bc5db67ef4d0120b47de6f07 --- firmware/App/Services/SystemCommMessages.h (.../SystemCommMessages.h) (revision 6419179374edcd65da462de84e8aeaefb7e20320) +++ firmware/App/Services/SystemCommMessages.h (.../SystemCommMessages.h) (revision 5d13922ee2e8c851bc5db67ef4d0120b47de6f07) @@ -27,7 +27,8 @@ #include "DialOutFlow.h" #include "Dialysis.h" #include "FluidLeak.h" -#include "Prime.h" +#include "Prime.h" +#include "ModePostTreat.h" #include "ModePreTreat.h" #include "ModeTreatment.h" #include "MsgQueues.h" @@ -228,6 +229,21 @@ // MSG_ID_HD_RECIRC_CMD_RESPONSE BOOL sendTreatmentEndCmdResponse( BOOL accepted, U32 rejReason ); +// MSG_ID_UI_PATIENT_DISCONNECTION_CONFIRM +void handlePatientDisconnectionConfirmCmd( MESSAGE_T *message ); + +// MSG_ID_UI_DISPOSABLE_REMOVAL_CONFIRM +void handleDisposableRemovalConfirmCmd( MESSAGE_T *message ); + +// MSG_ID_HD_DISPOSABLE_REMOVAL_CONFIRM_RESPONSE +BOOL sendDisposableRemovalConfirmResponse( BOOL accepted, U32 reason ); + +// MSG_ID_UI_TREATMENT_LOG_DATA_REQUEST +void handleUITreatmentLogDataRequest( MESSAGE_T *message ); + +// MSG_ID_HD_TREATMENT_LOG_DATA_RESPONSE +BOOL sendTreatmentLogData( BOOL accepted, U32 reason, TREATMENT_LOG_DATA_PAYLOAD_T *logDataPtr ); + // *********** public DG command functions ********** // MSG_ID_SET_DG_DIALYSATE_TEMP_TARGETS @@ -307,6 +323,9 @@ // MSG_ID_TREATMENT_STATE BOOL broadcastTreatmentState( TREATMENT_STATE_DATA_T payload ); +// MSG_ID_HD_POST_TREATMENT_STATE +BOOL broadcastPostTreatmentState( U32 postTreatmentSubMode ); + // MSG_ID_PRE_TREATMENT_STATE BOOL broadcastPreTreatmentState( PRE_TREATMENT_STATE_DATA_T *preTreatmentDataPtr );