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. """ # Construct protocol superclass. SamiProtocol.__init__(self, prompts, newline, driver_event) ## Continue building protocol state machine from SamiProtocol self._protocol_fsm.add_handler( ProtocolState.SCHEDULED_SAMPLE, ProtocolEvent.SUCCESS, self._handler_sample_success) self._protocol_fsm.add_handler( ProtocolState.SCHEDULED_SAMPLE, ProtocolEvent.TIMEOUT, self._handler_sample_timeout) self._protocol_fsm.add_handler( ProtocolState.POLLED_SAMPLE, ProtocolEvent.SUCCESS, self._handler_sample_success) self._protocol_fsm.add_handler( ProtocolState.POLLED_SAMPLE, ProtocolEvent.TIMEOUT, self._handler_sample_timeout) # State state machine in UNKNOWN state. self._protocol_fsm.start(ProtocolState.UNKNOWN) # build the chunker bot self._chunker = StringChunker(Protocol.sieve_function)
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. """ # Construct protocol superclass. SamiProtocol.__init__(self, prompts, newline, driver_event) ## Continue building protocol state machine from SamiProtocol self._protocol_fsm.add_handler(ProtocolState.SCHEDULED_SAMPLE, ProtocolEvent.SUCCESS, self._handler_sample_success) self._protocol_fsm.add_handler(ProtocolState.SCHEDULED_SAMPLE, ProtocolEvent.TIMEOUT, self._handler_sample_timeout) self._protocol_fsm.add_handler(ProtocolState.POLLED_SAMPLE, ProtocolEvent.SUCCESS, self._handler_sample_success) self._protocol_fsm.add_handler(ProtocolState.POLLED_SAMPLE, ProtocolEvent.TIMEOUT, self._handler_sample_timeout) # State state machine in UNKNOWN state. self._protocol_fsm.start(ProtocolState.UNKNOWN) # build the chunker bot self._chunker = StringChunker(Protocol.sieve_function)
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. """ # Construct protocol superclass. SamiProtocol.__init__(self, prompts, newline, driver_event) # Build protocol state machine. ### # most of these are defined in the base class with exception of handlers # defined below that differ for the two instruments (what defines # success and the timeout duration) ### # this state would be entered whenever an ACQUIRE_SAMPLE event occurred # while in the AUTOSAMPLE state and will last anywhere from a few # seconds to ~12 minutes depending on instrument and the type of # sampling. self._protocol_fsm.add_handler(ProtocolState.SCHEDULED_SAMPLE, ProtocolEvent.SUCCESS, self._handler_sample_success) self._protocol_fsm.add_handler(ProtocolState.SCHEDULED_SAMPLE, ProtocolEvent.TIMEOUT, self._handler_sample_timeout) # this state would be entered whenever an ACQUIRE_SAMPLE event occurred # while in either the COMMAND state (or via the discover transition # from the UNKNOWN state with the instrument unresponsive) and will # last anywhere from a few seconds to 3 minutes depending on instrument # and sample type. self._protocol_fsm.add_handler(ProtocolState.POLLED_SAMPLE, ProtocolEvent.SUCCESS, self._handler_sample_success) self._protocol_fsm.add_handler(ProtocolState.POLLED_SAMPLE, ProtocolEvent.TIMEOUT, self._handler_sample_timeout) # Add build handlers for device commands. ### primarily defined in base class self._add_build_handler(InstrumentCommand.ACQUIRE_SAMPLE_DEV1, self._build_sample_dev1) # Add response handlers for device commands. ### primarily defined in base class self._add_response_handler(InstrumentCommand.ACQUIRE_SAMPLE_DEV1, self._build_response_sample_dev1) # Add sample handlers # State state machine in UNKNOWN state. self._protocol_fsm.start(ProtocolState.UNKNOWN) # build the chunker self._chunker = StringChunker(Protocol.sieve_function)
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. """ # Construct protocol superclass. SamiProtocol.__init__(self, prompts, newline, driver_event) self._protocol_fsm.add_handler( Pco2wProtocolState.COMMAND, Pco2wProtocolEvent.ACQUIRE_BLANK_SAMPLE, self._handler_command_acquire_blank_sample) self._protocol_fsm.add_handler( Pco2wProtocolState.COMMAND, Pco2wProtocolEvent.DEIONIZED_WATER_FLUSH_100ML, self._handler_command_deionized_water_flush_100ml) self._protocol_fsm.add_handler( Pco2wProtocolState.COMMAND, Pco2wProtocolEvent.REAGENT_FLUSH_100ML, self._handler_command_reagent_flush_100ml) self._protocol_fsm.add_handler( SamiProtocolState.COMMAND, Pco2wProtocolEvent.DEIONIZED_WATER_FLUSH, self._handler_command_deionized_water_flush) self._protocol_fsm.add_handler( Pco2wProtocolState.AUTOSAMPLE, Pco2wProtocolEvent.ACQUIRE_BLANK_SAMPLE, self._handler_autosample_acquire_blank_sample) # this state would be entered whenever an ACQUIRE_BLANK_SAMPLE event # occurred while in the COMMAND state # and will last anywhere from a few seconds to 3 # minutes depending on instrument and sample type. self._protocol_fsm.add_handler(Pco2wProtocolState.POLLED_BLANK_SAMPLE, Pco2wProtocolEvent.ENTER, self._execution_state_enter) self._protocol_fsm.add_handler(Pco2wProtocolState.POLLED_BLANK_SAMPLE, Pco2wProtocolEvent.EXIT, self._execution_state_exit) self._protocol_fsm.add_handler(Pco2wProtocolState.POLLED_BLANK_SAMPLE, Pco2wProtocolEvent.EXECUTE, self._handler_take_blank_sample) self._protocol_fsm.add_handler( Pco2wProtocolState.POLLED_BLANK_SAMPLE, Pco2wProtocolEvent.SUCCESS, self._execution_success_to_command_state) self._protocol_fsm.add_handler( Pco2wProtocolState.POLLED_BLANK_SAMPLE, Pco2wProtocolEvent.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(Pco2wProtocolState.POLLED_BLANK_SAMPLE, Pco2wProtocolEvent.ACQUIRE_STATUS, self._handler_queue_acquire_status) # this state would be entered whenever an ACQUIRE_BLANK_SAMPLE event # occurred while in the AUTOSAMPLE state # and will last anywhere from a few seconds to 3 # minutes depending on instrument and sample type. self._protocol_fsm.add_handler( Pco2wProtocolState.SCHEDULED_BLANK_SAMPLE, Pco2wProtocolEvent.ENTER, self._execution_state_enter) self._protocol_fsm.add_handler( Pco2wProtocolState.SCHEDULED_BLANK_SAMPLE, Pco2wProtocolEvent.EXIT, self._execution_state_exit) self._protocol_fsm.add_handler( Pco2wProtocolState.SCHEDULED_BLANK_SAMPLE, Pco2wProtocolEvent.EXECUTE, self._handler_take_blank_sample) self._protocol_fsm.add_handler( Pco2wProtocolState.SCHEDULED_BLANK_SAMPLE, Pco2wProtocolEvent.SUCCESS, self._execution_success_to_autosample_state) self._protocol_fsm.add_handler( Pco2wProtocolState.SCHEDULED_BLANK_SAMPLE, Pco2wProtocolEvent.TIMEOUT, self._execution_timeout_to_autosample_state) ## Events to queue - intended for schedulable events occurring when a sample is being taken self._protocol_fsm.add_handler( Pco2wProtocolState.SCHEDULED_BLANK_SAMPLE, Pco2wProtocolEvent.ACQUIRE_STATUS, self._handler_queue_acquire_status) # this state would be entered whenever a DEIONIZED_WATER_FLUSH_100ML event # occurred while in the COMMAND state self._protocol_fsm.add_handler( Pco2wProtocolState.DEIONIZED_WATER_FLUSH_100ML, Pco2wProtocolEvent.ENTER, self._execution_state_enter) self._protocol_fsm.add_handler( Pco2wProtocolState.DEIONIZED_WATER_FLUSH_100ML, Pco2wProtocolEvent.EXIT, self._execution_state_exit) self._protocol_fsm.add_handler( Pco2wProtocolState.DEIONIZED_WATER_FLUSH_100ML, Pco2wProtocolEvent.EXECUTE, self._handler_deionized_water_flush_execute_100ml) self._protocol_fsm.add_handler( Pco2wProtocolState.DEIONIZED_WATER_FLUSH_100ML, Pco2wProtocolEvent.SUCCESS, self._execution_success_to_command_state) self._protocol_fsm.add_handler( Pco2wProtocolState.DEIONIZED_WATER_FLUSH_100ML, Pco2wProtocolEvent.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( Pco2wProtocolState.DEIONIZED_WATER_FLUSH_100ML, Pco2wProtocolEvent.ACQUIRE_STATUS, self._handler_queue_acquire_status) # this state would be entered whenever a REAGENT_FLUSH_100ML event # occurred while in the COMMAND state self._protocol_fsm.add_handler(Pco2wProtocolState.REAGENT_FLUSH_100ML, Pco2wProtocolEvent.ENTER, self._execution_state_enter) self._protocol_fsm.add_handler(Pco2wProtocolState.REAGENT_FLUSH_100ML, Pco2wProtocolEvent.EXIT, self._execution_state_exit) self._protocol_fsm.add_handler( Pco2wProtocolState.REAGENT_FLUSH_100ML, Pco2wProtocolEvent.EXECUTE, self._handler_reagent_flush_execute_100ml) self._protocol_fsm.add_handler( Pco2wProtocolState.REAGENT_FLUSH_100ML, Pco2wProtocolEvent.SUCCESS, self._execution_success_to_command_state) self._protocol_fsm.add_handler( Pco2wProtocolState.REAGENT_FLUSH_100ML, Pco2wProtocolEvent.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(Pco2wProtocolState.REAGENT_FLUSH_100ML, Pco2wProtocolEvent.ACQUIRE_STATUS, self._handler_queue_acquire_status) # this state would be entered whenever a DEIONIZED_WATER_FLUSH event # occurred while in the COMMAND state self._protocol_fsm.add_handler( Pco2wProtocolState.DEIONIZED_WATER_FLUSH, Pco2wProtocolEvent.ENTER, self._execution_state_enter) self._protocol_fsm.add_handler( Pco2wProtocolState.DEIONIZED_WATER_FLUSH, Pco2wProtocolEvent.EXIT, self._execution_state_exit) self._protocol_fsm.add_handler( Pco2wProtocolState.DEIONIZED_WATER_FLUSH, Pco2wProtocolEvent.EXECUTE, self._handler_deionized_water_flush_execute) self._protocol_fsm.add_handler( Pco2wProtocolState.DEIONIZED_WATER_FLUSH, Pco2wProtocolEvent.SUCCESS, self._execution_success_to_command_state) self._protocol_fsm.add_handler( Pco2wProtocolState.DEIONIZED_WATER_FLUSH, Pco2wProtocolEvent.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( Pco2wProtocolState.DEIONIZED_WATER_FLUSH, Pco2wProtocolEvent.ACQUIRE_STATUS, self._handler_queue_acquire_status) self._engineering_parameters.append(Pco2wParameter.PUMP_100ML_CYCLES) self._engineering_parameters.append( Pco2wParameter.DEIONIZED_WATER_FLUSH_DURATION) self._add_build_handler( Pco2wInstrumentCommand.PCO2W_ACQUIRE_BLANK_SAMPLE, self._build_simple_command) self._add_build_handler( Pco2wInstrumentCommand.PCO2W_PUMP_DEIONIZED_WATER, self._build_pump_command) self._add_build_handler(Pco2wInstrumentCommand.PCO2W_PUMP_REAGENT, self._build_pump_command) # Add response handlers for device commands. self._add_response_handler( Pco2wInstrumentCommand.PCO2W_ACQUIRE_BLANK_SAMPLE, self._parse_response_blank_sample_sami) self._add_response_handler( Pco2wInstrumentCommand.PCO2W_PUMP_DEIONIZED_WATER, self._parse_response_newline) self._add_response_handler(Pco2wInstrumentCommand.PCO2W_PUMP_REAGENT, self._parse_response_newline)
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. """ # Construct protocol superclass. SamiProtocol.__init__(self, prompts, newline, driver_event) self._protocol_fsm.add_handler( Pco2wProtocolState.COMMAND, Pco2wProtocolEvent.ACQUIRE_BLANK_SAMPLE, self._handler_command_acquire_blank_sample) self._protocol_fsm.add_handler( Pco2wProtocolState.COMMAND, Pco2wProtocolEvent.DEIONIZED_WATER_FLUSH_100ML, self._handler_command_deionized_water_flush_100ml) self._protocol_fsm.add_handler( Pco2wProtocolState.COMMAND, Pco2wProtocolEvent.REAGENT_FLUSH_100ML, self._handler_command_reagent_flush_100ml) self._protocol_fsm.add_handler( SamiProtocolState.COMMAND, Pco2wProtocolEvent.DEIONIZED_WATER_FLUSH, self._handler_command_deionized_water_flush) self._protocol_fsm.add_handler( Pco2wProtocolState.AUTOSAMPLE, Pco2wProtocolEvent.ACQUIRE_BLANK_SAMPLE, self._handler_autosample_acquire_blank_sample) # this state would be entered whenever an ACQUIRE_BLANK_SAMPLE event # occurred while in the COMMAND state # and will last anywhere from a few seconds to 3 # minutes depending on instrument and sample type. self._protocol_fsm.add_handler( Pco2wProtocolState.POLLED_BLANK_SAMPLE, Pco2wProtocolEvent.ENTER, self._execution_state_enter) self._protocol_fsm.add_handler( Pco2wProtocolState.POLLED_BLANK_SAMPLE, Pco2wProtocolEvent.EXIT, self._execution_state_exit) self._protocol_fsm.add_handler( Pco2wProtocolState.POLLED_BLANK_SAMPLE, Pco2wProtocolEvent.EXECUTE, self._handler_take_blank_sample) self._protocol_fsm.add_handler( Pco2wProtocolState.POLLED_BLANK_SAMPLE, Pco2wProtocolEvent.SUCCESS, self._execution_success_to_command_state) self._protocol_fsm.add_handler( Pco2wProtocolState.POLLED_BLANK_SAMPLE, Pco2wProtocolEvent.TIMEOUT, self._execution_timeout_to_command_state) # this state would be entered whenever an ACQUIRE_BLANK_SAMPLE event # occurred while in the AUTOSAMPLE state # and will last anywhere from a few seconds to 3 # minutes depending on instrument and sample type. self._protocol_fsm.add_handler( Pco2wProtocolState.SCHEDULED_BLANK_SAMPLE, Pco2wProtocolEvent.ENTER, self._execution_state_enter) self._protocol_fsm.add_handler( Pco2wProtocolState.SCHEDULED_BLANK_SAMPLE, Pco2wProtocolEvent.EXIT, self._execution_state_exit) self._protocol_fsm.add_handler( Pco2wProtocolState.SCHEDULED_BLANK_SAMPLE, Pco2wProtocolEvent.EXECUTE, self._handler_take_blank_sample) self._protocol_fsm.add_handler( Pco2wProtocolState.SCHEDULED_BLANK_SAMPLE, Pco2wProtocolEvent.SUCCESS, self._execution_success_to_autosample_state) self._protocol_fsm.add_handler( Pco2wProtocolState.SCHEDULED_BLANK_SAMPLE, Pco2wProtocolEvent.TIMEOUT, self._execution_timeout_to_autosample_state) # this state would be entered whenever a DEIONIZED_WATER_FLUSH_100ML event # occurred while in the COMMAND state self._protocol_fsm.add_handler( Pco2wProtocolState.DEIONIZED_WATER_FLUSH_100ML, Pco2wProtocolEvent.ENTER, self._execution_state_enter) self._protocol_fsm.add_handler( Pco2wProtocolState.DEIONIZED_WATER_FLUSH_100ML, Pco2wProtocolEvent.EXIT, self._execution_state_exit) self._protocol_fsm.add_handler( Pco2wProtocolState.DEIONIZED_WATER_FLUSH_100ML, Pco2wProtocolEvent.EXECUTE, self._handler_deionized_water_flush_execute_100ml) self._protocol_fsm.add_handler( Pco2wProtocolState.DEIONIZED_WATER_FLUSH_100ML, Pco2wProtocolEvent.SUCCESS, self._execution_success_to_command_state) self._protocol_fsm.add_handler( Pco2wProtocolState.DEIONIZED_WATER_FLUSH_100ML, Pco2wProtocolEvent.TIMEOUT, self._execution_timeout_to_command_state) # this state would be entered whenever a REAGENT_FLUSH_100ML event # occurred while in the COMMAND state self._protocol_fsm.add_handler( Pco2wProtocolState.REAGENT_FLUSH_100ML, Pco2wProtocolEvent.ENTER, self._execution_state_enter) self._protocol_fsm.add_handler( Pco2wProtocolState.REAGENT_FLUSH_100ML, Pco2wProtocolEvent.EXIT, self._execution_state_exit) self._protocol_fsm.add_handler( Pco2wProtocolState.REAGENT_FLUSH_100ML, Pco2wProtocolEvent.EXECUTE, self._handler_reagent_flush_execute_100ml) self._protocol_fsm.add_handler( Pco2wProtocolState.REAGENT_FLUSH_100ML, Pco2wProtocolEvent.SUCCESS, self._execution_success_to_command_state) self._protocol_fsm.add_handler( Pco2wProtocolState.REAGENT_FLUSH_100ML, Pco2wProtocolEvent.TIMEOUT, self._execution_timeout_to_command_state) # this state would be entered whenever a DEIONIZED_WATER_FLUSH event # occurred while in the COMMAND state self._protocol_fsm.add_handler( Pco2wProtocolState.DEIONIZED_WATER_FLUSH, Pco2wProtocolEvent.ENTER, self._execution_state_enter) self._protocol_fsm.add_handler( Pco2wProtocolState.DEIONIZED_WATER_FLUSH, Pco2wProtocolEvent.EXIT, self._execution_state_exit) self._protocol_fsm.add_handler( Pco2wProtocolState.DEIONIZED_WATER_FLUSH, Pco2wProtocolEvent.EXECUTE, self._handler_deionized_water_flush_execute) self._protocol_fsm.add_handler( Pco2wProtocolState.DEIONIZED_WATER_FLUSH, Pco2wProtocolEvent.SUCCESS, self._execution_success_to_command_state) self._protocol_fsm.add_handler( Pco2wProtocolState.DEIONIZED_WATER_FLUSH, Pco2wProtocolEvent.TIMEOUT, self._execution_timeout_to_command_state) self._engineering_parameters.append(Pco2wParameter.PUMP_100ML_CYCLES) self._engineering_parameters.append(Pco2wParameter.DEIONIZED_WATER_FLUSH_DURATION) self._add_build_handler(Pco2wInstrumentCommand.PCO2W_ACQUIRE_BLANK_SAMPLE, self._build_simple_command) self._add_build_handler(Pco2wInstrumentCommand.PCO2W_PUMP_DEIONIZED_WATER, self._build_pump_command) self._add_build_handler(Pco2wInstrumentCommand.PCO2W_PUMP_REAGENT, self._build_pump_command) # Add response handlers for device commands. self._add_response_handler(Pco2wInstrumentCommand.PCO2W_ACQUIRE_BLANK_SAMPLE, self._parse_response_blank_sample_sami) self._add_response_handler(Pco2wInstrumentCommand.PCO2W_PUMP_DEIONIZED_WATER, self._parse_response_newline) self._add_response_handler(Pco2wInstrumentCommand.PCO2W_PUMP_REAGENT, self._parse_response_newline)