Skip to content

Commit

Permalink
Adding the required functionality when 'averaging_time' or 'integrati…
Browse files Browse the repository at this point in the history
…on_time' is updated to the areadetector.QuadEM PVGroup
  • Loading branch information
awalter-bnl committed Apr 19, 2024
1 parent de81c0d commit 5a4d7da
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
Binary file not shown.
33 changes: 32 additions & 1 deletion src/ari_sxn_simbeamline/Caproto_servers/area_detector/quad_em.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from caproto.server import (pvproperty, PVGroup, SubGroup,
ioc_arg_parser, run)
import math
from plugin_base import PluginBase, pvproperty_rbv
import random
from stats_plugin import StatsPlugin
Expand All @@ -26,7 +27,8 @@ class QuadEM(PVGroup):
3. Add description of averaging/integration time update here.
TODO:
1. ...
1. Think about adding a 'Continuous' acquire_mode as well as the current
'Single' acquire_mode.
"""
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs) # call the PluginBase __init__ function
Expand Down Expand Up @@ -54,6 +56,17 @@ def _generate_current(self):

return currents

def _reset_num_average(self):
"""This is a function that resets num_averaged when required.
num_averaged requires to be reset whenever averaging_time or
integration_time is changed. This function will be used as the
putter hook for these.
"""
self.num_average = math.floor(self.averaging_time/self.integration_time)

return

integration_time = pvproperty_rbv(name=':IntegrationTime', dtype=float, value=0.0004)
averaging_time = pvproperty_rbv(name=':AveragingTime', dtype=float, value=1.0)
model = pvproperty(name=':Model', dtype=str, read_only=True, value='NSLS_EM')
Expand Down Expand Up @@ -144,6 +157,24 @@ async def acquire(self, instance, value):

return value

@averaging_time.setpoint.putter
async def averaging_time(obj, instance, value):
"""
This is a putter function that updates num_average when averaging_time is set
"""
obj.parent._reset_num_average()

return value

@integration_time.setpoint.putter
async def integration_time(obj, instance, value):
"""
This is a putter function that updates num_average when integration_time is set
"""
obj.parent._reset_num_average()

return value


# Add some code to start a version of the server if this file is 'run'.
if __name__ == "__main__":
Expand Down

0 comments on commit 5a4d7da

Please sign in to comment.