コード例 #1
0
 def prop_callback(self, mocker, observer_persistence):
     connector: MagicMock = mocker.stub()
     helper = UIHelper(connector, observer_persistence)
     # prop_spy: MagicMock = mocker.stub()
     o1 = ObservableStub(lambda win, item_name, value: int(value))
     properties_holder = PropertiesHolder(o1.get_properties())
     prop_callback = helper.get_properties_callback('o1', properties_holder)
     return prop_callback
コード例 #2
0
    def _run(self, ui_helper: UIHelper, data: TensorObservableData,
             properties: List[ObserverPropertiesItem],
             callbacks: ObserverCallbacks):
        self._properties_holder.properties = properties

        self._call_ui(ui_helper, data, properties)

        if not self.observer_registered:
            properties_callback = ui_helper.get_properties_callback(
                self.name, self._properties_holder, no_update=True)
            self.observer_registered = True
            ui_helper.clear_callbacks(self.name)

            def event_callback(event: EventData):
                logger.debug(f"Event: {event.event_type}")
                if event.event_type == 'property_updated':
                    properties_callback(event)
                elif event.event_type == 'window_closed':
                    self._observer_system.signals.window_closed.emit(self.name)

            ui_helper.register_event_callback(self.name, event_callback)

            for cb in callbacks.callbacks:
                if cb.command == 'event':
                    ui_helper.register_event_callback(self.name, cb.callback)
                elif cb.command == 'request':
                    ui_helper.register_request_callback(self.name, cb.callback)
コード例 #3
0
 def __init__(self, update_period: float = 0.1, storage_file: str = None):
     super().__init__(storage_file)
     self._ui_api = self._connect()
     self._ui_helper = UIHelper(self._ui_api, self.observer_persistence)
     self.update_period = update_period
     self._should_stop = False
     self._start()
コード例 #4
0
 def _call_ui(self, ui_helper: UIHelper, data: TensorObservableData,
              properties: List[ObserverPropertiesItem]):
     params = MemoryBlockParams(data.params.scale, data.params.projection,
                                None)
     ui_helper.ui_api.memory_block(data.tensor,
                                   params,
                                   UIHelper.convert_properties(properties),
                                   win=f'{self.name}')
コード例 #5
0
 def _call_ui(self, ui_helper: UIHelper, data: HierarchicalObservableData,
              properties: List[ObserverPropertiesItem]):
     ui_helper.ui_api.hierarchical_observer(
         data.groups_stacking,
         data.items_per_row,
         data.image_groups, [
             to_nested_dict(group_params)
             for group_params in data.params_groups
         ],
         UIHelper.convert_properties(properties),
         win=f'{self.name}')
コード例 #6
0
 def _run(self, ui_helper: UIHelper, data,
          properties: List[ObserverPropertiesItem],
          callbacks: ObserverCallbacks):
     ui_helper.properties(win=self.name,
                          items=self.observable.get_properties())
コード例 #7
0
 def _call_ui(self, ui_helper: UIHelper, data: ClusterObserverData,
              properties: List[ObserverPropertiesItem]):
     ui_helper.ui_api.cluster_observer(
         data, UIHelper.convert_properties(properties), win=self.name)