Ejemplo n.º 1
0
 def test_registering_same_component_with_different_types_succeeds(self):
     o = object()
     Registry.register_component(o, {"one", "two"})
     Registry.register_component(o, {"three"})
     self.assertEqual(o, Registry.get_component("one"))
     self.assertEqual(o, Registry.get_component("three"))
     Registry.unregister_component(o, {"three"})
     self.assertEqual(o, Registry.get_component("one"))
     self.assertIsNone(Registry.get_component("three"))
     Registry.unregister_component(o)
     self.assertIsNone(Registry.get_component("one"))
 def component_unregistered(component, component_types):
     if "video_device" in component_types:
         for hardware_source in HardwareSource.HardwareSourceManager(
         ).hardware_sources:
             if getattr(hardware_source, "video_device",
                        None) and hardware_source.video_device == component:
                 video_configuration.video_sources.remove_item(
                     video_configuration.video_sources.items.index(
                         hardware_source))
                 video_configuration._remove_video_device(component)
                 Registry.unregister_component(hardware_source)
                 HardwareSource.HardwareSourceManager(
                 ).unregister_hardware_source(hardware_source)
Ejemplo n.º 3
0
 def close(self) -> None:
     self.document_controller.periodic()
     self.document_controller.close()
     for ex in self.__exit_stack:
         ex.close()
     stem_controller.unregister_event_loop()
     self.camera_hardware_source.close()
     HardwareSource.HardwareSourceManager().unregister_hardware_source(
         self.camera_hardware_source)
     ScanDevice.stop()
     scan_base.stop()
     Registry.unregister_component(
         Registry.get_component("stem_controller"), {"stem_controller"})
     HardwareSource.HardwareSourceManager()._close_instruments()
     HardwareSource.stop()
     super().close()
Ejemplo n.º 4
0
 def component_unregistered(component: Registry._ComponentType,
                            component_types: typing.Set[str]) -> None:
     if "video_device" in component_types:
         for hardware_source in HardwareSource.HardwareSourceManager(
         ).hardware_sources:
             if isinstance(hardware_source,
                           VideoHardwareSource) and getattr(
                               hardware_source, "video_device", None
                           ) and hardware_source.video_device == component:
                 video_configuration.video_sources.remove_item(
                     video_configuration.video_sources.items.index(
                         hardware_source))
                 video_configuration._remove_video_device(component)
                 Registry.unregister_component(hardware_source)
                 HardwareSource.HardwareSourceManager(
                 ).unregister_hardware_source(hardware_source)
Ejemplo n.º 5
0
 def remove_hardware_source(self, hardware_source):
     hardware_source.abort_playing()
     component = hardware_source.video_device
     Registry.unregister_component(component)
     self.__save()
 def component_unregistered(component, component_types):
     if "camera_module" in component_types:
         camera_hardware_source = component.hardware_source
         Registry.unregister_component(camera_hardware_source)
         HardwareSource.HardwareSourceManager().unregister_hardware_source(
             camera_hardware_source)
Ejemplo n.º 7
0
def stop() -> None:
    Registry.unregister_component(Registry.get_component("scan_device"),
                                  {"scan_device"})