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.
Files changed (492) hide show
  1. zaber_motion/__init__.py +103 -103
  2. zaber_motion/ascii/__init__.py +73 -73
  3. zaber_motion/ascii/all_axes.py +352 -352
  4. zaber_motion/ascii/axis.py +1673 -1673
  5. zaber_motion/ascii/axis_group.py +391 -391
  6. zaber_motion/ascii/axis_settings.py +752 -752
  7. zaber_motion/ascii/connection.py +1174 -1174
  8. zaber_motion/ascii/device.py +908 -908
  9. zaber_motion/ascii/device_io.py +1170 -1170
  10. zaber_motion/ascii/device_settings.py +735 -735
  11. zaber_motion/ascii/lockstep.py +1184 -1184
  12. zaber_motion/ascii/oscilloscope.py +635 -635
  13. zaber_motion/ascii/oscilloscope_data.py +240 -240
  14. zaber_motion/ascii/pvt.py +105 -105
  15. zaber_motion/ascii/pvt_buffer.py +146 -146
  16. zaber_motion/ascii/pvt_io.py +630 -630
  17. zaber_motion/ascii/pvt_sequence.py +1530 -1530
  18. zaber_motion/ascii/servo_tuner.py +637 -637
  19. zaber_motion/ascii/setting_constants.py +1755 -1755
  20. zaber_motion/ascii/storage.py +905 -905
  21. zaber_motion/ascii/stream.py +2182 -2182
  22. zaber_motion/ascii/stream_buffer.py +101 -101
  23. zaber_motion/ascii/stream_io.py +700 -700
  24. zaber_motion/ascii/streams.py +105 -105
  25. zaber_motion/ascii/transport.py +202 -202
  26. zaber_motion/ascii/trigger.py +886 -886
  27. zaber_motion/ascii/triggers.py +241 -241
  28. zaber_motion/ascii/warning_flags.py +178 -178
  29. zaber_motion/ascii/warnings.py +152 -152
  30. zaber_motion/async_utils.py +46 -46
  31. zaber_motion/binary/__init__.py +14 -14
  32. zaber_motion/binary/connection.py +648 -648
  33. zaber_motion/binary/device.py +924 -924
  34. zaber_motion/binary/device_settings.py +121 -121
  35. zaber_motion/bindings.py +50 -50
  36. zaber_motion/call.py +198 -198
  37. zaber_motion/convert_exception.py +138 -138
  38. zaber_motion/dto/__init__.py +11 -11
  39. zaber_motion/dto/ascii/__init__.py +46 -46
  40. zaber_motion/dto/ascii/alert_event.py +110 -110
  41. zaber_motion/dto/ascii/axis_identity.py +134 -134
  42. zaber_motion/dto/ascii/axis_type.py +14 -14
  43. zaber_motion/dto/ascii/can_set_state_axis_response.py +69 -69
  44. zaber_motion/dto/ascii/can_set_state_device_response.py +75 -75
  45. zaber_motion/dto/ascii/conversion_factor.py +81 -81
  46. zaber_motion/dto/ascii/device_identity.py +136 -136
  47. zaber_motion/dto/ascii/device_io_info.py +108 -108
  48. zaber_motion/dto/ascii/digital_output_action.py +13 -13
  49. zaber_motion/dto/ascii/get_axis_setting.py +64 -64
  50. zaber_motion/dto/ascii/get_axis_setting_result.py +81 -81
  51. zaber_motion/dto/ascii/get_setting.py +88 -88
  52. zaber_motion/dto/ascii/get_setting_result.py +87 -87
  53. zaber_motion/dto/ascii/io_port_label.py +84 -84
  54. zaber_motion/dto/ascii/io_port_type.py +14 -14
  55. zaber_motion/dto/ascii/lockstep_axes.py +108 -108
  56. zaber_motion/dto/ascii/measurement_sequence.py +73 -73
  57. zaber_motion/dto/ascii/message_type.py +14 -14
  58. zaber_motion/dto/ascii/optional_measurement_sequence.py +71 -71
  59. zaber_motion/dto/ascii/oscilloscope_capture_properties.py +116 -116
  60. zaber_motion/dto/ascii/oscilloscope_data_source.py +11 -11
  61. zaber_motion/dto/ascii/paramset_info.py +92 -92
  62. zaber_motion/dto/ascii/pid_tuning.py +125 -125
  63. zaber_motion/dto/ascii/pvt_axis_definition.py +70 -70
  64. zaber_motion/dto/ascii/pvt_axis_type.py +11 -11
  65. zaber_motion/dto/ascii/pvt_csv_data.py +75 -75
  66. zaber_motion/dto/ascii/pvt_mode.py +12 -12
  67. zaber_motion/dto/ascii/pvt_sequence_data.py +99 -99
  68. zaber_motion/dto/ascii/response.py +137 -137
  69. zaber_motion/dto/ascii/servo_tuning_param.py +66 -66
  70. zaber_motion/dto/ascii/servo_tuning_paramset.py +21 -21
  71. zaber_motion/dto/ascii/set_state_axis_response.py +75 -75
  72. zaber_motion/dto/ascii/set_state_device_response.py +80 -80
  73. zaber_motion/dto/ascii/simple_tuning.py +118 -118
  74. zaber_motion/dto/ascii/simple_tuning_param_definition.py +100 -100
  75. zaber_motion/dto/ascii/stream_axis_definition.py +70 -70
  76. zaber_motion/dto/ascii/stream_axis_type.py +11 -11
  77. zaber_motion/dto/ascii/stream_mode.py +13 -13
  78. zaber_motion/dto/ascii/trigger_action.py +12 -12
  79. zaber_motion/dto/ascii/trigger_condition.py +15 -15
  80. zaber_motion/dto/ascii/trigger_enabled_state.py +68 -68
  81. zaber_motion/dto/ascii/trigger_operation.py +12 -12
  82. zaber_motion/dto/ascii/trigger_state.py +114 -114
  83. zaber_motion/dto/ascii/unknown_response_event.py +137 -137
  84. zaber_motion/dto/axis_address.py +74 -74
  85. zaber_motion/dto/binary/__init__.py +11 -11
  86. zaber_motion/dto/binary/binary_settings.py +74 -74
  87. zaber_motion/dto/binary/command_code.py +106 -106
  88. zaber_motion/dto/binary/device_identity.py +156 -156
  89. zaber_motion/dto/binary/device_type.py +12 -12
  90. zaber_motion/dto/binary/error_code.py +101 -101
  91. zaber_motion/dto/binary/message.py +91 -91
  92. zaber_motion/dto/binary/reply_code.py +16 -16
  93. zaber_motion/dto/binary/reply_only_event.py +91 -91
  94. zaber_motion/dto/binary/unknown_response_event.py +91 -91
  95. zaber_motion/dto/channel_address.py +74 -74
  96. zaber_motion/dto/device_db_source.py +66 -66
  97. zaber_motion/dto/device_db_source_type.py +11 -11
  98. zaber_motion/dto/exceptions/__init__.py +24 -24
  99. zaber_motion/dto/exceptions/binary_command_failed_exception_data.py +57 -57
  100. zaber_motion/dto/exceptions/command_failed_exception_data.py +151 -151
  101. zaber_motion/dto/exceptions/command_too_long_exception_data.py +98 -98
  102. zaber_motion/dto/exceptions/device_address_conflict_exception_data.py +63 -63
  103. zaber_motion/dto/exceptions/device_db_failed_exception_data.py +74 -74
  104. zaber_motion/dto/exceptions/device_db_inner_error.py +85 -85
  105. zaber_motion/dto/exceptions/g_code_execution_exception_data.py +75 -75
  106. zaber_motion/dto/exceptions/g_code_syntax_exception_data.py +75 -75
  107. zaber_motion/dto/exceptions/invalid_packet_exception_data.py +63 -63
  108. zaber_motion/dto/exceptions/invalid_pvt_point.py +69 -69
  109. zaber_motion/dto/exceptions/invalid_response_exception_data.py +51 -51
  110. zaber_motion/dto/exceptions/movement_failed_exception_data.py +104 -104
  111. zaber_motion/dto/exceptions/movement_interrupted_exception_data.py +104 -104
  112. zaber_motion/dto/exceptions/operation_failed_exception_data.py +104 -104
  113. zaber_motion/dto/exceptions/pvt_execution_exception_data.py +86 -86
  114. zaber_motion/dto/exceptions/pvt_movement_failed_exception_data.py +69 -69
  115. zaber_motion/dto/exceptions/pvt_movement_interrupted_exception_data.py +69 -69
  116. zaber_motion/dto/exceptions/set_device_state_exception_data.py +176 -176
  117. zaber_motion/dto/exceptions/set_peripheral_state_exception_data.py +121 -121
  118. zaber_motion/dto/exceptions/stream_execution_exception_data.py +63 -63
  119. zaber_motion/dto/exceptions/stream_movement_failed_exception_data.py +69 -69
  120. zaber_motion/dto/exceptions/stream_movement_interrupted_exception_data.py +69 -69
  121. zaber_motion/dto/firmware_version.py +91 -91
  122. zaber_motion/dto/gcode/__init__.py +9 -9
  123. zaber_motion/dto/gcode/axis_definition.py +74 -74
  124. zaber_motion/dto/gcode/axis_mapping.py +69 -69
  125. zaber_motion/dto/gcode/axis_transformation.py +79 -79
  126. zaber_motion/dto/gcode/device_definition.py +99 -99
  127. zaber_motion/dto/gcode/translate_message.py +87 -87
  128. zaber_motion/dto/gcode/translate_result.py +79 -79
  129. zaber_motion/dto/gcode/translator_config.py +84 -84
  130. zaber_motion/dto/log_output_mode.py +13 -13
  131. zaber_motion/dto/measurement.py +67 -67
  132. zaber_motion/dto/microscopy/__init__.py +6 -6
  133. zaber_motion/dto/microscopy/autofocus_status.py +57 -57
  134. zaber_motion/dto/microscopy/microscope_config.py +159 -159
  135. zaber_motion/dto/microscopy/third_party_components.py +55 -55
  136. zaber_motion/dto/microscopy/wdi_autofocus_provider_status.py +57 -57
  137. zaber_motion/dto/named_parameter.py +64 -64
  138. zaber_motion/dto/product/__init__.py +5 -5
  139. zaber_motion/dto/product/process_controller_mode.py +13 -13
  140. zaber_motion/dto/product/process_controller_source.py +72 -72
  141. zaber_motion/dto/product/process_controller_source_sensor.py +11 -11
  142. zaber_motion/dto/requests/__init__.py +256 -254
  143. zaber_motion/dto/requests/alert_event_wrapper.py +82 -82
  144. zaber_motion/dto/requests/autofocus_focus_request.py +131 -131
  145. zaber_motion/dto/requests/autofocus_get_objective_params_request.py +121 -121
  146. zaber_motion/dto/requests/autofocus_get_objective_params_response.py +56 -56
  147. zaber_motion/dto/requests/autofocus_get_status_response.py +50 -50
  148. zaber_motion/dto/requests/autofocus_set_objective_params_request.py +141 -141
  149. zaber_motion/dto/requests/axes_empty_request.py +95 -95
  150. zaber_motion/dto/requests/axes_get_setting_request.py +121 -121
  151. zaber_motion/dto/requests/axes_move_request.py +114 -114
  152. zaber_motion/dto/requests/axis_empty_request.py +79 -79
  153. zaber_motion/dto/requests/axis_move_type.py +12 -12
  154. zaber_motion/dto/requests/axis_to_string_request.py +88 -88
  155. zaber_motion/dto/requests/binary_device_detect_request.py +56 -56
  156. zaber_motion/dto/requests/binary_device_detect_response.py +57 -57
  157. zaber_motion/dto/requests/binary_device_get_setting_request.py +89 -89
  158. zaber_motion/dto/requests/binary_device_home_request.py +88 -88
  159. zaber_motion/dto/requests/binary_device_move_request.py +111 -111
  160. zaber_motion/dto/requests/binary_device_set_setting_request.py +100 -100
  161. zaber_motion/dto/requests/binary_device_stop_request.py +88 -88
  162. zaber_motion/dto/requests/binary_generic_with_units_request.py +122 -122
  163. zaber_motion/dto/requests/binary_message_collection.py +56 -56
  164. zaber_motion/dto/requests/binary_reply_only_event_wrapper.py +82 -82
  165. zaber_motion/dto/requests/bool_response.py +43 -43
  166. zaber_motion/dto/requests/can_set_state_axis_response.py +60 -60
  167. zaber_motion/dto/requests/can_set_state_request.py +100 -100
  168. zaber_motion/dto/requests/channel_on.py +96 -84
  169. zaber_motion/dto/requests/channel_set_intensity.py +90 -90
  170. zaber_motion/dto/requests/check_version_request.py +54 -54
  171. zaber_motion/dto/requests/custom_interface_close_request.py +60 -60
  172. zaber_motion/dto/requests/custom_interface_open_response.py +51 -51
  173. zaber_motion/dto/requests/custom_interface_read_request.py +51 -51
  174. zaber_motion/dto/requests/custom_interface_write_request.py +60 -60
  175. zaber_motion/dto/requests/device_cancel_all_outputs_schedule_request.py +80 -80
  176. zaber_motion/dto/requests/device_cancel_output_schedule_request.py +84 -84
  177. zaber_motion/dto/requests/device_convert_setting_request.py +116 -116
  178. zaber_motion/dto/requests/device_detect_request.py +68 -68
  179. zaber_motion/dto/requests/device_detect_response.py +57 -57
  180. zaber_motion/dto/requests/device_empty_request.py +65 -65
  181. zaber_motion/dto/requests/device_get_all_analog_io_request.py +74 -74
  182. zaber_motion/dto/requests/device_get_all_analog_io_response.py +54 -54
  183. zaber_motion/dto/requests/device_get_all_digital_io_request.py +74 -74
  184. zaber_motion/dto/requests/device_get_all_digital_io_response.py +46 -46
  185. zaber_motion/dto/requests/device_get_analog_io_request.py +88 -88
  186. zaber_motion/dto/requests/device_get_digital_io_request.py +88 -88
  187. zaber_motion/dto/requests/device_get_setting_request.py +100 -100
  188. zaber_motion/dto/requests/device_get_storage_request.py +93 -93
  189. zaber_motion/dto/requests/device_get_warnings_request.py +84 -84
  190. zaber_motion/dto/requests/device_get_warnings_response.py +51 -51
  191. zaber_motion/dto/requests/device_home_request.py +84 -84
  192. zaber_motion/dto/requests/device_identify_request.py +77 -77
  193. zaber_motion/dto/requests/device_move_request.py +177 -177
  194. zaber_motion/dto/requests/device_move_sin_request.py +140 -140
  195. zaber_motion/dto/requests/device_multi_get_setting_request.py +118 -118
  196. zaber_motion/dto/requests/device_on_all_request.py +56 -56
  197. zaber_motion/dto/requests/device_on_all_response.py +57 -57
  198. zaber_motion/dto/requests/device_restore_request.py +84 -84
  199. zaber_motion/dto/requests/device_set_all_analog_outputs_request.py +82 -82
  200. zaber_motion/dto/requests/device_set_all_analog_outputs_schedule_request.py +121 -121
  201. zaber_motion/dto/requests/device_set_all_digital_outputs_request.py +83 -83
  202. zaber_motion/dto/requests/device_set_all_digital_outputs_schedule_request.py +122 -122
  203. zaber_motion/dto/requests/device_set_analog_output_request.py +90 -90
  204. zaber_motion/dto/requests/device_set_analog_output_schedule_request.py +124 -124
  205. zaber_motion/dto/requests/device_set_digital_output_request.py +91 -91
  206. zaber_motion/dto/requests/device_set_digital_output_schedule_request.py +125 -125
  207. zaber_motion/dto/requests/device_set_lowpass_filter_request.py +102 -102
  208. zaber_motion/dto/requests/device_set_setting_bool_request.py +93 -93
  209. zaber_motion/dto/requests/device_set_setting_int_request.py +102 -102
  210. zaber_motion/dto/requests/device_set_setting_request.py +111 -111
  211. zaber_motion/dto/requests/device_set_setting_str_request.py +97 -97
  212. zaber_motion/dto/requests/device_set_storage_bool_request.py +93 -93
  213. zaber_motion/dto/requests/device_set_storage_number_request.py +99 -99
  214. zaber_motion/dto/requests/device_set_storage_request.py +102 -102
  215. zaber_motion/dto/requests/device_set_unit_conversions_request.py +108 -108
  216. zaber_motion/dto/requests/device_stop_request.py +84 -84
  217. zaber_motion/dto/requests/device_storage_list_keys_request.py +88 -88
  218. zaber_motion/dto/requests/device_storage_request.py +88 -88
  219. zaber_motion/dto/requests/device_type.py +8 -8
  220. zaber_motion/dto/requests/device_wait_until_idle_request.py +84 -84
  221. zaber_motion/dto/requests/disconnected_event.py +101 -101
  222. zaber_motion/dto/requests/double_array_response.py +54 -54
  223. zaber_motion/dto/requests/double_response.py +48 -48
  224. zaber_motion/dto/requests/driver_enable_request.py +90 -90
  225. zaber_motion/dto/requests/empty_autofocus_request.py +107 -107
  226. zaber_motion/dto/requests/empty_request.py +38 -38
  227. zaber_motion/dto/requests/errors.py +68 -68
  228. zaber_motion/dto/requests/find_device_request.py +65 -65
  229. zaber_motion/dto/requests/find_device_response.py +51 -51
  230. zaber_motion/dto/requests/forget_devices_request.py +71 -71
  231. zaber_motion/dto/requests/gateway_event.py +45 -45
  232. zaber_motion/dto/requests/gateway_request.py +45 -45
  233. zaber_motion/dto/requests/gateway_response.py +69 -69
  234. zaber_motion/dto/requests/generic_binary_request.py +107 -107
  235. zaber_motion/dto/requests/generic_command_request.py +107 -107
  236. zaber_motion/dto/requests/generic_command_response_collection.py +56 -56
  237. zaber_motion/dto/requests/get_all_io_port_labels_response.py +56 -56
  238. zaber_motion/dto/requests/get_axis_setting_results.py +56 -56
  239. zaber_motion/dto/requests/get_io_port_label_request.py +91 -91
  240. zaber_motion/dto/requests/get_setting_results.py +56 -56
  241. zaber_motion/dto/requests/get_simple_tuning_param_definition_response.py +56 -56
  242. zaber_motion/dto/requests/int_64_response.py +51 -51
  243. zaber_motion/dto/requests/int_array_response.py +57 -57
  244. zaber_motion/dto/requests/int_request.py +51 -51
  245. zaber_motion/dto/requests/int_response.py +51 -51
  246. zaber_motion/dto/requests/interface_empty_request.py +51 -51
  247. zaber_motion/dto/requests/interface_type.py +11 -11
  248. zaber_motion/dto/requests/load_paramset.py +102 -102
  249. zaber_motion/dto/requests/lockstep_disable_request.py +84 -84
  250. zaber_motion/dto/requests/lockstep_empty_request.py +79 -79
  251. zaber_motion/dto/requests/lockstep_enable_request.py +99 -99
  252. zaber_motion/dto/requests/lockstep_get_axis_numbers_response.py +57 -57
  253. zaber_motion/dto/requests/lockstep_get_request.py +91 -91
  254. zaber_motion/dto/requests/lockstep_home_request.py +84 -84
  255. zaber_motion/dto/requests/lockstep_move_request.py +163 -163
  256. zaber_motion/dto/requests/lockstep_move_sin_request.py +140 -140
  257. zaber_motion/dto/requests/lockstep_set_request.py +116 -116
  258. zaber_motion/dto/requests/lockstep_stop_request.py +84 -84
  259. zaber_motion/dto/requests/lockstep_wait_until_idle_request.py +84 -84
  260. zaber_motion/dto/requests/microscope_config_response.py +50 -50
  261. zaber_motion/dto/requests/microscope_empty_request.py +65 -65
  262. zaber_motion/dto/requests/microscope_find_request.py +63 -63
  263. zaber_motion/dto/requests/microscope_init_request.py +70 -70
  264. zaber_motion/dto/requests/microscope_trigger_camera_request.py +107 -107
  265. zaber_motion/dto/requests/objective_changer_change_request.py +119 -119
  266. zaber_motion/dto/requests/objective_changer_create_response.py +79 -79
  267. zaber_motion/dto/requests/objective_changer_get_current_response.py +51 -51
  268. zaber_motion/dto/requests/objective_changer_request.py +93 -93
  269. zaber_motion/dto/requests/objective_changer_set_request.py +116 -116
  270. zaber_motion/dto/requests/open_binary_interface_request.py +100 -100
  271. zaber_motion/dto/requests/open_interface_request.py +159 -159
  272. zaber_motion/dto/requests/open_interface_response.py +51 -51
  273. zaber_motion/dto/requests/oscilloscope_add_io_channel_request.py +91 -91
  274. zaber_motion/dto/requests/oscilloscope_add_setting_channel_request.py +88 -88
  275. zaber_motion/dto/requests/oscilloscope_data_get_request.py +63 -63
  276. zaber_motion/dto/requests/oscilloscope_data_get_sample_time_request.py +77 -77
  277. zaber_motion/dto/requests/oscilloscope_data_get_samples_response.py +54 -54
  278. zaber_motion/dto/requests/oscilloscope_data_identifier.py +51 -51
  279. zaber_motion/dto/requests/oscilloscope_read_response.py +57 -57
  280. zaber_motion/dto/requests/oscilloscope_request.py +65 -65
  281. zaber_motion/dto/requests/oscilloscope_start_request.py +79 -79
  282. zaber_motion/dto/requests/prepare_command_request.py +108 -108
  283. zaber_motion/dto/requests/process_on.py +107 -107
  284. zaber_motion/dto/requests/pvt_buffer_get_sequence_data_request.py +79 -79
  285. zaber_motion/dto/requests/pvt_csv_request.py +59 -59
  286. zaber_motion/dto/requests/pvt_generate_positions_request.py +74 -74
  287. zaber_motion/dto/requests/pvt_generate_velocities_and_times_request.py +96 -96
  288. zaber_motion/dto/requests/pvt_generate_velocities_request.py +93 -93
  289. zaber_motion/dto/requests/pvt_load_csv_request.py +45 -45
  290. zaber_motion/dto/requests/pvt_point_request.py +145 -145
  291. zaber_motion/dto/requests/pvt_points_request.py +147 -147
  292. zaber_motion/dto/requests/pvt_save_csv_request.py +74 -74
  293. zaber_motion/dto/requests/pvt_submit_sequence_data_request.py +93 -93
  294. zaber_motion/dto/requests/renumber_request.py +79 -79
  295. zaber_motion/dto/requests/response_type.py +8 -8
  296. zaber_motion/dto/requests/servo_tuning_paramset_response.py +48 -48
  297. zaber_motion/dto/requests/servo_tuning_request.py +91 -91
  298. zaber_motion/dto/requests/set_device_db_layered_sources_request.py +56 -56
  299. zaber_motion/dto/requests/set_device_db_source_request.py +63 -63
  300. zaber_motion/dto/requests/set_interface_checksum_enabled_request.py +56 -56
  301. zaber_motion/dto/requests/set_interface_timeout_request.py +65 -65
  302. zaber_motion/dto/requests/set_internal_mode_request.py +43 -43
  303. zaber_motion/dto/requests/set_io_port_label_request.py +100 -100
  304. zaber_motion/dto/requests/set_log_output_request.py +57 -57
  305. zaber_motion/dto/requests/set_process_controller_source.py +93 -93
  306. zaber_motion/dto/requests/set_servo_tuning_pid_request.py +135 -135
  307. zaber_motion/dto/requests/set_servo_tuning_request.py +116 -116
  308. zaber_motion/dto/requests/set_simple_tuning.py +174 -174
  309. zaber_motion/dto/requests/set_state_request.py +93 -93
  310. zaber_motion/dto/requests/stream_arc_request.py +199 -199
  311. zaber_motion/dto/requests/stream_buffer_erase_request.py +84 -84
  312. zaber_motion/dto/requests/stream_buffer_get_content_request.py +84 -84
  313. zaber_motion/dto/requests/stream_buffer_get_content_response.py +51 -51
  314. zaber_motion/dto/requests/stream_buffer_list.py +70 -70
  315. zaber_motion/dto/requests/stream_call_request.py +112 -112
  316. zaber_motion/dto/requests/stream_cancel_all_outputs_schedule_request.py +99 -99
  317. zaber_motion/dto/requests/stream_cancel_output_schedule_request.py +103 -103
  318. zaber_motion/dto/requests/stream_circle_request.py +155 -155
  319. zaber_motion/dto/requests/stream_empty_request.py +84 -84
  320. zaber_motion/dto/requests/stream_generic_command_batch_request.py +99 -99
  321. zaber_motion/dto/requests/stream_generic_command_request.py +93 -93
  322. zaber_motion/dto/requests/stream_get_axes_response.py +75 -75
  323. zaber_motion/dto/requests/stream_get_max_centripetal_acceleration_request.py +96 -96
  324. zaber_motion/dto/requests/stream_get_max_speed_request.py +96 -96
  325. zaber_motion/dto/requests/stream_get_max_tangential_acceleration_request.py +96 -96
  326. zaber_motion/dto/requests/stream_line_request.py +135 -135
  327. zaber_motion/dto/requests/stream_mode_response.py +60 -60
  328. zaber_motion/dto/requests/stream_segment_type.py +8 -8
  329. zaber_motion/dto/requests/stream_set_all_analog_outputs_request.py +101 -101
  330. zaber_motion/dto/requests/stream_set_all_analog_outputs_schedule_request.py +140 -140
  331. zaber_motion/dto/requests/stream_set_all_digital_outputs_request.py +102 -102
  332. zaber_motion/dto/requests/stream_set_all_digital_outputs_schedule_request.py +141 -141
  333. zaber_motion/dto/requests/stream_set_analog_output_request.py +109 -109
  334. zaber_motion/dto/requests/stream_set_analog_output_schedule_request.py +143 -143
  335. zaber_motion/dto/requests/stream_set_digital_output_request.py +110 -110
  336. zaber_motion/dto/requests/stream_set_digital_output_schedule_request.py +144 -144
  337. zaber_motion/dto/requests/stream_set_hold_request.py +89 -89
  338. zaber_motion/dto/requests/stream_set_max_centripetal_acceleration_request.py +107 -107
  339. zaber_motion/dto/requests/stream_set_max_speed_request.py +107 -107
  340. zaber_motion/dto/requests/stream_set_max_tangential_acceleration_request.py +107 -107
  341. zaber_motion/dto/requests/stream_setup_live_composite_request.py +123 -123
  342. zaber_motion/dto/requests/stream_setup_live_request.py +104 -104
  343. zaber_motion/dto/requests/stream_setup_store_arbitrary_axes_request.py +126 -126
  344. zaber_motion/dto/requests/stream_setup_store_composite_request.py +151 -151
  345. zaber_motion/dto/requests/stream_setup_store_request.py +132 -132
  346. zaber_motion/dto/requests/stream_wait_analog_input_request.py +118 -118
  347. zaber_motion/dto/requests/stream_wait_digital_input_request.py +103 -103
  348. zaber_motion/dto/requests/stream_wait_request.py +107 -107
  349. zaber_motion/dto/requests/stream_wait_until_idle_request.py +89 -89
  350. zaber_motion/dto/requests/string_array_response.py +51 -51
  351. zaber_motion/dto/requests/string_response.py +45 -45
  352. zaber_motion/dto/requests/test_event.py +45 -45
  353. zaber_motion/dto/requests/test_request.py +55 -55
  354. zaber_motion/dto/requests/test_request_complex.py +57 -0
  355. zaber_motion/dto/requests/test_response.py +45 -45
  356. zaber_motion/dto/requests/test_response_long.py +51 -51
  357. zaber_motion/dto/requests/toggle_device_db_store_request.py +50 -50
  358. zaber_motion/dto/requests/tools_list_serial_ports_response.py +51 -51
  359. zaber_motion/dto/requests/translator_create_from_device_request.py +97 -97
  360. zaber_motion/dto/requests/translator_create_live_request.py +91 -91
  361. zaber_motion/dto/requests/translator_create_request.py +62 -62
  362. zaber_motion/dto/requests/translator_create_response.py +51 -51
  363. zaber_motion/dto/requests/translator_empty_request.py +51 -51
  364. zaber_motion/dto/requests/translator_flush_live_request.py +56 -56
  365. zaber_motion/dto/requests/translator_flush_response.py +51 -51
  366. zaber_motion/dto/requests/translator_get_axis_offset_request.py +81 -81
  367. zaber_motion/dto/requests/translator_get_axis_position_request.py +72 -72
  368. zaber_motion/dto/requests/translator_set_axis_position_request.py +83 -83
  369. zaber_motion/dto/requests/translator_set_feed_rate_override_request.py +62 -62
  370. zaber_motion/dto/requests/translator_set_traverse_rate_request.py +74 -74
  371. zaber_motion/dto/requests/translator_translate_request.py +60 -60
  372. zaber_motion/dto/requests/trigger_clear_action_request.py +91 -91
  373. zaber_motion/dto/requests/trigger_empty_request.py +79 -79
  374. zaber_motion/dto/requests/trigger_enable_request.py +93 -93
  375. zaber_motion/dto/requests/trigger_enabled_states.py +56 -56
  376. zaber_motion/dto/requests/trigger_fire_at_interval_request.py +102 -102
  377. zaber_motion/dto/requests/trigger_fire_when_distance_travelled_request.py +116 -116
  378. zaber_motion/dto/requests/trigger_fire_when_io_request.py +128 -128
  379. zaber_motion/dto/requests/trigger_fire_when_request.py +88 -88
  380. zaber_motion/dto/requests/trigger_fire_when_setting_request.py +137 -137
  381. zaber_motion/dto/requests/trigger_on_fire_request.py +114 -114
  382. zaber_motion/dto/requests/trigger_on_fire_set_request.py +149 -149
  383. zaber_motion/dto/requests/trigger_on_fire_set_to_setting_request.py +149 -149
  384. zaber_motion/dto/requests/trigger_set_label_request.py +88 -88
  385. zaber_motion/dto/requests/trigger_states.py +56 -56
  386. zaber_motion/dto/requests/unit_convert_unit_request.py +71 -71
  387. zaber_motion/dto/requests/unit_get_enum_request.py +45 -45
  388. zaber_motion/dto/requests/unit_get_enum_response.py +48 -48
  389. zaber_motion/dto/requests/unit_get_symbol_request.py +48 -48
  390. zaber_motion/dto/requests/unit_get_symbol_response.py +45 -45
  391. zaber_motion/dto/requests/unknown_binary_response_event_wrapper.py +82 -82
  392. zaber_motion/dto/requests/unknown_response_event_wrapper.py +82 -82
  393. zaber_motion/dto/requests/wait_to_clear_warnings_request.py +105 -105
  394. zaber_motion/dto/requests/wait_to_respond_request.py +76 -76
  395. zaber_motion/dto/requests/wdi_generic_float_request.py +119 -0
  396. zaber_motion/dto/requests/wdi_generic_request.py +136 -136
  397. zaber_motion/dto/requests/wdi_get_status_response.py +50 -50
  398. zaber_motion/dto/rotation_direction.py +13 -13
  399. zaber_motion/dto_object.py +18 -18
  400. zaber_motion/events.py +112 -112
  401. zaber_motion/exceptions/__init__.py +87 -87
  402. zaber_motion/exceptions/bad_command_exception.py +10 -10
  403. zaber_motion/exceptions/bad_data_exception.py +10 -10
  404. zaber_motion/exceptions/binary_command_failed_exception.py +27 -27
  405. zaber_motion/exceptions/command_failed_exception.py +27 -27
  406. zaber_motion/exceptions/command_preempted_exception.py +10 -10
  407. zaber_motion/exceptions/command_too_long_exception.py +27 -27
  408. zaber_motion/exceptions/connection_closed_exception.py +10 -10
  409. zaber_motion/exceptions/connection_failed_exception.py +10 -10
  410. zaber_motion/exceptions/conversion_failed_exception.py +10 -10
  411. zaber_motion/exceptions/device_address_conflict_exception.py +27 -27
  412. zaber_motion/exceptions/device_busy_exception.py +10 -10
  413. zaber_motion/exceptions/device_db_failed_exception.py +27 -27
  414. zaber_motion/exceptions/device_detection_failed_exception.py +10 -10
  415. zaber_motion/exceptions/device_failed_exception.py +11 -11
  416. zaber_motion/exceptions/device_not_identified_exception.py +10 -10
  417. zaber_motion/exceptions/driver_disabled_exception.py +10 -10
  418. zaber_motion/exceptions/g_code_execution_exception.py +27 -27
  419. zaber_motion/exceptions/g_code_syntax_exception.py +27 -27
  420. zaber_motion/exceptions/incompatible_shared_library_exception.py +11 -11
  421. zaber_motion/exceptions/internal_error_exception.py +10 -10
  422. zaber_motion/exceptions/invalid_argument_exception.py +10 -10
  423. zaber_motion/exceptions/invalid_csv_data_exception.py +10 -10
  424. zaber_motion/exceptions/invalid_data_exception.py +10 -10
  425. zaber_motion/exceptions/invalid_operation_exception.py +10 -10
  426. zaber_motion/exceptions/invalid_packet_exception.py +27 -27
  427. zaber_motion/exceptions/invalid_park_state_exception.py +10 -10
  428. zaber_motion/exceptions/invalid_request_data_exception.py +11 -11
  429. zaber_motion/exceptions/invalid_response_exception.py +27 -27
  430. zaber_motion/exceptions/io_channel_out_of_range_exception.py +10 -10
  431. zaber_motion/exceptions/io_failed_exception.py +10 -10
  432. zaber_motion/exceptions/lockstep_enabled_exception.py +10 -10
  433. zaber_motion/exceptions/lockstep_not_enabled_exception.py +10 -10
  434. zaber_motion/exceptions/motion_lib_exception.py +18 -18
  435. zaber_motion/exceptions/movement_failed_exception.py +27 -27
  436. zaber_motion/exceptions/movement_interrupted_exception.py +27 -27
  437. zaber_motion/exceptions/no_device_found_exception.py +10 -10
  438. zaber_motion/exceptions/no_value_for_key_exception.py +10 -10
  439. zaber_motion/exceptions/not_supported_exception.py +10 -10
  440. zaber_motion/exceptions/operation_failed_exception.py +27 -27
  441. zaber_motion/exceptions/os_failed_exception.py +10 -10
  442. zaber_motion/exceptions/out_of_request_ids_exception.py +10 -10
  443. zaber_motion/exceptions/pvt_discontinuity_exception.py +10 -10
  444. zaber_motion/exceptions/pvt_execution_exception.py +27 -27
  445. zaber_motion/exceptions/pvt_mode_exception.py +10 -10
  446. zaber_motion/exceptions/pvt_movement_failed_exception.py +27 -27
  447. zaber_motion/exceptions/pvt_movement_interrupted_exception.py +27 -27
  448. zaber_motion/exceptions/pvt_sequence_generation_failed_exception.py +10 -10
  449. zaber_motion/exceptions/pvt_setup_failed_exception.py +10 -10
  450. zaber_motion/exceptions/remote_mode_exception.py +11 -11
  451. zaber_motion/exceptions/request_timeout_exception.py +10 -10
  452. zaber_motion/exceptions/serial_port_busy_exception.py +10 -10
  453. zaber_motion/exceptions/set_device_state_failed_exception.py +27 -27
  454. zaber_motion/exceptions/set_peripheral_state_failed_exception.py +27 -27
  455. zaber_motion/exceptions/setting_not_found_exception.py +10 -10
  456. zaber_motion/exceptions/stream_discontinuity_exception.py +10 -10
  457. zaber_motion/exceptions/stream_execution_exception.py +27 -27
  458. zaber_motion/exceptions/stream_mode_exception.py +10 -10
  459. zaber_motion/exceptions/stream_movement_failed_exception.py +27 -27
  460. zaber_motion/exceptions/stream_movement_interrupted_exception.py +27 -27
  461. zaber_motion/exceptions/stream_setup_failed_exception.py +10 -10
  462. zaber_motion/exceptions/timeout_exception.py +10 -10
  463. zaber_motion/exceptions/transport_already_used_exception.py +10 -10
  464. zaber_motion/exceptions/unknown_request_exception.py +10 -10
  465. zaber_motion/gcode/__init__.py +11 -11
  466. zaber_motion/gcode/offline_translator.py +401 -401
  467. zaber_motion/gcode/translator.py +424 -424
  468. zaber_motion/library.py +179 -179
  469. zaber_motion/microscopy/__init__.py +14 -14
  470. zaber_motion/microscopy/autofocus.py +645 -645
  471. zaber_motion/microscopy/camera_trigger.py +108 -108
  472. zaber_motion/microscopy/filter_changer.py +167 -167
  473. zaber_motion/microscopy/illuminator.py +163 -139
  474. zaber_motion/microscopy/illuminator_channel.py +629 -616
  475. zaber_motion/microscopy/microscope.py +315 -315
  476. zaber_motion/microscopy/objective_changer.py +403 -403
  477. zaber_motion/microscopy/wdi_autofocus_provider.py +536 -396
  478. zaber_motion/product/__init__.py +7 -7
  479. zaber_motion/product/process.py +818 -818
  480. zaber_motion/product/process_controller.py +134 -134
  481. zaber_motion/serialization.py +32 -32
  482. zaber_motion/tools.py +78 -78
  483. zaber_motion/unit_table.py +86 -86
  484. zaber_motion/units.py +206 -206
  485. zaber_motion/version.py +1 -1
  486. {zaber_motion-7.13.0.dist-info → zaber_motion-7.15.0.dist-info}/LICENSE.txt +2119 -2119
  487. {zaber_motion-7.13.0.dist-info → zaber_motion-7.15.0.dist-info}/METADATA +1 -1
  488. zaber_motion-7.15.0.dist-info/RECORD +496 -0
  489. zaber_motion_bindings/zaber-motion-core-windows-386.dll +0 -0
  490. zaber_motion-7.13.0.dist-info/RECORD +0 -494
  491. {zaber_motion-7.13.0.dist-info → zaber_motion-7.15.0.dist-info}/WHEEL +0 -0
  492. {zaber_motion-7.13.0.dist-info → zaber_motion-7.15.0.dist-info}/top_level.txt +0 -0
@@ -1,648 +1,648 @@
1
- # ===== THIS FILE IS GENERATED FROM A TEMPLATE ===== #
2
- # ============== DO NOT EDIT DIRECTLY ============== #
3
-
4
- # pylint: disable=too-many-arguments
5
-
6
- from typing import Generator, List, Any, Optional, TypeVar
7
- import asyncio
8
- from reactivex.subject import ReplaySubject
9
- from reactivex import operators as rxop, Observable
10
-
11
- from ..call import call, call_async, call_sync
12
- from ..convert_exception import convert_exception
13
- from ..events import filter_events
14
- from ..exceptions.motion_lib_exception import MotionLibException
15
-
16
- from .device import Device
17
- from ..dto.binary.command_code import CommandCode
18
- from ..dto.binary.message import Message
19
- from ..dto.binary.reply_only_event import ReplyOnlyEvent
20
- from ..dto.binary.unknown_response_event import UnknownResponseEvent
21
- from ..dto import requests as dto
22
-
23
-
24
- TConnectionEvents = TypeVar(
25
- "TConnectionEvents",
26
- dto.UnknownBinaryResponseEventWrapper,
27
- dto.BinaryReplyOnlyEventWrapper,
28
- dto.DisconnectedEvent)
29
-
30
-
31
- class Connection:
32
- """
33
- Class representing access to particular connection (serial port, TCP connection) using the legacy Binary protocol.
34
- """
35
-
36
- @property
37
- def unknown_response(self) -> Observable[UnknownResponseEvent]:
38
- """
39
- Event invoked when a response from a device cannot be matched to any known request.
40
- """
41
- return self._unknown_response
42
-
43
- @property
44
- def reply_only(self) -> Observable[ReplyOnlyEvent]:
45
- """
46
- Event invoked when a reply-only command such as a move tracking message is received from a device.
47
- """
48
- return self._reply_only
49
-
50
- @property
51
- def disconnected(self) -> Observable[MotionLibException]:
52
- """
53
- Event invoked when connection is interrupted or closed.
54
- """
55
- return self._disconnected
56
-
57
- DEFAULT_BAUD_RATE = 9600
58
- """
59
- Default baud rate for serial connections.
60
- """
61
-
62
- @property
63
- def interface_id(self) -> int:
64
- """
65
- The interface ID identifies thisConnection instance with the underlying library.
66
- """
67
- return self._interface_id
68
-
69
- @property
70
- def is_open(self) -> bool:
71
- """
72
- Returns whether the connection is open.
73
- Does not guarantee that the subsequent requests will succeed.
74
- """
75
- return self.__retrieve_is_open()
76
-
77
- def __init__(self, interface_id: int):
78
- self._interface_id: int = interface_id
79
- self.__setup_events()
80
-
81
- @staticmethod
82
- def open_serial_port(
83
- port_name: str,
84
- baud_rate: int = DEFAULT_BAUD_RATE,
85
- use_message_ids: bool = False
86
- ) -> 'Connection':
87
- """
88
- Opens a serial port.
89
-
90
- Args:
91
- port_name: Name of the port to open.
92
- baud_rate: Optional baud rate (defaults to 9600).
93
- use_message_ids: Enable use of message IDs (defaults to disabled).
94
- All your devices must be pre-configured to match.
95
-
96
- Returns:
97
- An object representing the port.
98
- """
99
- request = dto.OpenBinaryInterfaceRequest(
100
- interface_type=dto.InterfaceType.SERIAL_PORT,
101
- port_name=port_name,
102
- baud_rate=baud_rate,
103
- use_message_ids=use_message_ids,
104
- )
105
- response = call(
106
- "binary/interface/open",
107
- request,
108
- dto.OpenInterfaceResponse.from_binary)
109
- return Connection(response.interface_id)
110
-
111
- @staticmethod
112
- def open_serial_port_async(
113
- port_name: str,
114
- baud_rate: int = DEFAULT_BAUD_RATE,
115
- use_message_ids: bool = False
116
- ) -> 'AsyncBinaryConnectionOpener':
117
- """
118
- Opens a serial port.
119
-
120
- Args:
121
- port_name: Name of the port to open.
122
- baud_rate: Optional baud rate (defaults to 9600).
123
- use_message_ids: Enable use of message IDs (defaults to disabled).
124
- All your devices must be pre-configured to match.
125
-
126
- Returns:
127
- An object representing the port.
128
- """
129
- request = dto.OpenBinaryInterfaceRequest(
130
- interface_type=dto.InterfaceType.SERIAL_PORT,
131
- port_name=port_name,
132
- baud_rate=baud_rate,
133
- use_message_ids=use_message_ids,
134
- )
135
- return AsyncBinaryConnectionOpener(request)
136
-
137
- @staticmethod
138
- def open_tcp(
139
- host_name: str,
140
- port: int,
141
- use_message_ids: bool = False
142
- ) -> 'Connection':
143
- """
144
- Opens a TCP connection.
145
-
146
- Args:
147
- host_name: Hostname or IP address.
148
- port: Port number.
149
- use_message_ids: Enable use of message IDs (defaults to disabled).
150
- All your devices must be pre-configured to match.
151
-
152
- Returns:
153
- An object representing the connection.
154
- """
155
- request = dto.OpenBinaryInterfaceRequest(
156
- interface_type=dto.InterfaceType.TCP,
157
- host_name=host_name,
158
- port=port,
159
- use_message_ids=use_message_ids,
160
- )
161
- response = call(
162
- "binary/interface/open",
163
- request,
164
- dto.OpenInterfaceResponse.from_binary)
165
- return Connection(response.interface_id)
166
-
167
- @staticmethod
168
- def open_tcp_async(
169
- host_name: str,
170
- port: int,
171
- use_message_ids: bool = False
172
- ) -> 'AsyncBinaryConnectionOpener':
173
- """
174
- Opens a TCP connection.
175
-
176
- Args:
177
- host_name: Hostname or IP address.
178
- port: Port number.
179
- use_message_ids: Enable use of message IDs (defaults to disabled).
180
- All your devices must be pre-configured to match.
181
-
182
- Returns:
183
- An object representing the connection.
184
- """
185
- request = dto.OpenBinaryInterfaceRequest(
186
- interface_type=dto.InterfaceType.TCP,
187
- host_name=host_name,
188
- port=port,
189
- use_message_ids=use_message_ids,
190
- )
191
- return AsyncBinaryConnectionOpener(request)
192
-
193
- def close(
194
- self
195
- ) -> None:
196
- """
197
- Close the connection.
198
- """
199
- request = dto.InterfaceEmptyRequest(
200
- interface_id=self.interface_id,
201
- )
202
- call("interface/close", request)
203
-
204
- async def close_async(
205
- self
206
- ) -> None:
207
- """
208
- Close the connection.
209
- """
210
- request = dto.InterfaceEmptyRequest(
211
- interface_id=self.interface_id,
212
- )
213
- await call_async("interface/close", request)
214
-
215
- def generic_command(
216
- self,
217
- device: int,
218
- command: CommandCode,
219
- data: int = 0,
220
- timeout: float = 0.0,
221
- check_errors: bool = True
222
- ) -> Message:
223
- """
224
- Sends a generic Binary command to this connection.
225
- For more information please refer to the
226
- [Binary Protocol Manual](https://www.zaber.com/protocol-manual?protocol=Binary#topic_quick_command_reference).
227
-
228
- Args:
229
- device: Device address to send the command to. Use zero for broadcast.
230
- command: Command to send.
231
- data: Optional data argument to the command. Defaults to zero.
232
- timeout: Number of seconds to wait for a response from the device. 0 or negative defaults to 0.5s.
233
- check_errors: Controls whether to throw an exception when the device rejects the command.
234
-
235
- Returns:
236
- A response to the command.
237
- """
238
- request = dto.GenericBinaryRequest(
239
- interface_id=self.interface_id,
240
- device=device,
241
- command=command,
242
- data=data,
243
- timeout=timeout,
244
- check_errors=check_errors,
245
- )
246
- response = call(
247
- "binary/interface/generic_command",
248
- request,
249
- Message.from_binary)
250
- return response
251
-
252
- async def generic_command_async(
253
- self,
254
- device: int,
255
- command: CommandCode,
256
- data: int = 0,
257
- timeout: float = 0.0,
258
- check_errors: bool = True
259
- ) -> Message:
260
- """
261
- Sends a generic Binary command to this connection.
262
- For more information please refer to the
263
- [Binary Protocol Manual](https://www.zaber.com/protocol-manual?protocol=Binary#topic_quick_command_reference).
264
-
265
- Args:
266
- device: Device address to send the command to. Use zero for broadcast.
267
- command: Command to send.
268
- data: Optional data argument to the command. Defaults to zero.
269
- timeout: Number of seconds to wait for a response from the device. 0 or negative defaults to 0.5s.
270
- check_errors: Controls whether to throw an exception when the device rejects the command.
271
-
272
- Returns:
273
- A response to the command.
274
- """
275
- request = dto.GenericBinaryRequest(
276
- interface_id=self.interface_id,
277
- device=device,
278
- command=command,
279
- data=data,
280
- timeout=timeout,
281
- check_errors=check_errors,
282
- )
283
- response = await call_async(
284
- "binary/interface/generic_command",
285
- request,
286
- Message.from_binary)
287
- return response
288
-
289
- def generic_command_no_response(
290
- self,
291
- device: int,
292
- command: CommandCode,
293
- data: int = 0
294
- ) -> None:
295
- """
296
- Sends a generic Binary command to this connection without expecting a response.
297
- For more information please refer to the
298
- [Binary Protocol Manual](https://www.zaber.com/protocol-manual?protocol=Binary#topic_quick_command_reference).
299
-
300
- Args:
301
- device: Device address to send the command to. Use zero for broadcast.
302
- command: Command to send.
303
- data: Optional data argument to the command. Defaults to zero.
304
- """
305
- request = dto.GenericBinaryRequest(
306
- interface_id=self.interface_id,
307
- device=device,
308
- command=command,
309
- data=data,
310
- )
311
- call("binary/interface/generic_command_no_response", request)
312
-
313
- async def generic_command_no_response_async(
314
- self,
315
- device: int,
316
- command: CommandCode,
317
- data: int = 0
318
- ) -> None:
319
- """
320
- Sends a generic Binary command to this connection without expecting a response.
321
- For more information please refer to the
322
- [Binary Protocol Manual](https://www.zaber.com/protocol-manual?protocol=Binary#topic_quick_command_reference).
323
-
324
- Args:
325
- device: Device address to send the command to. Use zero for broadcast.
326
- command: Command to send.
327
- data: Optional data argument to the command. Defaults to zero.
328
- """
329
- request = dto.GenericBinaryRequest(
330
- interface_id=self.interface_id,
331
- device=device,
332
- command=command,
333
- data=data,
334
- )
335
- await call_async("binary/interface/generic_command_no_response", request)
336
-
337
- def generic_command_multi_response(
338
- self,
339
- command: CommandCode,
340
- data: int = 0,
341
- timeout: float = 0.0,
342
- check_errors: bool = True
343
- ) -> List[Message]:
344
- """
345
- Sends a generic Binary command to this connection and expects responses from one or more devices.
346
- Responses are returned in order of arrival.
347
- For more information please refer to the
348
- [Binary Protocol Manual](https://www.zaber.com/protocol-manual?protocol=Binary#topic_quick_command_reference).
349
-
350
- Args:
351
- command: Command to send.
352
- data: Optional data argument to the command. Defaults to zero.
353
- timeout: Number of seconds to wait for all responses from the device chain. 0 or negative defaults to 0.5s.
354
- check_errors: Controls whether to throw an exception when any device rejects the command.
355
-
356
- Returns:
357
- All responses to the command.
358
- """
359
- request = dto.GenericBinaryRequest(
360
- interface_id=self.interface_id,
361
- command=command,
362
- data=data,
363
- timeout=timeout,
364
- check_errors=check_errors,
365
- )
366
- response = call(
367
- "binary/interface/generic_command_multi_response",
368
- request,
369
- dto.BinaryMessageCollection.from_binary)
370
- return response.messages
371
-
372
- async def generic_command_multi_response_async(
373
- self,
374
- command: CommandCode,
375
- data: int = 0,
376
- timeout: float = 0.0,
377
- check_errors: bool = True
378
- ) -> List[Message]:
379
- """
380
- Sends a generic Binary command to this connection and expects responses from one or more devices.
381
- Responses are returned in order of arrival.
382
- For more information please refer to the
383
- [Binary Protocol Manual](https://www.zaber.com/protocol-manual?protocol=Binary#topic_quick_command_reference).
384
-
385
- Args:
386
- command: Command to send.
387
- data: Optional data argument to the command. Defaults to zero.
388
- timeout: Number of seconds to wait for all responses from the device chain. 0 or negative defaults to 0.5s.
389
- check_errors: Controls whether to throw an exception when any device rejects the command.
390
-
391
- Returns:
392
- All responses to the command.
393
- """
394
- request = dto.GenericBinaryRequest(
395
- interface_id=self.interface_id,
396
- command=command,
397
- data=data,
398
- timeout=timeout,
399
- check_errors=check_errors,
400
- )
401
- response = await call_async(
402
- "binary/interface/generic_command_multi_response",
403
- request,
404
- dto.BinaryMessageCollection.from_binary)
405
- return response.messages
406
-
407
- def renumber_devices(
408
- self
409
- ) -> int:
410
- """
411
- Renumbers devices present on this connection. After renumbering, you must identify devices again.
412
-
413
- Returns:
414
- Total number of devices that responded to the renumber.
415
- """
416
- request = dto.InterfaceEmptyRequest(
417
- interface_id=self.interface_id,
418
- )
419
- response = call(
420
- "binary/device/renumber",
421
- request,
422
- dto.IntResponse.from_binary)
423
- return response.value
424
-
425
- async def renumber_devices_async(
426
- self
427
- ) -> int:
428
- """
429
- Renumbers devices present on this connection. After renumbering, you must identify devices again.
430
-
431
- Returns:
432
- Total number of devices that responded to the renumber.
433
- """
434
- request = dto.InterfaceEmptyRequest(
435
- interface_id=self.interface_id,
436
- )
437
- response = await call_async(
438
- "binary/device/renumber",
439
- request,
440
- dto.IntResponse.from_binary)
441
- return response.value
442
-
443
- def detect_devices(
444
- self,
445
- identify_devices: bool = True
446
- ) -> List[Device]:
447
- """
448
- Attempts to detect any devices present on this connection.
449
-
450
- Args:
451
- identify_devices: Determines whether device identification should be performed as well.
452
-
453
- Returns:
454
- Array of detected devices.
455
- """
456
- request = dto.BinaryDeviceDetectRequest(
457
- interface_id=self.interface_id,
458
- identify_devices=identify_devices,
459
- )
460
- response = call(
461
- "binary/device/detect",
462
- request,
463
- dto.BinaryDeviceDetectResponse.from_binary)
464
- return list(map(self.get_device, response.devices))
465
-
466
- async def detect_devices_async(
467
- self,
468
- identify_devices: bool = True
469
- ) -> List[Device]:
470
- """
471
- Attempts to detect any devices present on this connection.
472
-
473
- Args:
474
- identify_devices: Determines whether device identification should be performed as well.
475
-
476
- Returns:
477
- Array of detected devices.
478
- """
479
- request = dto.BinaryDeviceDetectRequest(
480
- interface_id=self.interface_id,
481
- identify_devices=identify_devices,
482
- )
483
- response = await call_async(
484
- "binary/device/detect",
485
- request,
486
- dto.BinaryDeviceDetectResponse.from_binary)
487
- return list(map(self.get_device, response.devices))
488
-
489
- def get_device(
490
- self,
491
- device_address: int
492
- ) -> Device:
493
- """
494
- Gets a Device class instance which allows you to control a particular device on this connection.
495
- Devices are numbered from 1.
496
-
497
- Args:
498
- device_address: Address of device intended to control. Address is configured for each device.
499
-
500
- Returns:
501
- Device instance.
502
- """
503
- if device_address <= 0:
504
- raise ValueError('Invalid value; physical devices are numbered from 1.')
505
-
506
- return Device(self, device_address)
507
-
508
- def __retrieve_is_open(
509
- self
510
- ) -> bool:
511
- """
512
- Returns is open.
513
-
514
- Returns:
515
- Is open.
516
- """
517
- request = dto.InterfaceEmptyRequest(
518
- interface_id=self.interface_id,
519
- )
520
- response = call_sync(
521
- "interface/get_is_open",
522
- request,
523
- dto.BoolResponse.from_binary)
524
- return response.value
525
-
526
- def __repr__(
527
- self
528
- ) -> str:
529
- """
530
- Returns a string that represents the connection.
531
-
532
- Returns:
533
- A string that represents the connection.
534
- """
535
- request = dto.InterfaceEmptyRequest(
536
- interface_id=self.interface_id,
537
- )
538
- response = call_sync(
539
- "interface/to_string",
540
- request,
541
- dto.StringResponse.from_binary)
542
- return response.value
543
-
544
- @staticmethod
545
- def __free(
546
- interface_id: int
547
- ) -> None:
548
- """
549
- Releases native resources of the connection.
550
-
551
- Args:
552
- interface_id: The ID of the connection.
553
- """
554
- request = dto.InterfaceEmptyRequest(
555
- interface_id=interface_id,
556
- )
557
- call_sync("interface/free", request)
558
-
559
- def __enter__(self) -> 'Connection':
560
- """ __enter__ """
561
- return self
562
-
563
- def __exit__(self, _type: Any, _value: Any, _traceback: Any) -> None:
564
- """ __exit__ """
565
- self.close()
566
-
567
- def __setup_events(self) -> None:
568
- def filter_connection_event(
569
- data: TConnectionEvents,
570
- ) -> bool:
571
- return data.interface_id == self._interface_id
572
-
573
- self._disconnected = ReplaySubject[MotionLibException]() # terminates all the events
574
-
575
- unknown_response = filter_events('binary/interface/unknown_response', dto.UnknownBinaryResponseEventWrapper)
576
- self._unknown_response = unknown_response.pipe(
577
- rxop.filter(filter_connection_event),
578
- rxop.take_until(self.disconnected),
579
- rxop.map(map_unknown_response)
580
- )
581
-
582
- reply_only = filter_events('binary/interface/reply_only', dto.BinaryReplyOnlyEventWrapper)
583
- self._reply_only = reply_only.pipe(
584
- rxop.filter(filter_connection_event),
585
- rxop.take_until(self.disconnected),
586
- rxop.map(map_reply_only)
587
- )
588
-
589
- disconnected = filter_events('interface/disconnected', dto.DisconnectedEvent)
590
- disconnected.pipe(
591
- rxop.filter(filter_connection_event),
592
- rxop.take(1),
593
- rxop.map(map_disconnect)
594
- ).subscribe(self._disconnected)
595
-
596
- def __del__(self) -> None:
597
- Connection.__free(self._interface_id)
598
-
599
-
600
- class AsyncBinaryConnectionOpener:
601
- '''Provides a connection in an asynchronous context using `await` or `async with`'''
602
- def __init__(self, request: dto.OpenBinaryInterfaceRequest) -> None:
603
- self._request = request
604
- self._resource: Optional[Connection] = None
605
-
606
- async def _create_resource(self) -> Connection:
607
- task = asyncio.ensure_future(call_async(
608
- "binary/interface/open",
609
- self._request,
610
- dto.OpenInterfaceResponse.from_binary))
611
-
612
- try:
613
- response = await asyncio.shield(task)
614
- except asyncio.CancelledError:
615
- async def cancel() -> None:
616
- try:
617
- response = await task
618
- await Connection(response.interface_id).close_async()
619
- except MotionLibException:
620
- pass
621
-
622
- asyncio.ensure_future(cancel())
623
- raise
624
-
625
- return Connection(response.interface_id)
626
-
627
- def __await__(self) -> Generator[Any, None, 'Connection']:
628
- return self._create_resource().__await__()
629
-
630
- async def __aenter__(self) -> 'Connection':
631
- self._resource = await self._create_resource()
632
- return self._resource
633
-
634
- async def __aexit__(self, exc_type: Any, exc: Any, trace: Any) -> None:
635
- if self._resource is not None:
636
- await self._resource.close_async()
637
-
638
-
639
- def map_unknown_response(event: dto.UnknownBinaryResponseEventWrapper) -> UnknownResponseEvent:
640
- return event.unknown_response
641
-
642
-
643
- def map_reply_only(event: dto.BinaryReplyOnlyEventWrapper) -> ReplyOnlyEvent:
644
- return event.reply
645
-
646
-
647
- def map_disconnect(event: dto.DisconnectedEvent) -> MotionLibException:
648
- return convert_exception(event.error_type, event.error_message)
1
+ # ===== THIS FILE IS GENERATED FROM A TEMPLATE ===== #
2
+ # ============== DO NOT EDIT DIRECTLY ============== #
3
+
4
+ # pylint: disable=too-many-arguments
5
+
6
+ from typing import Generator, List, Any, Optional, TypeVar
7
+ import asyncio
8
+ from reactivex.subject import ReplaySubject
9
+ from reactivex import operators as rxop, Observable
10
+
11
+ from ..call import call, call_async, call_sync
12
+ from ..convert_exception import convert_exception
13
+ from ..events import filter_events
14
+ from ..exceptions.motion_lib_exception import MotionLibException
15
+
16
+ from .device import Device
17
+ from ..dto.binary.command_code import CommandCode
18
+ from ..dto.binary.message import Message
19
+ from ..dto.binary.reply_only_event import ReplyOnlyEvent
20
+ from ..dto.binary.unknown_response_event import UnknownResponseEvent
21
+ from ..dto import requests as dto
22
+
23
+
24
+ TConnectionEvents = TypeVar(
25
+ "TConnectionEvents",
26
+ dto.UnknownBinaryResponseEventWrapper,
27
+ dto.BinaryReplyOnlyEventWrapper,
28
+ dto.DisconnectedEvent)
29
+
30
+
31
+ class Connection:
32
+ """
33
+ Class representing access to particular connection (serial port, TCP connection) using the legacy Binary protocol.
34
+ """
35
+
36
+ @property
37
+ def unknown_response(self) -> Observable[UnknownResponseEvent]:
38
+ """
39
+ Event invoked when a response from a device cannot be matched to any known request.
40
+ """
41
+ return self._unknown_response
42
+
43
+ @property
44
+ def reply_only(self) -> Observable[ReplyOnlyEvent]:
45
+ """
46
+ Event invoked when a reply-only command such as a move tracking message is received from a device.
47
+ """
48
+ return self._reply_only
49
+
50
+ @property
51
+ def disconnected(self) -> Observable[MotionLibException]:
52
+ """
53
+ Event invoked when connection is interrupted or closed.
54
+ """
55
+ return self._disconnected
56
+
57
+ DEFAULT_BAUD_RATE = 9600
58
+ """
59
+ Default baud rate for serial connections.
60
+ """
61
+
62
+ @property
63
+ def interface_id(self) -> int:
64
+ """
65
+ The interface ID identifies thisConnection instance with the underlying library.
66
+ """
67
+ return self._interface_id
68
+
69
+ @property
70
+ def is_open(self) -> bool:
71
+ """
72
+ Returns whether the connection is open.
73
+ Does not guarantee that the subsequent requests will succeed.
74
+ """
75
+ return self.__retrieve_is_open()
76
+
77
+ def __init__(self, interface_id: int):
78
+ self._interface_id: int = interface_id
79
+ self.__setup_events()
80
+
81
+ @staticmethod
82
+ def open_serial_port(
83
+ port_name: str,
84
+ baud_rate: int = DEFAULT_BAUD_RATE,
85
+ use_message_ids: bool = False
86
+ ) -> 'Connection':
87
+ """
88
+ Opens a serial port.
89
+
90
+ Args:
91
+ port_name: Name of the port to open.
92
+ baud_rate: Optional baud rate (defaults to 9600).
93
+ use_message_ids: Enable use of message IDs (defaults to disabled).
94
+ All your devices must be pre-configured to match.
95
+
96
+ Returns:
97
+ An object representing the port.
98
+ """
99
+ request = dto.OpenBinaryInterfaceRequest(
100
+ interface_type=dto.InterfaceType.SERIAL_PORT,
101
+ port_name=port_name,
102
+ baud_rate=baud_rate,
103
+ use_message_ids=use_message_ids,
104
+ )
105
+ response = call(
106
+ "binary/interface/open",
107
+ request,
108
+ dto.OpenInterfaceResponse.from_binary)
109
+ return Connection(response.interface_id)
110
+
111
+ @staticmethod
112
+ def open_serial_port_async(
113
+ port_name: str,
114
+ baud_rate: int = DEFAULT_BAUD_RATE,
115
+ use_message_ids: bool = False
116
+ ) -> 'AsyncBinaryConnectionOpener':
117
+ """
118
+ Opens a serial port.
119
+
120
+ Args:
121
+ port_name: Name of the port to open.
122
+ baud_rate: Optional baud rate (defaults to 9600).
123
+ use_message_ids: Enable use of message IDs (defaults to disabled).
124
+ All your devices must be pre-configured to match.
125
+
126
+ Returns:
127
+ An object representing the port.
128
+ """
129
+ request = dto.OpenBinaryInterfaceRequest(
130
+ interface_type=dto.InterfaceType.SERIAL_PORT,
131
+ port_name=port_name,
132
+ baud_rate=baud_rate,
133
+ use_message_ids=use_message_ids,
134
+ )
135
+ return AsyncBinaryConnectionOpener(request)
136
+
137
+ @staticmethod
138
+ def open_tcp(
139
+ host_name: str,
140
+ port: int,
141
+ use_message_ids: bool = False
142
+ ) -> 'Connection':
143
+ """
144
+ Opens a TCP connection.
145
+
146
+ Args:
147
+ host_name: Hostname or IP address.
148
+ port: Port number.
149
+ use_message_ids: Enable use of message IDs (defaults to disabled).
150
+ All your devices must be pre-configured to match.
151
+
152
+ Returns:
153
+ An object representing the connection.
154
+ """
155
+ request = dto.OpenBinaryInterfaceRequest(
156
+ interface_type=dto.InterfaceType.TCP,
157
+ host_name=host_name,
158
+ port=port,
159
+ use_message_ids=use_message_ids,
160
+ )
161
+ response = call(
162
+ "binary/interface/open",
163
+ request,
164
+ dto.OpenInterfaceResponse.from_binary)
165
+ return Connection(response.interface_id)
166
+
167
+ @staticmethod
168
+ def open_tcp_async(
169
+ host_name: str,
170
+ port: int,
171
+ use_message_ids: bool = False
172
+ ) -> 'AsyncBinaryConnectionOpener':
173
+ """
174
+ Opens a TCP connection.
175
+
176
+ Args:
177
+ host_name: Hostname or IP address.
178
+ port: Port number.
179
+ use_message_ids: Enable use of message IDs (defaults to disabled).
180
+ All your devices must be pre-configured to match.
181
+
182
+ Returns:
183
+ An object representing the connection.
184
+ """
185
+ request = dto.OpenBinaryInterfaceRequest(
186
+ interface_type=dto.InterfaceType.TCP,
187
+ host_name=host_name,
188
+ port=port,
189
+ use_message_ids=use_message_ids,
190
+ )
191
+ return AsyncBinaryConnectionOpener(request)
192
+
193
+ def close(
194
+ self
195
+ ) -> None:
196
+ """
197
+ Close the connection.
198
+ """
199
+ request = dto.InterfaceEmptyRequest(
200
+ interface_id=self.interface_id,
201
+ )
202
+ call("interface/close", request)
203
+
204
+ async def close_async(
205
+ self
206
+ ) -> None:
207
+ """
208
+ Close the connection.
209
+ """
210
+ request = dto.InterfaceEmptyRequest(
211
+ interface_id=self.interface_id,
212
+ )
213
+ await call_async("interface/close", request)
214
+
215
+ def generic_command(
216
+ self,
217
+ device: int,
218
+ command: CommandCode,
219
+ data: int = 0,
220
+ timeout: float = 0.0,
221
+ check_errors: bool = True
222
+ ) -> Message:
223
+ """
224
+ Sends a generic Binary command to this connection.
225
+ For more information please refer to the
226
+ [Binary Protocol Manual](https://www.zaber.com/protocol-manual?protocol=Binary#topic_quick_command_reference).
227
+
228
+ Args:
229
+ device: Device address to send the command to. Use zero for broadcast.
230
+ command: Command to send.
231
+ data: Optional data argument to the command. Defaults to zero.
232
+ timeout: Number of seconds to wait for a response from the device. 0 or negative defaults to 0.5s.
233
+ check_errors: Controls whether to throw an exception when the device rejects the command.
234
+
235
+ Returns:
236
+ A response to the command.
237
+ """
238
+ request = dto.GenericBinaryRequest(
239
+ interface_id=self.interface_id,
240
+ device=device,
241
+ command=command,
242
+ data=data,
243
+ timeout=timeout,
244
+ check_errors=check_errors,
245
+ )
246
+ response = call(
247
+ "binary/interface/generic_command",
248
+ request,
249
+ Message.from_binary)
250
+ return response
251
+
252
+ async def generic_command_async(
253
+ self,
254
+ device: int,
255
+ command: CommandCode,
256
+ data: int = 0,
257
+ timeout: float = 0.0,
258
+ check_errors: bool = True
259
+ ) -> Message:
260
+ """
261
+ Sends a generic Binary command to this connection.
262
+ For more information please refer to the
263
+ [Binary Protocol Manual](https://www.zaber.com/protocol-manual?protocol=Binary#topic_quick_command_reference).
264
+
265
+ Args:
266
+ device: Device address to send the command to. Use zero for broadcast.
267
+ command: Command to send.
268
+ data: Optional data argument to the command. Defaults to zero.
269
+ timeout: Number of seconds to wait for a response from the device. 0 or negative defaults to 0.5s.
270
+ check_errors: Controls whether to throw an exception when the device rejects the command.
271
+
272
+ Returns:
273
+ A response to the command.
274
+ """
275
+ request = dto.GenericBinaryRequest(
276
+ interface_id=self.interface_id,
277
+ device=device,
278
+ command=command,
279
+ data=data,
280
+ timeout=timeout,
281
+ check_errors=check_errors,
282
+ )
283
+ response = await call_async(
284
+ "binary/interface/generic_command",
285
+ request,
286
+ Message.from_binary)
287
+ return response
288
+
289
+ def generic_command_no_response(
290
+ self,
291
+ device: int,
292
+ command: CommandCode,
293
+ data: int = 0
294
+ ) -> None:
295
+ """
296
+ Sends a generic Binary command to this connection without expecting a response.
297
+ For more information please refer to the
298
+ [Binary Protocol Manual](https://www.zaber.com/protocol-manual?protocol=Binary#topic_quick_command_reference).
299
+
300
+ Args:
301
+ device: Device address to send the command to. Use zero for broadcast.
302
+ command: Command to send.
303
+ data: Optional data argument to the command. Defaults to zero.
304
+ """
305
+ request = dto.GenericBinaryRequest(
306
+ interface_id=self.interface_id,
307
+ device=device,
308
+ command=command,
309
+ data=data,
310
+ )
311
+ call("binary/interface/generic_command_no_response", request)
312
+
313
+ async def generic_command_no_response_async(
314
+ self,
315
+ device: int,
316
+ command: CommandCode,
317
+ data: int = 0
318
+ ) -> None:
319
+ """
320
+ Sends a generic Binary command to this connection without expecting a response.
321
+ For more information please refer to the
322
+ [Binary Protocol Manual](https://www.zaber.com/protocol-manual?protocol=Binary#topic_quick_command_reference).
323
+
324
+ Args:
325
+ device: Device address to send the command to. Use zero for broadcast.
326
+ command: Command to send.
327
+ data: Optional data argument to the command. Defaults to zero.
328
+ """
329
+ request = dto.GenericBinaryRequest(
330
+ interface_id=self.interface_id,
331
+ device=device,
332
+ command=command,
333
+ data=data,
334
+ )
335
+ await call_async("binary/interface/generic_command_no_response", request)
336
+
337
+ def generic_command_multi_response(
338
+ self,
339
+ command: CommandCode,
340
+ data: int = 0,
341
+ timeout: float = 0.0,
342
+ check_errors: bool = True
343
+ ) -> List[Message]:
344
+ """
345
+ Sends a generic Binary command to this connection and expects responses from one or more devices.
346
+ Responses are returned in order of arrival.
347
+ For more information please refer to the
348
+ [Binary Protocol Manual](https://www.zaber.com/protocol-manual?protocol=Binary#topic_quick_command_reference).
349
+
350
+ Args:
351
+ command: Command to send.
352
+ data: Optional data argument to the command. Defaults to zero.
353
+ timeout: Number of seconds to wait for all responses from the device chain. 0 or negative defaults to 0.5s.
354
+ check_errors: Controls whether to throw an exception when any device rejects the command.
355
+
356
+ Returns:
357
+ All responses to the command.
358
+ """
359
+ request = dto.GenericBinaryRequest(
360
+ interface_id=self.interface_id,
361
+ command=command,
362
+ data=data,
363
+ timeout=timeout,
364
+ check_errors=check_errors,
365
+ )
366
+ response = call(
367
+ "binary/interface/generic_command_multi_response",
368
+ request,
369
+ dto.BinaryMessageCollection.from_binary)
370
+ return response.messages
371
+
372
+ async def generic_command_multi_response_async(
373
+ self,
374
+ command: CommandCode,
375
+ data: int = 0,
376
+ timeout: float = 0.0,
377
+ check_errors: bool = True
378
+ ) -> List[Message]:
379
+ """
380
+ Sends a generic Binary command to this connection and expects responses from one or more devices.
381
+ Responses are returned in order of arrival.
382
+ For more information please refer to the
383
+ [Binary Protocol Manual](https://www.zaber.com/protocol-manual?protocol=Binary#topic_quick_command_reference).
384
+
385
+ Args:
386
+ command: Command to send.
387
+ data: Optional data argument to the command. Defaults to zero.
388
+ timeout: Number of seconds to wait for all responses from the device chain. 0 or negative defaults to 0.5s.
389
+ check_errors: Controls whether to throw an exception when any device rejects the command.
390
+
391
+ Returns:
392
+ All responses to the command.
393
+ """
394
+ request = dto.GenericBinaryRequest(
395
+ interface_id=self.interface_id,
396
+ command=command,
397
+ data=data,
398
+ timeout=timeout,
399
+ check_errors=check_errors,
400
+ )
401
+ response = await call_async(
402
+ "binary/interface/generic_command_multi_response",
403
+ request,
404
+ dto.BinaryMessageCollection.from_binary)
405
+ return response.messages
406
+
407
+ def renumber_devices(
408
+ self
409
+ ) -> int:
410
+ """
411
+ Renumbers devices present on this connection. After renumbering, you must identify devices again.
412
+
413
+ Returns:
414
+ Total number of devices that responded to the renumber.
415
+ """
416
+ request = dto.InterfaceEmptyRequest(
417
+ interface_id=self.interface_id,
418
+ )
419
+ response = call(
420
+ "binary/device/renumber",
421
+ request,
422
+ dto.IntResponse.from_binary)
423
+ return response.value
424
+
425
+ async def renumber_devices_async(
426
+ self
427
+ ) -> int:
428
+ """
429
+ Renumbers devices present on this connection. After renumbering, you must identify devices again.
430
+
431
+ Returns:
432
+ Total number of devices that responded to the renumber.
433
+ """
434
+ request = dto.InterfaceEmptyRequest(
435
+ interface_id=self.interface_id,
436
+ )
437
+ response = await call_async(
438
+ "binary/device/renumber",
439
+ request,
440
+ dto.IntResponse.from_binary)
441
+ return response.value
442
+
443
+ def detect_devices(
444
+ self,
445
+ identify_devices: bool = True
446
+ ) -> List[Device]:
447
+ """
448
+ Attempts to detect any devices present on this connection.
449
+
450
+ Args:
451
+ identify_devices: Determines whether device identification should be performed as well.
452
+
453
+ Returns:
454
+ Array of detected devices.
455
+ """
456
+ request = dto.BinaryDeviceDetectRequest(
457
+ interface_id=self.interface_id,
458
+ identify_devices=identify_devices,
459
+ )
460
+ response = call(
461
+ "binary/device/detect",
462
+ request,
463
+ dto.BinaryDeviceDetectResponse.from_binary)
464
+ return list(map(self.get_device, response.devices))
465
+
466
+ async def detect_devices_async(
467
+ self,
468
+ identify_devices: bool = True
469
+ ) -> List[Device]:
470
+ """
471
+ Attempts to detect any devices present on this connection.
472
+
473
+ Args:
474
+ identify_devices: Determines whether device identification should be performed as well.
475
+
476
+ Returns:
477
+ Array of detected devices.
478
+ """
479
+ request = dto.BinaryDeviceDetectRequest(
480
+ interface_id=self.interface_id,
481
+ identify_devices=identify_devices,
482
+ )
483
+ response = await call_async(
484
+ "binary/device/detect",
485
+ request,
486
+ dto.BinaryDeviceDetectResponse.from_binary)
487
+ return list(map(self.get_device, response.devices))
488
+
489
+ def get_device(
490
+ self,
491
+ device_address: int
492
+ ) -> Device:
493
+ """
494
+ Gets a Device class instance which allows you to control a particular device on this connection.
495
+ Devices are numbered from 1.
496
+
497
+ Args:
498
+ device_address: Address of device intended to control. Address is configured for each device.
499
+
500
+ Returns:
501
+ Device instance.
502
+ """
503
+ if device_address <= 0:
504
+ raise ValueError('Invalid value; physical devices are numbered from 1.')
505
+
506
+ return Device(self, device_address)
507
+
508
+ def __retrieve_is_open(
509
+ self
510
+ ) -> bool:
511
+ """
512
+ Returns is open.
513
+
514
+ Returns:
515
+ Is open.
516
+ """
517
+ request = dto.InterfaceEmptyRequest(
518
+ interface_id=self.interface_id,
519
+ )
520
+ response = call_sync(
521
+ "interface/get_is_open",
522
+ request,
523
+ dto.BoolResponse.from_binary)
524
+ return response.value
525
+
526
+ def __repr__(
527
+ self
528
+ ) -> str:
529
+ """
530
+ Returns a string that represents the connection.
531
+
532
+ Returns:
533
+ A string that represents the connection.
534
+ """
535
+ request = dto.InterfaceEmptyRequest(
536
+ interface_id=self.interface_id,
537
+ )
538
+ response = call_sync(
539
+ "interface/to_string",
540
+ request,
541
+ dto.StringResponse.from_binary)
542
+ return response.value
543
+
544
+ @staticmethod
545
+ def __free(
546
+ interface_id: int
547
+ ) -> None:
548
+ """
549
+ Releases native resources of the connection.
550
+
551
+ Args:
552
+ interface_id: The ID of the connection.
553
+ """
554
+ request = dto.InterfaceEmptyRequest(
555
+ interface_id=interface_id,
556
+ )
557
+ call_sync("interface/free", request)
558
+
559
+ def __enter__(self) -> 'Connection':
560
+ """ __enter__ """
561
+ return self
562
+
563
+ def __exit__(self, _type: Any, _value: Any, _traceback: Any) -> None:
564
+ """ __exit__ """
565
+ self.close()
566
+
567
+ def __setup_events(self) -> None:
568
+ def filter_connection_event(
569
+ data: TConnectionEvents,
570
+ ) -> bool:
571
+ return data.interface_id == self._interface_id
572
+
573
+ self._disconnected = ReplaySubject[MotionLibException]() # terminates all the events
574
+
575
+ unknown_response = filter_events('binary/interface/unknown_response', dto.UnknownBinaryResponseEventWrapper)
576
+ self._unknown_response = unknown_response.pipe(
577
+ rxop.filter(filter_connection_event),
578
+ rxop.take_until(self.disconnected),
579
+ rxop.map(map_unknown_response)
580
+ )
581
+
582
+ reply_only = filter_events('binary/interface/reply_only', dto.BinaryReplyOnlyEventWrapper)
583
+ self._reply_only = reply_only.pipe(
584
+ rxop.filter(filter_connection_event),
585
+ rxop.take_until(self.disconnected),
586
+ rxop.map(map_reply_only)
587
+ )
588
+
589
+ disconnected = filter_events('interface/disconnected', dto.DisconnectedEvent)
590
+ disconnected.pipe(
591
+ rxop.filter(filter_connection_event),
592
+ rxop.take(1),
593
+ rxop.map(map_disconnect)
594
+ ).subscribe(self._disconnected)
595
+
596
+ def __del__(self) -> None:
597
+ Connection.__free(self._interface_id)
598
+
599
+
600
+ class AsyncBinaryConnectionOpener:
601
+ '''Provides a connection in an asynchronous context using `await` or `async with`'''
602
+ def __init__(self, request: dto.OpenBinaryInterfaceRequest) -> None:
603
+ self._request = request
604
+ self._resource: Optional[Connection] = None
605
+
606
+ async def _create_resource(self) -> Connection:
607
+ task = asyncio.ensure_future(call_async(
608
+ "binary/interface/open",
609
+ self._request,
610
+ dto.OpenInterfaceResponse.from_binary))
611
+
612
+ try:
613
+ response = await asyncio.shield(task)
614
+ except asyncio.CancelledError:
615
+ async def cancel() -> None:
616
+ try:
617
+ response = await task
618
+ await Connection(response.interface_id).close_async()
619
+ except MotionLibException:
620
+ pass
621
+
622
+ asyncio.ensure_future(cancel())
623
+ raise
624
+
625
+ return Connection(response.interface_id)
626
+
627
+ def __await__(self) -> Generator[Any, None, 'Connection']:
628
+ return self._create_resource().__await__()
629
+
630
+ async def __aenter__(self) -> 'Connection':
631
+ self._resource = await self._create_resource()
632
+ return self._resource
633
+
634
+ async def __aexit__(self, exc_type: Any, exc: Any, trace: Any) -> None:
635
+ if self._resource is not None:
636
+ await self._resource.close_async()
637
+
638
+
639
+ def map_unknown_response(event: dto.UnknownBinaryResponseEventWrapper) -> UnknownResponseEvent:
640
+ return event.unknown_response
641
+
642
+
643
+ def map_reply_only(event: dto.BinaryReplyOnlyEventWrapper) -> ReplyOnlyEvent:
644
+ return event.reply
645
+
646
+
647
+ def map_disconnect(event: dto.DisconnectedEvent) -> MotionLibException:
648
+ return convert_exception(event.error_type, event.error_message)