Index: firmware/App/Controllers/ConductivitySensors.c =================================================================== diff -u -r8fe65bf6222137cc7182ccacff3a5f2fb2f03753 -rab14e70c7bac24b0c3ebd02c6763285cdd3951ce --- firmware/App/Controllers/ConductivitySensors.c (.../ConductivitySensors.c) (revision 8fe65bf6222137cc7182ccacff3a5f2fb2f03753) +++ firmware/App/Controllers/ConductivitySensors.c (.../ConductivitySensors.c) (revision ab14e70c7bac24b0c3ebd02c6763285cdd3951ce) @@ -145,6 +145,8 @@ compensatedConductivityValues[ i ].ovData = 0.0; compensatedConductivityValues[ i ].ovInitData = 0.0; compensatedConductivityValues[ i ].override = OVERRIDE_RESET; + + benignPolynomialCalRecord( &condSensorsCalRecord.condSensors[ i ] ); } setFPGACPiProbeType( COND_CPI_SENSOR_PROBE_TYPE ); Index: firmware/App/Controllers/Heaters.c =================================================================== diff -u -r8fe65bf6222137cc7182ccacff3a5f2fb2f03753 -rab14e70c7bac24b0c3ebd02c6763285cdd3951ce --- firmware/App/Controllers/Heaters.c (.../Heaters.c) (revision 8fe65bf6222137cc7182ccacff3a5f2fb2f03753) +++ firmware/App/Controllers/Heaters.c (.../Heaters.c) (revision ab14e70c7bac24b0c3ebd02c6763285cdd3951ce) @@ -59,7 +59,7 @@ #define HEATERS_MAX_ALLOWED_INTERNAL_TEMPERATURE_C 170.0F ///< Heaters max allowed internal temperature in C. #define HEATERS_MAX_ALLOWED_COLD_JUNCTION_TEMPERATURE_C 80.0F ///< Heaters max allowed cold junction temperature in C. #define HEATERS_MAX_ALLOWED_INTERNAL_TEMPERATURE_TIMEOUT_MS ( 2 * SEC_PER_MIN * MS_PER_SECOND ) ///< Heaters max allowed internal temperature timeout in milliseconds. -#define HEATERS_ON_NO_FLOW_TIMEOUT_MS ( 2 * SEC_PER_MIN * MS_PER_SECOND ) ///< Heaters on with no flow time out in milliseconds. +#define HEATERS_ON_NO_FLOW_TIMEOUT_MS ( 2 * MS_PER_SECOND ) ///< Heaters on with no flow time out in milliseconds. #define HEATERS_MAX_OPERATING_VOLTAGE_V 24.0F ///< Heaters max operating voltage in volts. #define HEATERS_VOLTAGE_MONITOR_TIME_INTERVAL ( MS_PER_SECOND / TASK_PRIORITY_INTERVAL ) ///< Heaters voltage monitor timer interval. #define HEATERS_MAX_VOLTAGE_OUT_OF_RANGE_TOL 0.2F ///< Heaters max voltage out of range tolerance. @@ -89,20 +89,19 @@ /// Heaters data structure typedef struct { - F32 targetTemp; ///< Heater target temperature. + F32 targetTemp; ///< Heater target temperature. HEATERS_STATE_T state; ///< Heater state. BOOL startHeaterSignal; ///< Heater start indication flag. BOOL isHeaterOn; ///< Heater on/off status flag. - F32 dutycycle; ///< Heater duty cycle. - F32 targetROFlow; ///< Heater target flow. - U32 heaterOnWithNoFlowTimer; // TODO remove ///< Heater on with no flow timer. + F32 dutycycle; ///< Heater duty cycle. + F32 dutyCyleBeforeFlow; + F32 targetROFlow; ///< Heater target flow. + U32 heaterOnWithNoFlowTimer; ///< Heater on with no flow timer. BOOL isFlowBelowMin; ///< Heater flow below minimum flag indicator. BOOL hasTargetTempChanged; ///< Heater target temperature change flag indicator. - F32 heaterEfficiency; ///< Heater efficiency during the run. + F32 heaterEfficiency; ///< Heater efficiency during the run. BOOL hasTargetBeenReached; ///< Heater flag to indicate whether the target temperature has been reached. - U32 tempOutOfRangeTimer; ///< Heater temperature out of range timer TODO remove once the mechanical thermal cutoff was implemented - BOOL isHeaterTempOutOfRange; ///< Heater temperature out of range flag indicator TODO remove once the mechanical thermal cutoff was implemented F32 temporaryInterimTemperature; ///< TODO remove } HEATER_STATUS_T; @@ -149,8 +148,6 @@ for ( heater = DG_PRIMARY_HEATER; heater < NUM_OF_DG_HEATERS; heater++ ) { heatersStatus[ heater ].startHeaterSignal = FALSE; - heatersStatus[ heater ].tempOutOfRangeTimer = 0; - heatersStatus[ heater ].isHeaterTempOutOfRange = FALSE; heatersStatus[ heater ].state = HEATER_EXEC_STATE_OFF; heatersStatus[ heater ].targetTemp = 0.0; heatersStatus[ heater ].dutycycle = 0.0; @@ -362,50 +359,58 @@ *************************************************************************/ void execHeatersMonitor( void ) { -#ifndef _RELEASE_ - if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_HEATERS_MONITOR ) != SW_CONFIG_ENABLE_VALUE ) -#endif + DG_HEATERS_T heater; + + for ( heater = DG_PRIMARY_HEATER; heater < NUM_OF_DG_HEATERS; heater++ ) { - DG_HEATERS_T heater; + F32 maxDutyCycle = MAX( heatersStatus[ heater ].dutyCyleBeforeFlow, heatersStatus[ heater ].dutycycle ); - for ( heater = DG_PRIMARY_HEATER; heater < NUM_OF_DG_HEATERS; heater++ ) + // Check if a heater is on and whether is duty cycle is not zero + if ( ( TRUE == heatersStatus[ heater ].isHeaterOn ) && ( maxDutyCycle > NEARLY_ZERO ) ) { - // Check if a heater is on and whether is duty cycle is not zero - if ( ( TRUE == heatersStatus[ heater ].isHeaterOn ) && ( ( heatersStatus[ heater ].dutycycle - HEATERS_MIN_DUTY_CYCLE ) > NEARLY_ZERO ) ) - { - // TODO add the function that gets the flow of the new flow sensor for DG. For now it is assumed that trimmer heater flow sensor - // is not 0 so the heater can run if needed - F32 measFlow = ( DG_PRIMARY_HEATER == heater ? getMeasuredROFlowRateLPM() : 50.0 ); - // TODO get the minimum new flow sensor flow sensor - F32 minFlow = ( DG_PRIMARY_HEATER == heater ? MIN_RO_FLOWRATE_LPM : MIN_RO_FLOWRATE_LPM ); - BOOL isFlowLow = ( measFlow < minFlow ? TRUE : FALSE ); + // TODO add the function that gets the flow of the new flow sensor for DG. For now it is assumed that trimmer heater flow sensor + // is not 0 so the heater can run if needed + F32 measFlow = ( DG_PRIMARY_HEATER == heater ? getMeasuredROFlowRateLPM() : 50.0 ); + // TODO get the minimum new flow sensor flow sensor + F32 minFlow = ( DG_PRIMARY_HEATER == heater ? MIN_RO_FLOWRATE_LPM : MIN_RO_FLOWRATE_LPM ); + BOOL isFlowLow = ( measFlow < minFlow ? TRUE : FALSE ); - if ( TRUE == isFlowLow ) + if ( TRUE == isFlowLow ) + { + // Check if the flow of the heater is below minimum for the first time + if ( FALSE == heatersStatus[ heater ].isFlowBelowMin ) { - // Check if the flow of the heater is below minimum for the first time - if ( FALSE == heatersStatus[ heater ].isFlowBelowMin ) - { - heatersStatus[ heater ].isFlowBelowMin = TRUE; - heatersStatus[ heater ].heaterOnWithNoFlowTimer = getMSTimerCount(); - } - else if ( TRUE == didTimeout( heatersStatus[ heater ].heaterOnWithNoFlowTimer, HEATERS_ON_NO_FLOW_TIMEOUT_MS ) ) - { - // Heater has been on with no flow time out - stopHeater( heater ); + heatersStatus[ heater ].isFlowBelowMin = TRUE; + heatersStatus[ heater ].heaterOnWithNoFlowTimer = getMSTimerCount(); + heatersStatus[ heater ].dutyCyleBeforeFlow = heatersStatus[ heater ].dutycycle; + } + else if ( TRUE == didTimeout( heatersStatus[ heater ].heaterOnWithNoFlowTimer, HEATERS_ON_NO_FLOW_TIMEOUT_MS ) ) + { + setHeaterDutyCycle( heater, HEATERS_MIN_DUTY_CYCLE ); - ALARM_ID_T alarm = ( DG_PRIMARY_HEATER == heater ? ALARM_ID_DG_PRIMARY_HEATER_ON_WITH_NO_FLOW_TIMEOUT : - ALARM_ID_DG_TRIMMER_HEATER_ON_WITH_NO_FLOW_TIMEOUT ); - activateAlarmNoData( alarm ); - } + /*ALARM_ID_T alarm = ( DG_PRIMARY_HEATER == heater ? ALARM_ID_DG_PRIMARY_HEATER_ON_WITH_NO_FLOW_TIMEOUT : + ALARM_ID_DG_TRIMMER_HEATER_ON_WITH_NO_FLOW_TIMEOUT ); + activateAlarmNoData( alarm ); TODO DEBUG_DENALI*/ } - else + } + else + { + if ( TRUE == heatersStatus[ heater ].isFlowBelowMin ) { - heatersStatus[ heater ].isFlowBelowMin = FALSE; - heatersStatus[ heater ].heaterOnWithNoFlowTimer = getMSTimerCount(); + setHeaterDutyCycle( heater, heatersStatus[ heater ].dutyCyleBeforeFlow ); } + + heatersStatus[ heater ].isFlowBelowMin = FALSE; + heatersStatus[ heater ].heaterOnWithNoFlowTimer = getMSTimerCount(); + } } + } +#ifndef _RELEASE_ + if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_HEATERS_MONITOR ) != SW_CONFIG_ENABLE_VALUE ) +#endif + { monitorHeatersVoltage(); } @@ -882,7 +887,7 @@ // Check trimmer heater's voltage if ( fabs( ( HEATERS_MAX_OPERATING_VOLTAGE_V * trimmer ) - trimmerVoltage ) > HEATERS_MAX_VOLTAGE_OUT_OF_RANGE_TOL * trimmerVoltage ) { - SET_ALARM_WITH_1_F32_DATA( ALARM_ID_DG_TRIMMER_HEATER_VOLTAGE_OUT_OF_RANGE, trimmerVoltage ); + //SET_ALARM_WITH_1_F32_DATA( ALARM_ID_DG_TRIMMER_HEATER_VOLTAGE_OUT_OF_RANGE, trimmerVoltage ); // TODO DEBUG_DENALI } voltageMonitorTimeCounter = 0; Index: firmware/App/Controllers/LoadCell.c =================================================================== diff -u -r1af5c9d200064f18e2727e896f74308e683492a7 -rab14e70c7bac24b0c3ebd02c6763285cdd3951ce --- firmware/App/Controllers/LoadCell.c (.../LoadCell.c) (revision 1af5c9d200064f18e2727e896f74308e683492a7) +++ firmware/App/Controllers/LoadCell.c (.../LoadCell.c) (revision ab14e70c7bac24b0c3ebd02c6763285cdd3951ce) @@ -103,22 +103,21 @@ smallReadingsIdx = 0; largeReadingsIdx = 0; loadCellDataPublicationTimerCounter = DATA_PUBLISH_COUNTER_START_COUNT; + loadCellFilterTimerCount = 0; for ( i = 0; i < NUM_OF_LOAD_CELLS; i++ ) { - loadcells[ i ].rawReading = 0; + benignPolynomialCalRecord( &loadCellsCalRecord.loadCells[ i ] ); - loadcells[ i ].weight.data = 0.0; - loadcells[ i ].weight.ovData = 0.0; - loadcells[ i ].weight.ovInitData = 0.0; - loadcells[ i ].weight.override = OVERRIDE_RESET; - - loadcells[ i ].autoCalOffset = 0.0; - - loadcells[ i ].largeFilterTotal = 0.0; + loadcells[ i ].rawReading = 0; + loadcells[ i ].weight.data = 0.0; + loadcells[ i ].weight.ovData = 0.0; + loadcells[ i ].weight.ovInitData = 0.0; + loadcells[ i ].weight.override = OVERRIDE_RESET; + loadcells[ i ].autoCalOffset = 0.0; + loadcells[ i ].largeFilterTotal = 0.0; loadcells[ i ].largeFilteredWeight = 0.0; - - loadcells[ i ].smallFilterTotal = 0.0; + loadcells[ i ].smallFilterTotal = 0.0; loadcells[ i ].smallFilteredWeight = 0.0; for ( j = 0; j < SIZE_OF_SMALL_LOAD_CELL_AVG; j++ ) @@ -174,7 +173,7 @@ b2 = ( b2 >> 31 ); if ( TRUE == isPersistentAlarmTriggered( ALARM_ID_DG_LOAD_CELL_ADC_ERROR, ( ( a1 > 0 ) || ( a2 > 0 ) || ( b1 > 0 ) || ( b2 > 0 ) ) ) ) { - SET_ALARM_WITH_1_U32_DATA( ALARM_ID_DG_LOAD_CELL_ADC_ERROR, ( a1 | a2 | b1 | b2 ) ) + //SET_ALARM_WITH_1_U32_DATA( ALARM_ID_DG_LOAD_CELL_ADC_ERROR, ( a1 | a2 | b1 | b2 ) ) // TODO DEBUG_DENALI } // TODO use ALARM_ID_DG_LOAD_CELL_FPGA_READ_ERROR for read error Index: firmware/App/Controllers/ROPump.c =================================================================== diff -u -r1e22b6ff6f42ddc57ad6c17e56057ab8a3765680 -rab14e70c7bac24b0c3ebd02c6763285cdd3951ce --- firmware/App/Controllers/ROPump.c (.../ROPump.c) (revision 1e22b6ff6f42ddc57ad6c17e56057ab8a3765680) +++ firmware/App/Controllers/ROPump.c (.../ROPump.c) (revision ab14e70c7bac24b0c3ebd02c6763285cdd3951ce) @@ -415,13 +415,15 @@ // Check whether the Duty cycle is out of range BOOL isDCOutOfRange = ( fabs( roPumpFeedbackDutyCyclePct - roPumpDutyCyclePctSet ) > ROP_DUTY_CYCLE_OUT_OF_RANGE_TOLERANCE ? TRUE : FALSE ); + /* TODO this is commented until the DVT boards are available checkPersistentAlarm( ALARM_ID_RO_PUMP_DUTY_CYCLE_OUT_OF_RANGE, isDCOutOfRange, roPumpFeedbackDutyCyclePct, roPumpDutyCyclePctSet ); // Check if it the alarm has timed out and if the pump is supposed to be off but it is still on, activate the safety shutdown + if ( ( TRUE == isAlarmActive( ALARM_ID_RO_PUMP_DUTY_CYCLE_OUT_OF_RANGE ) ) && ( FALSE == isROPumpOn ) ) { activateSafetyShutdown(); - } + }*/ } // Publish RO pump data on interval Index: firmware/App/Controllers/TemperatureSensors.c =================================================================== diff -u -r8fe65bf6222137cc7182ccacff3a5f2fb2f03753 -rab14e70c7bac24b0c3ebd02c6763285cdd3951ce --- firmware/App/Controllers/TemperatureSensors.c (.../TemperatureSensors.c) (revision 8fe65bf6222137cc7182ccacff3a5f2fb2f03753) +++ firmware/App/Controllers/TemperatureSensors.c (.../TemperatureSensors.c) (revision ab14e70c7bac24b0c3ebd02c6763285cdd3951ce) @@ -204,6 +204,8 @@ for ( i = 0; i < NUM_OF_TEMPERATURE_SENSORS; ++i ) { memset( &tempSensors[ i ], 0x0, sizeof( TEMP_SENSOR_T ) ); + + benignPolynomialCalRecord( &tempSensorCalRecord.tempSensors[ i ] ); } // Initialize TPi and TPo constants Index: firmware/App/Controllers/Voltages.c =================================================================== diff -u -ra9315539f527b92523b1598ff91e47db4d71dae2 -rab14e70c7bac24b0c3ebd02c6763285cdd3951ce --- firmware/App/Controllers/Voltages.c (.../Voltages.c) (revision a9315539f527b92523b1598ff91e47db4d71dae2) +++ firmware/App/Controllers/Voltages.c (.../Voltages.c) (revision ab14e70c7bac24b0c3ebd02c6763285cdd3951ce) @@ -224,14 +224,14 @@ { if ( ++voltageAlarmPersistenceCtr[ i ] > VOLTAGES_ALARM_PERSISTENCE ) { - SET_ALARM_WITH_2_F32_DATA( ALARM_ID_DG_VOLTAGE_OUT_OF_RANGE, (F32)i, volts ) + //SET_ALARM_WITH_2_F32_DATA( ALARM_ID_DG_VOLTAGE_OUT_OF_RANGE, (F32)i, volts ) // TODO DEBUG_DENALI } } else if ( volts < MIN_VOLTAGES[ i ] ) { if ( ++voltageAlarmPersistenceCtr[ i ] > VOLTAGES_ALARM_PERSISTENCE ) { - SET_ALARM_WITH_2_F32_DATA( ALARM_ID_DG_VOLTAGE_OUT_OF_RANGE, (F32)i, volts ) + //SET_ALARM_WITH_2_F32_DATA( ALARM_ID_DG_VOLTAGE_OUT_OF_RANGE, (F32)i, volts ) // TODO DEBUG_DENALI } } else Index: firmware/App/Modes/ModeChemicalDisinfect.c =================================================================== diff -u -r1e22b6ff6f42ddc57ad6c17e56057ab8a3765680 -rab14e70c7bac24b0c3ebd02c6763285cdd3951ce --- firmware/App/Modes/ModeChemicalDisinfect.c (.../ModeChemicalDisinfect.c) (revision 1e22b6ff6f42ddc57ad6c17e56057ab8a3765680) +++ firmware/App/Modes/ModeChemicalDisinfect.c (.../ModeChemicalDisinfect.c) (revision ab14e70c7bac24b0c3ebd02c6763285cdd3951ce) @@ -618,7 +618,7 @@ } #ifndef _RELEASE_ - if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_DISINFECT_CONDUCTIVITY_CHECK ) != SW_CONFIG_ENABLE_VALUE ) + if ( SW_CONFIG_ENABLE_VALUE == getSoftwareConfigStatus( SW_CONFIG_DISABLE_DISINFECT_CONDUCTIVITY_CHECK ) ) { hasConductivityPassed = TRUE; } @@ -2143,17 +2143,20 @@ break; } - if ( TRUE == isAlarmNeeded ) +#ifndef _RELEASE_ + if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_CAPS_MONITOR ) != SW_CONFIG_ENABLE_VALUE ) +#endif { - // Set the variables to fail and go to cancel water path. Set the pending alarm to no alarm so the cancel water path - // will not be raising the alarm at end of the cancel water path. The recoverable alarm is raised here in this function - U32 ConcCap = (U32)getSwitchStatus( CONCENTRATE_CAP ); - U32 DialysateCap = (U32)getSwitchStatus( DIALYSATE_CAP ); - prevChemDisinfectState = chemDisinfectState; - chemDisinfectState = DG_CHEM_DISINFECT_STATE_CANCEL_WATER_PATH; - alarmDetectedPendingTrigger = ALARM_ID_NO_ALARM; - - SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DG_DIALYSATE_OR_CONC_CAP_NOT_IN_PROPER_POSITION, ConcCap, DialysateCap ) + if ( TRUE == isAlarmNeeded ) + { + // Set the variables to fail and go to cancel water path. Set the pending alarm to no alarm so the cancel water path + // will not be raising the alarm at end of the cancel water path. The recoverable alarm is raised here in this function + U32 ConcCap = (U32)getSwitchStatus( CONCENTRATE_CAP ); + U32 DialysateCap = (U32)getSwitchStatus( DIALYSATE_CAP ); + prevChemDisinfectState = chemDisinfectState; + chemDisinfectState = DG_CHEM_DISINFECT_STATE_CANCEL_WATER_PATH; + alarmDetectedPendingTrigger = ALARM_ID_DG_DIALYSATE_OR_CONC_CAP_NOT_IN_PROPER_POSITION; + } } } Index: firmware/App/Modes/ModeFill.c =================================================================== diff -u -ra6dff99e22bb6f646adfe3acf4f461cb43aec979 -rab14e70c7bac24b0c3ebd02c6763285cdd3951ce --- firmware/App/Modes/ModeFill.c (.../ModeFill.c) (revision a6dff99e22bb6f646adfe3acf4f461cb43aec979) +++ firmware/App/Modes/ModeFill.c (.../ModeFill.c) (revision ab14e70c7bac24b0c3ebd02c6763285cdd3951ce) @@ -713,8 +713,6 @@ fillStatus.fillFlowRateRunningSum += getMeasuredROFlowRateLPM(); fillStatus.fillTemperatureRunningSum += getTemperatureValue( (U32)TEMPSENSORS_OUTLET_PRIMARY_HEATER ); - //setBadAvgConductivityDetectedFlag( FALSE ); - // TODO: Check for open straw door status and alarm if closed // Check if run out of time to fill the reservoir if ( TRUE == didTimeout( dialysateFillStartTime, DIALYSATE_FILL_TIME_OUT ) ) Index: firmware/App/Modes/ModeFlush.c =================================================================== diff -u -rc3d66517a6642f3e1d33c2508bc736920b32e792 -rab14e70c7bac24b0c3ebd02c6763285cdd3951ce --- firmware/App/Modes/ModeFlush.c (.../ModeFlush.c) (revision c3d66517a6642f3e1d33c2508bc736920b32e792) +++ firmware/App/Modes/ModeFlush.c (.../ModeFlush.c) (revision ab14e70c7bac24b0c3ebd02c6763285cdd3951ce) @@ -1049,16 +1049,19 @@ *************************************************************************/ static void monitorModeFlush( void ) { - if ( ( STATE_OPEN == getSwitchStatus( CONCENTRATE_CAP ) ) || ( STATE_OPEN == getSwitchStatus( DIALYSATE_CAP ) ) ) +#ifndef _RELEASE_ + if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_CAPS_MONITOR ) != SW_CONFIG_ENABLE_VALUE ) +#endif { - // Set the variables to fail and go to cancel water path. Set the pending alarm to no alarm so the cancel water path - // will not be raising the alarm at end of the cancel water path. The recoverable alarm is raised here in this function - U32 cap = (U32)( STATE_OPEN == getSwitchStatus( CONCENTRATE_CAP ) ? CONCENTRATE_CAP : DIALYSATE_CAP ); - prevFlushState = flushState; - flushState = DG_FLUSH_STATE_CANCEL_WATER_PATH; - alarmDetectedPendingTrigger = ALARM_ID_NO_ALARM; - - SET_ALARM_WITH_1_U32_DATA( ALARM_ID_DG_DIALYSATE_OR_CONC_CAP_NOT_IN_PROPER_POSITION, cap ) + if ( ( STATE_OPEN == getSwitchStatus( CONCENTRATE_CAP ) ) || ( STATE_OPEN == getSwitchStatus( DIALYSATE_CAP ) ) ) + { + // Set the variables to fail and go to cancel water path. Set the pending alarm to no alarm so the cancel water path + // will not be raising the alarm at end of the cancel water path. The recoverable alarm is raised here in this function + U32 cap = (U32)( STATE_OPEN == getSwitchStatus( CONCENTRATE_CAP ) ? CONCENTRATE_CAP : DIALYSATE_CAP ); + prevFlushState = flushState; + flushState = DG_FLUSH_STATE_CANCEL_WATER_PATH; + alarmDetectedPendingTrigger = ALARM_ID_DG_DIALYSATE_OR_CONC_CAP_NOT_IN_PROPER_POSITION; + } } } Index: firmware/App/Modes/ModeGenIdle.c =================================================================== diff -u -ra6dff99e22bb6f646adfe3acf4f461cb43aec979 -rab14e70c7bac24b0c3ebd02c6763285cdd3951ce --- firmware/App/Modes/ModeGenIdle.c (.../ModeGenIdle.c) (revision a6dff99e22bb6f646adfe3acf4f461cb43aec979) +++ firmware/App/Modes/ModeGenIdle.c (.../ModeGenIdle.c) (revision ab14e70c7bac24b0c3ebd02c6763285cdd3951ce) @@ -58,7 +58,6 @@ // several times to drain and fill and handle a bad fill. static DG_GEN_IDLE_MODE_BAD_FILL_STATE_T badFillState = DG_HANDLE_BAD_FILL_STATE_START; ///< Initialize bad fill sub-state. static U32 hdLostCommStartTime_ms; ///< Lost communication with HD start time in ms. -static U32 genIdlePublicationTimerCounter; ///< Used to schedule bad fill sub-states publication to CAN bus. static U32 targetFillVolumeML; ///< Save the target fill volume before calling startFillCmd(). static BOOL handleBadFillFlag; ///< Internal signal flag to handle bad fill. static HD_OP_MODE_T hdMode; ///< HD operations mode. @@ -70,15 +69,15 @@ static DG_GEN_IDLE_MODE_STATE_T handleIdleStartState( void ); static DG_GEN_IDLE_MODE_STATE_T handleFlushWaterState( void ); -static DG_GEN_IDLE_MODE_STATE_T handleBadFillState( void ); // This state has sub-states 1.0 to 1.4 +static DG_GEN_IDLE_MODE_STATE_T handleBadFillState( void ); -static DG_GEN_IDLE_MODE_BAD_FILL_STATE_T handleFirstDrainState( void ); // idle 1.0 -static DG_GEN_IDLE_MODE_BAD_FILL_STATE_T handleFlushFillState( void ); // idle 1.1 -static DG_GEN_IDLE_MODE_BAD_FILL_STATE_T handleSecondDrainState( void ); // idle 1.2 -static DG_GEN_IDLE_MODE_BAD_FILL_STATE_T handleRefillState( void ); // idle 1.3 -static DG_GEN_IDLE_MODE_BAD_FILL_STATE_T handleClearAlarmState( void ); // idle 1.4 +static DG_GEN_IDLE_MODE_BAD_FILL_STATE_T handleStartState( void ); +static DG_GEN_IDLE_MODE_BAD_FILL_STATE_T handleFirstDrainState( void ); +static DG_GEN_IDLE_MODE_BAD_FILL_STATE_T handleFlushFillState( void ); +static DG_GEN_IDLE_MODE_BAD_FILL_STATE_T handleSecondDrainState( void ); +static DG_GEN_IDLE_MODE_BAD_FILL_STATE_T handleRefillState( void ); -static void publishBadFillSubstates( void ); +static void publishBadFillSubstates( U32 badFill ); /*********************************************************************//** * @brief @@ -91,7 +90,6 @@ { genIdleState = DG_GEN_IDLE_MODE_STATE_START; hdLostCommStartTime_ms = 0; - genIdlePublicationTimerCounter = DATA_PUBLISH_COUNTER_START_COUNT; } /*********************************************************************//** @@ -243,8 +241,6 @@ break; } - publishBadFillSubstates(); - return (U32)genIdleState; } @@ -304,30 +300,25 @@ switch ( badFillState ) { case DG_HANDLE_BAD_FILL_STATE_START: - badFillState = DG_HANDLE_BAD_FILL_STATE_FIRST_DRAIN; - requestNewOperationMode( DG_MODE_DRAI ); // go to drain mode to empty bad dialysate because this is a bad fill + badFillState = handleStartState(); break; - case DG_HANDLE_BAD_FILL_STATE_FIRST_DRAIN: // idle 1.0 + case DG_HANDLE_BAD_FILL_STATE_FIRST_DRAIN: badFillState = handleFirstDrainState(); break; - case DG_HANDLE_BAD_FILL_STATE_FLUSH_FILL: // idle 1.1 + case DG_HANDLE_BAD_FILL_STATE_FLUSH_FILL: badFillState = handleFlushFillState(); break; - case DG_HANDLE_BAD_FILL_STATE_SECOND_DRAIN: // idle 1.2. + case DG_HANDLE_BAD_FILL_STATE_SECOND_DRAIN: badFillState = handleSecondDrainState(); break; case DG_HANDLE_BAD_FILL_STATE_REFILL: - badFillState = handleRefillState(); // idle 1.3 + badFillState = handleRefillState(); break; - case DG_HANDLE_BAD_FILL_STATE_CLEAR_ALARM: - badFillState = handleClearAlarmState(); // idle 1.4 - break; - default: SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DG_SOFTWARE_FAULT, SW_FAULT_ID_GEN_IDLE_MODE_INVALID_EXEC_STATE, genIdleState ) badFillState = DG_HANDLE_BAD_FILL_STATE_START; @@ -339,6 +330,27 @@ /*********************************************************************//** * @brief + * The handleStartState function executes the start state of the handle bad + * fill state machine. + * @details Inputs: none + * @details Outputs: none + * @return the next state + *************************************************************************/ +static DG_GEN_IDLE_MODE_BAD_FILL_STATE_T handleStartState( void ) +{ + DG_GEN_IDLE_MODE_BAD_FILL_STATE_T state = DG_HANDLE_BAD_FILL_STATE_FIRST_DRAIN; + + // Publish the state prior to requesting a drain and transitioning to drain mode + publishBadFillSubstates( state ); + + // Drain the bad filled reservoir first + requestNewOperationMode( DG_MODE_DRAI ); + + return state; +} + +/*********************************************************************//** + * @brief * The handleFirstDrainState function executes the first drain state of the * handle bad fill state machine. * @details Inputs: none @@ -347,15 +359,26 @@ *************************************************************************/ static DG_GEN_IDLE_MODE_BAD_FILL_STATE_T handleFirstDrainState( void ) { - DG_GEN_IDLE_MODE_BAD_FILL_STATE_T state = DG_HANDLE_BAD_FILL_STATE_FIRST_DRAIN; // after first drain is completed, go to next bad fill sub-state + DG_GEN_IDLE_MODE_BAD_FILL_STATE_T state = DG_HANDLE_BAD_FILL_STATE_FIRST_DRAIN; - if ( FALSE == isAlarmActive( ALARM_ID_FILL_CONDUCTIVITY_OUT_OF_RANGE ) ) // alarm is no longer active - cleared by user + // Check if the alarm has been cleared by the user and if yes, continue with the fill + if ( FALSE == isAlarmActive( ALARM_ID_FILL_CONDUCTIVITY_OUT_OF_RANGE ) ) { - targetFillVolumeML = getTargetFillVolumeML(); // save the HD target fill volume before command 1000 mL fill volume - startFillCmd( BAD_FLUSH_FILL_TARGET_VOLUME_ML, getTargetFillFlowRateLPM() ); + // Save the HD target fill volume before command 1000 mL fill volume + targetFillVolumeML = getTargetFillVolumeML(); state = DG_HANDLE_BAD_FILL_STATE_FLUSH_FILL; + + // Publish the state prior to transitioning to fill mode + publishBadFillSubstates( state ); + + // Start the flush fill + startFillCmd( BAD_FLUSH_FILL_TARGET_VOLUME_ML, getTargetFillFlowRateLPM() ); } + else + { + publishBadFillSubstates( state ); + } return state; } @@ -372,23 +395,11 @@ { DG_GEN_IDLE_MODE_BAD_FILL_STATE_T state = DG_HANDLE_BAD_FILL_STATE_SECOND_DRAIN; - requestNewOperationMode( DG_MODE_DRAI ); // go to drain mode to empty bad dialysate because this is a bad fill + // Publish the state prior to transitioning to drain mode + publishBadFillSubstates( state ); - /*if ( FALSE == isAlarmActive( ALARM_ID_FILL_CONDUCTIVITY_OUT_OF_RANGE ) ) // alarm is no longer active - cleared by user - { - targetFillVolumeML = getTargetFillVolumeML(); // save the HD target fill volume before command 1000 mL fill volume - startFillCmd( BAD_FLUSH_FILL_TARGET_VOLUME_ML, getTargetFillFlowRateLPM() ); + requestNewOperationMode( DG_MODE_DRAI ); - if ( TRUE == handleBadFillFlag ) - { - result = DG_HANDLE_BAD_FILL_STATE_FIRST_DRAIN; // (idle 1.0) - } - else - { - result = DG_HANDLE_BAD_FILL_STATE_SECOND_DRAIN; // (idle 1.2) - } - }*/ - return state; } @@ -402,11 +413,13 @@ *************************************************************************/ static DG_GEN_IDLE_MODE_BAD_FILL_STATE_T handleSecondDrainState( void ) { - DG_GEN_IDLE_MODE_BAD_FILL_STATE_T state = DG_HANDLE_BAD_FILL_STATE_CLEAR_ALARM; // after second drain completed, go to refill sub-state (idle 1.3) + DG_GEN_IDLE_MODE_BAD_FILL_STATE_T state = DG_HANDLE_BAD_FILL_STATE_REFILL; - //requestNewOperationMode( DG_MODE_DRAI ); // go to drain mode to empty bad dialysate because this is a bad fill + // Publish the state prior to transitioning to fill mode + publishBadFillSubstates( state ); - startFillCmd( targetFillVolumeML, getTargetFillFlowRateLPM() ); // refill to the saved target fill volume (~1500 mL) + // Refill to the saved target fill volume (~1500 mL) + startFillCmd( targetFillVolumeML, getTargetFillFlowRateLPM() ); return state; } @@ -421,53 +434,34 @@ *************************************************************************/ static DG_GEN_IDLE_MODE_BAD_FILL_STATE_T handleRefillState( void ) { - DG_GEN_IDLE_MODE_BAD_FILL_STATE_T result = DG_HANDLE_BAD_FILL_STATE_CLEAR_ALARM; // (idle 1.4) + DG_GEN_IDLE_MODE_BAD_FILL_STATE_T state = DG_HANDLE_BAD_FILL_STATE_START; - startFillCmd( targetFillVolumeML, getTargetFillFlowRateLPM() ); // refill to the saved target fill volume (~1500 mL) + publishBadFillSubstates( state ); - return result; -} - -/*********************************************************************//** - * @brief - * The handleClearAlarmState function executes the clear alarm state of the - * handle bad fill state machine. - * @details Inputs: none - * @details Outputs: none - * @return the next state - *************************************************************************/ -static DG_GEN_IDLE_MODE_BAD_FILL_STATE_T handleClearAlarmState( void ) -{ - DG_GEN_IDLE_MODE_BAD_FILL_STATE_T result = DG_HANDLE_BAD_FILL_STATE_START; - - // clear wait for dialysate alarm condition to allow resume + // Clear wait for dialysate alarm condition to allow resume clearAlarmCondition( ALARM_ID_CREATING_DIALYSATE_PLEASE_WAIT ); // resume option will appear - handleBadFillFlag = FALSE; // set flag to FALSE here so next call to idle exec will move to normal flush water state - genIdleState = DG_GEN_IDLE_MODE_STATE_START; + // Set flag to FALSE here so next call to idle exec will move to normal flush water state + handleBadFillFlag = FALSE; - return result; + return state; } /*********************************************************************//** * @brief * The publishBadFillSubstates function publishes idle mode bad fill * sub-states at the set interval. - * @details Inputs: genIdlePublicationTimerCounter - * @details Outputs: genIdlePublicationTimerCounter + * @details Inputs: none + * @details Outputs: none + * @param badFill the bad fill state that has to be published * @return none *************************************************************************/ -static void publishBadFillSubstates( void ) +static void publishBadFillSubstates( U32 badFill ) { - // publish bad fill sub-states on interval - if ( ++genIdlePublicationTimerCounter >= getU32OverrideValue( &badFillSubstatesPublishInterval ) ) - { - GEN_IDLE_BAD_FILL_STATE data; + GEN_IDLE_BAD_FILL_STATE data; - data.badFillState = (U32)badFillState; + data.badFillState = badFill; - broadcastData( MSG_ID_DG_BAD_FILL_SUB_STATE, COMM_BUFFER_OUT_CAN_DG_BROADCAST, (U08*)&data, sizeof( GEN_IDLE_BAD_FILL_STATE ) ); - genIdlePublicationTimerCounter = 0; - } + broadcastData( MSG_ID_DG_BAD_FILL_SUB_STATE, COMM_BUFFER_OUT_CAN_DG_BROADCAST, (U08*)&data, sizeof( GEN_IDLE_BAD_FILL_STATE ) ); } Index: firmware/App/Modes/ModeHeatDisinfect.c =================================================================== diff -u -r1e22b6ff6f42ddc57ad6c17e56057ab8a3765680 -rab14e70c7bac24b0c3ebd02c6763285cdd3951ce --- firmware/App/Modes/ModeHeatDisinfect.c (.../ModeHeatDisinfect.c) (revision 1e22b6ff6f42ddc57ad6c17e56057ab8a3765680) +++ firmware/App/Modes/ModeHeatDisinfect.c (.../ModeHeatDisinfect.c) (revision ab14e70c7bac24b0c3ebd02c6763285cdd3951ce) @@ -624,7 +624,7 @@ } #ifndef _RELEASE_ - if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_DISINFECT_CONDUCTIVITY_CHECK ) != SW_CONFIG_ENABLE_VALUE ) + if ( SW_CONFIG_ENABLE_VALUE == getSoftwareConfigStatus( SW_CONFIG_DISABLE_DISINFECT_CONDUCTIVITY_CHECK ) ) { hasConductivityPassed = TRUE; } @@ -2067,16 +2067,19 @@ *************************************************************************/ static void monitorModeHeatDisinfect( void ) { - if ( ( STATE_OPEN == getSwitchStatus( CONCENTRATE_CAP ) ) && ( STATE_OPEN == getSwitchStatus( DIALYSATE_CAP ) ) ) +#ifndef _RELEASE_ + if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_CAPS_MONITOR ) != SW_CONFIG_ENABLE_VALUE ) +#endif { - // Set the variables to fail and go to cancel water path. Set the pending alarm to no alarm so the cancel water path - // will not be raising the alarm at end of the cancel water path. The recoverable alarm is raised here in this function - U32 cap = (U32)( STATE_OPEN == getSwitchStatus( CONCENTRATE_CAP ) ? CONCENTRATE_CAP : DIALYSATE_CAP ); - prevHeatDisinfectState = heatDisinfectState; - heatDisinfectState = DG_HEAT_DISINFECT_STATE_CANCEL_WATER_PATH; - alarmDetectedPendingTrigger = ALARM_ID_NO_ALARM; - - SET_ALARM_WITH_1_U32_DATA( ALARM_ID_DG_DIALYSATE_OR_CONC_CAP_NOT_IN_PROPER_POSITION, cap ) + if ( ( STATE_OPEN == getSwitchStatus( CONCENTRATE_CAP ) ) && ( STATE_OPEN == getSwitchStatus( DIALYSATE_CAP ) ) ) + { + // Set the variables to fail and go to cancel water path. Set the pending alarm to no alarm so the cancel water path + // will not be raising the alarm at end of the cancel water path. The recoverable alarm is raised here in this function + U32 cap = (U32)( STATE_OPEN == getSwitchStatus( CONCENTRATE_CAP ) ? CONCENTRATE_CAP : DIALYSATE_CAP ); + prevHeatDisinfectState = heatDisinfectState; + heatDisinfectState = DG_HEAT_DISINFECT_STATE_CANCEL_WATER_PATH; + alarmDetectedPendingTrigger = ALARM_ID_DG_DIALYSATE_OR_CONC_CAP_NOT_IN_PROPER_POSITION; + } } } Index: firmware/App/Modes/ModeStandby.c =================================================================== diff -u -r8fe65bf6222137cc7182ccacff3a5f2fb2f03753 -rab14e70c7bac24b0c3ebd02c6763285cdd3951ce --- firmware/App/Modes/ModeStandby.c (.../ModeStandby.c) (revision 8fe65bf6222137cc7182ccacff3a5f2fb2f03753) +++ firmware/App/Modes/ModeStandby.c (.../ModeStandby.c) (revision ab14e70c7bac24b0c3ebd02c6763285cdd3951ce) @@ -410,17 +410,22 @@ cmdResponse.commandID = DG_CMD_START_FLUSH; cmdResponse.rejected = FALSE; cmdResponse.rejectCode = DG_CMD_REQUEST_REJECT_REASON_NONE; + OPN_CLS_STATE_T concCap = getSwitchStatus( CONCENTRATE_CAP ); + OPN_CLS_STATE_T diaCap = getSwitchStatus( DIALYSATE_CAP ); - if ( ( STATE_OPEN == getSwitchStatus( CONCENTRATE_CAP ) ) || ( STATE_OPEN == getSwitchStatus( DIALYSATE_CAP ) ) ) - { #ifndef _RELEASE_ - if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_CAPS_MONITOR ) != SW_CONFIG_ENABLE_VALUE ) + if ( SW_CONFIG_ENABLE_VALUE == getSoftwareConfigStatus( SW_CONFIG_DISABLE_CAPS_MONITOR ) ) + { + concCap = STATE_CLOSED; + diaCap = STATE_CLOSED; + } #endif - { - cmdResponse.rejected = TRUE; - cmdResponse.rejectCode = ( STATE_OPEN == getSwitchStatus( DIALYSATE_CAP ) ? REQUEST_REJECT_REASON_DG_DIALYSATE_CAP_OPEN : - REQUEST_REJECT_REASON_DG_CONCENTRATE_CAP_OPEN ); - } + + if ( ( STATE_OPEN == concCap ) || ( STATE_OPEN == diaCap ) ) + { + cmdResponse.rejected = TRUE; + cmdResponse.rejectCode = ( STATE_OPEN == getSwitchStatus( DIALYSATE_CAP ) ? REQUEST_REJECT_REASON_DG_DIALYSATE_CAP_OPEN : + REQUEST_REJECT_REASON_DG_CONCENTRATE_CAP_OPEN ); } else { @@ -450,20 +455,25 @@ { DG_CMD_RESPONSE_T cmdResponse; - cmdResponse.commandID = DG_CMD_START_HEAT_DISINFECT; - cmdResponse.rejected = FALSE; - cmdResponse.rejectCode = DG_CMD_REQUEST_REJECT_REASON_NONE; + cmdResponse.commandID = DG_CMD_START_HEAT_DISINFECT; + cmdResponse.rejected = FALSE; + cmdResponse.rejectCode = DG_CMD_REQUEST_REJECT_REASON_NONE; + OPN_CLS_STATE_T concCap = getSwitchStatus( CONCENTRATE_CAP ); + OPN_CLS_STATE_T diaCap = getSwitchStatus( DIALYSATE_CAP ); - if ( ( STATE_OPEN == getSwitchStatus( CONCENTRATE_CAP ) ) || ( STATE_OPEN == getSwitchStatus( DIALYSATE_CAP ) ) ) - { #ifndef _RELEASE_ - if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_CAPS_MONITOR ) != SW_CONFIG_ENABLE_VALUE ) + if ( SW_CONFIG_ENABLE_VALUE == getSoftwareConfigStatus( SW_CONFIG_DISABLE_CAPS_MONITOR ) ) + { + concCap = STATE_CLOSED; + diaCap = STATE_CLOSED; + } #endif - { - cmdResponse.rejected = TRUE; - cmdResponse.rejectCode = ( STATE_OPEN == getSwitchStatus( DIALYSATE_CAP ) ? REQUEST_REJECT_REASON_DG_DIALYSATE_CAP_OPEN : - REQUEST_REJECT_REASON_DG_CONCENTRATE_CAP_OPEN ); - } + + if ( ( STATE_OPEN == concCap ) || ( STATE_OPEN == diaCap ) ) + { + cmdResponse.rejected = TRUE; + cmdResponse.rejectCode = ( STATE_OPEN == getSwitchStatus( DIALYSATE_CAP ) ? REQUEST_REJECT_REASON_DG_DIALYSATE_CAP_OPEN : + REQUEST_REJECT_REASON_DG_CONCENTRATE_CAP_OPEN ); } else { @@ -492,27 +502,30 @@ // Chemical disinfect cannot be run in solo mode because the user has to confirm that the acid is inserted or removed if ( ( DG_MODE_STAN == getCurrentOperationMode() ) && ( DG_STANDBY_MODE_STATE_IDLE == standbyState ) ) { -#ifndef DISABLE_CAP_SWITCHES DG_CMD_RESPONSE_T cmdResponse; cmdResponse.commandID = DG_CMD_START_CHEM_DISINFECT; cmdResponse.rejected = FALSE; cmdResponse.rejectCode = DG_CMD_REQUEST_REJECT_REASON_NONE; + OPN_CLS_STATE_T concCap = getSwitchStatus( CONCENTRATE_CAP ); + OPN_CLS_STATE_T diaCap = getSwitchStatus( DIALYSATE_CAP ); - // When chemical disinfect is about to be started, both caps must be closed - if ( ( STATE_OPEN == getSwitchStatus( CONCENTRATE_CAP ) ) || ( STATE_OPEN == getSwitchStatus( DIALYSATE_CAP ) ) ) - { #ifndef _RELEASE_ - if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_CAPS_MONITOR ) != SW_CONFIG_ENABLE_VALUE ) + if ( SW_CONFIG_ENABLE_VALUE == getSoftwareConfigStatus( SW_CONFIG_DISABLE_CAPS_MONITOR ) ) + { + concCap = STATE_CLOSED; + diaCap = STATE_CLOSED; + } #endif - { - cmdResponse.rejected = TRUE; - cmdResponse.rejectCode = ( STATE_OPEN == getSwitchStatus( DIALYSATE_CAP ) ? REQUEST_REJECT_REASON_DG_DIALYSATE_CAP_OPEN : - REQUEST_REJECT_REASON_DG_CONCENTRATE_CAP_OPEN ); - } + + // When chemical disinfect is about to be started, both caps must be closed + if ( ( STATE_OPEN == concCap ) || ( STATE_OPEN == diaCap ) ) + { + cmdResponse.rejected = TRUE; + cmdResponse.rejectCode = ( STATE_OPEN == getSwitchStatus( DIALYSATE_CAP ) ? REQUEST_REJECT_REASON_DG_DIALYSATE_CAP_OPEN : + REQUEST_REJECT_REASON_DG_CONCENTRATE_CAP_OPEN ); } else -#endif { pendingStartDGChemicalDisinfectRequest = TRUE; status = TRUE; Index: firmware/App/Services/SystemComm.c =================================================================== diff -u -r1e22b6ff6f42ddc57ad6c17e56057ab8a3765680 -rab14e70c7bac24b0c3ebd02c6763285cdd3951ce --- firmware/App/Services/SystemComm.c (.../SystemComm.c) (revision 1e22b6ff6f42ddc57ad6c17e56057ab8a3765680) +++ firmware/App/Services/SystemComm.c (.../SystemComm.c) (revision ab14e70c7bac24b0c3ebd02c6763285cdd3951ce) @@ -655,7 +655,7 @@ if ( TRUE == didTimeout( timeOfLastHDCheckIn, HD_COMM_TIMEOUT_IN_MS ) ) { hdCommunicationStatus.data = FALSE; - //activateAlarmNoData( ALARM_ID_HD_COMM_TIMEOUT ); + activateAlarmNoData( ALARM_ID_HD_COMM_TIMEOUT ); } }