Index: firmware/App/Modes/ModeStandby.c =================================================================== diff -u -rc429cf7f50851acbaca6e800957ef44cc1fa2162 -re781d3b87509e75ae6a2bde6da3d5819b7b5a2da --- firmware/App/Modes/ModeStandby.c (.../ModeStandby.c) (revision c429cf7f50851acbaca6e800957ef44cc1fa2162) +++ firmware/App/Modes/ModeStandby.c (.../ModeStandby.c) (revision e781d3b87509e75ae6a2bde6da3d5819b7b5a2da) @@ -974,25 +974,26 @@ U32 lastFlushCompleteDate = data.dgUsageInfo.lastBasicFlushCompleteDateEpoch; U32 lastStartTxTimeDate = usageRecord.txLastStartTimeEpoch; - // Last Treatment Start > Last Heat Disinfect Complete AND Last Treatment Start > Last Chem Disinfect Complete - BOOL hasDisBeenDone = ( ( ( lastStartTxTimeDate > lastChemCompleteDate ) && ( lastStartTxTimeDate > lastHeatCompleteDate ) ) ? FALSE : TRUE ); + // Last Treatment Start < Last Heat Disinfect Complete or Last Treatment Start < Last Chem Disinfect Complete so it means at least a heat disinfect + // or a chemical disinfect has been done since the last treatment + BOOL hasDisBeenDone = ( ( ( lastStartTxTimeDate < lastChemCompleteDate ) || ( lastStartTxTimeDate < lastHeatCompleteDate ) ) ? TRUE : FALSE ); - // Last Chem Disinfect Complete < Current Time – Chem Disinfect Interval + // Last Chem Disinfect Complete < Current Time – Chem Disinfect Interval, so the chemical disinfect that has been done has not been expired BOOL isChemDisValid = ( lastChemCompleteDate < ( getRTCTimestamp() - DISINFECTS_TIME_INTERVAL_S ) ? TRUE : FALSE ); - // Last Heat Disinfect Complete < Current Time – Heat Disinfect Interval + // Last Heat Disinfect Complete < Current Time – Heat Disinfect Interval, so the heat disinfect that has been done has not been expired BOOL isHeatDisValid = ( lastHeatCompleteDate < ( getRTCTimestamp() - DISINFECTS_TIME_INTERVAL_S ) ? TRUE : FALSE ); - // Last Chem Flush Complete < Last Chem Disinfect Start - BOOL isChemFlushComplete = ( lastChemFlushCompleteDate < lastChemCompleteDate ? FALSE : TRUE ); + // Last Chem Flush Complete < Last Chem Disinfect Start, so after running a chemical disinfect, a chemical disinfect flush has been done + BOOL isChemFlushComplete = ( lastChemFlushCompleteDate > lastChemCompleteDate ? TRUE : FALSE ); - // Last Basic Flush Complete < Current Time – Flush Interval AND Last Heat Disinfect Complete < Current Time – Flush Interval - // AND Last Chem Flush Complete < Current Time – Flush Interval - BOOL isBasicFlushValid = ( lastFlushCompleteDate < ( getRTCTimestamp() - FLUSH_TIME_INTERVAL_S ) ? TRUE : FALSE ); - BOOL isHeatDisFlushValid = ( lastHeatCompleteDate < ( getRTCTimestamp() - FLUSH_TIME_INTERVAL_S ) ? TRUE : FALSE ); - BOOL isChemFlushValid = ( lastChemFlushCompleteDate < ( getRTCTimestamp() - FLUSH_TIME_INTERVAL_S ) ? TRUE : FALSE ); - BOOL isFlushValid = ( isBasicFlushValid | isHeatDisFlushValid | isChemFlushValid ); + // If either of the basic flush, heat disinfect, or chemical disinfect flush have been done within the interval, it means the filters have been flushed + BOOL isBasicFlushValid = ( lastFlushCompleteDate < ( getRTCTimestamp() - FLUSH_TIME_INTERVAL_S ) ? TRUE : TRUE ); + BOOL isHeatDisFlushValid = ( lastHeatCompleteDate < ( getRTCTimestamp() - FLUSH_TIME_INTERVAL_S ) ? TRUE : TRUE ); + BOOL isChemFlushValid = ( lastChemFlushCompleteDate < ( getRTCTimestamp() - FLUSH_TIME_INTERVAL_S ) ? TRUE : TRUE ); + BOOL isFlushValid = ( isBasicFlushValid || isHeatDisFlushValid || isChemFlushValid ); + // If all of the above conditions are true, it means we can start a treatment if ( ( TRUE == hasDisBeenDone ) && ( TRUE == isChemDisValid ) && ( TRUE == isHeatDisValid ) && ( TRUE == isChemFlushComplete ) && ( TRUE == isFlushValid ) ) { status = TRUE; Index: firmware/App/Modes/OperationModes.c =================================================================== diff -u -ref6283257df7c1f993d58fb934da57ea3e0a7067 -re781d3b87509e75ae6a2bde6da3d5819b7b5a2da --- firmware/App/Modes/OperationModes.c (.../OperationModes.c) (revision ef6283257df7c1f993d58fb934da57ea3e0a7067) +++ firmware/App/Modes/OperationModes.c (.../OperationModes.c) (revision e781d3b87509e75ae6a2bde6da3d5819b7b5a2da) @@ -163,7 +163,7 @@ // 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 U32 txElapsedTimeMS = calcTimeSince( getTreatmentStartTimeStamp() ); - F32 txElapsedTimeHrs = (F32)txElapsedTimeMS / ( MIN_PER_HOUR * SEC_PER_MIN * MS_PER_SECOND ); + F32 txElapsedTimeHrs = (F32)( txElapsedTimeMS / ( MIN_PER_HOUR * SEC_PER_MIN * MS_PER_SECOND ) ); // Write the treatment hours and set the service to be false so the treatment hours is not reset setTxTimeHours( txElapsedTimeHrs ); } Index: firmware/App/Services/AlarmMgmtSWFaults.h =================================================================== diff -u -re482c9636c0e359386156d21a5518d59e727eb39 -re781d3b87509e75ae6a2bde6da3d5819b7b5a2da --- firmware/App/Services/AlarmMgmtSWFaults.h (.../AlarmMgmtSWFaults.h) (revision e482c9636c0e359386156d21a5518d59e727eb39) +++ firmware/App/Services/AlarmMgmtSWFaults.h (.../AlarmMgmtSWFaults.h) (revision e781d3b87509e75ae6a2bde6da3d5819b7b5a2da) @@ -176,6 +176,8 @@ SW_FAULT_ID_BLOOD_LEAK_INVALID_EMB_MODE_CMD_SELECTED, // 145 SW_FAULT_ID_INVALID_FPGA_ERROR_GROUP_SELECTED, SW_FAULT_ID_HD_SYRINGE_NOT_PRELOADED, + SW_FAULT_ID_NVDATA_MANAGEMENT_OPS_TIMEOUT, + SW_FAULT_ID_NVDATA_RTC_RAM_OPS_FAILURE, NUM_OF_SW_FAULT_IDS } SW_FAULT_ID_T; Index: firmware/App/Services/SystemComm.c =================================================================== diff -u -r4c20c78459041883eb73acf414cc6c42ed6e7821 -re781d3b87509e75ae6a2bde6da3d5819b7b5a2da --- firmware/App/Services/SystemComm.c (.../SystemComm.c) (revision 4c20c78459041883eb73acf414cc6c42ed6e7821) +++ firmware/App/Services/SystemComm.c (.../SystemComm.c) (revision e781d3b87509e75ae6a2bde6da3d5819b7b5a2da) @@ -1163,6 +1163,10 @@ handleUIConfirmationResponse( message ); break; + case MSG_ID_HD_SET_SERVICE_TIME: + handleSetHDServiceTime( message ); + break; + // NOTE: this always must be the last case case MSG_ID_TESTER_LOGIN_REQUEST: handleTesterLogInRequest( message ); @@ -1684,6 +1688,10 @@ handleTestDialOutSetPWM( message ); break; + case MSG_ID_HD_NV_RECORD_CRC_OVERRIDE: + handleTestHDNVRecordCRCOverride( message ); + break; + // The default cannot be reached in VectorCAST since the cases are run in a for loop default: // Unrecognized message ID received - ignore Index: firmware/App/Services/SystemCommMessages.c =================================================================== diff -u -rc429cf7f50851acbaca6e800957ef44cc1fa2162 -re781d3b87509e75ae6a2bde6da3d5819b7b5a2da --- firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision c429cf7f50851acbaca6e800957ef44cc1fa2162) +++ firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision e781d3b87509e75ae6a2bde6da3d5819b7b5a2da) @@ -7079,6 +7079,45 @@ } /*********************************************************************//** + * @brief + * The sendHDUsageRecord function sends out the HD service record. + * @details Inputs: none + * @details Outputs: HD system record msg constructed and queued + * @param msgCurrNum: current payload number + * @param msgTotalNum: total number of payloads + * @param length: buffer length to be written + * @param srvcRcrdAddress: start address of the usage record + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendHDUsageRecord( U32 payloadCurrNum, U32 payloadTotalNum, U32 length, U08* sysRcrdAddress ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_HD_SEND_USAGE_INFO_RECORD; + msg.hdr.payloadLen = sizeof( U32 ) + sizeof( U32 ) + sizeof( U32 ) + length; + + memcpy( payloadPtr, &payloadCurrNum, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + + memcpy( payloadPtr, &payloadTotalNum, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + + memcpy( payloadPtr, &length, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + + memcpy( payloadPtr, sysRcrdAddress, length ); + + // 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_PC, ACK_NOT_REQUIRED ); + + return result; +} + +/*********************************************************************//** * @brief * The handleUIServiceModeRequest function handles a request to enter service * mode. @@ -7098,10 +7137,9 @@ { if ( ( MODE_STAN == currentMode ) || ( MODE_FAUL == currentMode ) ) { - requestNewOperationMode( MODE_SERV ); - if ( (DG_MODE_STAN == currentDGMode) || (DG_MODE_FAUL == currentDGMode) ) + if ( ( DG_MODE_STAN == currentDGMode ) || ( DG_MODE_FAUL == currentDGMode ) ) { status = TRUE; cmdSetDGToServiceMode(); @@ -7270,6 +7308,27 @@ } /*********************************************************************//** + * @brief + * The handleSetHDServiceTime function sets the HD service time once the + * command is received from UI + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleSetHDServiceTime( MESSAGE_T *message ) +{ + BOOL result = FALSE; + + if ( 0 == message->hdr.payloadLen ) + { + result = setServiceTime(); + } + + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, result ); +} + +/*********************************************************************//** * @brief * The handleGetHDUsageInfoRecord function handles a request to get the HD * usage information record. @@ -7583,4 +7642,29 @@ sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } +/*********************************************************************//** +* @brief +* The handleTestHDNVRecordCRCOverride function handles a request to override +* the selected NV record's CRC. +* @details Inputs: none +* @details Outputs: message handled +* @param message a pointer to the message to handle +* @return none +*************************************************************************/ +void handleTestHDNVRecordCRCOverride( 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 ) ); + result = testSetNVRecordCRCOverride( payload.index, (U16)payload.state.u32 ); + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + /**@}*/ Index: firmware/App/Services/SystemCommMessages.h =================================================================== diff -u -raa7b1f5f68aae23c1c52b32658fcb625c29accfb -re781d3b87509e75ae6a2bde6da3d5819b7b5a2da --- firmware/App/Services/SystemCommMessages.h (.../SystemCommMessages.h) (revision aa7b1f5f68aae23c1c52b32658fcb625c29accfb) +++ firmware/App/Services/SystemCommMessages.h (.../SystemCommMessages.h) (revision e781d3b87509e75ae6a2bde6da3d5819b7b5a2da) @@ -431,6 +431,9 @@ // MSG_ID_HD_SET_SW_CONFIG_RECORD void handleSetHDSoftwareConfigRecord( MESSAGE_T *message ); +// MSG_ID_HD_SEND_USAGE_INFO_RECORD +BOOL sendHDUsageRecord( U32 payloadCurrNum, U32 payloadTotalNum, U32 length, U08* sysRcrdAddress ); + // MSG_ID_HD_SEND_ALARMS_COMMAND void handleResendAllAlarmsCommand( MESSAGE_T* message ); @@ -455,6 +458,9 @@ // MSG_ID_DG_USAGE_DATA void handleDGUsageInfoData( MESSAGE_T *message ); +// MSG_ID_HD_SET_SERVICE_TIME +void handleSetHDServiceTime( MESSAGE_T *message ); + // *********** public test support message functions ********** // MSG_TESTER_LOG_IN @@ -842,6 +848,9 @@ // MSG_ID_HD_DIAL_OUT_SET_PWM void handleTestDialOutSetPWM( MESSAGE_T* message ); +// MSG_ID_HD_NV_RECORD_CRC_OVERRIDE +void handleTestHDNVRecordCRCOverride( MESSAGE_T *message ); + /**@}*/ #endif