Index: firmware/App/Monitors/Switches.c =================================================================== diff -u -reca350134b358d583fe4364a117d744684d28788 -rfbb3995c14aae438604df63073c0023b408a4555 --- firmware/App/Monitors/Switches.c (.../Switches.c) (revision eca350134b358d583fe4364a117d744684d28788) +++ firmware/App/Monitors/Switches.c (.../Switches.c) (revision fbb3995c14aae438604df63073c0023b408a4555) @@ -30,20 +30,32 @@ // ********** private definitions ********** -#define SWITCHES_DATA_PUB_INTERVAL ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) ///< Interval (ms/task time) at which the switches data is published on the CAN bus. -#define SWITCHES_DEBOUNCE_TIME_MS ( MS_PER_SECOND / 4 ) ///< Switches FPGA status check interval. -#define DATA_PUBLISH_COUNTER_START_COUNT 90 ///< Data publish counter start count. - +#define SWITCHES_DATA_PUB_INTERVAL ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) ///< Interval (ms/task time) at which the switches data is published on the CAN bus. +#define SWITCHES_DEBOUNCE_TIME_MS ( MS_PER_SECOND / 4 ) ///< Switches FPGA status check interval. +#define DATA_PUBLISH_COUNTER_START_COUNT 90 ///< Data publish counter start count. +#define MAX_CONNECTOR_NOT_IN_PLACE_ALARMS 3 ///< Maximum number of times the connector not in place alarm can occur. +#define MAX_CAP_NOT_CLOSED_ALARMS 3 ///< Maximum number of times the cap not closed alarm can occur. +#define MAX_CAP_NOT_CLOSED_INTERVAL ( ( 5 * SECONDS_PER_MINUTE *MS_PER_SECOND ) / TASK_GENERAL_INTERVAL ) + ///< Maximum length of time the cap can be not closed in timer intervals // ********** private data ********** static U32 switchesDataPublicationCounter; ///< Switches data publication counter. static OVERRIDE_U32_T switchesDataPublishInterval; ///< Interval (in ms) at which to publish switches data to CAN bus. static OVERRIDE_U32_T switchesStatus[ NUM_OF_SWITCHES ]; ///< Debounced switch states. static U32 switchDebounceStartTimes[ NUM_OF_SWITCHES ]; ///< Switch debounce start times. +static BOOL requireConnectorInPlace_CapNotParked; ///< Check for connector in place and cap parked condition +static BOOL requireCapClosed_CapNotParked; ///< Check for cap closed and cap not parked condition +static BOOL alarmConnectorNotInPlace_CapNotParked; ///< Is the ConnectorNotInPlace_CapNotParked alarm active? +static BOOL alarmCapNotClosed_CapParked; ///< Is the CapClosed_CapNotParked alarm active? +static U32 alarmConnectorNotInPlace_CapNotParked_count; ///< Is the ConnectorNotInPlace_CapNotParked alarm active? +static U32 alarmCapNotClosed_CapParked_count; ///< Is the CapClosed_CapNotParked alarm active? +static U32 alarmCapNotClosed_CapParked_seconds_counter; ///< Total duration of CapClosed_CapNotParked alarm. +static U32 alarmCapNotClosed_CapParked_timer; ///< Timer for the duration of CapClosed_CapNotParked alarm. // ********** private function prototypes ********** static void publishSwitchesData( void ); +static void handleSwitchAlarms( void ); /*********************************************************************//** * @brief @@ -62,6 +74,14 @@ switchesDataPublishInterval.ovData = SWITCHES_DATA_PUB_INTERVAL; switchesDataPublishInterval.ovInitData = 0; switchesDataPublishInterval.override = OVERRIDE_RESET; + requireConnectorInPlace_CapParked = FALSE; + requireCapClosed_CapNotParked = FALSE; + alarmConnectorNotInPlace_CapNotParked = FALSE; + alarmCapNotClosed_CapParked = FALSE; + alarmConnectorNotInPlace_CapNotParked_count = 0; + alarmCapNotClosed_CapParked_count = 0; + alarmCapNotClosed_CapParked_seconds_counter = 0; + alarmCapNotClosed_CapParked_timer = 0; // Initialize all the switches for ( i = 0; i < NUM_OF_SWITCHES; i++ ) @@ -78,7 +98,7 @@ * @brief * The execSwitches function executes the switches monitor executive. * Switch state changes are debounced for 250ms before formalizing them. - * @details \b Inputs: switchesStatus[], switchDebounceStartTimes[] + * @details \b Inputs: FPGA switch states, switchesStatus[], switchDebounceStartTimes[] * @details \b Outputs: switchesStatus[], switchDebounceStartTimes[] * @return none *************************************************************************/ @@ -126,13 +146,94 @@ } } + // Check for switch alarms + handleSwitchAlarms(); // Handle publishing switches data publishSwitchesData(); } /*********************************************************************//** * @brief + * The handleSwitchAlarms function checks for switch related alarms. + * @details \b Alarm: ALARM_ID_HDF_DISPOSABLE_NOT_CONNECTED if HDF disposable + * is not connected and cap is not parked. + * @details \b Alarm: ALARM_ID_HDF_CAP_NOT_CLOSED if HDF cap is not + * closed on the HDF port. Additionally the cap must not be detected in the park position. + * @details \b Inputs: requireConnectorInPlace_CapParked, requireCapClosed_CapNotParked, switchesStatus + * @details \b Outputs: alarms if required conditions are not met + * @return none + *************************************************************************/ +static void handleSwitchAlarms( void ) +{ +#ifndef _RELEASE_ +// if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_SWITCHES_MONITOR ) != SW_CONFIG_ENABLE_VALUE ) +#endif + { + // Check for connector not in place alarm during treatment + // The optical switches should show that the connector is in place, and in addition + // the cap should be in its parked position. + if ( TRUE == requireConnectorInPlace_CapParked ) + { + if ( getSwitchState( D101_SWCH ) != STATE_CLOSED && + getSwitchState( D102_SWCH ) != STATE_OPEN && + getSwitchState( D103_SWCH ) != STATE_CLOSED &&) + { + activateAlarmNoData( ALARM_ID_HDF_DISPOSABLE_NOT_CONNECTED ); + if ( FALSE == alarmConnectorNotInPlace_CapNotParked ) + { + if ( ++alarmConnectorNotInPlace_CapNotParked_count >= MAX_CONNECTOR_NOT_IN_PLACE_ALARMS ) + { + // This alarm can only occur a limited number of times before treatment is ended + //END TREATMENT + } + } + alarmConnectorNotInPlace_CapNotParked = TRUE; + } + else + { + clearAlarmCondition( ALARM_ID_HDF_DISPOSABLE_NOT_CONNECTED ); + alarmConnectorNotInPlace_CapNotParked = FALSE; + } + } + + // Check for cap not closed alarm during disinfect + // The cap should be over the connector port and in the closed position, and in addition + // the cap parked indicator should not be activated. + if ( TRUE == requireCapClosed_CapNotParked ) + { + if ( getSwitchState( D101_SWCH ) != STATE_OPEN && + getSwitchState( D102_SWCH ) != STATE_CLOSED && + getSwitchState( D103_SWCH ) != STATE_OPEN &&) + { + activateAlarmNoData( ALARM_ID_HDF_CAP_NOT_CLOSED ); + if ( FALSE == alarmCapNotClosed_CapParked ) + { + if ( ++alarmCapNotClosed_CapParked_count >= MAX_CAP_NOT_CLOSED_ALARMS ) + { + // This alarm can only occur a limited number of times before disinfect must be restarted + //REQUIRE DISINFECT + } + } + alarmCapNotClosed_CapParked = TRUE; + // Increment the timer for this alarm. This should happen at all times that the alarm is active + if ( ++alarmCapNotClosed_CapParked_timer > MAX_CAP_NOT_CLOSED_INTERVAL ) + { + // This alarm can only be active for a limited amount of time before disinfect must be performed + //REQUIRE DISINFECT + } + } + else + { + clearAlarmCondition( ALARM_ID_HDF_CAP_NOT_CLOSED ); + alarmCapNotClosed_CapParked = FALSE; + } + } + } +} + +/*********************************************************************//** + * @brief * The getSwitchState function returns the state of a given switch. * @details \b Alarm: ALARM_ID_DD_SOFTWARE_FAULT if given switch ID is invalid. * @details \b Inputs: switchesStatus @@ -158,6 +259,40 @@ /*********************************************************************//** * @brief + * The requireCapParked_ConnectorInPlace function sets flags that determine whether + * the HDF disposable must be connected and the HDF cap parked in current state. + * Associated alarms will be triggered if switches not in required state. + * @details \b Inputs: required or not required + * @details \b Outputs: requireConnectorInPlace_CapParked + * @param door is door required to be closed in current state? + * @return none + *************************************************************************/ + // This alarm is active only during treatment and HDF is requested +void requireConnectorInPlace_CapParked( BOOL required ) +{ + requireConnectorInPlace_CapParked = required; +} + +/*********************************************************************//** + * @brief + * The requireCapClosed_CapNotParked function sets flags that determine whether + * the HDF disposable port must be blocked by the HDF cap. + * Additionally the cap must not be in the parked position. + * Associated alarms will be triggered if switches not in required state. + * @details \b Inputs: required or not required + * @details \b Outputs: requireCapClosed_CapNotParked + * @return none + *************************************************************************/ + //! This alarm is meant to be active during all non-treatment modes. This activation mechanism + // could be replaced by a mode check in handleSwitchAlarms to remove the burden + // of calling this function multiple times +void requireCapClosed_CapNotParked( BOOL required ) +{ + requireCapClosed_CapNotParked = required; +} + +/*********************************************************************//** + * @brief * The publishSwitchesData function broadcasts the switches data at the * publication interval. * @details \b Message \b Sent: MSG_ID_DD_SWITCHES_DATA Index: firmware/App/Monitors/Switches.h =================================================================== diff -u -reca350134b358d583fe4364a117d744684d28788 -rfbb3995c14aae438604df63073c0023b408a4555 --- firmware/App/Monitors/Switches.h (.../Switches.h) (revision eca350134b358d583fe4364a117d744684d28788) +++ firmware/App/Monitors/Switches.h (.../Switches.h) (revision fbb3995c14aae438604df63073c0023b408a4555) @@ -40,7 +40,7 @@ NUM_OF_SWITCHES ///< Number of switches } SWITCH_T; -/// TD switches data publish structure +/// DD switches data publish structure typedef struct { U32 d101Sw1; ///< HDF cap closed connector on switch @@ -55,7 +55,8 @@ void execSwitches( void ); OPN_CLS_STATE_T getSwitchState( SWITCH_T switchId ); - +void requireConnectorInPlace_CapParked( BOOL required ); +void requireCapClosed_CapNotParked( BOOL required ); BOOL testSwitchesDataPublishIntervalOverride( MESSAGE_T *message ); BOOL testSwitchOverride( MESSAGE_T *message ); Fisheye: Tag fbb3995c14aae438604df63073c0023b408a4555 refers to a dead (removed) revision in file `firmware/App/Services/FpgaDD.c'. Fisheye: No comparison available. Pass `N' to diff? Index: firmware/App/Services/FpgaDD.h =================================================================== diff -u -r11fcfaffab49f00f358124c8c285a821632eba24 -rfbb3995c14aae438604df63073c0023b408a4555 --- firmware/App/Services/FpgaDD.h (.../FpgaDD.h) (revision 11fcfaffab49f00f358124c8c285a821632eba24) +++ firmware/App/Services/FpgaDD.h (.../FpgaDD.h) (revision fbb3995c14aae438604df63073c0023b408a4555) @@ -322,6 +322,11 @@ U16 getFPGAP40PumpPWM( void ); U16 getFPGAP40PumpTachCount( void ); +// HDF switches +BOOL getD101HDFCapConnectorStatus( void ); +BOOL getD102HDFCapConnectorStatus( void ); +BOOL getD103HDFCapParkedStatus( void ); + /**@}*/ #endif Fisheye: Tag fbb3995c14aae438604df63073c0023b408a4555 refers to a dead (removed) revision in file `firmware/App/Tasks/TaskGeneral.c'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag fbb3995c14aae438604df63073c0023b408a4555 refers to a dead (removed) revision in file `firmware/source/sys_main.c'. Fisheye: No comparison available. Pass `N' to diff?