Index: firmware/App/Controllers/Valves.c =================================================================== diff -u -r837e86dd59014bd075bc39839c8b4b6324288880 -rbc1ec8e71e5e5e7aef6d84775e07f5935653593f --- firmware/App/Controllers/Valves.c (.../Valves.c) (revision 837e86dd59014bd075bc39839c8b4b6324288880) +++ firmware/App/Controllers/Valves.c (.../Valves.c) (revision bc1ec8e71e5e5e7aef6d84775e07f5935653593f) @@ -515,6 +515,35 @@ BOOL result = u32ArrayOverride( message, &valveStates[0], NUM_OF_VALVES - 1, 0, NUM_OF_VALVE_STATES - 1 ); return result; +} + +/*********************************************************************//** + * @brief + * The testBCValveStatesOverride function overrides the state of all + * balancing chamber valves with a given bits (corresponding to BC valve + * enumeration order). + * @details \b Inputs: none + * @details \b Outputs: valveStates[] + * @param message Override message from Dialin which includes the states + * to override the balancing chamber valves to. + * @return TRUE if override successful, FALSE if not + *************************************************************************/ +BOOL testBCValveStatesOverride( MESSAGE_T *message ) +{ + DD_BC_VALVE_OVERRIDE_PAYLOAD_T payload; + VALVES_T valve; + BOOL result = FALSE; + + memcpy( (U08*)(&payload), message, sizeof( DD_BC_VALVE_OVERRIDE_PAYLOAD_T ) ); + for ( valve = FIRST_BC_VALVE; valve <= LAST_BC_VALVE; valve++ ) + { + U32 mask = 0x1 << (valve - FIRST_BC_VALVE); + VALVE_STATE_NAMES_T pos = ( ( ( payload.valveStatesBits & mask ) != 0 ) ? VALVE_STATE_OPEN : VALVE_STATE_CLOSED ); + + result = setValveState( valve, pos ); + } + + return result; } /*********************************************************************//**