Index: firmware/App/Controllers/Valves.c =================================================================== diff -u -r0e809b89fe509c2968c3445898466dd8dd9411a9 -r88faf0b2c2b71c6d6b75637a11f7d5de41e351af --- firmware/App/Controllers/Valves.c (.../Valves.c) (revision 0e809b89fe509c2968c3445898466dd8dd9411a9) +++ firmware/App/Controllers/Valves.c (.../Valves.c) (revision 88faf0b2c2b71c6d6b75637a11f7d5de41e351af) @@ -56,7 +56,7 @@ { VALVE_POSITION_T commandedPosition; ///< Valve commanded position enum. VALVE_POSITION_T currentPosition; ///< Valve current position enum. - S16 priorEncPosition; ///< Valve prior position in encoder counts. +// S16 priorEncPosition; ///< Valve prior position in encoder counts. BOOL hasTransitionBeenRequested; ///< Valve transition request flag. VALVE_STATE_T controlState; ///< Valve control state. U32 valveOpsStartTime; ///< Valve transition start time. @@ -165,7 +165,8 @@ { if ( ( TRUE == force ) || ( FALSE == currentValveStates[ valve ].hasValveBeenHomed ) ) { - if ( ( FALSE == isPinchValveBusy( valve ) ) && ( FALSE == currentValveStates[ valve ].hasHomingBeenRequested ) && + if ( ( FALSE == isPinchValveBusy( valve ) ) && + ( FALSE == currentValveStates[ valve ].hasHomingBeenRequested ) && ( FALSE == currentValveStates[ valve ].homingOperationActive ) ) { currentValveStates[ valve ].hasHomingBeenRequested = TRUE; @@ -306,7 +307,8 @@ break; default: - SET_ALARM_WITH_2_U32_DATA( ALARM_ID_TD_SOFTWARE_FAULT, SW_FAULT_ID_TD_VALVES_INVALID_STATE, (U32)currentValveStates[ valve ].controlState ) + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_TD_SOFTWARE_FAULT, SW_FAULT_ID_TD_VALVES_INVALID_STATE, + (U32)currentValveStates[ valve ].controlState ) currentValveStates[ valve ].currentPosition = VALVE_POSITION_NOT_IN_POSITION; currentValveStates[ valve ].hasValveBeenHomed = FALSE; currentValveStates[ valve ].controlState = VALVE_STATE_HOMING_NOT_HOMED; @@ -341,7 +343,7 @@ // // return valvesSelfTestResult; //} -// + /*********************************************************************//** * @brief * The handleValvesWait4PostState function handles the Wait for POST state @@ -375,45 +377,6 @@ * @param valve ID of valve for which to handle the Not Homed state * @return next state of the state machine for the given valve *************************************************************************/ -//static VALVE_STATE_T handleValvesNotHomedState( VALVE_T valve ) -//{ -// VALVE_STATE_T nextState = VALVE_STATE_HOMING_NOT_HOMED; -// -// if ( ( TRUE == currentValveStates[ valve ].hasHomingBeenRequested ) && -// ( FALSE == currentValveStates[ valve ].homingOperationActive ) ) -// { -// if ( TRUE == homePinchValve( valve ) ) -// { -// currentValveStates[ valve ].hasHomingBeenRequested = FALSE; -// currentValveStates[ valve ].hasValveBeenHomed = FALSE; -// currentValveStates[ valve ].homingOperationActive = TRUE; -// currentValveStates[ valve ].currentPosition = VALVE_POSITION_NOT_IN_POSITION; -// currentValveStates[ valve ].valveOpsStartTime = getMSTimerCount(); -// } -// } -// else if ( ( TRUE == currentValveStates[ valve ].homingOperationActive ) && ( TRUE == isPinchValveHomed( valve ) ) ) -// { -// currentValveStates[ valve ].homingOperationActive = FALSE; -// currentValveStates[ valve ].hasValveBeenHomed = TRUE; -// currentValveStates[ valve ].commandedPosition = VALVE_POSITION_C_CLOSE; -// currentValveStates[ valve ].currentPosition = getCurrentValveABCPosition( valve ); -// nextState = VALVE_STATE_IDLE; -// } -// else if ( ( TRUE == currentValveStates[ valve ].homingOperationActive ) && -// ( TRUE == didTimeout( currentValveStates[ valve ].valveOpsStartTime, VALVE_HOMING_TIMEOUT_MS ) ) && -// ( TRUE != getCPLDACPowerLossDetected() ) ) -// { -// currentValveStates[ valve ].homingOperationActive = FALSE; -// currentValveStates[ valve ].hasValveBeenHomed = FALSE; -// currentValveStates[ valve ].currentPosition = VALVE_POSITION_NOT_IN_POSITION; -// -// SET_ALARM_WITH_2_U32_DATA( ALARM_ID_TD_VALVE_TRANSITION_TIMEOUT, (U32)valve, (U32)getPinchValvePosition( valve ) ) -// } -// -// return nextState; -//} - - static VALVE_STATE_T handleValvesNotHomedState( VALVE_T valve ) { VALVE_STATE_T nextState = VALVE_STATE_HOMING_NOT_HOMED; @@ -437,26 +400,26 @@ if ( TRUE == movePinchValveToStoredPosition( valve, VALVE_POSITION_C_CLOSE ) ) { currentValveStates[ valve ].commandedPosition = VALVE_POSITION_C_CLOSE; - currentValveStates[ valve ].currentPosition = VALVE_POSITION_NOT_IN_POSITION; + currentValveStates[ valve ].currentPosition = VALVE_POSITION_NOT_IN_POSITION; currentValveStates[ valve ].valveOpsStartTime = getMSTimerCount(); - nextState = VALVE_STATE_IN_TRANSITION; + nextState = VALVE_STATE_IN_TRANSITION; } else { currentValveStates[ valve ].hasValveBeenHomed = FALSE; - currentValveStates[ valve ].currentPosition = VALVE_POSITION_NOT_IN_POSITION; - nextState = VALVE_STATE_HOMING_NOT_HOMED; + currentValveStates[ valve ].currentPosition = VALVE_POSITION_NOT_IN_POSITION; + nextState = VALVE_STATE_HOMING_NOT_HOMED; } } else if ( ( TRUE == currentValveStates[ valve ].homingOperationActive ) && - ( TRUE == didTimeout( currentValveStates[ valve ].valveOpsStartTime, VALVE_HOMING_TIMEOUT_MS ) ) && - ( TRUE != getCPLDACPowerLossDetected() ) ) + ( TRUE == didTimeout( currentValveStates[ valve ].valveOpsStartTime, VALVE_HOMING_TIMEOUT_MS ) ) && + ( TRUE != getCPLDACPowerLossDetected() ) ) { currentValveStates[ valve ].homingOperationActive = FALSE; currentValveStates[ valve ].hasValveBeenHomed = FALSE; currentValveStates[ valve ].currentPosition = VALVE_POSITION_NOT_IN_POSITION; SET_ALARM_WITH_2_U32_DATA( ALARM_ID_TD_VALVE_TRANSITION_TIMEOUT, (U32)valve, (U32)getPinchValvePosition( valve ) ) - nextState = VALVE_STATE_HOMING_NOT_HOMED; + nextState = VALVE_STATE_HOMING_NOT_HOMED; } return nextState; @@ -528,8 +491,8 @@ } else { - currentValveStates[ valve ].currentPosition = VALVE_POSITION_NOT_IN_POSITION; - // TODO - alarm + currentValveStates[ valve ].currentPosition = VALVE_POSITION_NOT_IN_POSITION; + // TODO - alarm later nextState = VALVE_STATE_IDLE; } }