def __call__(self, inputs={}, outputs=[], current=0, total=1, **params): all_input_names = topo.sim.objects(GeneratorSheet).keys() if 'default' in inputs: for input_name in all_input_names: inputs[input_name] = inputs['default'] del inputs['default'] for input_name in set(all_input_names).difference(set(inputs.keys())): inputs[input_name] = pattern.Constant(scale=0) if current == 0: self.timer = copy.copy(topo.sim.timer) self.timer.stop = False if hasattr(topo, 'guimain'): topo.guimain.open_progress_window(self.timer) self.install_sheetview = True if self.timer.stop: raise MeasurementInterrupt(current, total) self.timer.update_timer('Measurement Timer', current, total) responses = super(pattern_response, self).__call__(inputs=inputs, outputs=outputs, **params) if hasattr(topo, 'guimain') and current == total: topo.guimain.refresh_activity_windows() return responses
def __call__(self, inputs={}, outputs=[], current=0, total=1, **params): all_input_names = topo.sim.objects(GeneratorSheet).keys() if 'default' in inputs: for input_name in all_input_names: inputs[input_name] = inputs['default'] del inputs['default'] for input_name in set(all_input_names).difference(set(inputs.keys())): inputs[input_name] = pattern.Constant(scale=0) if current == 0: self.timer = copy.copy(topo.sim.timer) self.timer.stop = False self._progress = current if hasattr(topo, 'guimain'): topo.guimain.open_progress_window(self.timer) self.install_sheetview = True self.progressbar = None elif self.progress_bar: self.progressbar = ProgressBar(label='Measurement Progress') else: self.progressbar = None if self.timer.stop: raise MeasurementInterrupt(current, total) self.timer.update_timer('Measurement Timer', current, total) progress = float(current) / total * 100 if total else 100 if self.progressbar and (progress > self._progress or progress == 100): self._progress = progress + 1 # +1 reduces fast updates/flicker self.progressbar(progress) responses = super(pattern_response, self).__call__(inputs=inputs, outputs=outputs, **params) if hasattr(topo, 'guimain') and current == total: topo.guimain.refresh_activity_windows() return responses