Skip to content

Commit

Permalink
Modify ub.calc to get axes names from a passed hardware object - #33
Browse files Browse the repository at this point in the history
  • Loading branch information
robwalton committed Aug 12, 2013
1 parent a2cdb4d commit 7d13c63
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions diffcalc/ub/calc.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,25 +67,28 @@ class UBCalculation:
of the code.
"""

def __init__(self, diffractometer_axes_names, diffractometerPluginObject,
def __init__(self, hardware, diffractometerPluginObject,
persister, strategy, include_sigtau=True):

# The diffractometer geometry is required to map the internal angles
# into those used by this diffractometer (for display only)

self._diffractometer_axes_names = diffractometer_axes_names
self._hardware = hardware
self._geometry = diffractometerPluginObject
self._persister = persister
self._strategy = strategy
self._include_sigtau = include_sigtau
self.reference = YouReference(self) # TODO: move into _state and persist
self._clear()

def _get_diffractometer_axes_names(self):
return self._hardware.get_axes_names()

def _clear(self, name=None):
# NOTE the Diffraction calculator is expecting this object to exist in
# the long run. We can't remove this entire object, and recreate it.
# It also contains a required link to the angle calculator.
reflist = ReflectionList(self._geometry, self._diffractometer_axes_names)
reflist = ReflectionList(self._geometry, self._get_diffractometer_axes_names())
self._state = UBCalcState(name=name, reflist=reflist)
self._U = None
self._UB = None
Expand All @@ -105,7 +108,7 @@ def start_new(self, name):

def load(self, name):
state = self._persister.load(name)
self._state = decode_ubcalcstate(state, self._geometry, self._diffractometer_axes_names)
self._state = decode_ubcalcstate(state, self._geometry, self._get_diffractometer_axes_names())
if self._state.manual_U is not None:
self.set_U_manually(self._state.manual_U)
elif self._state.manual_UB is not None:
Expand Down

0 comments on commit 7d13c63

Please sign in to comment.