zaber-motion 7.13.0__py3-none-win32.whl → 7.15.0__py3-none-win32.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- zaber_motion/__init__.py +103 -103
- zaber_motion/ascii/__init__.py +73 -73
- zaber_motion/ascii/all_axes.py +352 -352
- zaber_motion/ascii/axis.py +1673 -1673
- zaber_motion/ascii/axis_group.py +391 -391
- zaber_motion/ascii/axis_settings.py +752 -752
- zaber_motion/ascii/connection.py +1174 -1174
- zaber_motion/ascii/device.py +908 -908
- zaber_motion/ascii/device_io.py +1170 -1170
- zaber_motion/ascii/device_settings.py +735 -735
- zaber_motion/ascii/lockstep.py +1184 -1184
- zaber_motion/ascii/oscilloscope.py +635 -635
- zaber_motion/ascii/oscilloscope_data.py +240 -240
- zaber_motion/ascii/pvt.py +105 -105
- zaber_motion/ascii/pvt_buffer.py +146 -146
- zaber_motion/ascii/pvt_io.py +630 -630
- zaber_motion/ascii/pvt_sequence.py +1530 -1530
- zaber_motion/ascii/servo_tuner.py +637 -637
- zaber_motion/ascii/setting_constants.py +1755 -1755
- zaber_motion/ascii/storage.py +905 -905
- zaber_motion/ascii/stream.py +2182 -2182
- zaber_motion/ascii/stream_buffer.py +101 -101
- zaber_motion/ascii/stream_io.py +700 -700
- zaber_motion/ascii/streams.py +105 -105
- zaber_motion/ascii/transport.py +202 -202
- zaber_motion/ascii/trigger.py +886 -886
- zaber_motion/ascii/triggers.py +241 -241
- zaber_motion/ascii/warning_flags.py +178 -178
- zaber_motion/ascii/warnings.py +152 -152
- zaber_motion/async_utils.py +46 -46
- zaber_motion/binary/__init__.py +14 -14
- zaber_motion/binary/connection.py +648 -648
- zaber_motion/binary/device.py +924 -924
- zaber_motion/binary/device_settings.py +121 -121
- zaber_motion/bindings.py +50 -50
- zaber_motion/call.py +198 -198
- zaber_motion/convert_exception.py +138 -138
- zaber_motion/dto/__init__.py +11 -11
- zaber_motion/dto/ascii/__init__.py +46 -46
- zaber_motion/dto/ascii/alert_event.py +110 -110
- zaber_motion/dto/ascii/axis_identity.py +134 -134
- zaber_motion/dto/ascii/axis_type.py +14 -14
- zaber_motion/dto/ascii/can_set_state_axis_response.py +69 -69
- zaber_motion/dto/ascii/can_set_state_device_response.py +75 -75
- zaber_motion/dto/ascii/conversion_factor.py +81 -81
- zaber_motion/dto/ascii/device_identity.py +136 -136
- zaber_motion/dto/ascii/device_io_info.py +108 -108
- zaber_motion/dto/ascii/digital_output_action.py +13 -13
- zaber_motion/dto/ascii/get_axis_setting.py +64 -64
- zaber_motion/dto/ascii/get_axis_setting_result.py +81 -81
- zaber_motion/dto/ascii/get_setting.py +88 -88
- zaber_motion/dto/ascii/get_setting_result.py +87 -87
- zaber_motion/dto/ascii/io_port_label.py +84 -84
- zaber_motion/dto/ascii/io_port_type.py +14 -14
- zaber_motion/dto/ascii/lockstep_axes.py +108 -108
- zaber_motion/dto/ascii/measurement_sequence.py +73 -73
- zaber_motion/dto/ascii/message_type.py +14 -14
- zaber_motion/dto/ascii/optional_measurement_sequence.py +71 -71
- zaber_motion/dto/ascii/oscilloscope_capture_properties.py +116 -116
- zaber_motion/dto/ascii/oscilloscope_data_source.py +11 -11
- zaber_motion/dto/ascii/paramset_info.py +92 -92
- zaber_motion/dto/ascii/pid_tuning.py +125 -125
- zaber_motion/dto/ascii/pvt_axis_definition.py +70 -70
- zaber_motion/dto/ascii/pvt_axis_type.py +11 -11
- zaber_motion/dto/ascii/pvt_csv_data.py +75 -75
- zaber_motion/dto/ascii/pvt_mode.py +12 -12
- zaber_motion/dto/ascii/pvt_sequence_data.py +99 -99
- zaber_motion/dto/ascii/response.py +137 -137
- zaber_motion/dto/ascii/servo_tuning_param.py +66 -66
- zaber_motion/dto/ascii/servo_tuning_paramset.py +21 -21
- zaber_motion/dto/ascii/set_state_axis_response.py +75 -75
- zaber_motion/dto/ascii/set_state_device_response.py +80 -80
- zaber_motion/dto/ascii/simple_tuning.py +118 -118
- zaber_motion/dto/ascii/simple_tuning_param_definition.py +100 -100
- zaber_motion/dto/ascii/stream_axis_definition.py +70 -70
- zaber_motion/dto/ascii/stream_axis_type.py +11 -11
- zaber_motion/dto/ascii/stream_mode.py +13 -13
- zaber_motion/dto/ascii/trigger_action.py +12 -12
- zaber_motion/dto/ascii/trigger_condition.py +15 -15
- zaber_motion/dto/ascii/trigger_enabled_state.py +68 -68
- zaber_motion/dto/ascii/trigger_operation.py +12 -12
- zaber_motion/dto/ascii/trigger_state.py +114 -114
- zaber_motion/dto/ascii/unknown_response_event.py +137 -137
- zaber_motion/dto/axis_address.py +74 -74
- zaber_motion/dto/binary/__init__.py +11 -11
- zaber_motion/dto/binary/binary_settings.py +74 -74
- zaber_motion/dto/binary/command_code.py +106 -106
- zaber_motion/dto/binary/device_identity.py +156 -156
- zaber_motion/dto/binary/device_type.py +12 -12
- zaber_motion/dto/binary/error_code.py +101 -101
- zaber_motion/dto/binary/message.py +91 -91
- zaber_motion/dto/binary/reply_code.py +16 -16
- zaber_motion/dto/binary/reply_only_event.py +91 -91
- zaber_motion/dto/binary/unknown_response_event.py +91 -91
- zaber_motion/dto/channel_address.py +74 -74
- zaber_motion/dto/device_db_source.py +66 -66
- zaber_motion/dto/device_db_source_type.py +11 -11
- zaber_motion/dto/exceptions/__init__.py +24 -24
- zaber_motion/dto/exceptions/binary_command_failed_exception_data.py +57 -57
- zaber_motion/dto/exceptions/command_failed_exception_data.py +151 -151
- zaber_motion/dto/exceptions/command_too_long_exception_data.py +98 -98
- zaber_motion/dto/exceptions/device_address_conflict_exception_data.py +63 -63
- zaber_motion/dto/exceptions/device_db_failed_exception_data.py +74 -74
- zaber_motion/dto/exceptions/device_db_inner_error.py +85 -85
- zaber_motion/dto/exceptions/g_code_execution_exception_data.py +75 -75
- zaber_motion/dto/exceptions/g_code_syntax_exception_data.py +75 -75
- zaber_motion/dto/exceptions/invalid_packet_exception_data.py +63 -63
- zaber_motion/dto/exceptions/invalid_pvt_point.py +69 -69
- zaber_motion/dto/exceptions/invalid_response_exception_data.py +51 -51
- zaber_motion/dto/exceptions/movement_failed_exception_data.py +104 -104
- zaber_motion/dto/exceptions/movement_interrupted_exception_data.py +104 -104
- zaber_motion/dto/exceptions/operation_failed_exception_data.py +104 -104
- zaber_motion/dto/exceptions/pvt_execution_exception_data.py +86 -86
- zaber_motion/dto/exceptions/pvt_movement_failed_exception_data.py +69 -69
- zaber_motion/dto/exceptions/pvt_movement_interrupted_exception_data.py +69 -69
- zaber_motion/dto/exceptions/set_device_state_exception_data.py +176 -176
- zaber_motion/dto/exceptions/set_peripheral_state_exception_data.py +121 -121
- zaber_motion/dto/exceptions/stream_execution_exception_data.py +63 -63
- zaber_motion/dto/exceptions/stream_movement_failed_exception_data.py +69 -69
- zaber_motion/dto/exceptions/stream_movement_interrupted_exception_data.py +69 -69
- zaber_motion/dto/firmware_version.py +91 -91
- zaber_motion/dto/gcode/__init__.py +9 -9
- zaber_motion/dto/gcode/axis_definition.py +74 -74
- zaber_motion/dto/gcode/axis_mapping.py +69 -69
- zaber_motion/dto/gcode/axis_transformation.py +79 -79
- zaber_motion/dto/gcode/device_definition.py +99 -99
- zaber_motion/dto/gcode/translate_message.py +87 -87
- zaber_motion/dto/gcode/translate_result.py +79 -79
- zaber_motion/dto/gcode/translator_config.py +84 -84
- zaber_motion/dto/log_output_mode.py +13 -13
- zaber_motion/dto/measurement.py +67 -67
- zaber_motion/dto/microscopy/__init__.py +6 -6
- zaber_motion/dto/microscopy/autofocus_status.py +57 -57
- zaber_motion/dto/microscopy/microscope_config.py +159 -159
- zaber_motion/dto/microscopy/third_party_components.py +55 -55
- zaber_motion/dto/microscopy/wdi_autofocus_provider_status.py +57 -57
- zaber_motion/dto/named_parameter.py +64 -64
- zaber_motion/dto/product/__init__.py +5 -5
- zaber_motion/dto/product/process_controller_mode.py +13 -13
- zaber_motion/dto/product/process_controller_source.py +72 -72
- zaber_motion/dto/product/process_controller_source_sensor.py +11 -11
- zaber_motion/dto/requests/__init__.py +256 -254
- zaber_motion/dto/requests/alert_event_wrapper.py +82 -82
- zaber_motion/dto/requests/autofocus_focus_request.py +131 -131
- zaber_motion/dto/requests/autofocus_get_objective_params_request.py +121 -121
- zaber_motion/dto/requests/autofocus_get_objective_params_response.py +56 -56
- zaber_motion/dto/requests/autofocus_get_status_response.py +50 -50
- zaber_motion/dto/requests/autofocus_set_objective_params_request.py +141 -141
- zaber_motion/dto/requests/axes_empty_request.py +95 -95
- zaber_motion/dto/requests/axes_get_setting_request.py +121 -121
- zaber_motion/dto/requests/axes_move_request.py +114 -114
- zaber_motion/dto/requests/axis_empty_request.py +79 -79
- zaber_motion/dto/requests/axis_move_type.py +12 -12
- zaber_motion/dto/requests/axis_to_string_request.py +88 -88
- zaber_motion/dto/requests/binary_device_detect_request.py +56 -56
- zaber_motion/dto/requests/binary_device_detect_response.py +57 -57
- zaber_motion/dto/requests/binary_device_get_setting_request.py +89 -89
- zaber_motion/dto/requests/binary_device_home_request.py +88 -88
- zaber_motion/dto/requests/binary_device_move_request.py +111 -111
- zaber_motion/dto/requests/binary_device_set_setting_request.py +100 -100
- zaber_motion/dto/requests/binary_device_stop_request.py +88 -88
- zaber_motion/dto/requests/binary_generic_with_units_request.py +122 -122
- zaber_motion/dto/requests/binary_message_collection.py +56 -56
- zaber_motion/dto/requests/binary_reply_only_event_wrapper.py +82 -82
- zaber_motion/dto/requests/bool_response.py +43 -43
- zaber_motion/dto/requests/can_set_state_axis_response.py +60 -60
- zaber_motion/dto/requests/can_set_state_request.py +100 -100
- zaber_motion/dto/requests/channel_on.py +96 -84
- zaber_motion/dto/requests/channel_set_intensity.py +90 -90
- zaber_motion/dto/requests/check_version_request.py +54 -54
- zaber_motion/dto/requests/custom_interface_close_request.py +60 -60
- zaber_motion/dto/requests/custom_interface_open_response.py +51 -51
- zaber_motion/dto/requests/custom_interface_read_request.py +51 -51
- zaber_motion/dto/requests/custom_interface_write_request.py +60 -60
- zaber_motion/dto/requests/device_cancel_all_outputs_schedule_request.py +80 -80
- zaber_motion/dto/requests/device_cancel_output_schedule_request.py +84 -84
- zaber_motion/dto/requests/device_convert_setting_request.py +116 -116
- zaber_motion/dto/requests/device_detect_request.py +68 -68
- zaber_motion/dto/requests/device_detect_response.py +57 -57
- zaber_motion/dto/requests/device_empty_request.py +65 -65
- zaber_motion/dto/requests/device_get_all_analog_io_request.py +74 -74
- zaber_motion/dto/requests/device_get_all_analog_io_response.py +54 -54
- zaber_motion/dto/requests/device_get_all_digital_io_request.py +74 -74
- zaber_motion/dto/requests/device_get_all_digital_io_response.py +46 -46
- zaber_motion/dto/requests/device_get_analog_io_request.py +88 -88
- zaber_motion/dto/requests/device_get_digital_io_request.py +88 -88
- zaber_motion/dto/requests/device_get_setting_request.py +100 -100
- zaber_motion/dto/requests/device_get_storage_request.py +93 -93
- zaber_motion/dto/requests/device_get_warnings_request.py +84 -84
- zaber_motion/dto/requests/device_get_warnings_response.py +51 -51
- zaber_motion/dto/requests/device_home_request.py +84 -84
- zaber_motion/dto/requests/device_identify_request.py +77 -77
- zaber_motion/dto/requests/device_move_request.py +177 -177
- zaber_motion/dto/requests/device_move_sin_request.py +140 -140
- zaber_motion/dto/requests/device_multi_get_setting_request.py +118 -118
- zaber_motion/dto/requests/device_on_all_request.py +56 -56
- zaber_motion/dto/requests/device_on_all_response.py +57 -57
- zaber_motion/dto/requests/device_restore_request.py +84 -84
- zaber_motion/dto/requests/device_set_all_analog_outputs_request.py +82 -82
- zaber_motion/dto/requests/device_set_all_analog_outputs_schedule_request.py +121 -121
- zaber_motion/dto/requests/device_set_all_digital_outputs_request.py +83 -83
- zaber_motion/dto/requests/device_set_all_digital_outputs_schedule_request.py +122 -122
- zaber_motion/dto/requests/device_set_analog_output_request.py +90 -90
- zaber_motion/dto/requests/device_set_analog_output_schedule_request.py +124 -124
- zaber_motion/dto/requests/device_set_digital_output_request.py +91 -91
- zaber_motion/dto/requests/device_set_digital_output_schedule_request.py +125 -125
- zaber_motion/dto/requests/device_set_lowpass_filter_request.py +102 -102
- zaber_motion/dto/requests/device_set_setting_bool_request.py +93 -93
- zaber_motion/dto/requests/device_set_setting_int_request.py +102 -102
- zaber_motion/dto/requests/device_set_setting_request.py +111 -111
- zaber_motion/dto/requests/device_set_setting_str_request.py +97 -97
- zaber_motion/dto/requests/device_set_storage_bool_request.py +93 -93
- zaber_motion/dto/requests/device_set_storage_number_request.py +99 -99
- zaber_motion/dto/requests/device_set_storage_request.py +102 -102
- zaber_motion/dto/requests/device_set_unit_conversions_request.py +108 -108
- zaber_motion/dto/requests/device_stop_request.py +84 -84
- zaber_motion/dto/requests/device_storage_list_keys_request.py +88 -88
- zaber_motion/dto/requests/device_storage_request.py +88 -88
- zaber_motion/dto/requests/device_type.py +8 -8
- zaber_motion/dto/requests/device_wait_until_idle_request.py +84 -84
- zaber_motion/dto/requests/disconnected_event.py +101 -101
- zaber_motion/dto/requests/double_array_response.py +54 -54
- zaber_motion/dto/requests/double_response.py +48 -48
- zaber_motion/dto/requests/driver_enable_request.py +90 -90
- zaber_motion/dto/requests/empty_autofocus_request.py +107 -107
- zaber_motion/dto/requests/empty_request.py +38 -38
- zaber_motion/dto/requests/errors.py +68 -68
- zaber_motion/dto/requests/find_device_request.py +65 -65
- zaber_motion/dto/requests/find_device_response.py +51 -51
- zaber_motion/dto/requests/forget_devices_request.py +71 -71
- zaber_motion/dto/requests/gateway_event.py +45 -45
- zaber_motion/dto/requests/gateway_request.py +45 -45
- zaber_motion/dto/requests/gateway_response.py +69 -69
- zaber_motion/dto/requests/generic_binary_request.py +107 -107
- zaber_motion/dto/requests/generic_command_request.py +107 -107
- zaber_motion/dto/requests/generic_command_response_collection.py +56 -56
- zaber_motion/dto/requests/get_all_io_port_labels_response.py +56 -56
- zaber_motion/dto/requests/get_axis_setting_results.py +56 -56
- zaber_motion/dto/requests/get_io_port_label_request.py +91 -91
- zaber_motion/dto/requests/get_setting_results.py +56 -56
- zaber_motion/dto/requests/get_simple_tuning_param_definition_response.py +56 -56
- zaber_motion/dto/requests/int_64_response.py +51 -51
- zaber_motion/dto/requests/int_array_response.py +57 -57
- zaber_motion/dto/requests/int_request.py +51 -51
- zaber_motion/dto/requests/int_response.py +51 -51
- zaber_motion/dto/requests/interface_empty_request.py +51 -51
- zaber_motion/dto/requests/interface_type.py +11 -11
- zaber_motion/dto/requests/load_paramset.py +102 -102
- zaber_motion/dto/requests/lockstep_disable_request.py +84 -84
- zaber_motion/dto/requests/lockstep_empty_request.py +79 -79
- zaber_motion/dto/requests/lockstep_enable_request.py +99 -99
- zaber_motion/dto/requests/lockstep_get_axis_numbers_response.py +57 -57
- zaber_motion/dto/requests/lockstep_get_request.py +91 -91
- zaber_motion/dto/requests/lockstep_home_request.py +84 -84
- zaber_motion/dto/requests/lockstep_move_request.py +163 -163
- zaber_motion/dto/requests/lockstep_move_sin_request.py +140 -140
- zaber_motion/dto/requests/lockstep_set_request.py +116 -116
- zaber_motion/dto/requests/lockstep_stop_request.py +84 -84
- zaber_motion/dto/requests/lockstep_wait_until_idle_request.py +84 -84
- zaber_motion/dto/requests/microscope_config_response.py +50 -50
- zaber_motion/dto/requests/microscope_empty_request.py +65 -65
- zaber_motion/dto/requests/microscope_find_request.py +63 -63
- zaber_motion/dto/requests/microscope_init_request.py +70 -70
- zaber_motion/dto/requests/microscope_trigger_camera_request.py +107 -107
- zaber_motion/dto/requests/objective_changer_change_request.py +119 -119
- zaber_motion/dto/requests/objective_changer_create_response.py +79 -79
- zaber_motion/dto/requests/objective_changer_get_current_response.py +51 -51
- zaber_motion/dto/requests/objective_changer_request.py +93 -93
- zaber_motion/dto/requests/objective_changer_set_request.py +116 -116
- zaber_motion/dto/requests/open_binary_interface_request.py +100 -100
- zaber_motion/dto/requests/open_interface_request.py +159 -159
- zaber_motion/dto/requests/open_interface_response.py +51 -51
- zaber_motion/dto/requests/oscilloscope_add_io_channel_request.py +91 -91
- zaber_motion/dto/requests/oscilloscope_add_setting_channel_request.py +88 -88
- zaber_motion/dto/requests/oscilloscope_data_get_request.py +63 -63
- zaber_motion/dto/requests/oscilloscope_data_get_sample_time_request.py +77 -77
- zaber_motion/dto/requests/oscilloscope_data_get_samples_response.py +54 -54
- zaber_motion/dto/requests/oscilloscope_data_identifier.py +51 -51
- zaber_motion/dto/requests/oscilloscope_read_response.py +57 -57
- zaber_motion/dto/requests/oscilloscope_request.py +65 -65
- zaber_motion/dto/requests/oscilloscope_start_request.py +79 -79
- zaber_motion/dto/requests/prepare_command_request.py +108 -108
- zaber_motion/dto/requests/process_on.py +107 -107
- zaber_motion/dto/requests/pvt_buffer_get_sequence_data_request.py +79 -79
- zaber_motion/dto/requests/pvt_csv_request.py +59 -59
- zaber_motion/dto/requests/pvt_generate_positions_request.py +74 -74
- zaber_motion/dto/requests/pvt_generate_velocities_and_times_request.py +96 -96
- zaber_motion/dto/requests/pvt_generate_velocities_request.py +93 -93
- zaber_motion/dto/requests/pvt_load_csv_request.py +45 -45
- zaber_motion/dto/requests/pvt_point_request.py +145 -145
- zaber_motion/dto/requests/pvt_points_request.py +147 -147
- zaber_motion/dto/requests/pvt_save_csv_request.py +74 -74
- zaber_motion/dto/requests/pvt_submit_sequence_data_request.py +93 -93
- zaber_motion/dto/requests/renumber_request.py +79 -79
- zaber_motion/dto/requests/response_type.py +8 -8
- zaber_motion/dto/requests/servo_tuning_paramset_response.py +48 -48
- zaber_motion/dto/requests/servo_tuning_request.py +91 -91
- zaber_motion/dto/requests/set_device_db_layered_sources_request.py +56 -56
- zaber_motion/dto/requests/set_device_db_source_request.py +63 -63
- zaber_motion/dto/requests/set_interface_checksum_enabled_request.py +56 -56
- zaber_motion/dto/requests/set_interface_timeout_request.py +65 -65
- zaber_motion/dto/requests/set_internal_mode_request.py +43 -43
- zaber_motion/dto/requests/set_io_port_label_request.py +100 -100
- zaber_motion/dto/requests/set_log_output_request.py +57 -57
- zaber_motion/dto/requests/set_process_controller_source.py +93 -93
- zaber_motion/dto/requests/set_servo_tuning_pid_request.py +135 -135
- zaber_motion/dto/requests/set_servo_tuning_request.py +116 -116
- zaber_motion/dto/requests/set_simple_tuning.py +174 -174
- zaber_motion/dto/requests/set_state_request.py +93 -93
- zaber_motion/dto/requests/stream_arc_request.py +199 -199
- zaber_motion/dto/requests/stream_buffer_erase_request.py +84 -84
- zaber_motion/dto/requests/stream_buffer_get_content_request.py +84 -84
- zaber_motion/dto/requests/stream_buffer_get_content_response.py +51 -51
- zaber_motion/dto/requests/stream_buffer_list.py +70 -70
- zaber_motion/dto/requests/stream_call_request.py +112 -112
- zaber_motion/dto/requests/stream_cancel_all_outputs_schedule_request.py +99 -99
- zaber_motion/dto/requests/stream_cancel_output_schedule_request.py +103 -103
- zaber_motion/dto/requests/stream_circle_request.py +155 -155
- zaber_motion/dto/requests/stream_empty_request.py +84 -84
- zaber_motion/dto/requests/stream_generic_command_batch_request.py +99 -99
- zaber_motion/dto/requests/stream_generic_command_request.py +93 -93
- zaber_motion/dto/requests/stream_get_axes_response.py +75 -75
- zaber_motion/dto/requests/stream_get_max_centripetal_acceleration_request.py +96 -96
- zaber_motion/dto/requests/stream_get_max_speed_request.py +96 -96
- zaber_motion/dto/requests/stream_get_max_tangential_acceleration_request.py +96 -96
- zaber_motion/dto/requests/stream_line_request.py +135 -135
- zaber_motion/dto/requests/stream_mode_response.py +60 -60
- zaber_motion/dto/requests/stream_segment_type.py +8 -8
- zaber_motion/dto/requests/stream_set_all_analog_outputs_request.py +101 -101
- zaber_motion/dto/requests/stream_set_all_analog_outputs_schedule_request.py +140 -140
- zaber_motion/dto/requests/stream_set_all_digital_outputs_request.py +102 -102
- zaber_motion/dto/requests/stream_set_all_digital_outputs_schedule_request.py +141 -141
- zaber_motion/dto/requests/stream_set_analog_output_request.py +109 -109
- zaber_motion/dto/requests/stream_set_analog_output_schedule_request.py +143 -143
- zaber_motion/dto/requests/stream_set_digital_output_request.py +110 -110
- zaber_motion/dto/requests/stream_set_digital_output_schedule_request.py +144 -144
- zaber_motion/dto/requests/stream_set_hold_request.py +89 -89
- zaber_motion/dto/requests/stream_set_max_centripetal_acceleration_request.py +107 -107
- zaber_motion/dto/requests/stream_set_max_speed_request.py +107 -107
- zaber_motion/dto/requests/stream_set_max_tangential_acceleration_request.py +107 -107
- zaber_motion/dto/requests/stream_setup_live_composite_request.py +123 -123
- zaber_motion/dto/requests/stream_setup_live_request.py +104 -104
- zaber_motion/dto/requests/stream_setup_store_arbitrary_axes_request.py +126 -126
- zaber_motion/dto/requests/stream_setup_store_composite_request.py +151 -151
- zaber_motion/dto/requests/stream_setup_store_request.py +132 -132
- zaber_motion/dto/requests/stream_wait_analog_input_request.py +118 -118
- zaber_motion/dto/requests/stream_wait_digital_input_request.py +103 -103
- zaber_motion/dto/requests/stream_wait_request.py +107 -107
- zaber_motion/dto/requests/stream_wait_until_idle_request.py +89 -89
- zaber_motion/dto/requests/string_array_response.py +51 -51
- zaber_motion/dto/requests/string_response.py +45 -45
- zaber_motion/dto/requests/test_event.py +45 -45
- zaber_motion/dto/requests/test_request.py +55 -55
- zaber_motion/dto/requests/test_request_complex.py +57 -0
- zaber_motion/dto/requests/test_response.py +45 -45
- zaber_motion/dto/requests/test_response_long.py +51 -51
- zaber_motion/dto/requests/toggle_device_db_store_request.py +50 -50
- zaber_motion/dto/requests/tools_list_serial_ports_response.py +51 -51
- zaber_motion/dto/requests/translator_create_from_device_request.py +97 -97
- zaber_motion/dto/requests/translator_create_live_request.py +91 -91
- zaber_motion/dto/requests/translator_create_request.py +62 -62
- zaber_motion/dto/requests/translator_create_response.py +51 -51
- zaber_motion/dto/requests/translator_empty_request.py +51 -51
- zaber_motion/dto/requests/translator_flush_live_request.py +56 -56
- zaber_motion/dto/requests/translator_flush_response.py +51 -51
- zaber_motion/dto/requests/translator_get_axis_offset_request.py +81 -81
- zaber_motion/dto/requests/translator_get_axis_position_request.py +72 -72
- zaber_motion/dto/requests/translator_set_axis_position_request.py +83 -83
- zaber_motion/dto/requests/translator_set_feed_rate_override_request.py +62 -62
- zaber_motion/dto/requests/translator_set_traverse_rate_request.py +74 -74
- zaber_motion/dto/requests/translator_translate_request.py +60 -60
- zaber_motion/dto/requests/trigger_clear_action_request.py +91 -91
- zaber_motion/dto/requests/trigger_empty_request.py +79 -79
- zaber_motion/dto/requests/trigger_enable_request.py +93 -93
- zaber_motion/dto/requests/trigger_enabled_states.py +56 -56
- zaber_motion/dto/requests/trigger_fire_at_interval_request.py +102 -102
- zaber_motion/dto/requests/trigger_fire_when_distance_travelled_request.py +116 -116
- zaber_motion/dto/requests/trigger_fire_when_io_request.py +128 -128
- zaber_motion/dto/requests/trigger_fire_when_request.py +88 -88
- zaber_motion/dto/requests/trigger_fire_when_setting_request.py +137 -137
- zaber_motion/dto/requests/trigger_on_fire_request.py +114 -114
- zaber_motion/dto/requests/trigger_on_fire_set_request.py +149 -149
- zaber_motion/dto/requests/trigger_on_fire_set_to_setting_request.py +149 -149
- zaber_motion/dto/requests/trigger_set_label_request.py +88 -88
- zaber_motion/dto/requests/trigger_states.py +56 -56
- zaber_motion/dto/requests/unit_convert_unit_request.py +71 -71
- zaber_motion/dto/requests/unit_get_enum_request.py +45 -45
- zaber_motion/dto/requests/unit_get_enum_response.py +48 -48
- zaber_motion/dto/requests/unit_get_symbol_request.py +48 -48
- zaber_motion/dto/requests/unit_get_symbol_response.py +45 -45
- zaber_motion/dto/requests/unknown_binary_response_event_wrapper.py +82 -82
- zaber_motion/dto/requests/unknown_response_event_wrapper.py +82 -82
- zaber_motion/dto/requests/wait_to_clear_warnings_request.py +105 -105
- zaber_motion/dto/requests/wait_to_respond_request.py +76 -76
- zaber_motion/dto/requests/wdi_generic_float_request.py +119 -0
- zaber_motion/dto/requests/wdi_generic_request.py +136 -136
- zaber_motion/dto/requests/wdi_get_status_response.py +50 -50
- zaber_motion/dto/rotation_direction.py +13 -13
- zaber_motion/dto_object.py +18 -18
- zaber_motion/events.py +112 -112
- zaber_motion/exceptions/__init__.py +87 -87
- zaber_motion/exceptions/bad_command_exception.py +10 -10
- zaber_motion/exceptions/bad_data_exception.py +10 -10
- zaber_motion/exceptions/binary_command_failed_exception.py +27 -27
- zaber_motion/exceptions/command_failed_exception.py +27 -27
- zaber_motion/exceptions/command_preempted_exception.py +10 -10
- zaber_motion/exceptions/command_too_long_exception.py +27 -27
- zaber_motion/exceptions/connection_closed_exception.py +10 -10
- zaber_motion/exceptions/connection_failed_exception.py +10 -10
- zaber_motion/exceptions/conversion_failed_exception.py +10 -10
- zaber_motion/exceptions/device_address_conflict_exception.py +27 -27
- zaber_motion/exceptions/device_busy_exception.py +10 -10
- zaber_motion/exceptions/device_db_failed_exception.py +27 -27
- zaber_motion/exceptions/device_detection_failed_exception.py +10 -10
- zaber_motion/exceptions/device_failed_exception.py +11 -11
- zaber_motion/exceptions/device_not_identified_exception.py +10 -10
- zaber_motion/exceptions/driver_disabled_exception.py +10 -10
- zaber_motion/exceptions/g_code_execution_exception.py +27 -27
- zaber_motion/exceptions/g_code_syntax_exception.py +27 -27
- zaber_motion/exceptions/incompatible_shared_library_exception.py +11 -11
- zaber_motion/exceptions/internal_error_exception.py +10 -10
- zaber_motion/exceptions/invalid_argument_exception.py +10 -10
- zaber_motion/exceptions/invalid_csv_data_exception.py +10 -10
- zaber_motion/exceptions/invalid_data_exception.py +10 -10
- zaber_motion/exceptions/invalid_operation_exception.py +10 -10
- zaber_motion/exceptions/invalid_packet_exception.py +27 -27
- zaber_motion/exceptions/invalid_park_state_exception.py +10 -10
- zaber_motion/exceptions/invalid_request_data_exception.py +11 -11
- zaber_motion/exceptions/invalid_response_exception.py +27 -27
- zaber_motion/exceptions/io_channel_out_of_range_exception.py +10 -10
- zaber_motion/exceptions/io_failed_exception.py +10 -10
- zaber_motion/exceptions/lockstep_enabled_exception.py +10 -10
- zaber_motion/exceptions/lockstep_not_enabled_exception.py +10 -10
- zaber_motion/exceptions/motion_lib_exception.py +18 -18
- zaber_motion/exceptions/movement_failed_exception.py +27 -27
- zaber_motion/exceptions/movement_interrupted_exception.py +27 -27
- zaber_motion/exceptions/no_device_found_exception.py +10 -10
- zaber_motion/exceptions/no_value_for_key_exception.py +10 -10
- zaber_motion/exceptions/not_supported_exception.py +10 -10
- zaber_motion/exceptions/operation_failed_exception.py +27 -27
- zaber_motion/exceptions/os_failed_exception.py +10 -10
- zaber_motion/exceptions/out_of_request_ids_exception.py +10 -10
- zaber_motion/exceptions/pvt_discontinuity_exception.py +10 -10
- zaber_motion/exceptions/pvt_execution_exception.py +27 -27
- zaber_motion/exceptions/pvt_mode_exception.py +10 -10
- zaber_motion/exceptions/pvt_movement_failed_exception.py +27 -27
- zaber_motion/exceptions/pvt_movement_interrupted_exception.py +27 -27
- zaber_motion/exceptions/pvt_sequence_generation_failed_exception.py +10 -10
- zaber_motion/exceptions/pvt_setup_failed_exception.py +10 -10
- zaber_motion/exceptions/remote_mode_exception.py +11 -11
- zaber_motion/exceptions/request_timeout_exception.py +10 -10
- zaber_motion/exceptions/serial_port_busy_exception.py +10 -10
- zaber_motion/exceptions/set_device_state_failed_exception.py +27 -27
- zaber_motion/exceptions/set_peripheral_state_failed_exception.py +27 -27
- zaber_motion/exceptions/setting_not_found_exception.py +10 -10
- zaber_motion/exceptions/stream_discontinuity_exception.py +10 -10
- zaber_motion/exceptions/stream_execution_exception.py +27 -27
- zaber_motion/exceptions/stream_mode_exception.py +10 -10
- zaber_motion/exceptions/stream_movement_failed_exception.py +27 -27
- zaber_motion/exceptions/stream_movement_interrupted_exception.py +27 -27
- zaber_motion/exceptions/stream_setup_failed_exception.py +10 -10
- zaber_motion/exceptions/timeout_exception.py +10 -10
- zaber_motion/exceptions/transport_already_used_exception.py +10 -10
- zaber_motion/exceptions/unknown_request_exception.py +10 -10
- zaber_motion/gcode/__init__.py +11 -11
- zaber_motion/gcode/offline_translator.py +401 -401
- zaber_motion/gcode/translator.py +424 -424
- zaber_motion/library.py +179 -179
- zaber_motion/microscopy/__init__.py +14 -14
- zaber_motion/microscopy/autofocus.py +645 -645
- zaber_motion/microscopy/camera_trigger.py +108 -108
- zaber_motion/microscopy/filter_changer.py +167 -167
- zaber_motion/microscopy/illuminator.py +163 -139
- zaber_motion/microscopy/illuminator_channel.py +629 -616
- zaber_motion/microscopy/microscope.py +315 -315
- zaber_motion/microscopy/objective_changer.py +403 -403
- zaber_motion/microscopy/wdi_autofocus_provider.py +536 -396
- zaber_motion/product/__init__.py +7 -7
- zaber_motion/product/process.py +818 -818
- zaber_motion/product/process_controller.py +134 -134
- zaber_motion/serialization.py +32 -32
- zaber_motion/tools.py +78 -78
- zaber_motion/unit_table.py +86 -86
- zaber_motion/units.py +206 -206
- zaber_motion/version.py +1 -1
- {zaber_motion-7.13.0.dist-info → zaber_motion-7.15.0.dist-info}/LICENSE.txt +2119 -2119
- {zaber_motion-7.13.0.dist-info → zaber_motion-7.15.0.dist-info}/METADATA +1 -1
- zaber_motion-7.15.0.dist-info/RECORD +496 -0
- zaber_motion_bindings/zaber-motion-core-windows-386.dll +0 -0
- zaber_motion-7.13.0.dist-info/RECORD +0 -494
- {zaber_motion-7.13.0.dist-info → zaber_motion-7.15.0.dist-info}/WHEEL +0 -0
- {zaber_motion-7.13.0.dist-info → zaber_motion-7.15.0.dist-info}/top_level.txt +0 -0
zaber_motion/ascii/connection.py
CHANGED
|
@@ -1,1174 +1,1174 @@
|
|
|
1
|
-
# ===== THIS FILE IS GENERATED FROM A TEMPLATE ===== #
|
|
2
|
-
# ============== DO NOT EDIT DIRECTLY ============== #
|
|
3
|
-
|
|
4
|
-
from typing import Generator, List, Any, Optional, TypeVar
|
|
5
|
-
import asyncio
|
|
6
|
-
from reactivex.subject import ReplaySubject
|
|
7
|
-
from reactivex import operators as rxop, Observable
|
|
8
|
-
|
|
9
|
-
from ..call import call, call_async, call_sync
|
|
10
|
-
from ..convert_exception import convert_exception
|
|
11
|
-
from ..events import filter_events
|
|
12
|
-
from ..exceptions.motion_lib_exception import MotionLibException
|
|
13
|
-
|
|
14
|
-
from .device import Device
|
|
15
|
-
from .transport import Transport
|
|
16
|
-
from ..dto.ascii.response import Response
|
|
17
|
-
from ..dto.ascii.unknown_response_event import UnknownResponseEvent
|
|
18
|
-
from ..dto.ascii.alert_event import AlertEvent
|
|
19
|
-
from ..dto import requests as dto
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
TConnectionEvents = TypeVar(
|
|
23
|
-
"TConnectionEvents",
|
|
24
|
-
dto.UnknownResponseEventWrapper,
|
|
25
|
-
dto.AlertEventWrapper,
|
|
26
|
-
dto.DisconnectedEvent)
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
class Connection:
|
|
30
|
-
"""
|
|
31
|
-
Class representing access to particular connection (serial port, TCP connection).
|
|
32
|
-
"""
|
|
33
|
-
|
|
34
|
-
@property
|
|
35
|
-
def unknown_response(self) -> Observable[UnknownResponseEvent]:
|
|
36
|
-
"""
|
|
37
|
-
Event invoked when a response from a device cannot be matched to any known request.
|
|
38
|
-
"""
|
|
39
|
-
return self._unknown_response
|
|
40
|
-
|
|
41
|
-
@property
|
|
42
|
-
def alert(self) -> Observable[AlertEvent]:
|
|
43
|
-
"""
|
|
44
|
-
Event invoked when an alert is received from a device.
|
|
45
|
-
"""
|
|
46
|
-
return self._alert
|
|
47
|
-
|
|
48
|
-
@property
|
|
49
|
-
def disconnected(self) -> Observable[MotionLibException]:
|
|
50
|
-
"""
|
|
51
|
-
Event invoked when connection is interrupted or closed.
|
|
52
|
-
"""
|
|
53
|
-
return self._disconnected
|
|
54
|
-
|
|
55
|
-
DEFAULT_BAUD_RATE = 115200
|
|
56
|
-
"""
|
|
57
|
-
Default baud rate for serial connections.
|
|
58
|
-
"""
|
|
59
|
-
|
|
60
|
-
TCP_PORT_CHAIN = 55550
|
|
61
|
-
"""
|
|
62
|
-
Commands sent over this port are forwarded to the device chain.
|
|
63
|
-
The bandwidth may be limited as the commands are forwarded over a serial connection.
|
|
64
|
-
"""
|
|
65
|
-
|
|
66
|
-
NETWORK_SHARE_PORT = 11421
|
|
67
|
-
"""
|
|
68
|
-
Local area network share port.
|
|
69
|
-
"""
|
|
70
|
-
|
|
71
|
-
TCP_PORT_DEVICE_ONLY = 55551
|
|
72
|
-
"""
|
|
73
|
-
Commands send over this port are processed only by the device
|
|
74
|
-
and not forwarded to the rest of the chain.
|
|
75
|
-
Using this port typically makes the communication faster.
|
|
76
|
-
"""
|
|
77
|
-
|
|
78
|
-
@property
|
|
79
|
-
def interface_id(self) -> int:
|
|
80
|
-
"""
|
|
81
|
-
The interface ID identifies this Connection instance with the underlying library.
|
|
82
|
-
"""
|
|
83
|
-
return self._interface_id
|
|
84
|
-
|
|
85
|
-
@property
|
|
86
|
-
def default_request_timeout(self) -> int:
|
|
87
|
-
"""
|
|
88
|
-
The default timeout, in milliseconds, for a device to respond to a request.
|
|
89
|
-
Setting the timeout to a too low value may cause request timeout exceptions.
|
|
90
|
-
The initial value is 1000 (one second).
|
|
91
|
-
"""
|
|
92
|
-
return self.__retrieve_timeout()
|
|
93
|
-
|
|
94
|
-
@default_request_timeout.setter
|
|
95
|
-
def default_request_timeout(self, value: int) -> None:
|
|
96
|
-
"""
|
|
97
|
-
The default timeout, in milliseconds, for a device to respond to a request.
|
|
98
|
-
Setting the timeout to a too low value may cause request timeout exceptions.
|
|
99
|
-
The initial value is 1000 (one second).
|
|
100
|
-
"""
|
|
101
|
-
self.__change_timeout(value)
|
|
102
|
-
|
|
103
|
-
@property
|
|
104
|
-
def checksum_enabled(self) -> bool:
|
|
105
|
-
"""
|
|
106
|
-
Controls whether outgoing messages contain checksum.
|
|
107
|
-
"""
|
|
108
|
-
return self.__retrieve_checksum_enabled()
|
|
109
|
-
|
|
110
|
-
@checksum_enabled.setter
|
|
111
|
-
def checksum_enabled(self, value: bool) -> None:
|
|
112
|
-
"""
|
|
113
|
-
Controls whether outgoing messages contain checksum.
|
|
114
|
-
"""
|
|
115
|
-
self.__change_checksum_enabled(value)
|
|
116
|
-
|
|
117
|
-
@property
|
|
118
|
-
def is_open(self) -> bool:
|
|
119
|
-
"""
|
|
120
|
-
Returns whether the connection is open.
|
|
121
|
-
Does not guarantee that subsequent requests will succeed.
|
|
122
|
-
"""
|
|
123
|
-
return self.__retrieve_is_open()
|
|
124
|
-
|
|
125
|
-
def __init__(self, interface_id: int):
|
|
126
|
-
self._interface_id: int = interface_id
|
|
127
|
-
self.__setup_events(0)
|
|
128
|
-
|
|
129
|
-
@staticmethod
|
|
130
|
-
def open_serial_port(
|
|
131
|
-
port_name: str,
|
|
132
|
-
baud_rate: int = DEFAULT_BAUD_RATE,
|
|
133
|
-
direct: bool = False
|
|
134
|
-
) -> 'Connection':
|
|
135
|
-
"""
|
|
136
|
-
Opens a serial port, if Zaber Launcher controls the port, the port will be opened through Zaber Launcher.
|
|
137
|
-
Zaber Launcher allows sharing of the port between multiple applications,
|
|
138
|
-
If port sharing is not desirable, use the `direct` parameter.
|
|
139
|
-
|
|
140
|
-
Args:
|
|
141
|
-
port_name: Name of the port to open.
|
|
142
|
-
baud_rate: Optional baud rate (defaults to 115200).
|
|
143
|
-
direct: If true will connect to the serial port directly,
|
|
144
|
-
failing if the connection is already opened by a message router instance.
|
|
145
|
-
|
|
146
|
-
Returns:
|
|
147
|
-
An object representing the port.
|
|
148
|
-
"""
|
|
149
|
-
request = dto.OpenInterfaceRequest(
|
|
150
|
-
interface_type=dto.InterfaceType.SERIAL_PORT,
|
|
151
|
-
port_name=port_name,
|
|
152
|
-
baud_rate=baud_rate,
|
|
153
|
-
reject_routed_connection=direct,
|
|
154
|
-
)
|
|
155
|
-
response = call(
|
|
156
|
-
"interface/open",
|
|
157
|
-
request,
|
|
158
|
-
dto.OpenInterfaceResponse.from_binary)
|
|
159
|
-
return Connection(response.interface_id)
|
|
160
|
-
|
|
161
|
-
@staticmethod
|
|
162
|
-
def open_serial_port_async(
|
|
163
|
-
port_name: str,
|
|
164
|
-
baud_rate: int = DEFAULT_BAUD_RATE,
|
|
165
|
-
direct: bool = False
|
|
166
|
-
) -> 'AsyncConnectionOpener':
|
|
167
|
-
"""
|
|
168
|
-
Opens a serial port, if Zaber Launcher controls the port, the port will be opened through Zaber Launcher.
|
|
169
|
-
Zaber Launcher allows sharing of the port between multiple applications,
|
|
170
|
-
If port sharing is not desirable, use the `direct` parameter.
|
|
171
|
-
|
|
172
|
-
Args:
|
|
173
|
-
port_name: Name of the port to open.
|
|
174
|
-
baud_rate: Optional baud rate (defaults to 115200).
|
|
175
|
-
direct: If true will connect to the serial port directly,
|
|
176
|
-
failing if the connection is already opened by a message router instance.
|
|
177
|
-
|
|
178
|
-
Returns:
|
|
179
|
-
An object representing the port.
|
|
180
|
-
"""
|
|
181
|
-
request = dto.OpenInterfaceRequest(
|
|
182
|
-
interface_type=dto.InterfaceType.SERIAL_PORT,
|
|
183
|
-
port_name=port_name,
|
|
184
|
-
baud_rate=baud_rate,
|
|
185
|
-
reject_routed_connection=direct,
|
|
186
|
-
)
|
|
187
|
-
return AsyncConnectionOpener(request)
|
|
188
|
-
|
|
189
|
-
@staticmethod
|
|
190
|
-
def open_tcp(
|
|
191
|
-
host_name: str,
|
|
192
|
-
port: int = TCP_PORT_CHAIN
|
|
193
|
-
) -> 'Connection':
|
|
194
|
-
"""
|
|
195
|
-
Opens a TCP connection.
|
|
196
|
-
|
|
197
|
-
Args:
|
|
198
|
-
host_name: Hostname or IP address.
|
|
199
|
-
port: Optional port number (defaults to 55550).
|
|
200
|
-
|
|
201
|
-
Returns:
|
|
202
|
-
An object representing the connection.
|
|
203
|
-
"""
|
|
204
|
-
request = dto.OpenInterfaceRequest(
|
|
205
|
-
interface_type=dto.InterfaceType.TCP,
|
|
206
|
-
host_name=host_name,
|
|
207
|
-
port=port,
|
|
208
|
-
)
|
|
209
|
-
response = call(
|
|
210
|
-
"interface/open",
|
|
211
|
-
request,
|
|
212
|
-
dto.OpenInterfaceResponse.from_binary)
|
|
213
|
-
return Connection(response.interface_id)
|
|
214
|
-
|
|
215
|
-
@staticmethod
|
|
216
|
-
def open_tcp_async(
|
|
217
|
-
host_name: str,
|
|
218
|
-
port: int = TCP_PORT_CHAIN
|
|
219
|
-
) -> 'AsyncConnectionOpener':
|
|
220
|
-
"""
|
|
221
|
-
Opens a TCP connection.
|
|
222
|
-
|
|
223
|
-
Args:
|
|
224
|
-
host_name: Hostname or IP address.
|
|
225
|
-
port: Optional port number (defaults to 55550).
|
|
226
|
-
|
|
227
|
-
Returns:
|
|
228
|
-
An object representing the connection.
|
|
229
|
-
"""
|
|
230
|
-
request = dto.OpenInterfaceRequest(
|
|
231
|
-
interface_type=dto.InterfaceType.TCP,
|
|
232
|
-
host_name=host_name,
|
|
233
|
-
port=port,
|
|
234
|
-
)
|
|
235
|
-
return AsyncConnectionOpener(request)
|
|
236
|
-
|
|
237
|
-
@staticmethod
|
|
238
|
-
def open_custom(
|
|
239
|
-
transport: Transport
|
|
240
|
-
) -> 'Connection':
|
|
241
|
-
"""
|
|
242
|
-
Opens a connection using a custom transport.
|
|
243
|
-
|
|
244
|
-
Args:
|
|
245
|
-
transport: The custom connection transport.
|
|
246
|
-
|
|
247
|
-
Returns:
|
|
248
|
-
An object representing the connection.
|
|
249
|
-
"""
|
|
250
|
-
request = dto.OpenInterfaceRequest(
|
|
251
|
-
interface_type=dto.InterfaceType.CUSTOM,
|
|
252
|
-
transport=transport.transport_id,
|
|
253
|
-
)
|
|
254
|
-
response = call(
|
|
255
|
-
"interface/open",
|
|
256
|
-
request,
|
|
257
|
-
dto.OpenInterfaceResponse.from_binary)
|
|
258
|
-
return Connection(response.interface_id)
|
|
259
|
-
|
|
260
|
-
@staticmethod
|
|
261
|
-
def open_custom_async(
|
|
262
|
-
transport: Transport
|
|
263
|
-
) -> 'AsyncConnectionOpener':
|
|
264
|
-
"""
|
|
265
|
-
Opens a connection using a custom transport.
|
|
266
|
-
|
|
267
|
-
Args:
|
|
268
|
-
transport: The custom connection transport.
|
|
269
|
-
|
|
270
|
-
Returns:
|
|
271
|
-
An object representing the connection.
|
|
272
|
-
"""
|
|
273
|
-
request = dto.OpenInterfaceRequest(
|
|
274
|
-
interface_type=dto.InterfaceType.CUSTOM,
|
|
275
|
-
transport=transport.transport_id,
|
|
276
|
-
)
|
|
277
|
-
return AsyncConnectionOpener(request)
|
|
278
|
-
|
|
279
|
-
@staticmethod
|
|
280
|
-
def open_iot(
|
|
281
|
-
cloud_id: str,
|
|
282
|
-
token: str = "unauthenticated",
|
|
283
|
-
connection_name: Optional[str] = None,
|
|
284
|
-
realm: Optional[str] = None,
|
|
285
|
-
api: str = "https://api.zaber.io"
|
|
286
|
-
) -> 'Connection':
|
|
287
|
-
"""
|
|
288
|
-
Opens a secured connection to a cloud connected device chain.
|
|
289
|
-
Use this method to connect to devices on your account.
|
|
290
|
-
|
|
291
|
-
Args:
|
|
292
|
-
cloud_id: The cloud ID to connect to.
|
|
293
|
-
token: The token to authenticate with. By default the connection will be unauthenticated.
|
|
294
|
-
connection_name: The name of the connection to open.
|
|
295
|
-
Can be left empty to default to the only connection present.
|
|
296
|
-
Otherwise, use serial port name for serial port connection or hostname:port for TCP connection.
|
|
297
|
-
realm: The realm to connect to.
|
|
298
|
-
Can be left empty for the default account realm.
|
|
299
|
-
api: The URL of the API to receive connection info from.
|
|
300
|
-
|
|
301
|
-
Returns:
|
|
302
|
-
An object representing the connection.
|
|
303
|
-
"""
|
|
304
|
-
request = dto.OpenInterfaceRequest(
|
|
305
|
-
interface_type=dto.InterfaceType.IOT,
|
|
306
|
-
cloud_id=cloud_id,
|
|
307
|
-
token=token,
|
|
308
|
-
connection_name=connection_name,
|
|
309
|
-
realm=realm,
|
|
310
|
-
api=api,
|
|
311
|
-
)
|
|
312
|
-
response = call(
|
|
313
|
-
"interface/open",
|
|
314
|
-
request,
|
|
315
|
-
dto.OpenInterfaceResponse.from_binary)
|
|
316
|
-
return Connection(response.interface_id)
|
|
317
|
-
|
|
318
|
-
@staticmethod
|
|
319
|
-
def open_iot_async(
|
|
320
|
-
cloud_id: str,
|
|
321
|
-
token: str = "unauthenticated",
|
|
322
|
-
connection_name: Optional[str] = None,
|
|
323
|
-
realm: Optional[str] = None,
|
|
324
|
-
api: str = "https://api.zaber.io"
|
|
325
|
-
) -> 'AsyncConnectionOpener':
|
|
326
|
-
"""
|
|
327
|
-
Opens a secured connection to a cloud connected device chain.
|
|
328
|
-
Use this method to connect to devices on your account.
|
|
329
|
-
|
|
330
|
-
Args:
|
|
331
|
-
cloud_id: The cloud ID to connect to.
|
|
332
|
-
token: The token to authenticate with. By default the connection will be unauthenticated.
|
|
333
|
-
connection_name: The name of the connection to open.
|
|
334
|
-
Can be left empty to default to the only connection present.
|
|
335
|
-
Otherwise, use serial port name for serial port connection or hostname:port for TCP connection.
|
|
336
|
-
realm: The realm to connect to.
|
|
337
|
-
Can be left empty for the default account realm.
|
|
338
|
-
api: The URL of the API to receive connection info from.
|
|
339
|
-
|
|
340
|
-
Returns:
|
|
341
|
-
An object representing the connection.
|
|
342
|
-
"""
|
|
343
|
-
request = dto.OpenInterfaceRequest(
|
|
344
|
-
interface_type=dto.InterfaceType.IOT,
|
|
345
|
-
cloud_id=cloud_id,
|
|
346
|
-
token=token,
|
|
347
|
-
connection_name=connection_name,
|
|
348
|
-
realm=realm,
|
|
349
|
-
api=api,
|
|
350
|
-
)
|
|
351
|
-
return AsyncConnectionOpener(request)
|
|
352
|
-
|
|
353
|
-
@staticmethod
|
|
354
|
-
def open_network_share(
|
|
355
|
-
host_name: str,
|
|
356
|
-
port: int = NETWORK_SHARE_PORT,
|
|
357
|
-
connection_name: Optional[str] = None
|
|
358
|
-
) -> 'Connection':
|
|
359
|
-
"""
|
|
360
|
-
Opens a connection to Zaber Launcher in your Local Area Network.
|
|
361
|
-
The connection is not secured.
|
|
362
|
-
|
|
363
|
-
Args:
|
|
364
|
-
host_name: Hostname or IP address.
|
|
365
|
-
port: Port number.
|
|
366
|
-
connection_name: The name of the connection to open.
|
|
367
|
-
Can be left empty to default to the only connection present.
|
|
368
|
-
Otherwise, use serial port name for serial port connection or hostname:port for TCP connection.
|
|
369
|
-
|
|
370
|
-
Returns:
|
|
371
|
-
An object representing the connection.
|
|
372
|
-
"""
|
|
373
|
-
request = dto.OpenInterfaceRequest(
|
|
374
|
-
interface_type=dto.InterfaceType.NETWORK_SHARE,
|
|
375
|
-
host_name=host_name,
|
|
376
|
-
port=port,
|
|
377
|
-
connection_name=connection_name,
|
|
378
|
-
)
|
|
379
|
-
response = call(
|
|
380
|
-
"interface/open",
|
|
381
|
-
request,
|
|
382
|
-
dto.OpenInterfaceResponse.from_binary)
|
|
383
|
-
return Connection(response.interface_id)
|
|
384
|
-
|
|
385
|
-
@staticmethod
|
|
386
|
-
def open_network_share_async(
|
|
387
|
-
host_name: str,
|
|
388
|
-
port: int = NETWORK_SHARE_PORT,
|
|
389
|
-
connection_name: Optional[str] = None
|
|
390
|
-
) -> 'AsyncConnectionOpener':
|
|
391
|
-
"""
|
|
392
|
-
Opens a connection to Zaber Launcher in your Local Area Network.
|
|
393
|
-
The connection is not secured.
|
|
394
|
-
|
|
395
|
-
Args:
|
|
396
|
-
host_name: Hostname or IP address.
|
|
397
|
-
port: Port number.
|
|
398
|
-
connection_name: The name of the connection to open.
|
|
399
|
-
Can be left empty to default to the only connection present.
|
|
400
|
-
Otherwise, use serial port name for serial port connection or hostname:port for TCP connection.
|
|
401
|
-
|
|
402
|
-
Returns:
|
|
403
|
-
An object representing the connection.
|
|
404
|
-
"""
|
|
405
|
-
request = dto.OpenInterfaceRequest(
|
|
406
|
-
interface_type=dto.InterfaceType.NETWORK_SHARE,
|
|
407
|
-
host_name=host_name,
|
|
408
|
-
port=port,
|
|
409
|
-
connection_name=connection_name,
|
|
410
|
-
)
|
|
411
|
-
return AsyncConnectionOpener(request)
|
|
412
|
-
|
|
413
|
-
def reopen(
|
|
414
|
-
self
|
|
415
|
-
) -> None:
|
|
416
|
-
"""
|
|
417
|
-
Reopens the connection.
|
|
418
|
-
To continue using events on the connection, you must resubscribe to event observables.
|
|
419
|
-
Throws an exception if the connection is already open.
|
|
420
|
-
"""
|
|
421
|
-
request = dto.InterfaceEmptyRequest(
|
|
422
|
-
interface_id=self.interface_id,
|
|
423
|
-
)
|
|
424
|
-
response = call(
|
|
425
|
-
"interface/reopen",
|
|
426
|
-
request,
|
|
427
|
-
dto.IntResponse.from_binary)
|
|
428
|
-
self.__setup_events(response.value)
|
|
429
|
-
|
|
430
|
-
async def reopen_async(
|
|
431
|
-
self
|
|
432
|
-
) -> None:
|
|
433
|
-
"""
|
|
434
|
-
Reopens the connection.
|
|
435
|
-
To continue using events on the connection, you must resubscribe to event observables.
|
|
436
|
-
Throws an exception if the connection is already open.
|
|
437
|
-
"""
|
|
438
|
-
request = dto.InterfaceEmptyRequest(
|
|
439
|
-
interface_id=self.interface_id,
|
|
440
|
-
)
|
|
441
|
-
response = await call_async(
|
|
442
|
-
"interface/reopen",
|
|
443
|
-
request,
|
|
444
|
-
dto.IntResponse.from_binary)
|
|
445
|
-
self.__setup_events(response.value)
|
|
446
|
-
|
|
447
|
-
def generic_command(
|
|
448
|
-
self,
|
|
449
|
-
command: str,
|
|
450
|
-
device: int = 0,
|
|
451
|
-
axis: int = 0,
|
|
452
|
-
check_errors: bool = True,
|
|
453
|
-
timeout: int = 0
|
|
454
|
-
) -> Response:
|
|
455
|
-
"""
|
|
456
|
-
Sends a generic ASCII command to this connection.
|
|
457
|
-
For more information refer to the [ASCII Protocol Manual](https://www.zaber.com/protocol-manual#topic_commands).
|
|
458
|
-
|
|
459
|
-
Args:
|
|
460
|
-
command: Command and its parameters.
|
|
461
|
-
device: Optional device address to send the command to.
|
|
462
|
-
axis: Optional axis number to send the command to.
|
|
463
|
-
check_errors: Controls whether to throw an exception when the device rejects the command.
|
|
464
|
-
timeout: The timeout, in milliseconds, for a device to respond to the command.
|
|
465
|
-
Overrides the connection default request timeout.
|
|
466
|
-
|
|
467
|
-
Returns:
|
|
468
|
-
A response to the command.
|
|
469
|
-
"""
|
|
470
|
-
request = dto.GenericCommandRequest(
|
|
471
|
-
interface_id=self.interface_id,
|
|
472
|
-
command=command,
|
|
473
|
-
device=device,
|
|
474
|
-
axis=axis,
|
|
475
|
-
check_errors=check_errors,
|
|
476
|
-
timeout=timeout,
|
|
477
|
-
)
|
|
478
|
-
response = call(
|
|
479
|
-
"interface/generic_command",
|
|
480
|
-
request,
|
|
481
|
-
Response.from_binary)
|
|
482
|
-
return response
|
|
483
|
-
|
|
484
|
-
async def generic_command_async(
|
|
485
|
-
self,
|
|
486
|
-
command: str,
|
|
487
|
-
device: int = 0,
|
|
488
|
-
axis: int = 0,
|
|
489
|
-
check_errors: bool = True,
|
|
490
|
-
timeout: int = 0
|
|
491
|
-
) -> Response:
|
|
492
|
-
"""
|
|
493
|
-
Sends a generic ASCII command to this connection.
|
|
494
|
-
For more information refer to the [ASCII Protocol Manual](https://www.zaber.com/protocol-manual#topic_commands).
|
|
495
|
-
|
|
496
|
-
Args:
|
|
497
|
-
command: Command and its parameters.
|
|
498
|
-
device: Optional device address to send the command to.
|
|
499
|
-
axis: Optional axis number to send the command to.
|
|
500
|
-
check_errors: Controls whether to throw an exception when the device rejects the command.
|
|
501
|
-
timeout: The timeout, in milliseconds, for a device to respond to the command.
|
|
502
|
-
Overrides the connection default request timeout.
|
|
503
|
-
|
|
504
|
-
Returns:
|
|
505
|
-
A response to the command.
|
|
506
|
-
"""
|
|
507
|
-
request = dto.GenericCommandRequest(
|
|
508
|
-
interface_id=self.interface_id,
|
|
509
|
-
command=command,
|
|
510
|
-
device=device,
|
|
511
|
-
axis=axis,
|
|
512
|
-
check_errors=check_errors,
|
|
513
|
-
timeout=timeout,
|
|
514
|
-
)
|
|
515
|
-
response = await call_async(
|
|
516
|
-
"interface/generic_command",
|
|
517
|
-
request,
|
|
518
|
-
Response.from_binary)
|
|
519
|
-
return response
|
|
520
|
-
|
|
521
|
-
def generic_command_no_response(
|
|
522
|
-
self,
|
|
523
|
-
command: str,
|
|
524
|
-
device: int = 0,
|
|
525
|
-
axis: int = 0
|
|
526
|
-
) -> None:
|
|
527
|
-
"""
|
|
528
|
-
Sends a generic ASCII command to this connection without expecting a response and without adding a message ID.
|
|
529
|
-
For more information refer to the [ASCII Protocol Manual](https://www.zaber.com/protocol-manual#topic_commands).
|
|
530
|
-
|
|
531
|
-
Args:
|
|
532
|
-
command: Command and its parameters.
|
|
533
|
-
device: Optional device address to send the command to.
|
|
534
|
-
Specifying -1 omits the number completely.
|
|
535
|
-
axis: Optional axis number to send the command to.
|
|
536
|
-
Specifying -1 omits the number completely.
|
|
537
|
-
"""
|
|
538
|
-
request = dto.GenericCommandRequest(
|
|
539
|
-
interface_id=self.interface_id,
|
|
540
|
-
command=command,
|
|
541
|
-
device=device,
|
|
542
|
-
axis=axis,
|
|
543
|
-
)
|
|
544
|
-
call("interface/generic_command_no_response", request)
|
|
545
|
-
|
|
546
|
-
async def generic_command_no_response_async(
|
|
547
|
-
self,
|
|
548
|
-
command: str,
|
|
549
|
-
device: int = 0,
|
|
550
|
-
axis: int = 0
|
|
551
|
-
) -> None:
|
|
552
|
-
"""
|
|
553
|
-
Sends a generic ASCII command to this connection without expecting a response and without adding a message ID.
|
|
554
|
-
For more information refer to the [ASCII Protocol Manual](https://www.zaber.com/protocol-manual#topic_commands).
|
|
555
|
-
|
|
556
|
-
Args:
|
|
557
|
-
command: Command and its parameters.
|
|
558
|
-
device: Optional device address to send the command to.
|
|
559
|
-
Specifying -1 omits the number completely.
|
|
560
|
-
axis: Optional axis number to send the command to.
|
|
561
|
-
Specifying -1 omits the number completely.
|
|
562
|
-
"""
|
|
563
|
-
request = dto.GenericCommandRequest(
|
|
564
|
-
interface_id=self.interface_id,
|
|
565
|
-
command=command,
|
|
566
|
-
device=device,
|
|
567
|
-
axis=axis,
|
|
568
|
-
)
|
|
569
|
-
await call_async("interface/generic_command_no_response", request)
|
|
570
|
-
|
|
571
|
-
def generic_command_multi_response(
|
|
572
|
-
self,
|
|
573
|
-
command: str,
|
|
574
|
-
device: int = 0,
|
|
575
|
-
axis: int = 0,
|
|
576
|
-
check_errors: bool = True,
|
|
577
|
-
timeout: int = 0
|
|
578
|
-
) -> List[Response]:
|
|
579
|
-
"""
|
|
580
|
-
Sends a generic ASCII command to this connection and expect multiple responses,
|
|
581
|
-
either from one device or from many devices.
|
|
582
|
-
Responses are returned in order of arrival.
|
|
583
|
-
For more information refer to the [ASCII Protocol Manual](https://www.zaber.com/protocol-manual#topic_commands).
|
|
584
|
-
|
|
585
|
-
Args:
|
|
586
|
-
command: Command and its parameters.
|
|
587
|
-
device: Optional device address to send the command to.
|
|
588
|
-
axis: Optional axis number to send the command to.
|
|
589
|
-
check_errors: Controls whether to throw an exception when a device rejects the command.
|
|
590
|
-
timeout: The timeout, in milliseconds, for a device to respond to the command.
|
|
591
|
-
Overrides the connection default request timeout.
|
|
592
|
-
|
|
593
|
-
Returns:
|
|
594
|
-
All responses to the command.
|
|
595
|
-
"""
|
|
596
|
-
request = dto.GenericCommandRequest(
|
|
597
|
-
interface_id=self.interface_id,
|
|
598
|
-
command=command,
|
|
599
|
-
device=device,
|
|
600
|
-
axis=axis,
|
|
601
|
-
check_errors=check_errors,
|
|
602
|
-
timeout=timeout,
|
|
603
|
-
)
|
|
604
|
-
response = call(
|
|
605
|
-
"interface/generic_command_multi_response",
|
|
606
|
-
request,
|
|
607
|
-
dto.GenericCommandResponseCollection.from_binary)
|
|
608
|
-
return response.responses
|
|
609
|
-
|
|
610
|
-
async def generic_command_multi_response_async(
|
|
611
|
-
self,
|
|
612
|
-
command: str,
|
|
613
|
-
device: int = 0,
|
|
614
|
-
axis: int = 0,
|
|
615
|
-
check_errors: bool = True,
|
|
616
|
-
timeout: int = 0
|
|
617
|
-
) -> List[Response]:
|
|
618
|
-
"""
|
|
619
|
-
Sends a generic ASCII command to this connection and expect multiple responses,
|
|
620
|
-
either from one device or from many devices.
|
|
621
|
-
Responses are returned in order of arrival.
|
|
622
|
-
For more information refer to the [ASCII Protocol Manual](https://www.zaber.com/protocol-manual#topic_commands).
|
|
623
|
-
|
|
624
|
-
Args:
|
|
625
|
-
command: Command and its parameters.
|
|
626
|
-
device: Optional device address to send the command to.
|
|
627
|
-
axis: Optional axis number to send the command to.
|
|
628
|
-
check_errors: Controls whether to throw an exception when a device rejects the command.
|
|
629
|
-
timeout: The timeout, in milliseconds, for a device to respond to the command.
|
|
630
|
-
Overrides the connection default request timeout.
|
|
631
|
-
|
|
632
|
-
Returns:
|
|
633
|
-
All responses to the command.
|
|
634
|
-
"""
|
|
635
|
-
request = dto.GenericCommandRequest(
|
|
636
|
-
interface_id=self.interface_id,
|
|
637
|
-
command=command,
|
|
638
|
-
device=device,
|
|
639
|
-
axis=axis,
|
|
640
|
-
check_errors=check_errors,
|
|
641
|
-
timeout=timeout,
|
|
642
|
-
)
|
|
643
|
-
response = await call_async(
|
|
644
|
-
"interface/generic_command_multi_response",
|
|
645
|
-
request,
|
|
646
|
-
dto.GenericCommandResponseCollection.from_binary)
|
|
647
|
-
return response.responses
|
|
648
|
-
|
|
649
|
-
def enable_alerts(
|
|
650
|
-
self
|
|
651
|
-
) -> None:
|
|
652
|
-
"""
|
|
653
|
-
Enables alerts for all devices on the connection.
|
|
654
|
-
This will change the "comm.alert" setting to 1 on all supported devices.
|
|
655
|
-
"""
|
|
656
|
-
request = dto.GenericCommandRequest(
|
|
657
|
-
interface_id=self.interface_id,
|
|
658
|
-
command="set comm.alert 1",
|
|
659
|
-
)
|
|
660
|
-
call("interface/generic_command_no_response", request)
|
|
661
|
-
|
|
662
|
-
async def enable_alerts_async(
|
|
663
|
-
self
|
|
664
|
-
) -> None:
|
|
665
|
-
"""
|
|
666
|
-
Enables alerts for all devices on the connection.
|
|
667
|
-
This will change the "comm.alert" setting to 1 on all supported devices.
|
|
668
|
-
"""
|
|
669
|
-
request = dto.GenericCommandRequest(
|
|
670
|
-
interface_id=self.interface_id,
|
|
671
|
-
command="set comm.alert 1",
|
|
672
|
-
)
|
|
673
|
-
await call_async("interface/generic_command_no_response", request)
|
|
674
|
-
|
|
675
|
-
def disable_alerts(
|
|
676
|
-
self
|
|
677
|
-
) -> None:
|
|
678
|
-
"""
|
|
679
|
-
Disables alerts for all devices on the connection.
|
|
680
|
-
This will change the "comm.alert" setting to 0 on all supported devices.
|
|
681
|
-
"""
|
|
682
|
-
request = dto.GenericCommandRequest(
|
|
683
|
-
interface_id=self.interface_id,
|
|
684
|
-
command="set comm.alert 0",
|
|
685
|
-
)
|
|
686
|
-
call("interface/generic_command_no_response", request)
|
|
687
|
-
|
|
688
|
-
async def disable_alerts_async(
|
|
689
|
-
self
|
|
690
|
-
) -> None:
|
|
691
|
-
"""
|
|
692
|
-
Disables alerts for all devices on the connection.
|
|
693
|
-
This will change the "comm.alert" setting to 0 on all supported devices.
|
|
694
|
-
"""
|
|
695
|
-
request = dto.GenericCommandRequest(
|
|
696
|
-
interface_id=self.interface_id,
|
|
697
|
-
command="set comm.alert 0",
|
|
698
|
-
)
|
|
699
|
-
await call_async("interface/generic_command_no_response", request)
|
|
700
|
-
|
|
701
|
-
def reset_ids(
|
|
702
|
-
self
|
|
703
|
-
) -> None:
|
|
704
|
-
"""
|
|
705
|
-
Resets ASCII protocol message IDs. Only for testing purposes.
|
|
706
|
-
"""
|
|
707
|
-
request = dto.InterfaceEmptyRequest(
|
|
708
|
-
interface_id=self.interface_id,
|
|
709
|
-
)
|
|
710
|
-
call_sync("interface/reset_ids", request)
|
|
711
|
-
|
|
712
|
-
def close(
|
|
713
|
-
self
|
|
714
|
-
) -> None:
|
|
715
|
-
"""
|
|
716
|
-
Close the connection.
|
|
717
|
-
"""
|
|
718
|
-
request = dto.InterfaceEmptyRequest(
|
|
719
|
-
interface_id=self.interface_id,
|
|
720
|
-
)
|
|
721
|
-
call("interface/close", request)
|
|
722
|
-
|
|
723
|
-
async def close_async(
|
|
724
|
-
self
|
|
725
|
-
) -> None:
|
|
726
|
-
"""
|
|
727
|
-
Close the connection.
|
|
728
|
-
"""
|
|
729
|
-
request = dto.InterfaceEmptyRequest(
|
|
730
|
-
interface_id=self.interface_id,
|
|
731
|
-
)
|
|
732
|
-
await call_async("interface/close", request)
|
|
733
|
-
|
|
734
|
-
def get_device(
|
|
735
|
-
self,
|
|
736
|
-
device_address: int
|
|
737
|
-
) -> Device:
|
|
738
|
-
"""
|
|
739
|
-
Gets a Device class instance which allows you to control a particular device on this connection.
|
|
740
|
-
Devices are numbered from 1.
|
|
741
|
-
|
|
742
|
-
Args:
|
|
743
|
-
device_address: Address of device intended to control. Address is configured for each device.
|
|
744
|
-
|
|
745
|
-
Returns:
|
|
746
|
-
Device instance.
|
|
747
|
-
"""
|
|
748
|
-
if device_address <= 0:
|
|
749
|
-
raise ValueError('Invalid value; physical devices are numbered from 1.')
|
|
750
|
-
|
|
751
|
-
return Device(self, device_address)
|
|
752
|
-
|
|
753
|
-
def renumber_devices(
|
|
754
|
-
self,
|
|
755
|
-
first_address: int = 1
|
|
756
|
-
) -> int:
|
|
757
|
-
"""
|
|
758
|
-
Renumbers devices present on this connection. After renumbering, devices need to be identified again.
|
|
759
|
-
|
|
760
|
-
Args:
|
|
761
|
-
first_address: This is the address that the device closest to the computer is given.
|
|
762
|
-
Remaining devices are numbered consecutively.
|
|
763
|
-
|
|
764
|
-
Returns:
|
|
765
|
-
Total number of devices that responded to the renumber.
|
|
766
|
-
"""
|
|
767
|
-
if first_address <= 0:
|
|
768
|
-
raise ValueError('Invalid value; device addresses are numbered from 1.')
|
|
769
|
-
|
|
770
|
-
request = dto.RenumberRequest(
|
|
771
|
-
interface_id=self.interface_id,
|
|
772
|
-
address=first_address,
|
|
773
|
-
)
|
|
774
|
-
response = call(
|
|
775
|
-
"device/renumber_all",
|
|
776
|
-
request,
|
|
777
|
-
dto.IntResponse.from_binary)
|
|
778
|
-
return response.value
|
|
779
|
-
|
|
780
|
-
async def renumber_devices_async(
|
|
781
|
-
self,
|
|
782
|
-
first_address: int = 1
|
|
783
|
-
) -> int:
|
|
784
|
-
"""
|
|
785
|
-
Renumbers devices present on this connection. After renumbering, devices need to be identified again.
|
|
786
|
-
|
|
787
|
-
Args:
|
|
788
|
-
first_address: This is the address that the device closest to the computer is given.
|
|
789
|
-
Remaining devices are numbered consecutively.
|
|
790
|
-
|
|
791
|
-
Returns:
|
|
792
|
-
Total number of devices that responded to the renumber.
|
|
793
|
-
"""
|
|
794
|
-
if first_address <= 0:
|
|
795
|
-
raise ValueError('Invalid value; device addresses are numbered from 1.')
|
|
796
|
-
|
|
797
|
-
request = dto.RenumberRequest(
|
|
798
|
-
interface_id=self.interface_id,
|
|
799
|
-
address=first_address,
|
|
800
|
-
)
|
|
801
|
-
response = await call_async(
|
|
802
|
-
"device/renumber_all",
|
|
803
|
-
request,
|
|
804
|
-
dto.IntResponse.from_binary)
|
|
805
|
-
return response.value
|
|
806
|
-
|
|
807
|
-
def detect_devices(
|
|
808
|
-
self,
|
|
809
|
-
identify_devices: bool = True
|
|
810
|
-
) -> List[Device]:
|
|
811
|
-
"""
|
|
812
|
-
Attempts to detect any devices present on this connection.
|
|
813
|
-
|
|
814
|
-
Args:
|
|
815
|
-
identify_devices: Determines whether device identification should be performed as well.
|
|
816
|
-
|
|
817
|
-
Returns:
|
|
818
|
-
Array of detected devices.
|
|
819
|
-
"""
|
|
820
|
-
request = dto.DeviceDetectRequest(
|
|
821
|
-
interface_id=self.interface_id,
|
|
822
|
-
identify_devices=identify_devices,
|
|
823
|
-
)
|
|
824
|
-
response = call(
|
|
825
|
-
"device/detect",
|
|
826
|
-
request,
|
|
827
|
-
dto.DeviceDetectResponse.from_binary)
|
|
828
|
-
return list(map(self.get_device, response.devices))
|
|
829
|
-
|
|
830
|
-
async def detect_devices_async(
|
|
831
|
-
self,
|
|
832
|
-
identify_devices: bool = True
|
|
833
|
-
) -> List[Device]:
|
|
834
|
-
"""
|
|
835
|
-
Attempts to detect any devices present on this connection.
|
|
836
|
-
|
|
837
|
-
Args:
|
|
838
|
-
identify_devices: Determines whether device identification should be performed as well.
|
|
839
|
-
|
|
840
|
-
Returns:
|
|
841
|
-
Array of detected devices.
|
|
842
|
-
"""
|
|
843
|
-
request = dto.DeviceDetectRequest(
|
|
844
|
-
interface_id=self.interface_id,
|
|
845
|
-
identify_devices=identify_devices,
|
|
846
|
-
)
|
|
847
|
-
response = await call_async(
|
|
848
|
-
"device/detect",
|
|
849
|
-
request,
|
|
850
|
-
dto.DeviceDetectResponse.from_binary)
|
|
851
|
-
return list(map(self.get_device, response.devices))
|
|
852
|
-
|
|
853
|
-
def forget_devices(
|
|
854
|
-
self,
|
|
855
|
-
except_devices: List[int] = []
|
|
856
|
-
) -> None:
|
|
857
|
-
"""
|
|
858
|
-
Forgets all the information associated with devices on the connection.
|
|
859
|
-
Useful when devices are removed from the chain indefinitely.
|
|
860
|
-
|
|
861
|
-
Args:
|
|
862
|
-
except_devices: Addresses of devices that should not be forgotten.
|
|
863
|
-
"""
|
|
864
|
-
request = dto.ForgetDevicesRequest(
|
|
865
|
-
interface_id=self.interface_id,
|
|
866
|
-
except_devices=except_devices,
|
|
867
|
-
)
|
|
868
|
-
call_sync("device/forget", request)
|
|
869
|
-
|
|
870
|
-
def stop_all(
|
|
871
|
-
self,
|
|
872
|
-
wait_until_idle: bool = True
|
|
873
|
-
) -> List[int]:
|
|
874
|
-
"""
|
|
875
|
-
Stops all of the devices on this connection.
|
|
876
|
-
|
|
877
|
-
Args:
|
|
878
|
-
wait_until_idle: Determines whether the function should return immediately
|
|
879
|
-
or wait until the devices are stopped.
|
|
880
|
-
|
|
881
|
-
Returns:
|
|
882
|
-
The addresses of the devices that were stopped by this command.
|
|
883
|
-
"""
|
|
884
|
-
request = dto.DeviceOnAllRequest(
|
|
885
|
-
interface_id=self.interface_id,
|
|
886
|
-
wait_until_idle=wait_until_idle,
|
|
887
|
-
)
|
|
888
|
-
response = call(
|
|
889
|
-
"device/stop_all",
|
|
890
|
-
request,
|
|
891
|
-
dto.DeviceOnAllResponse.from_binary)
|
|
892
|
-
return response.device_addresses
|
|
893
|
-
|
|
894
|
-
async def stop_all_async(
|
|
895
|
-
self,
|
|
896
|
-
wait_until_idle: bool = True
|
|
897
|
-
) -> List[int]:
|
|
898
|
-
"""
|
|
899
|
-
Stops all of the devices on this connection.
|
|
900
|
-
|
|
901
|
-
Args:
|
|
902
|
-
wait_until_idle: Determines whether the function should return immediately
|
|
903
|
-
or wait until the devices are stopped.
|
|
904
|
-
|
|
905
|
-
Returns:
|
|
906
|
-
The addresses of the devices that were stopped by this command.
|
|
907
|
-
"""
|
|
908
|
-
request = dto.DeviceOnAllRequest(
|
|
909
|
-
interface_id=self.interface_id,
|
|
910
|
-
wait_until_idle=wait_until_idle,
|
|
911
|
-
)
|
|
912
|
-
response = await call_async(
|
|
913
|
-
"device/stop_all",
|
|
914
|
-
request,
|
|
915
|
-
dto.DeviceOnAllResponse.from_binary)
|
|
916
|
-
return response.device_addresses
|
|
917
|
-
|
|
918
|
-
def home_all(
|
|
919
|
-
self,
|
|
920
|
-
wait_until_idle: bool = True
|
|
921
|
-
) -> List[int]:
|
|
922
|
-
"""
|
|
923
|
-
Homes all of the devices on this connection.
|
|
924
|
-
|
|
925
|
-
Args:
|
|
926
|
-
wait_until_idle: Determines whether the function should return immediately
|
|
927
|
-
or wait until the devices are homed.
|
|
928
|
-
|
|
929
|
-
Returns:
|
|
930
|
-
The addresses of the devices that were homed by this command.
|
|
931
|
-
"""
|
|
932
|
-
request = dto.DeviceOnAllRequest(
|
|
933
|
-
interface_id=self.interface_id,
|
|
934
|
-
wait_until_idle=wait_until_idle,
|
|
935
|
-
)
|
|
936
|
-
response = call(
|
|
937
|
-
"device/home_all",
|
|
938
|
-
request,
|
|
939
|
-
dto.DeviceOnAllResponse.from_binary)
|
|
940
|
-
return response.device_addresses
|
|
941
|
-
|
|
942
|
-
async def home_all_async(
|
|
943
|
-
self,
|
|
944
|
-
wait_until_idle: bool = True
|
|
945
|
-
) -> List[int]:
|
|
946
|
-
"""
|
|
947
|
-
Homes all of the devices on this connection.
|
|
948
|
-
|
|
949
|
-
Args:
|
|
950
|
-
wait_until_idle: Determines whether the function should return immediately
|
|
951
|
-
or wait until the devices are homed.
|
|
952
|
-
|
|
953
|
-
Returns:
|
|
954
|
-
The addresses of the devices that were homed by this command.
|
|
955
|
-
"""
|
|
956
|
-
request = dto.DeviceOnAllRequest(
|
|
957
|
-
interface_id=self.interface_id,
|
|
958
|
-
wait_until_idle=wait_until_idle,
|
|
959
|
-
)
|
|
960
|
-
response = await call_async(
|
|
961
|
-
"device/home_all",
|
|
962
|
-
request,
|
|
963
|
-
dto.DeviceOnAllResponse.from_binary)
|
|
964
|
-
return response.device_addresses
|
|
965
|
-
|
|
966
|
-
def __repr__(
|
|
967
|
-
self
|
|
968
|
-
) -> str:
|
|
969
|
-
"""
|
|
970
|
-
Returns a string that represents the connection.
|
|
971
|
-
|
|
972
|
-
Returns:
|
|
973
|
-
A string that represents the connection.
|
|
974
|
-
"""
|
|
975
|
-
request = dto.InterfaceEmptyRequest(
|
|
976
|
-
interface_id=self.interface_id,
|
|
977
|
-
)
|
|
978
|
-
response = call_sync(
|
|
979
|
-
"interface/to_string",
|
|
980
|
-
request,
|
|
981
|
-
dto.StringResponse.from_binary)
|
|
982
|
-
return response.value
|
|
983
|
-
|
|
984
|
-
def __retrieve_timeout(
|
|
985
|
-
self
|
|
986
|
-
) -> int:
|
|
987
|
-
"""
|
|
988
|
-
Returns default request timeout.
|
|
989
|
-
|
|
990
|
-
Returns:
|
|
991
|
-
Default request timeout.
|
|
992
|
-
"""
|
|
993
|
-
request = dto.InterfaceEmptyRequest(
|
|
994
|
-
interface_id=self.interface_id,
|
|
995
|
-
)
|
|
996
|
-
response = call_sync(
|
|
997
|
-
"interface/get_timeout",
|
|
998
|
-
request,
|
|
999
|
-
dto.IntResponse.from_binary)
|
|
1000
|
-
return response.value
|
|
1001
|
-
|
|
1002
|
-
def __change_timeout(
|
|
1003
|
-
self,
|
|
1004
|
-
timeout: int
|
|
1005
|
-
) -> None:
|
|
1006
|
-
"""
|
|
1007
|
-
Sets default request timeout.
|
|
1008
|
-
|
|
1009
|
-
Args:
|
|
1010
|
-
timeout: Default request timeout.
|
|
1011
|
-
"""
|
|
1012
|
-
request = dto.SetInterfaceTimeoutRequest(
|
|
1013
|
-
interface_id=self.interface_id,
|
|
1014
|
-
timeout=timeout,
|
|
1015
|
-
)
|
|
1016
|
-
call_sync("interface/set_timeout", request)
|
|
1017
|
-
|
|
1018
|
-
def __retrieve_checksum_enabled(
|
|
1019
|
-
self
|
|
1020
|
-
) -> bool:
|
|
1021
|
-
"""
|
|
1022
|
-
Returns checksum enabled.
|
|
1023
|
-
|
|
1024
|
-
Returns:
|
|
1025
|
-
Checksum enabled.
|
|
1026
|
-
"""
|
|
1027
|
-
request = dto.InterfaceEmptyRequest(
|
|
1028
|
-
interface_id=self.interface_id,
|
|
1029
|
-
)
|
|
1030
|
-
response = call_sync(
|
|
1031
|
-
"interface/get_checksum_enabled",
|
|
1032
|
-
request,
|
|
1033
|
-
dto.BoolResponse.from_binary)
|
|
1034
|
-
return response.value
|
|
1035
|
-
|
|
1036
|
-
def __change_checksum_enabled(
|
|
1037
|
-
self,
|
|
1038
|
-
is_enabled: bool
|
|
1039
|
-
) -> None:
|
|
1040
|
-
"""
|
|
1041
|
-
Sets checksum enabled.
|
|
1042
|
-
|
|
1043
|
-
Args:
|
|
1044
|
-
is_enabled: Checksum enabled.
|
|
1045
|
-
"""
|
|
1046
|
-
request = dto.SetInterfaceChecksumEnabledRequest(
|
|
1047
|
-
interface_id=self.interface_id,
|
|
1048
|
-
is_enabled=is_enabled,
|
|
1049
|
-
)
|
|
1050
|
-
call_sync("interface/set_checksum_enabled", request)
|
|
1051
|
-
|
|
1052
|
-
def __retrieve_is_open(
|
|
1053
|
-
self
|
|
1054
|
-
) -> bool:
|
|
1055
|
-
"""
|
|
1056
|
-
Returns is open.
|
|
1057
|
-
|
|
1058
|
-
Returns:
|
|
1059
|
-
Is open.
|
|
1060
|
-
"""
|
|
1061
|
-
request = dto.InterfaceEmptyRequest(
|
|
1062
|
-
interface_id=self.interface_id,
|
|
1063
|
-
)
|
|
1064
|
-
response = call_sync(
|
|
1065
|
-
"interface/get_is_open",
|
|
1066
|
-
request,
|
|
1067
|
-
dto.BoolResponse.from_binary)
|
|
1068
|
-
return response.value
|
|
1069
|
-
|
|
1070
|
-
@staticmethod
|
|
1071
|
-
def __free(
|
|
1072
|
-
interface_id: int
|
|
1073
|
-
) -> None:
|
|
1074
|
-
"""
|
|
1075
|
-
Releases native resources of the connection.
|
|
1076
|
-
|
|
1077
|
-
Args:
|
|
1078
|
-
interface_id: The ID of the connection.
|
|
1079
|
-
"""
|
|
1080
|
-
request = dto.InterfaceEmptyRequest(
|
|
1081
|
-
interface_id=interface_id,
|
|
1082
|
-
)
|
|
1083
|
-
call_sync("interface/free", request)
|
|
1084
|
-
|
|
1085
|
-
def __enter__(self) -> 'Connection':
|
|
1086
|
-
""" __enter__ """
|
|
1087
|
-
return self
|
|
1088
|
-
|
|
1089
|
-
def __exit__(self, _type: Any, _value: Any, _traceback: Any) -> None:
|
|
1090
|
-
""" __exit__ """
|
|
1091
|
-
self.close()
|
|
1092
|
-
|
|
1093
|
-
def __setup_events(self, session_id: int) -> None:
|
|
1094
|
-
def filter_connection_event(
|
|
1095
|
-
data: TConnectionEvents,
|
|
1096
|
-
) -> bool:
|
|
1097
|
-
return data.interface_id == self._interface_id and data.session_id == session_id
|
|
1098
|
-
|
|
1099
|
-
self._disconnected = ReplaySubject[MotionLibException]() # terminates all the events
|
|
1100
|
-
|
|
1101
|
-
unknown_response = filter_events('interface/unknown_response', dto.UnknownResponseEventWrapper)
|
|
1102
|
-
self._unknown_response = unknown_response.pipe(
|
|
1103
|
-
rxop.filter(filter_connection_event),
|
|
1104
|
-
rxop.take_until(self.disconnected),
|
|
1105
|
-
rxop.map(map_unknown_response)
|
|
1106
|
-
)
|
|
1107
|
-
|
|
1108
|
-
alert = filter_events('interface/alert', dto.AlertEventWrapper)
|
|
1109
|
-
self._alert = alert.pipe(
|
|
1110
|
-
rxop.filter(filter_connection_event),
|
|
1111
|
-
rxop.take_until(self.disconnected),
|
|
1112
|
-
rxop.map(map_alert)
|
|
1113
|
-
)
|
|
1114
|
-
|
|
1115
|
-
disconnected = filter_events('interface/disconnected', dto.DisconnectedEvent)
|
|
1116
|
-
disconnected.pipe(
|
|
1117
|
-
rxop.filter(filter_connection_event),
|
|
1118
|
-
rxop.take(1),
|
|
1119
|
-
rxop.map(map_disconnect)
|
|
1120
|
-
).subscribe(self._disconnected)
|
|
1121
|
-
|
|
1122
|
-
def __del__(self) -> None:
|
|
1123
|
-
Connection.__free(self._interface_id)
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
class AsyncConnectionOpener:
|
|
1127
|
-
'''Provides a connection in an asynchronous context using `await` or `async with`'''
|
|
1128
|
-
def __init__(self, request: dto.OpenInterfaceRequest) -> None:
|
|
1129
|
-
self._request = request
|
|
1130
|
-
self._resource: Optional[Connection] = None
|
|
1131
|
-
|
|
1132
|
-
async def _create_resource(self) -> Connection:
|
|
1133
|
-
task = asyncio.ensure_future(call_async(
|
|
1134
|
-
"interface/open",
|
|
1135
|
-
self._request,
|
|
1136
|
-
dto.OpenInterfaceResponse.from_binary))
|
|
1137
|
-
|
|
1138
|
-
try:
|
|
1139
|
-
response = await asyncio.shield(task)
|
|
1140
|
-
except asyncio.CancelledError:
|
|
1141
|
-
async def cancel() -> None:
|
|
1142
|
-
try:
|
|
1143
|
-
response = await task
|
|
1144
|
-
await Connection(response.interface_id).close_async()
|
|
1145
|
-
except MotionLibException:
|
|
1146
|
-
pass
|
|
1147
|
-
|
|
1148
|
-
asyncio.ensure_future(cancel())
|
|
1149
|
-
raise
|
|
1150
|
-
|
|
1151
|
-
return Connection(response.interface_id)
|
|
1152
|
-
|
|
1153
|
-
def __await__(self) -> Generator[Any, None, 'Connection']:
|
|
1154
|
-
return self._create_resource().__await__()
|
|
1155
|
-
|
|
1156
|
-
async def __aenter__(self) -> 'Connection':
|
|
1157
|
-
self._resource = await self._create_resource()
|
|
1158
|
-
return self._resource
|
|
1159
|
-
|
|
1160
|
-
async def __aexit__(self, exc_type: Any, exc: Any, trace: Any) -> None:
|
|
1161
|
-
if self._resource is not None:
|
|
1162
|
-
await self._resource.close_async()
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
def map_unknown_response(event: dto.UnknownResponseEventWrapper) -> UnknownResponseEvent:
|
|
1166
|
-
return event.unknown_response
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
def map_alert(event: dto.AlertEventWrapper) -> AlertEvent:
|
|
1170
|
-
return event.alert
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
def map_disconnect(event: dto.DisconnectedEvent) -> MotionLibException:
|
|
1174
|
-
return convert_exception(event.error_type, event.error_message)
|
|
1
|
+
# ===== THIS FILE IS GENERATED FROM A TEMPLATE ===== #
|
|
2
|
+
# ============== DO NOT EDIT DIRECTLY ============== #
|
|
3
|
+
|
|
4
|
+
from typing import Generator, List, Any, Optional, TypeVar
|
|
5
|
+
import asyncio
|
|
6
|
+
from reactivex.subject import ReplaySubject
|
|
7
|
+
from reactivex import operators as rxop, Observable
|
|
8
|
+
|
|
9
|
+
from ..call import call, call_async, call_sync
|
|
10
|
+
from ..convert_exception import convert_exception
|
|
11
|
+
from ..events import filter_events
|
|
12
|
+
from ..exceptions.motion_lib_exception import MotionLibException
|
|
13
|
+
|
|
14
|
+
from .device import Device
|
|
15
|
+
from .transport import Transport
|
|
16
|
+
from ..dto.ascii.response import Response
|
|
17
|
+
from ..dto.ascii.unknown_response_event import UnknownResponseEvent
|
|
18
|
+
from ..dto.ascii.alert_event import AlertEvent
|
|
19
|
+
from ..dto import requests as dto
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
TConnectionEvents = TypeVar(
|
|
23
|
+
"TConnectionEvents",
|
|
24
|
+
dto.UnknownResponseEventWrapper,
|
|
25
|
+
dto.AlertEventWrapper,
|
|
26
|
+
dto.DisconnectedEvent)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class Connection:
|
|
30
|
+
"""
|
|
31
|
+
Class representing access to particular connection (serial port, TCP connection).
|
|
32
|
+
"""
|
|
33
|
+
|
|
34
|
+
@property
|
|
35
|
+
def unknown_response(self) -> Observable[UnknownResponseEvent]:
|
|
36
|
+
"""
|
|
37
|
+
Event invoked when a response from a device cannot be matched to any known request.
|
|
38
|
+
"""
|
|
39
|
+
return self._unknown_response
|
|
40
|
+
|
|
41
|
+
@property
|
|
42
|
+
def alert(self) -> Observable[AlertEvent]:
|
|
43
|
+
"""
|
|
44
|
+
Event invoked when an alert is received from a device.
|
|
45
|
+
"""
|
|
46
|
+
return self._alert
|
|
47
|
+
|
|
48
|
+
@property
|
|
49
|
+
def disconnected(self) -> Observable[MotionLibException]:
|
|
50
|
+
"""
|
|
51
|
+
Event invoked when connection is interrupted or closed.
|
|
52
|
+
"""
|
|
53
|
+
return self._disconnected
|
|
54
|
+
|
|
55
|
+
DEFAULT_BAUD_RATE = 115200
|
|
56
|
+
"""
|
|
57
|
+
Default baud rate for serial connections.
|
|
58
|
+
"""
|
|
59
|
+
|
|
60
|
+
TCP_PORT_CHAIN = 55550
|
|
61
|
+
"""
|
|
62
|
+
Commands sent over this port are forwarded to the device chain.
|
|
63
|
+
The bandwidth may be limited as the commands are forwarded over a serial connection.
|
|
64
|
+
"""
|
|
65
|
+
|
|
66
|
+
NETWORK_SHARE_PORT = 11421
|
|
67
|
+
"""
|
|
68
|
+
Local area network share port.
|
|
69
|
+
"""
|
|
70
|
+
|
|
71
|
+
TCP_PORT_DEVICE_ONLY = 55551
|
|
72
|
+
"""
|
|
73
|
+
Commands send over this port are processed only by the device
|
|
74
|
+
and not forwarded to the rest of the chain.
|
|
75
|
+
Using this port typically makes the communication faster.
|
|
76
|
+
"""
|
|
77
|
+
|
|
78
|
+
@property
|
|
79
|
+
def interface_id(self) -> int:
|
|
80
|
+
"""
|
|
81
|
+
The interface ID identifies this Connection instance with the underlying library.
|
|
82
|
+
"""
|
|
83
|
+
return self._interface_id
|
|
84
|
+
|
|
85
|
+
@property
|
|
86
|
+
def default_request_timeout(self) -> int:
|
|
87
|
+
"""
|
|
88
|
+
The default timeout, in milliseconds, for a device to respond to a request.
|
|
89
|
+
Setting the timeout to a too low value may cause request timeout exceptions.
|
|
90
|
+
The initial value is 1000 (one second).
|
|
91
|
+
"""
|
|
92
|
+
return self.__retrieve_timeout()
|
|
93
|
+
|
|
94
|
+
@default_request_timeout.setter
|
|
95
|
+
def default_request_timeout(self, value: int) -> None:
|
|
96
|
+
"""
|
|
97
|
+
The default timeout, in milliseconds, for a device to respond to a request.
|
|
98
|
+
Setting the timeout to a too low value may cause request timeout exceptions.
|
|
99
|
+
The initial value is 1000 (one second).
|
|
100
|
+
"""
|
|
101
|
+
self.__change_timeout(value)
|
|
102
|
+
|
|
103
|
+
@property
|
|
104
|
+
def checksum_enabled(self) -> bool:
|
|
105
|
+
"""
|
|
106
|
+
Controls whether outgoing messages contain checksum.
|
|
107
|
+
"""
|
|
108
|
+
return self.__retrieve_checksum_enabled()
|
|
109
|
+
|
|
110
|
+
@checksum_enabled.setter
|
|
111
|
+
def checksum_enabled(self, value: bool) -> None:
|
|
112
|
+
"""
|
|
113
|
+
Controls whether outgoing messages contain checksum.
|
|
114
|
+
"""
|
|
115
|
+
self.__change_checksum_enabled(value)
|
|
116
|
+
|
|
117
|
+
@property
|
|
118
|
+
def is_open(self) -> bool:
|
|
119
|
+
"""
|
|
120
|
+
Returns whether the connection is open.
|
|
121
|
+
Does not guarantee that subsequent requests will succeed.
|
|
122
|
+
"""
|
|
123
|
+
return self.__retrieve_is_open()
|
|
124
|
+
|
|
125
|
+
def __init__(self, interface_id: int):
|
|
126
|
+
self._interface_id: int = interface_id
|
|
127
|
+
self.__setup_events(0)
|
|
128
|
+
|
|
129
|
+
@staticmethod
|
|
130
|
+
def open_serial_port(
|
|
131
|
+
port_name: str,
|
|
132
|
+
baud_rate: int = DEFAULT_BAUD_RATE,
|
|
133
|
+
direct: bool = False
|
|
134
|
+
) -> 'Connection':
|
|
135
|
+
"""
|
|
136
|
+
Opens a serial port, if Zaber Launcher controls the port, the port will be opened through Zaber Launcher.
|
|
137
|
+
Zaber Launcher allows sharing of the port between multiple applications,
|
|
138
|
+
If port sharing is not desirable, use the `direct` parameter.
|
|
139
|
+
|
|
140
|
+
Args:
|
|
141
|
+
port_name: Name of the port to open.
|
|
142
|
+
baud_rate: Optional baud rate (defaults to 115200).
|
|
143
|
+
direct: If true will connect to the serial port directly,
|
|
144
|
+
failing if the connection is already opened by a message router instance.
|
|
145
|
+
|
|
146
|
+
Returns:
|
|
147
|
+
An object representing the port.
|
|
148
|
+
"""
|
|
149
|
+
request = dto.OpenInterfaceRequest(
|
|
150
|
+
interface_type=dto.InterfaceType.SERIAL_PORT,
|
|
151
|
+
port_name=port_name,
|
|
152
|
+
baud_rate=baud_rate,
|
|
153
|
+
reject_routed_connection=direct,
|
|
154
|
+
)
|
|
155
|
+
response = call(
|
|
156
|
+
"interface/open",
|
|
157
|
+
request,
|
|
158
|
+
dto.OpenInterfaceResponse.from_binary)
|
|
159
|
+
return Connection(response.interface_id)
|
|
160
|
+
|
|
161
|
+
@staticmethod
|
|
162
|
+
def open_serial_port_async(
|
|
163
|
+
port_name: str,
|
|
164
|
+
baud_rate: int = DEFAULT_BAUD_RATE,
|
|
165
|
+
direct: bool = False
|
|
166
|
+
) -> 'AsyncConnectionOpener':
|
|
167
|
+
"""
|
|
168
|
+
Opens a serial port, if Zaber Launcher controls the port, the port will be opened through Zaber Launcher.
|
|
169
|
+
Zaber Launcher allows sharing of the port between multiple applications,
|
|
170
|
+
If port sharing is not desirable, use the `direct` parameter.
|
|
171
|
+
|
|
172
|
+
Args:
|
|
173
|
+
port_name: Name of the port to open.
|
|
174
|
+
baud_rate: Optional baud rate (defaults to 115200).
|
|
175
|
+
direct: If true will connect to the serial port directly,
|
|
176
|
+
failing if the connection is already opened by a message router instance.
|
|
177
|
+
|
|
178
|
+
Returns:
|
|
179
|
+
An object representing the port.
|
|
180
|
+
"""
|
|
181
|
+
request = dto.OpenInterfaceRequest(
|
|
182
|
+
interface_type=dto.InterfaceType.SERIAL_PORT,
|
|
183
|
+
port_name=port_name,
|
|
184
|
+
baud_rate=baud_rate,
|
|
185
|
+
reject_routed_connection=direct,
|
|
186
|
+
)
|
|
187
|
+
return AsyncConnectionOpener(request)
|
|
188
|
+
|
|
189
|
+
@staticmethod
|
|
190
|
+
def open_tcp(
|
|
191
|
+
host_name: str,
|
|
192
|
+
port: int = TCP_PORT_CHAIN
|
|
193
|
+
) -> 'Connection':
|
|
194
|
+
"""
|
|
195
|
+
Opens a TCP connection.
|
|
196
|
+
|
|
197
|
+
Args:
|
|
198
|
+
host_name: Hostname or IP address.
|
|
199
|
+
port: Optional port number (defaults to 55550).
|
|
200
|
+
|
|
201
|
+
Returns:
|
|
202
|
+
An object representing the connection.
|
|
203
|
+
"""
|
|
204
|
+
request = dto.OpenInterfaceRequest(
|
|
205
|
+
interface_type=dto.InterfaceType.TCP,
|
|
206
|
+
host_name=host_name,
|
|
207
|
+
port=port,
|
|
208
|
+
)
|
|
209
|
+
response = call(
|
|
210
|
+
"interface/open",
|
|
211
|
+
request,
|
|
212
|
+
dto.OpenInterfaceResponse.from_binary)
|
|
213
|
+
return Connection(response.interface_id)
|
|
214
|
+
|
|
215
|
+
@staticmethod
|
|
216
|
+
def open_tcp_async(
|
|
217
|
+
host_name: str,
|
|
218
|
+
port: int = TCP_PORT_CHAIN
|
|
219
|
+
) -> 'AsyncConnectionOpener':
|
|
220
|
+
"""
|
|
221
|
+
Opens a TCP connection.
|
|
222
|
+
|
|
223
|
+
Args:
|
|
224
|
+
host_name: Hostname or IP address.
|
|
225
|
+
port: Optional port number (defaults to 55550).
|
|
226
|
+
|
|
227
|
+
Returns:
|
|
228
|
+
An object representing the connection.
|
|
229
|
+
"""
|
|
230
|
+
request = dto.OpenInterfaceRequest(
|
|
231
|
+
interface_type=dto.InterfaceType.TCP,
|
|
232
|
+
host_name=host_name,
|
|
233
|
+
port=port,
|
|
234
|
+
)
|
|
235
|
+
return AsyncConnectionOpener(request)
|
|
236
|
+
|
|
237
|
+
@staticmethod
|
|
238
|
+
def open_custom(
|
|
239
|
+
transport: Transport
|
|
240
|
+
) -> 'Connection':
|
|
241
|
+
"""
|
|
242
|
+
Opens a connection using a custom transport.
|
|
243
|
+
|
|
244
|
+
Args:
|
|
245
|
+
transport: The custom connection transport.
|
|
246
|
+
|
|
247
|
+
Returns:
|
|
248
|
+
An object representing the connection.
|
|
249
|
+
"""
|
|
250
|
+
request = dto.OpenInterfaceRequest(
|
|
251
|
+
interface_type=dto.InterfaceType.CUSTOM,
|
|
252
|
+
transport=transport.transport_id,
|
|
253
|
+
)
|
|
254
|
+
response = call(
|
|
255
|
+
"interface/open",
|
|
256
|
+
request,
|
|
257
|
+
dto.OpenInterfaceResponse.from_binary)
|
|
258
|
+
return Connection(response.interface_id)
|
|
259
|
+
|
|
260
|
+
@staticmethod
|
|
261
|
+
def open_custom_async(
|
|
262
|
+
transport: Transport
|
|
263
|
+
) -> 'AsyncConnectionOpener':
|
|
264
|
+
"""
|
|
265
|
+
Opens a connection using a custom transport.
|
|
266
|
+
|
|
267
|
+
Args:
|
|
268
|
+
transport: The custom connection transport.
|
|
269
|
+
|
|
270
|
+
Returns:
|
|
271
|
+
An object representing the connection.
|
|
272
|
+
"""
|
|
273
|
+
request = dto.OpenInterfaceRequest(
|
|
274
|
+
interface_type=dto.InterfaceType.CUSTOM,
|
|
275
|
+
transport=transport.transport_id,
|
|
276
|
+
)
|
|
277
|
+
return AsyncConnectionOpener(request)
|
|
278
|
+
|
|
279
|
+
@staticmethod
|
|
280
|
+
def open_iot(
|
|
281
|
+
cloud_id: str,
|
|
282
|
+
token: str = "unauthenticated",
|
|
283
|
+
connection_name: Optional[str] = None,
|
|
284
|
+
realm: Optional[str] = None,
|
|
285
|
+
api: str = "https://api.zaber.io"
|
|
286
|
+
) -> 'Connection':
|
|
287
|
+
"""
|
|
288
|
+
Opens a secured connection to a cloud connected device chain.
|
|
289
|
+
Use this method to connect to devices on your account.
|
|
290
|
+
|
|
291
|
+
Args:
|
|
292
|
+
cloud_id: The cloud ID to connect to.
|
|
293
|
+
token: The token to authenticate with. By default the connection will be unauthenticated.
|
|
294
|
+
connection_name: The name of the connection to open.
|
|
295
|
+
Can be left empty to default to the only connection present.
|
|
296
|
+
Otherwise, use serial port name for serial port connection or hostname:port for TCP connection.
|
|
297
|
+
realm: The realm to connect to.
|
|
298
|
+
Can be left empty for the default account realm.
|
|
299
|
+
api: The URL of the API to receive connection info from.
|
|
300
|
+
|
|
301
|
+
Returns:
|
|
302
|
+
An object representing the connection.
|
|
303
|
+
"""
|
|
304
|
+
request = dto.OpenInterfaceRequest(
|
|
305
|
+
interface_type=dto.InterfaceType.IOT,
|
|
306
|
+
cloud_id=cloud_id,
|
|
307
|
+
token=token,
|
|
308
|
+
connection_name=connection_name,
|
|
309
|
+
realm=realm,
|
|
310
|
+
api=api,
|
|
311
|
+
)
|
|
312
|
+
response = call(
|
|
313
|
+
"interface/open",
|
|
314
|
+
request,
|
|
315
|
+
dto.OpenInterfaceResponse.from_binary)
|
|
316
|
+
return Connection(response.interface_id)
|
|
317
|
+
|
|
318
|
+
@staticmethod
|
|
319
|
+
def open_iot_async(
|
|
320
|
+
cloud_id: str,
|
|
321
|
+
token: str = "unauthenticated",
|
|
322
|
+
connection_name: Optional[str] = None,
|
|
323
|
+
realm: Optional[str] = None,
|
|
324
|
+
api: str = "https://api.zaber.io"
|
|
325
|
+
) -> 'AsyncConnectionOpener':
|
|
326
|
+
"""
|
|
327
|
+
Opens a secured connection to a cloud connected device chain.
|
|
328
|
+
Use this method to connect to devices on your account.
|
|
329
|
+
|
|
330
|
+
Args:
|
|
331
|
+
cloud_id: The cloud ID to connect to.
|
|
332
|
+
token: The token to authenticate with. By default the connection will be unauthenticated.
|
|
333
|
+
connection_name: The name of the connection to open.
|
|
334
|
+
Can be left empty to default to the only connection present.
|
|
335
|
+
Otherwise, use serial port name for serial port connection or hostname:port for TCP connection.
|
|
336
|
+
realm: The realm to connect to.
|
|
337
|
+
Can be left empty for the default account realm.
|
|
338
|
+
api: The URL of the API to receive connection info from.
|
|
339
|
+
|
|
340
|
+
Returns:
|
|
341
|
+
An object representing the connection.
|
|
342
|
+
"""
|
|
343
|
+
request = dto.OpenInterfaceRequest(
|
|
344
|
+
interface_type=dto.InterfaceType.IOT,
|
|
345
|
+
cloud_id=cloud_id,
|
|
346
|
+
token=token,
|
|
347
|
+
connection_name=connection_name,
|
|
348
|
+
realm=realm,
|
|
349
|
+
api=api,
|
|
350
|
+
)
|
|
351
|
+
return AsyncConnectionOpener(request)
|
|
352
|
+
|
|
353
|
+
@staticmethod
|
|
354
|
+
def open_network_share(
|
|
355
|
+
host_name: str,
|
|
356
|
+
port: int = NETWORK_SHARE_PORT,
|
|
357
|
+
connection_name: Optional[str] = None
|
|
358
|
+
) -> 'Connection':
|
|
359
|
+
"""
|
|
360
|
+
Opens a connection to Zaber Launcher in your Local Area Network.
|
|
361
|
+
The connection is not secured.
|
|
362
|
+
|
|
363
|
+
Args:
|
|
364
|
+
host_name: Hostname or IP address.
|
|
365
|
+
port: Port number.
|
|
366
|
+
connection_name: The name of the connection to open.
|
|
367
|
+
Can be left empty to default to the only connection present.
|
|
368
|
+
Otherwise, use serial port name for serial port connection or hostname:port for TCP connection.
|
|
369
|
+
|
|
370
|
+
Returns:
|
|
371
|
+
An object representing the connection.
|
|
372
|
+
"""
|
|
373
|
+
request = dto.OpenInterfaceRequest(
|
|
374
|
+
interface_type=dto.InterfaceType.NETWORK_SHARE,
|
|
375
|
+
host_name=host_name,
|
|
376
|
+
port=port,
|
|
377
|
+
connection_name=connection_name,
|
|
378
|
+
)
|
|
379
|
+
response = call(
|
|
380
|
+
"interface/open",
|
|
381
|
+
request,
|
|
382
|
+
dto.OpenInterfaceResponse.from_binary)
|
|
383
|
+
return Connection(response.interface_id)
|
|
384
|
+
|
|
385
|
+
@staticmethod
|
|
386
|
+
def open_network_share_async(
|
|
387
|
+
host_name: str,
|
|
388
|
+
port: int = NETWORK_SHARE_PORT,
|
|
389
|
+
connection_name: Optional[str] = None
|
|
390
|
+
) -> 'AsyncConnectionOpener':
|
|
391
|
+
"""
|
|
392
|
+
Opens a connection to Zaber Launcher in your Local Area Network.
|
|
393
|
+
The connection is not secured.
|
|
394
|
+
|
|
395
|
+
Args:
|
|
396
|
+
host_name: Hostname or IP address.
|
|
397
|
+
port: Port number.
|
|
398
|
+
connection_name: The name of the connection to open.
|
|
399
|
+
Can be left empty to default to the only connection present.
|
|
400
|
+
Otherwise, use serial port name for serial port connection or hostname:port for TCP connection.
|
|
401
|
+
|
|
402
|
+
Returns:
|
|
403
|
+
An object representing the connection.
|
|
404
|
+
"""
|
|
405
|
+
request = dto.OpenInterfaceRequest(
|
|
406
|
+
interface_type=dto.InterfaceType.NETWORK_SHARE,
|
|
407
|
+
host_name=host_name,
|
|
408
|
+
port=port,
|
|
409
|
+
connection_name=connection_name,
|
|
410
|
+
)
|
|
411
|
+
return AsyncConnectionOpener(request)
|
|
412
|
+
|
|
413
|
+
def reopen(
|
|
414
|
+
self
|
|
415
|
+
) -> None:
|
|
416
|
+
"""
|
|
417
|
+
Reopens the connection.
|
|
418
|
+
To continue using events on the connection, you must resubscribe to event observables.
|
|
419
|
+
Throws an exception if the connection is already open.
|
|
420
|
+
"""
|
|
421
|
+
request = dto.InterfaceEmptyRequest(
|
|
422
|
+
interface_id=self.interface_id,
|
|
423
|
+
)
|
|
424
|
+
response = call(
|
|
425
|
+
"interface/reopen",
|
|
426
|
+
request,
|
|
427
|
+
dto.IntResponse.from_binary)
|
|
428
|
+
self.__setup_events(response.value)
|
|
429
|
+
|
|
430
|
+
async def reopen_async(
|
|
431
|
+
self
|
|
432
|
+
) -> None:
|
|
433
|
+
"""
|
|
434
|
+
Reopens the connection.
|
|
435
|
+
To continue using events on the connection, you must resubscribe to event observables.
|
|
436
|
+
Throws an exception if the connection is already open.
|
|
437
|
+
"""
|
|
438
|
+
request = dto.InterfaceEmptyRequest(
|
|
439
|
+
interface_id=self.interface_id,
|
|
440
|
+
)
|
|
441
|
+
response = await call_async(
|
|
442
|
+
"interface/reopen",
|
|
443
|
+
request,
|
|
444
|
+
dto.IntResponse.from_binary)
|
|
445
|
+
self.__setup_events(response.value)
|
|
446
|
+
|
|
447
|
+
def generic_command(
|
|
448
|
+
self,
|
|
449
|
+
command: str,
|
|
450
|
+
device: int = 0,
|
|
451
|
+
axis: int = 0,
|
|
452
|
+
check_errors: bool = True,
|
|
453
|
+
timeout: int = 0
|
|
454
|
+
) -> Response:
|
|
455
|
+
"""
|
|
456
|
+
Sends a generic ASCII command to this connection.
|
|
457
|
+
For more information refer to the [ASCII Protocol Manual](https://www.zaber.com/protocol-manual#topic_commands).
|
|
458
|
+
|
|
459
|
+
Args:
|
|
460
|
+
command: Command and its parameters.
|
|
461
|
+
device: Optional device address to send the command to.
|
|
462
|
+
axis: Optional axis number to send the command to.
|
|
463
|
+
check_errors: Controls whether to throw an exception when the device rejects the command.
|
|
464
|
+
timeout: The timeout, in milliseconds, for a device to respond to the command.
|
|
465
|
+
Overrides the connection default request timeout.
|
|
466
|
+
|
|
467
|
+
Returns:
|
|
468
|
+
A response to the command.
|
|
469
|
+
"""
|
|
470
|
+
request = dto.GenericCommandRequest(
|
|
471
|
+
interface_id=self.interface_id,
|
|
472
|
+
command=command,
|
|
473
|
+
device=device,
|
|
474
|
+
axis=axis,
|
|
475
|
+
check_errors=check_errors,
|
|
476
|
+
timeout=timeout,
|
|
477
|
+
)
|
|
478
|
+
response = call(
|
|
479
|
+
"interface/generic_command",
|
|
480
|
+
request,
|
|
481
|
+
Response.from_binary)
|
|
482
|
+
return response
|
|
483
|
+
|
|
484
|
+
async def generic_command_async(
|
|
485
|
+
self,
|
|
486
|
+
command: str,
|
|
487
|
+
device: int = 0,
|
|
488
|
+
axis: int = 0,
|
|
489
|
+
check_errors: bool = True,
|
|
490
|
+
timeout: int = 0
|
|
491
|
+
) -> Response:
|
|
492
|
+
"""
|
|
493
|
+
Sends a generic ASCII command to this connection.
|
|
494
|
+
For more information refer to the [ASCII Protocol Manual](https://www.zaber.com/protocol-manual#topic_commands).
|
|
495
|
+
|
|
496
|
+
Args:
|
|
497
|
+
command: Command and its parameters.
|
|
498
|
+
device: Optional device address to send the command to.
|
|
499
|
+
axis: Optional axis number to send the command to.
|
|
500
|
+
check_errors: Controls whether to throw an exception when the device rejects the command.
|
|
501
|
+
timeout: The timeout, in milliseconds, for a device to respond to the command.
|
|
502
|
+
Overrides the connection default request timeout.
|
|
503
|
+
|
|
504
|
+
Returns:
|
|
505
|
+
A response to the command.
|
|
506
|
+
"""
|
|
507
|
+
request = dto.GenericCommandRequest(
|
|
508
|
+
interface_id=self.interface_id,
|
|
509
|
+
command=command,
|
|
510
|
+
device=device,
|
|
511
|
+
axis=axis,
|
|
512
|
+
check_errors=check_errors,
|
|
513
|
+
timeout=timeout,
|
|
514
|
+
)
|
|
515
|
+
response = await call_async(
|
|
516
|
+
"interface/generic_command",
|
|
517
|
+
request,
|
|
518
|
+
Response.from_binary)
|
|
519
|
+
return response
|
|
520
|
+
|
|
521
|
+
def generic_command_no_response(
|
|
522
|
+
self,
|
|
523
|
+
command: str,
|
|
524
|
+
device: int = 0,
|
|
525
|
+
axis: int = 0
|
|
526
|
+
) -> None:
|
|
527
|
+
"""
|
|
528
|
+
Sends a generic ASCII command to this connection without expecting a response and without adding a message ID.
|
|
529
|
+
For more information refer to the [ASCII Protocol Manual](https://www.zaber.com/protocol-manual#topic_commands).
|
|
530
|
+
|
|
531
|
+
Args:
|
|
532
|
+
command: Command and its parameters.
|
|
533
|
+
device: Optional device address to send the command to.
|
|
534
|
+
Specifying -1 omits the number completely.
|
|
535
|
+
axis: Optional axis number to send the command to.
|
|
536
|
+
Specifying -1 omits the number completely.
|
|
537
|
+
"""
|
|
538
|
+
request = dto.GenericCommandRequest(
|
|
539
|
+
interface_id=self.interface_id,
|
|
540
|
+
command=command,
|
|
541
|
+
device=device,
|
|
542
|
+
axis=axis,
|
|
543
|
+
)
|
|
544
|
+
call("interface/generic_command_no_response", request)
|
|
545
|
+
|
|
546
|
+
async def generic_command_no_response_async(
|
|
547
|
+
self,
|
|
548
|
+
command: str,
|
|
549
|
+
device: int = 0,
|
|
550
|
+
axis: int = 0
|
|
551
|
+
) -> None:
|
|
552
|
+
"""
|
|
553
|
+
Sends a generic ASCII command to this connection without expecting a response and without adding a message ID.
|
|
554
|
+
For more information refer to the [ASCII Protocol Manual](https://www.zaber.com/protocol-manual#topic_commands).
|
|
555
|
+
|
|
556
|
+
Args:
|
|
557
|
+
command: Command and its parameters.
|
|
558
|
+
device: Optional device address to send the command to.
|
|
559
|
+
Specifying -1 omits the number completely.
|
|
560
|
+
axis: Optional axis number to send the command to.
|
|
561
|
+
Specifying -1 omits the number completely.
|
|
562
|
+
"""
|
|
563
|
+
request = dto.GenericCommandRequest(
|
|
564
|
+
interface_id=self.interface_id,
|
|
565
|
+
command=command,
|
|
566
|
+
device=device,
|
|
567
|
+
axis=axis,
|
|
568
|
+
)
|
|
569
|
+
await call_async("interface/generic_command_no_response", request)
|
|
570
|
+
|
|
571
|
+
def generic_command_multi_response(
|
|
572
|
+
self,
|
|
573
|
+
command: str,
|
|
574
|
+
device: int = 0,
|
|
575
|
+
axis: int = 0,
|
|
576
|
+
check_errors: bool = True,
|
|
577
|
+
timeout: int = 0
|
|
578
|
+
) -> List[Response]:
|
|
579
|
+
"""
|
|
580
|
+
Sends a generic ASCII command to this connection and expect multiple responses,
|
|
581
|
+
either from one device or from many devices.
|
|
582
|
+
Responses are returned in order of arrival.
|
|
583
|
+
For more information refer to the [ASCII Protocol Manual](https://www.zaber.com/protocol-manual#topic_commands).
|
|
584
|
+
|
|
585
|
+
Args:
|
|
586
|
+
command: Command and its parameters.
|
|
587
|
+
device: Optional device address to send the command to.
|
|
588
|
+
axis: Optional axis number to send the command to.
|
|
589
|
+
check_errors: Controls whether to throw an exception when a device rejects the command.
|
|
590
|
+
timeout: The timeout, in milliseconds, for a device to respond to the command.
|
|
591
|
+
Overrides the connection default request timeout.
|
|
592
|
+
|
|
593
|
+
Returns:
|
|
594
|
+
All responses to the command.
|
|
595
|
+
"""
|
|
596
|
+
request = dto.GenericCommandRequest(
|
|
597
|
+
interface_id=self.interface_id,
|
|
598
|
+
command=command,
|
|
599
|
+
device=device,
|
|
600
|
+
axis=axis,
|
|
601
|
+
check_errors=check_errors,
|
|
602
|
+
timeout=timeout,
|
|
603
|
+
)
|
|
604
|
+
response = call(
|
|
605
|
+
"interface/generic_command_multi_response",
|
|
606
|
+
request,
|
|
607
|
+
dto.GenericCommandResponseCollection.from_binary)
|
|
608
|
+
return response.responses
|
|
609
|
+
|
|
610
|
+
async def generic_command_multi_response_async(
|
|
611
|
+
self,
|
|
612
|
+
command: str,
|
|
613
|
+
device: int = 0,
|
|
614
|
+
axis: int = 0,
|
|
615
|
+
check_errors: bool = True,
|
|
616
|
+
timeout: int = 0
|
|
617
|
+
) -> List[Response]:
|
|
618
|
+
"""
|
|
619
|
+
Sends a generic ASCII command to this connection and expect multiple responses,
|
|
620
|
+
either from one device or from many devices.
|
|
621
|
+
Responses are returned in order of arrival.
|
|
622
|
+
For more information refer to the [ASCII Protocol Manual](https://www.zaber.com/protocol-manual#topic_commands).
|
|
623
|
+
|
|
624
|
+
Args:
|
|
625
|
+
command: Command and its parameters.
|
|
626
|
+
device: Optional device address to send the command to.
|
|
627
|
+
axis: Optional axis number to send the command to.
|
|
628
|
+
check_errors: Controls whether to throw an exception when a device rejects the command.
|
|
629
|
+
timeout: The timeout, in milliseconds, for a device to respond to the command.
|
|
630
|
+
Overrides the connection default request timeout.
|
|
631
|
+
|
|
632
|
+
Returns:
|
|
633
|
+
All responses to the command.
|
|
634
|
+
"""
|
|
635
|
+
request = dto.GenericCommandRequest(
|
|
636
|
+
interface_id=self.interface_id,
|
|
637
|
+
command=command,
|
|
638
|
+
device=device,
|
|
639
|
+
axis=axis,
|
|
640
|
+
check_errors=check_errors,
|
|
641
|
+
timeout=timeout,
|
|
642
|
+
)
|
|
643
|
+
response = await call_async(
|
|
644
|
+
"interface/generic_command_multi_response",
|
|
645
|
+
request,
|
|
646
|
+
dto.GenericCommandResponseCollection.from_binary)
|
|
647
|
+
return response.responses
|
|
648
|
+
|
|
649
|
+
def enable_alerts(
|
|
650
|
+
self
|
|
651
|
+
) -> None:
|
|
652
|
+
"""
|
|
653
|
+
Enables alerts for all devices on the connection.
|
|
654
|
+
This will change the "comm.alert" setting to 1 on all supported devices.
|
|
655
|
+
"""
|
|
656
|
+
request = dto.GenericCommandRequest(
|
|
657
|
+
interface_id=self.interface_id,
|
|
658
|
+
command="set comm.alert 1",
|
|
659
|
+
)
|
|
660
|
+
call("interface/generic_command_no_response", request)
|
|
661
|
+
|
|
662
|
+
async def enable_alerts_async(
|
|
663
|
+
self
|
|
664
|
+
) -> None:
|
|
665
|
+
"""
|
|
666
|
+
Enables alerts for all devices on the connection.
|
|
667
|
+
This will change the "comm.alert" setting to 1 on all supported devices.
|
|
668
|
+
"""
|
|
669
|
+
request = dto.GenericCommandRequest(
|
|
670
|
+
interface_id=self.interface_id,
|
|
671
|
+
command="set comm.alert 1",
|
|
672
|
+
)
|
|
673
|
+
await call_async("interface/generic_command_no_response", request)
|
|
674
|
+
|
|
675
|
+
def disable_alerts(
|
|
676
|
+
self
|
|
677
|
+
) -> None:
|
|
678
|
+
"""
|
|
679
|
+
Disables alerts for all devices on the connection.
|
|
680
|
+
This will change the "comm.alert" setting to 0 on all supported devices.
|
|
681
|
+
"""
|
|
682
|
+
request = dto.GenericCommandRequest(
|
|
683
|
+
interface_id=self.interface_id,
|
|
684
|
+
command="set comm.alert 0",
|
|
685
|
+
)
|
|
686
|
+
call("interface/generic_command_no_response", request)
|
|
687
|
+
|
|
688
|
+
async def disable_alerts_async(
|
|
689
|
+
self
|
|
690
|
+
) -> None:
|
|
691
|
+
"""
|
|
692
|
+
Disables alerts for all devices on the connection.
|
|
693
|
+
This will change the "comm.alert" setting to 0 on all supported devices.
|
|
694
|
+
"""
|
|
695
|
+
request = dto.GenericCommandRequest(
|
|
696
|
+
interface_id=self.interface_id,
|
|
697
|
+
command="set comm.alert 0",
|
|
698
|
+
)
|
|
699
|
+
await call_async("interface/generic_command_no_response", request)
|
|
700
|
+
|
|
701
|
+
def reset_ids(
|
|
702
|
+
self
|
|
703
|
+
) -> None:
|
|
704
|
+
"""
|
|
705
|
+
Resets ASCII protocol message IDs. Only for testing purposes.
|
|
706
|
+
"""
|
|
707
|
+
request = dto.InterfaceEmptyRequest(
|
|
708
|
+
interface_id=self.interface_id,
|
|
709
|
+
)
|
|
710
|
+
call_sync("interface/reset_ids", request)
|
|
711
|
+
|
|
712
|
+
def close(
|
|
713
|
+
self
|
|
714
|
+
) -> None:
|
|
715
|
+
"""
|
|
716
|
+
Close the connection.
|
|
717
|
+
"""
|
|
718
|
+
request = dto.InterfaceEmptyRequest(
|
|
719
|
+
interface_id=self.interface_id,
|
|
720
|
+
)
|
|
721
|
+
call("interface/close", request)
|
|
722
|
+
|
|
723
|
+
async def close_async(
|
|
724
|
+
self
|
|
725
|
+
) -> None:
|
|
726
|
+
"""
|
|
727
|
+
Close the connection.
|
|
728
|
+
"""
|
|
729
|
+
request = dto.InterfaceEmptyRequest(
|
|
730
|
+
interface_id=self.interface_id,
|
|
731
|
+
)
|
|
732
|
+
await call_async("interface/close", request)
|
|
733
|
+
|
|
734
|
+
def get_device(
|
|
735
|
+
self,
|
|
736
|
+
device_address: int
|
|
737
|
+
) -> Device:
|
|
738
|
+
"""
|
|
739
|
+
Gets a Device class instance which allows you to control a particular device on this connection.
|
|
740
|
+
Devices are numbered from 1.
|
|
741
|
+
|
|
742
|
+
Args:
|
|
743
|
+
device_address: Address of device intended to control. Address is configured for each device.
|
|
744
|
+
|
|
745
|
+
Returns:
|
|
746
|
+
Device instance.
|
|
747
|
+
"""
|
|
748
|
+
if device_address <= 0:
|
|
749
|
+
raise ValueError('Invalid value; physical devices are numbered from 1.')
|
|
750
|
+
|
|
751
|
+
return Device(self, device_address)
|
|
752
|
+
|
|
753
|
+
def renumber_devices(
|
|
754
|
+
self,
|
|
755
|
+
first_address: int = 1
|
|
756
|
+
) -> int:
|
|
757
|
+
"""
|
|
758
|
+
Renumbers devices present on this connection. After renumbering, devices need to be identified again.
|
|
759
|
+
|
|
760
|
+
Args:
|
|
761
|
+
first_address: This is the address that the device closest to the computer is given.
|
|
762
|
+
Remaining devices are numbered consecutively.
|
|
763
|
+
|
|
764
|
+
Returns:
|
|
765
|
+
Total number of devices that responded to the renumber.
|
|
766
|
+
"""
|
|
767
|
+
if first_address <= 0:
|
|
768
|
+
raise ValueError('Invalid value; device addresses are numbered from 1.')
|
|
769
|
+
|
|
770
|
+
request = dto.RenumberRequest(
|
|
771
|
+
interface_id=self.interface_id,
|
|
772
|
+
address=first_address,
|
|
773
|
+
)
|
|
774
|
+
response = call(
|
|
775
|
+
"device/renumber_all",
|
|
776
|
+
request,
|
|
777
|
+
dto.IntResponse.from_binary)
|
|
778
|
+
return response.value
|
|
779
|
+
|
|
780
|
+
async def renumber_devices_async(
|
|
781
|
+
self,
|
|
782
|
+
first_address: int = 1
|
|
783
|
+
) -> int:
|
|
784
|
+
"""
|
|
785
|
+
Renumbers devices present on this connection. After renumbering, devices need to be identified again.
|
|
786
|
+
|
|
787
|
+
Args:
|
|
788
|
+
first_address: This is the address that the device closest to the computer is given.
|
|
789
|
+
Remaining devices are numbered consecutively.
|
|
790
|
+
|
|
791
|
+
Returns:
|
|
792
|
+
Total number of devices that responded to the renumber.
|
|
793
|
+
"""
|
|
794
|
+
if first_address <= 0:
|
|
795
|
+
raise ValueError('Invalid value; device addresses are numbered from 1.')
|
|
796
|
+
|
|
797
|
+
request = dto.RenumberRequest(
|
|
798
|
+
interface_id=self.interface_id,
|
|
799
|
+
address=first_address,
|
|
800
|
+
)
|
|
801
|
+
response = await call_async(
|
|
802
|
+
"device/renumber_all",
|
|
803
|
+
request,
|
|
804
|
+
dto.IntResponse.from_binary)
|
|
805
|
+
return response.value
|
|
806
|
+
|
|
807
|
+
def detect_devices(
|
|
808
|
+
self,
|
|
809
|
+
identify_devices: bool = True
|
|
810
|
+
) -> List[Device]:
|
|
811
|
+
"""
|
|
812
|
+
Attempts to detect any devices present on this connection.
|
|
813
|
+
|
|
814
|
+
Args:
|
|
815
|
+
identify_devices: Determines whether device identification should be performed as well.
|
|
816
|
+
|
|
817
|
+
Returns:
|
|
818
|
+
Array of detected devices.
|
|
819
|
+
"""
|
|
820
|
+
request = dto.DeviceDetectRequest(
|
|
821
|
+
interface_id=self.interface_id,
|
|
822
|
+
identify_devices=identify_devices,
|
|
823
|
+
)
|
|
824
|
+
response = call(
|
|
825
|
+
"device/detect",
|
|
826
|
+
request,
|
|
827
|
+
dto.DeviceDetectResponse.from_binary)
|
|
828
|
+
return list(map(self.get_device, response.devices))
|
|
829
|
+
|
|
830
|
+
async def detect_devices_async(
|
|
831
|
+
self,
|
|
832
|
+
identify_devices: bool = True
|
|
833
|
+
) -> List[Device]:
|
|
834
|
+
"""
|
|
835
|
+
Attempts to detect any devices present on this connection.
|
|
836
|
+
|
|
837
|
+
Args:
|
|
838
|
+
identify_devices: Determines whether device identification should be performed as well.
|
|
839
|
+
|
|
840
|
+
Returns:
|
|
841
|
+
Array of detected devices.
|
|
842
|
+
"""
|
|
843
|
+
request = dto.DeviceDetectRequest(
|
|
844
|
+
interface_id=self.interface_id,
|
|
845
|
+
identify_devices=identify_devices,
|
|
846
|
+
)
|
|
847
|
+
response = await call_async(
|
|
848
|
+
"device/detect",
|
|
849
|
+
request,
|
|
850
|
+
dto.DeviceDetectResponse.from_binary)
|
|
851
|
+
return list(map(self.get_device, response.devices))
|
|
852
|
+
|
|
853
|
+
def forget_devices(
|
|
854
|
+
self,
|
|
855
|
+
except_devices: List[int] = []
|
|
856
|
+
) -> None:
|
|
857
|
+
"""
|
|
858
|
+
Forgets all the information associated with devices on the connection.
|
|
859
|
+
Useful when devices are removed from the chain indefinitely.
|
|
860
|
+
|
|
861
|
+
Args:
|
|
862
|
+
except_devices: Addresses of devices that should not be forgotten.
|
|
863
|
+
"""
|
|
864
|
+
request = dto.ForgetDevicesRequest(
|
|
865
|
+
interface_id=self.interface_id,
|
|
866
|
+
except_devices=except_devices,
|
|
867
|
+
)
|
|
868
|
+
call_sync("device/forget", request)
|
|
869
|
+
|
|
870
|
+
def stop_all(
|
|
871
|
+
self,
|
|
872
|
+
wait_until_idle: bool = True
|
|
873
|
+
) -> List[int]:
|
|
874
|
+
"""
|
|
875
|
+
Stops all of the devices on this connection.
|
|
876
|
+
|
|
877
|
+
Args:
|
|
878
|
+
wait_until_idle: Determines whether the function should return immediately
|
|
879
|
+
or wait until the devices are stopped.
|
|
880
|
+
|
|
881
|
+
Returns:
|
|
882
|
+
The addresses of the devices that were stopped by this command.
|
|
883
|
+
"""
|
|
884
|
+
request = dto.DeviceOnAllRequest(
|
|
885
|
+
interface_id=self.interface_id,
|
|
886
|
+
wait_until_idle=wait_until_idle,
|
|
887
|
+
)
|
|
888
|
+
response = call(
|
|
889
|
+
"device/stop_all",
|
|
890
|
+
request,
|
|
891
|
+
dto.DeviceOnAllResponse.from_binary)
|
|
892
|
+
return response.device_addresses
|
|
893
|
+
|
|
894
|
+
async def stop_all_async(
|
|
895
|
+
self,
|
|
896
|
+
wait_until_idle: bool = True
|
|
897
|
+
) -> List[int]:
|
|
898
|
+
"""
|
|
899
|
+
Stops all of the devices on this connection.
|
|
900
|
+
|
|
901
|
+
Args:
|
|
902
|
+
wait_until_idle: Determines whether the function should return immediately
|
|
903
|
+
or wait until the devices are stopped.
|
|
904
|
+
|
|
905
|
+
Returns:
|
|
906
|
+
The addresses of the devices that were stopped by this command.
|
|
907
|
+
"""
|
|
908
|
+
request = dto.DeviceOnAllRequest(
|
|
909
|
+
interface_id=self.interface_id,
|
|
910
|
+
wait_until_idle=wait_until_idle,
|
|
911
|
+
)
|
|
912
|
+
response = await call_async(
|
|
913
|
+
"device/stop_all",
|
|
914
|
+
request,
|
|
915
|
+
dto.DeviceOnAllResponse.from_binary)
|
|
916
|
+
return response.device_addresses
|
|
917
|
+
|
|
918
|
+
def home_all(
|
|
919
|
+
self,
|
|
920
|
+
wait_until_idle: bool = True
|
|
921
|
+
) -> List[int]:
|
|
922
|
+
"""
|
|
923
|
+
Homes all of the devices on this connection.
|
|
924
|
+
|
|
925
|
+
Args:
|
|
926
|
+
wait_until_idle: Determines whether the function should return immediately
|
|
927
|
+
or wait until the devices are homed.
|
|
928
|
+
|
|
929
|
+
Returns:
|
|
930
|
+
The addresses of the devices that were homed by this command.
|
|
931
|
+
"""
|
|
932
|
+
request = dto.DeviceOnAllRequest(
|
|
933
|
+
interface_id=self.interface_id,
|
|
934
|
+
wait_until_idle=wait_until_idle,
|
|
935
|
+
)
|
|
936
|
+
response = call(
|
|
937
|
+
"device/home_all",
|
|
938
|
+
request,
|
|
939
|
+
dto.DeviceOnAllResponse.from_binary)
|
|
940
|
+
return response.device_addresses
|
|
941
|
+
|
|
942
|
+
async def home_all_async(
|
|
943
|
+
self,
|
|
944
|
+
wait_until_idle: bool = True
|
|
945
|
+
) -> List[int]:
|
|
946
|
+
"""
|
|
947
|
+
Homes all of the devices on this connection.
|
|
948
|
+
|
|
949
|
+
Args:
|
|
950
|
+
wait_until_idle: Determines whether the function should return immediately
|
|
951
|
+
or wait until the devices are homed.
|
|
952
|
+
|
|
953
|
+
Returns:
|
|
954
|
+
The addresses of the devices that were homed by this command.
|
|
955
|
+
"""
|
|
956
|
+
request = dto.DeviceOnAllRequest(
|
|
957
|
+
interface_id=self.interface_id,
|
|
958
|
+
wait_until_idle=wait_until_idle,
|
|
959
|
+
)
|
|
960
|
+
response = await call_async(
|
|
961
|
+
"device/home_all",
|
|
962
|
+
request,
|
|
963
|
+
dto.DeviceOnAllResponse.from_binary)
|
|
964
|
+
return response.device_addresses
|
|
965
|
+
|
|
966
|
+
def __repr__(
|
|
967
|
+
self
|
|
968
|
+
) -> str:
|
|
969
|
+
"""
|
|
970
|
+
Returns a string that represents the connection.
|
|
971
|
+
|
|
972
|
+
Returns:
|
|
973
|
+
A string that represents the connection.
|
|
974
|
+
"""
|
|
975
|
+
request = dto.InterfaceEmptyRequest(
|
|
976
|
+
interface_id=self.interface_id,
|
|
977
|
+
)
|
|
978
|
+
response = call_sync(
|
|
979
|
+
"interface/to_string",
|
|
980
|
+
request,
|
|
981
|
+
dto.StringResponse.from_binary)
|
|
982
|
+
return response.value
|
|
983
|
+
|
|
984
|
+
def __retrieve_timeout(
|
|
985
|
+
self
|
|
986
|
+
) -> int:
|
|
987
|
+
"""
|
|
988
|
+
Returns default request timeout.
|
|
989
|
+
|
|
990
|
+
Returns:
|
|
991
|
+
Default request timeout.
|
|
992
|
+
"""
|
|
993
|
+
request = dto.InterfaceEmptyRequest(
|
|
994
|
+
interface_id=self.interface_id,
|
|
995
|
+
)
|
|
996
|
+
response = call_sync(
|
|
997
|
+
"interface/get_timeout",
|
|
998
|
+
request,
|
|
999
|
+
dto.IntResponse.from_binary)
|
|
1000
|
+
return response.value
|
|
1001
|
+
|
|
1002
|
+
def __change_timeout(
|
|
1003
|
+
self,
|
|
1004
|
+
timeout: int
|
|
1005
|
+
) -> None:
|
|
1006
|
+
"""
|
|
1007
|
+
Sets default request timeout.
|
|
1008
|
+
|
|
1009
|
+
Args:
|
|
1010
|
+
timeout: Default request timeout.
|
|
1011
|
+
"""
|
|
1012
|
+
request = dto.SetInterfaceTimeoutRequest(
|
|
1013
|
+
interface_id=self.interface_id,
|
|
1014
|
+
timeout=timeout,
|
|
1015
|
+
)
|
|
1016
|
+
call_sync("interface/set_timeout", request)
|
|
1017
|
+
|
|
1018
|
+
def __retrieve_checksum_enabled(
|
|
1019
|
+
self
|
|
1020
|
+
) -> bool:
|
|
1021
|
+
"""
|
|
1022
|
+
Returns checksum enabled.
|
|
1023
|
+
|
|
1024
|
+
Returns:
|
|
1025
|
+
Checksum enabled.
|
|
1026
|
+
"""
|
|
1027
|
+
request = dto.InterfaceEmptyRequest(
|
|
1028
|
+
interface_id=self.interface_id,
|
|
1029
|
+
)
|
|
1030
|
+
response = call_sync(
|
|
1031
|
+
"interface/get_checksum_enabled",
|
|
1032
|
+
request,
|
|
1033
|
+
dto.BoolResponse.from_binary)
|
|
1034
|
+
return response.value
|
|
1035
|
+
|
|
1036
|
+
def __change_checksum_enabled(
|
|
1037
|
+
self,
|
|
1038
|
+
is_enabled: bool
|
|
1039
|
+
) -> None:
|
|
1040
|
+
"""
|
|
1041
|
+
Sets checksum enabled.
|
|
1042
|
+
|
|
1043
|
+
Args:
|
|
1044
|
+
is_enabled: Checksum enabled.
|
|
1045
|
+
"""
|
|
1046
|
+
request = dto.SetInterfaceChecksumEnabledRequest(
|
|
1047
|
+
interface_id=self.interface_id,
|
|
1048
|
+
is_enabled=is_enabled,
|
|
1049
|
+
)
|
|
1050
|
+
call_sync("interface/set_checksum_enabled", request)
|
|
1051
|
+
|
|
1052
|
+
def __retrieve_is_open(
|
|
1053
|
+
self
|
|
1054
|
+
) -> bool:
|
|
1055
|
+
"""
|
|
1056
|
+
Returns is open.
|
|
1057
|
+
|
|
1058
|
+
Returns:
|
|
1059
|
+
Is open.
|
|
1060
|
+
"""
|
|
1061
|
+
request = dto.InterfaceEmptyRequest(
|
|
1062
|
+
interface_id=self.interface_id,
|
|
1063
|
+
)
|
|
1064
|
+
response = call_sync(
|
|
1065
|
+
"interface/get_is_open",
|
|
1066
|
+
request,
|
|
1067
|
+
dto.BoolResponse.from_binary)
|
|
1068
|
+
return response.value
|
|
1069
|
+
|
|
1070
|
+
@staticmethod
|
|
1071
|
+
def __free(
|
|
1072
|
+
interface_id: int
|
|
1073
|
+
) -> None:
|
|
1074
|
+
"""
|
|
1075
|
+
Releases native resources of the connection.
|
|
1076
|
+
|
|
1077
|
+
Args:
|
|
1078
|
+
interface_id: The ID of the connection.
|
|
1079
|
+
"""
|
|
1080
|
+
request = dto.InterfaceEmptyRequest(
|
|
1081
|
+
interface_id=interface_id,
|
|
1082
|
+
)
|
|
1083
|
+
call_sync("interface/free", request)
|
|
1084
|
+
|
|
1085
|
+
def __enter__(self) -> 'Connection':
|
|
1086
|
+
""" __enter__ """
|
|
1087
|
+
return self
|
|
1088
|
+
|
|
1089
|
+
def __exit__(self, _type: Any, _value: Any, _traceback: Any) -> None:
|
|
1090
|
+
""" __exit__ """
|
|
1091
|
+
self.close()
|
|
1092
|
+
|
|
1093
|
+
def __setup_events(self, session_id: int) -> None:
|
|
1094
|
+
def filter_connection_event(
|
|
1095
|
+
data: TConnectionEvents,
|
|
1096
|
+
) -> bool:
|
|
1097
|
+
return data.interface_id == self._interface_id and data.session_id == session_id
|
|
1098
|
+
|
|
1099
|
+
self._disconnected = ReplaySubject[MotionLibException]() # terminates all the events
|
|
1100
|
+
|
|
1101
|
+
unknown_response = filter_events('interface/unknown_response', dto.UnknownResponseEventWrapper)
|
|
1102
|
+
self._unknown_response = unknown_response.pipe(
|
|
1103
|
+
rxop.filter(filter_connection_event),
|
|
1104
|
+
rxop.take_until(self.disconnected),
|
|
1105
|
+
rxop.map(map_unknown_response)
|
|
1106
|
+
)
|
|
1107
|
+
|
|
1108
|
+
alert = filter_events('interface/alert', dto.AlertEventWrapper)
|
|
1109
|
+
self._alert = alert.pipe(
|
|
1110
|
+
rxop.filter(filter_connection_event),
|
|
1111
|
+
rxop.take_until(self.disconnected),
|
|
1112
|
+
rxop.map(map_alert)
|
|
1113
|
+
)
|
|
1114
|
+
|
|
1115
|
+
disconnected = filter_events('interface/disconnected', dto.DisconnectedEvent)
|
|
1116
|
+
disconnected.pipe(
|
|
1117
|
+
rxop.filter(filter_connection_event),
|
|
1118
|
+
rxop.take(1),
|
|
1119
|
+
rxop.map(map_disconnect)
|
|
1120
|
+
).subscribe(self._disconnected)
|
|
1121
|
+
|
|
1122
|
+
def __del__(self) -> None:
|
|
1123
|
+
Connection.__free(self._interface_id)
|
|
1124
|
+
|
|
1125
|
+
|
|
1126
|
+
class AsyncConnectionOpener:
|
|
1127
|
+
'''Provides a connection in an asynchronous context using `await` or `async with`'''
|
|
1128
|
+
def __init__(self, request: dto.OpenInterfaceRequest) -> None:
|
|
1129
|
+
self._request = request
|
|
1130
|
+
self._resource: Optional[Connection] = None
|
|
1131
|
+
|
|
1132
|
+
async def _create_resource(self) -> Connection:
|
|
1133
|
+
task = asyncio.ensure_future(call_async(
|
|
1134
|
+
"interface/open",
|
|
1135
|
+
self._request,
|
|
1136
|
+
dto.OpenInterfaceResponse.from_binary))
|
|
1137
|
+
|
|
1138
|
+
try:
|
|
1139
|
+
response = await asyncio.shield(task)
|
|
1140
|
+
except asyncio.CancelledError:
|
|
1141
|
+
async def cancel() -> None:
|
|
1142
|
+
try:
|
|
1143
|
+
response = await task
|
|
1144
|
+
await Connection(response.interface_id).close_async()
|
|
1145
|
+
except MotionLibException:
|
|
1146
|
+
pass
|
|
1147
|
+
|
|
1148
|
+
asyncio.ensure_future(cancel())
|
|
1149
|
+
raise
|
|
1150
|
+
|
|
1151
|
+
return Connection(response.interface_id)
|
|
1152
|
+
|
|
1153
|
+
def __await__(self) -> Generator[Any, None, 'Connection']:
|
|
1154
|
+
return self._create_resource().__await__()
|
|
1155
|
+
|
|
1156
|
+
async def __aenter__(self) -> 'Connection':
|
|
1157
|
+
self._resource = await self._create_resource()
|
|
1158
|
+
return self._resource
|
|
1159
|
+
|
|
1160
|
+
async def __aexit__(self, exc_type: Any, exc: Any, trace: Any) -> None:
|
|
1161
|
+
if self._resource is not None:
|
|
1162
|
+
await self._resource.close_async()
|
|
1163
|
+
|
|
1164
|
+
|
|
1165
|
+
def map_unknown_response(event: dto.UnknownResponseEventWrapper) -> UnknownResponseEvent:
|
|
1166
|
+
return event.unknown_response
|
|
1167
|
+
|
|
1168
|
+
|
|
1169
|
+
def map_alert(event: dto.AlertEventWrapper) -> AlertEvent:
|
|
1170
|
+
return event.alert
|
|
1171
|
+
|
|
1172
|
+
|
|
1173
|
+
def map_disconnect(event: dto.DisconnectedEvent) -> MotionLibException:
|
|
1174
|
+
return convert_exception(event.error_type, event.error_message)
|