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