本文整理汇总了Python中pychron.core.ui.thread.Thread.join方法的典型用法代码示例。如果您正苦于以下问题:Python Thread.join方法的具体用法?Python Thread.join怎么用?Python Thread.join使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pychron.core.ui.thread.Thread
的用法示例。
在下文中一共展示了Thread.join方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: PatternExecutor
# 需要导入模块: from pychron.core.ui.thread import Thread [as 别名]
# 或者: from pychron.core.ui.thread.Thread import join [as 别名]
class PatternExecutor(Patternable):
"""
a pattern is only good for one execution.
self.pattern needs to be reset after stop or finish using load_pattern(name_or_pickle)
"""
controller = Any
laser_manager = Any
show_patterning = Bool(False)
_alive = Bool(False)
def __init__(self, *args, **kw):
super(PatternExecutor, self).__init__(*args, **kw)
self._next_point = None
self.pattern = None
self._xy_thread = None
self._power_thread = None
self._z_thread = None
def start(self, show=False):
self._alive = True
if show:
self.show_pattern()
if self.pattern:
self.pattern.clear_graph()
def finish(self):
self._alive = False
self.close_pattern()
self.pattern = None
def set_stage_values(self, sm):
if self.pattern:
self.pattern.set_stage_values(sm)
def set_current_position(self, x, y, z):
if self.isPatterning():
graph = self.pattern.graph
graph.set_data([x], series=1, axis=0)
graph.set_data([y], series=1, axis=1)
graph.add_datum((x, y), series=2)
graph.redraw()
def load_pattern(self, name_or_pickle):
"""
look for name_or_pickle in local pattern dir
if not found try interpreting name_or_pickle is a pickled name_or_pickle
"""
if name_or_pickle is None:
path = self.open_file_dialog()
if path is None:
return
else:
path = self.is_local_pattern(name_or_pickle)
if path:
wfile = open(path, 'rb')
else:
# convert name_or_pickle into a file like obj
wfile = StringIO(name_or_pickle)
# self._load_pattern sets self.pattern
pattern = self._load_pattern(wfile, path)
self.on_trait_change(self.stop, 'canceled')
return pattern
def is_local_pattern(self, name):
def test_name(ni):
path = os.path.join(paths.pattern_dir, ni)
if os.path.isfile(path):
return path
for ni in (name, name + '.lp'):
p = test_name(ni)
if p:
return p
def stop(self):
self._alive = False
if self.controller:
self.info('User requested stop')
self.controller.stop()
if self.pattern is not None:
if self.controller:
self.controller.linear_move(self.pattern.cx, self.pattern.cy, source='pattern stop')
# self.pattern.close_ui()
self.info('Pattern {} stopped'.format(self.pattern_name))
# prevent future stops (AbortJogs from massspec) from executing
self.pattern = None
def isPatterning(self):
#.........这里部分代码省略.........
示例2: AutoFocusManager
# 需要导入模块: from pychron.core.ui.thread import Thread [as 别名]
# 或者: from pychron.core.ui.thread.Thread import join [as 别名]
class AutoFocusManager(Manager):
"""
currently uses passive focus techniques
see
http://en.wikipedia.org/wiki/Autofocus
"""
video = Any
laser_manager = Any
stage_controller = Any
canvas = Any
parameters = Instance(FocusParameters)
configure_button = Button('configure')
autofocus_button = Event
autofocus_label = Property(depends_on='autofocusing')
autofocusing = Bool
# threading event for cancel signal
_evt_autofocusing = None
image = Instance(Image, ())
graph = None
def dump_parameters(self):
p = os.path.join(paths.hidden_dir, 'autofocus_configure')
self.info('dumping parameters to {}'.format(p))
with open(p, 'wb') as f:
pickle.dump(self.parameters, f)
def load_parameter(self):
p = os.path.join(paths.hidden_dir, 'autofocus_configure')
if os.path.isfile(p):
with open(p, 'rb') as f:
try:
params = pickle.load(f)
self.info('loading parameters from {}'.format(p))
if not isinstance(params, FocusParameters):
self.info('out of date parameters file. using default')
params = FocusParameters()
return params
except Exception as e:
print('autofocus load parameter', e)
return FocusParameters()
else:
return FocusParameters()
def passive_focus(self, block=False, **kw):
self._evt_autofocusing = TEvent()
self._evt_autofocusing.clear()
# manager = self.laser_manager
oper = self.parameters.operator
self.info('passive focus. operator = {}'.format(oper))
g = self.graph
if not g:
g = Graph(plotcontainer_dict=dict(padding=10),
window_x=0.70,
window_y=20,
window_width=325,
window_height=325,
window_title='Autofocus'
)
self.graph = g
g.clear()
g.new_plot(padding=[40, 10, 10, 40],
xtitle='Z (mm)',
ytitle='Focus Measure ({})'.format(oper)
)
g.new_series()
g.new_series()
invoke_in_main_thread(self._open_graph)
target = self._passive_focus
self._passive_focus_thread = Thread(name='autofocus', target=target,
args=(self._evt_autofocusing,
),
kwargs=kw
)
self._passive_focus_thread.start()
if block:
# while 1:
# if not self._passive_focus_thread.isRunning():
# break
# time.sleep(0.25)
self._passive_focus_thread.join()
def _open_graph(self):
ui = self.graph.edit_traits()
self.add_window(ui)
#.........这里部分代码省略.........