Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 22 additions & 18 deletions src/pymodaq_plugins_template/daq_move_plugins/daq_move_Template.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,9 @@ def get_actuator_value(self):
float: The position obtained after scaling conversion.
"""
## TODO for your custom plugin
raise NotImplemented # when writing your own plugin remove this line
pos = DataActuator(data=self.controller.your_method_to_get_the_actuator_value()) # when writing your own plugin replace this line
raise NotImplementedError # when writing your own plugin remove this line
pos = DataActuator(data=self.controller.your_method_to_get_the_actuator_value(), # when writing your own plugin replace this line
units=self.axis_unit)
pos = self.get_position_with_scaling(pos)
return pos

Expand All @@ -91,8 +92,10 @@ def user_condition_to_reach_target(self) -> bool:
def close(self):
"""Terminate the communication protocol"""
## TODO for your custom plugin
raise NotImplemented # when writing your own plugin remove this line
# self.controller.your_method_to_terminate_the_communication() # when writing your own plugin replace this line
raise NotImplementedError # when writing your own plugin remove this line
if self.is_master:
# self.controller.your_method_to_terminate_the_communication() # when writing your own plugin replace this line
...

def commit_settings(self, param: Parameter):
"""Apply the consequences of a change of value in the detector settings
Expand Down Expand Up @@ -128,16 +131,17 @@ def ini_stage(self, controller=None):
initialized: bool
False if initialization failed otherwise True
"""
raise NotImplemented # TODO when writing your own plugin remove this line and modify the ones below
self.ini_stage_init(slave_controller=controller) # will be useful when controller is slave

raise NotImplementedError # TODO when writing your own plugin remove this line and modify the ones below
if self.is_master: # is needed when controller is master
self.controller = PythonWrapperOfYourInstrument(arg1, arg2, ...) # arguments for instantiation!)
initialized = self.controller.a_method_or_atttribute_to_check_if_init() # todo
# todo: enter here whatever is needed for your controller initialization and eventual
# opening of the communication channel
else:
self.controller = controller
initialized = True

info = "Whatever info you want to log"
initialized = self.controller.a_method_or_atttribute_to_check_if_init() # todo
return info, initialized

def move_abs(self, value: DataActuator):
Expand All @@ -152,8 +156,8 @@ def move_abs(self, value: DataActuator):
self.target_value = value
value = self.set_position_with_scaling(value) # apply scaling if the user specified one
## TODO for your custom plugin
raise NotImplemented # when writing your own plugin remove this line
self.controller.your_method_to_set_an_absolute_value(value.value()) # when writing your own plugin replace this line
raise NotImplementedError # when writing your own plugin remove this line
self.controller.your_method_to_set_an_absolute_value(value.value(self.axis_unit)) # when writing your own plugin replace this line
self.emit_status(ThreadCommand('Update_Status', ['Some info you want to log']))

def move_rel(self, value: DataActuator):
Expand All @@ -168,25 +172,25 @@ def move_rel(self, value: DataActuator):
value = self.set_position_relative_with_scaling(value)

## TODO for your custom plugin
raise NotImplemented # when writing your own plugin remove this line
self.controller.your_method_to_set_a_relative_value(value.value()) # when writing your own plugin replace this line
raise NotImplementedError # when writing your own plugin remove this line
self.controller.your_method_to_set_a_relative_value(value.value(self.axis_unit)) # when writing your own plugin replace this line
self.emit_status(ThreadCommand('Update_Status', ['Some info you want to log']))

def move_home(self):
"""Call the reference method of the controller"""

## TODO for your custom plugin
raise NotImplemented # when writing your own plugin remove this line
raise NotImplementedError # when writing your own plugin remove this line
self.controller.your_method_to_get_to_a_known_reference() # when writing your own plugin replace this line
self.emit_status(ThreadCommand('Update_Status', ['Some info you want to log']))

def stop_motion(self):
"""Stop the actuator and emits move_done signal"""
"""Stop the actuator and emits move_done signal"""

## TODO for your custom plugin
raise NotImplemented # when writing your own plugin remove this line
self.controller.your_method_to_stop_positioning() # when writing your own plugin replace this line
self.emit_status(ThreadCommand('Update_Status', ['Some info you want to log']))
## TODO for your custom plugin
raise NotImplementedError # when writing your own plugin remove this line
self.controller.your_method_to_stop_positioning() # when writing your own plugin replace this line
self.emit_status(ThreadCommand('Update_Status', ['Some info you want to log']))


if __name__ == '__main__':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,14 @@ def ini_detector(self, controller=None):
False if initialization failed otherwise True
"""

raise NotImplemented # TODO when writing your own plugin remove this line and modify the one below
self.ini_detector_init(slave_controller=controller)

raise NotImplementedError # TODO when writing your own plugin remove this line and modify the one below
if self.is_master:
self.controller = PythonWrapperOfYourInstrument() #instantiate you driver with whatever arguments are needed
self.controller.open_communication() # call eventual methods
initialized = self.controller.a_method_or_atttribute_to_check_if_init() # TODO
else:
self.controller = controller
initialized = True

# TODO for your custom plugin (optional) initialize viewers panel with the future type of data
self.dte_signal_temp.emit(DataToExport(name='myplugin',
Expand All @@ -97,14 +99,15 @@ def ini_detector(self, controller=None):
labels=['Mock1', 'label2'])]))

info = "Whatever info you want to log"
initialized = self.controller.a_method_or_atttribute_to_check_if_init() # TODO
return info, initialized

def close(self):
"""Terminate the communication protocol"""
## TODO for your custom plugin
raise NotImplemented # when writing your own plugin remove this line
# self.controller.your_method_to_terminate_the_communication() # when writing your own plugin replace this line
raise NotImplementedError # when writing your own plugin remove this line
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we should add a self.is_master clause??

if self.is_master:
# self.controller.your_method_to_terminate_the_communication() # when writing your own plugin replace this line
...

def grab_data(self, Naverage=1, **kwargs):
"""Start a grab from the detector
Expand All @@ -120,15 +123,15 @@ def grab_data(self, Naverage=1, **kwargs):
## TODO for your custom plugin: you should choose EITHER the synchrone or the asynchrone version following

# synchrone version (blocking function)
raise NotImplemented # when writing your own plugin remove this line
raise NotImplementedError # when writing your own plugin remove this line
data_tot = self.controller.your_method_to_start_a_grab_snap()
self.dte_signal.emit(DataToExport(name='myplugin',
data=[DataFromPlugins(name='Mock1', data=data_tot,
dim='Data0D', labels=['dat0', 'data1'])]))
#########################################################

# asynchrone version (non-blocking function with callback)
raise NotImplemented # when writing your own plugin remove this line
raise NotImplementedError # when writing your own plugin remove this line
self.controller.your_method_to_start_a_grab_snap(self.callback) # when writing your own plugin replace this line
#########################################################

Expand All @@ -143,7 +146,7 @@ def callback(self):
def stop(self):
"""Stop the current grab hardware wise if necessary"""
## TODO for your custom plugin
raise NotImplemented # when writing your own plugin remove this line
raise NotImplementedError # when writing your own plugin remove this line
self.controller.your_method_to_stop_acquisition() # when writing your own plugin replace this line
self.emit_status(ThreadCommand('Update_Status', ['Some info you want to log']))
##############################
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,14 @@ def ini_detector(self, controller=None):
False if initialization failed otherwise True
"""

raise NotImplemented # TODO when writing your own plugin remove this line and modify the one below
self.ini_detector_init(slave_controller=controller)

raise NotImplementedError # TODO when writing your own plugin remove this line and modify the one below
if self.is_master:
self.controller = PythonWrapperOfYourInstrument() #instantiate you driver with whatever arguments are needed
self.controller.open_communication() # call eventual methods
initialized = self.controller.a_method_or_atttribute_to_check_if_init() # TODO
else:
self.controller = controller
initialized = True

## TODO for your custom plugin
# get the x_axis (you may want to to this also in the commit settings if x_axis may have changed
Expand All @@ -108,14 +110,15 @@ def ini_detector(self, controller=None):
axes=[self.x_axis])]))

info = "Whatever info you want to log"
initialized = True
return info, initialized

def close(self):
"""Terminate the communication protocol"""
## TODO for your custom plugin
raise NotImplemented # when writing your own plugin remove this line
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see my other comment

# self.controller.your_method_to_terminate_the_communication() # when writing your own plugin replace this line
raise NotImplementedError # when writing your own plugin remove this line
if self.is_master:
# self.controller.your_method_to_terminate_the_communication() # when writing your own plugin replace this line
...

def grab_data(self, Naverage=1, **kwargs):
"""Start a grab from the detector
Expand Down Expand Up @@ -152,7 +155,7 @@ def callback(self):
def stop(self):
"""Stop the current grab hardware wise if necessary"""
## TODO for your custom plugin
raise NotImplemented # when writing your own plugin remove this line
raise NotImplementedError # when writing your own plugin remove this line
self.controller.your_method_to_stop_acquisition() # when writing your own plugin replace this line
self.emit_status(ThreadCommand('Update_Status', ['Some info you want to log']))
##############################
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,14 @@ def ini_detector(self, controller=None):
initialized: bool
False if initialization failed otherwise True
"""
raise NotImplemented # TODO when writing your own plugin remove this line and modify the one below
self.ini_detector_init(slave_controller=controller)

raise NotImplementedError # TODO when writing your own plugin remove this line and modify the one below
if self.is_master:
self.controller = PythonWrapperOfYourInstrument() #instantiate you driver with whatever arguments are needed
self.controller.open_communication() # call eventual methods
initialized = self.controller.a_method_or_atttribute_to_check_if_init() # TODO
else:
self.controller = controller
initialized = True

## TODO for your custom plugin
# get the x_axis (you may want to to this also in the commit settings if x_axis may have changed
Expand All @@ -105,14 +107,15 @@ def ini_detector(self, controller=None):
axes=[self.x_axis, self.y_axis]), ]))

info = "Whatever info you want to log"
initialized = True
return info, initialized

def close(self):
"""Terminate the communication protocol"""
## TODO for your custom plugin
raise NotImplemented # when writing your own plugin remove this line
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see my other comment

# self.controller.your_method_to_terminate_the_communication() # when writing your own plugin replace this line
raise NotImplementedError # when writing your own plugin remove this line
if self.is_master:
# self.controller.your_method_to_terminate_the_communication() # when writing your own plugin replace this line
...

def grab_data(self, Naverage=1, **kwargs):
"""Start a grab from the detector
Expand Down Expand Up @@ -150,7 +153,7 @@ def callback(self):
def stop(self):
"""Stop the current grab hardware wise if necessary"""
## TODO for your custom plugin
raise NotImplemented # when writing your own plugin remove this line
raise NotImplementedError # when writing your own plugin remove this line
self.controller.your_method_to_stop_acquisition() # when writing your own plugin replace this line
self.emit_status(ThreadCommand('Update_Status', ['Some info you want to log']))
##############################
Expand Down
Loading