Index: firmware/App/Modes/Prime.c =================================================================== diff -u -r604a7f0b5ffb72a8c5989f7476e4423181f54e4d -raa2e734a9f69c46bfdd88f138addd369e12bbd0a --- firmware/App/Modes/Prime.c (.../Prime.c) (revision 604a7f0b5ffb72a8c5989f7476e4423181f54e4d) +++ firmware/App/Modes/Prime.c (.../Prime.c) (revision aa2e734a9f69c46bfdd88f138addd369e12bbd0a) @@ -15,7 +15,13 @@ * ***************************************************************************/ +#include "AirTrap.h" +#include "AlarmMgmt.h" +#include "BloodFlow.h" +#include "DGInterface.h" #include "Prime.h" +#include "TaskGeneral.h" +#include "Valves.h" /** * @addtogroup Prime @@ -26,14 +32,16 @@ #define BLOOD_PUMP_FLOW_RATE_PURGE_AIR 100 ///< Blood pump flow rate during prime purge air state. #define BLOOD_PUMP_FLOW_RATE_COLLECT_AIR 300 ///< Blood pump flow rate during prime collect air state. -#define NO_AIR_DETECTED_COUNT ( 5 * MS_PER_SEC / TASK_GENERAL_INTERVAL ) ///< No air detected time period count. +#define NO_AIR_DETECTED_COUNT ( 5 * MS_PER_SECOND / TASK_GENERAL_INTERVAL ) ///< No air detected time period count. +#define PURGE_AIR_TIME_OUT_COUNT ( 5 * MS_PER_SECOND / TASK_GENERAL_INTERVAL ) ///< Time period count for purge air time out. // ********** private data ********** static PRE_TREATMENT_PRIME_STATE_T currentPrimeState; ///< Current state of the prime sub-mode state machine. static BOOL isPrimeCompleted; ///< Status if prime sequence has been completed. static BOOL primeStartReqReceived; ///< Flag to indicate if a request to start priming has been received. static U32 noAirDetectedTimerCounter; ///< No air detected timer counter. +static U32 purgeAirTimeOutTimerCount; ///< timer counter for purse air state time out. // ********** private function prototypes ********** @@ -70,6 +78,9 @@ currentPrimeState = PRIME_START_STATE; isPrimeCompleted = FALSE; primeStartReqReceived = FALSE; + + cmdSetDGActiveReservoir( DG_RESERVOIR_2 ); + cmdStartDGFill( FILL_RESERVOIR_TO_VOLUME_ML ); } /*********************************************************************//** @@ -132,7 +143,7 @@ setValvePosition( VDO, VALVE_POSITION_C_CLOSE ); setValvePosition( VBA, VALVE_POSITION_C_CLOSE ); setValvePosition( VBV, VALVE_POSITION_C_CLOSE ); - // TODO: setValvePosition( VBT, VALVE_POSITION_B_OPEN ); + setValveAirTrap( STATE_OPEN ); setBloodPumpTargetFlowRate( BLOOD_PUMP_FLOW_RATE_PURGE_AIR, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_OPEN_LOOP ); } @@ -152,6 +163,7 @@ if ( TRUE == primeStartReqReceived ) { purgeAirValvesBloodPumpControl(); + purgeAirTimeOutTimerCount = 0; state = PRIME_SALINE_PURGE_AIR_STATE; } @@ -170,13 +182,18 @@ { PRE_TREATMENT_PRIME_STATE_T state = PRIME_SALINE_PURGE_AIR_STATE; + if ( ++purgeAirTimeOutTimerCount > PURGE_AIR_TIME_OUT_COUNT ) + { + activateAlarmNoData( ALARM_ID_HD_PRIME_PURGE_AIR_TIME_OUT ); + } + if ( AIR_TRAP_LEVEL_FLUID == getAirTrapLevel( AIR_TRAP_LEVEL_SENSOR_UPPER ) ) { setValvePosition( VDI, VALVE_POSITION_C_CLOSE ); setValvePosition( VDO, VALVE_POSITION_C_CLOSE ); setValvePosition( VBA, VALVE_POSITION_B_OPEN ); setValvePosition( VBV, VALVE_POSITION_B_OPEN ); - // TODO: setValvePosition( VBT, VALVE_POSITION_C_CLOSE ); + setValveAirTrap( STATE_CLOSED ); setBloodPumpTargetFlowRate( BLOOD_PUMP_FLOW_RATE_COLLECT_AIR, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_OPEN_LOOP ); noAirDetectedTimerCounter = 0; @@ -202,6 +219,7 @@ if ( AIR_TRAP_LEVEL_AIR == getAirTrapLevel( AIR_TRAP_LEVEL_SENSOR_LOWER ) ) { purgeAirValvesBloodPumpControl(); + purgeAirTimeOutTimerCount = 0; state = PRIME_SALINE_PURGE_AIR_STATE; }