def __init__(self, prompts, newline, driver_event): """ Protocol constructor. @param prompts A BaseEnum class containing instrument prompts. @param newline The newline. @param driver_event Driver process event callback. """ # Build protocol state machine. self._protocol_fsm = ThreadSafeFSM( ProtocolState, ProtocolEvent, ProtocolEvent.ENTER, ProtocolEvent.EXIT) # Construct protocol superclass. Pco2wProtocol.__init__(self, prompts, newline, driver_event) # Build protocol state machine. self._protocol_fsm.add_handler( ProtocolState.COMMAND, ProtocolEvent.RUN_EXTERNAL_PUMP, self._handler_command_run_external_pump) # this state would be entered whenever a RUN_EXTERNAL_PUMP event # occurred while in the COMMAND state self._protocol_fsm.add_handler( ProtocolState.RUN_EXTERNAL_PUMP, ProtocolEvent.ENTER, self._execution_state_enter) self._protocol_fsm.add_handler( ProtocolState.RUN_EXTERNAL_PUMP, ProtocolEvent.EXIT, self._execution_state_exit) self._protocol_fsm.add_handler( ProtocolState.RUN_EXTERNAL_PUMP, ProtocolEvent.EXECUTE, self._handler_run_external_pump_execute) self._protocol_fsm.add_handler( ProtocolState.RUN_EXTERNAL_PUMP, ProtocolEvent.SUCCESS, self._execution_success_to_command_state) self._protocol_fsm.add_handler( ProtocolState.RUN_EXTERNAL_PUMP, ProtocolEvent.TIMEOUT, self._execution_timeout_to_command_state) ## Events to queue - intended for schedulable events occurring when a sample is being taken self._protocol_fsm.add_handler( ProtocolState.RUN_EXTERNAL_PUMP, ProtocolEvent.ACQUIRE_STATUS, self._handler_queue_acquire_status) # Add build handlers for device commands. ### primarily defined in base class self._add_build_handler(InstrumentCommand.PCO2WB_ACQUIRE_SAMPLE_DEV1, self._build_simple_command) # Add response handlers for device commands. ### primarily defined in base class self._add_response_handler(InstrumentCommand.PCO2WB_ACQUIRE_SAMPLE_DEV1, self._parse_response_sample_dev1) # Add sample handlers # Start state machine in UNKNOWN state. self._protocol_fsm.start(ProtocolState.UNKNOWN) # build the chunker self._chunker = StringChunker(Protocol.sieve_function) self._engineering_parameters.append(Parameter.EXTERNAL_PUMP_DELAY)
def __init__(self, prompts, newline, driver_event): """ Protocol constructor. @param prompts A BaseEnum class containing instrument prompts. @param newline The newline. @param driver_event Driver process event callback. """ # Build protocol state machine. self._protocol_fsm = ThreadSafeFSM(ProtocolState, ProtocolEvent, ProtocolEvent.ENTER, ProtocolEvent.EXIT) # Construct protocol superclass. Pco2wProtocol.__init__(self, prompts, newline, driver_event) # Build protocol state machine. # Start state machine in UNKNOWN state. self._protocol_fsm.start(ProtocolState.UNKNOWN) # build the chunker self._chunker = StringChunker(Protocol.sieve_function)