From 1c6a2abdcc56f5e437786ec55db29ad780cf21fb Mon Sep 17 00:00:00 2001 From: Douglas Clowes Date: Thu, 27 Jun 2013 15:52:52 +1000 Subject: [PATCH] Handle the non-AbsoluteEncoder motor --- .../TEST_SICS/fakeGalil/galilmotor.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/site_ansto/instrument/TEST_SICS/fakeGalil/galilmotor.py b/site_ansto/instrument/TEST_SICS/fakeGalil/galilmotor.py index 5d33429e..5d9fc5e8 100644 --- a/site_ansto/instrument/TEST_SICS/fakeGalil/galilmotor.py +++ b/site_ansto/instrument/TEST_SICS/fakeGalil/galilmotor.py @@ -89,11 +89,20 @@ class GalilMotor(object): def getPosition(self): '''Calculate the unit position''' - value = self.unitsHome + self.currentSteps / self.stepsPerX - value = self.getEncoder() - self.absEncHome - value /= self.cntsPerX - value += self.unitsHome - return value + if self.hasAbsEnc and self.cntsPerX != 0: + # absolute encoder case + value = self.getEncoder() - self.absEncHome + value /= self.cntsPerX + value += self.unitsHome + return value + elif self.stepsPerX != 0: + # handle non-AbsEncoder case + value = self.currentSteps - self.motorHome + value /= self.stepsPerX + return value + else: + # not-configured case + return -123.456 def doIteration(self, now): '''If moving then update speed and position using