It is not clear how one must proceed to register instruments that are not stem_controllers. As far as I can understand from the code, the preferable way is to use hardware_source_manager.register_instrument. This works fine if you are a stem_controller. If you are not, unregistering gives a key error because the method pop assumes you have the key in your dictionary (and you don't have any of 'probe_view', 'subscan_view', etc).
Is register_instrument the preferrable way of registering non-stem-controllers? If yes, I just slightly modified the code to avoid the annoying key error after exiting nionswift
edit: Thanks and sorry for misplacing the issue (should be in the nion-instrumentation repo).
def unregister_instrument(self, instrument: typing.Any) -> None:
if 'probe_view' in self.__m.get(instrument, dict()):
probe_view = self.__m.get(instrument, dict()).pop("probe_view")
if probe_view:
probe_view.close()
if 'subscan_view' in self.__m.get(instrument, dict()):
subscan_view = self.__m.get(instrument, dict()).pop("subscan_view")
if subscan_view:
subscan_view.close()
if 'line_scan_view' in self.__m.get(instrument, dict()):
line_scan_view = self.__m.get(instrument, dict()).pop("line_scan_view")
if line_scan_view:
line_scan_view.close()
if 'drift_view' in self.__m.get(instrument, dict()):
drift_view = self.__m.get(instrument, dict()).pop("drift_view")
if drift_view:
drift_view.close()
It is not clear how one must proceed to register instruments that are not stem_controllers. As far as I can understand from the code, the preferable way is to use hardware_source_manager.register_instrument. This works fine if you are a stem_controller. If you are not, unregistering gives a key error because the method pop assumes you have the key in your dictionary (and you don't have any of 'probe_view', 'subscan_view', etc).
Is register_instrument the preferrable way of registering non-stem-controllers? If yes, I just slightly modified the code to avoid the annoying key error after exiting nionswift
edit: Thanks and sorry for misplacing the issue (should be in the nion-instrumentation repo).