Loading SRT/Servers/SRTMinorServo/src/SRTMinorServoTest/mscu/servo.py +12 −2 Original line number Original line Diff line number Diff line from __future__ import division, with_statement from __future__ import division, with_statement import pdb import time import time import shelve import shelve import operator import operator Loading Loading @@ -125,6 +124,7 @@ class Servo(object): answer += ",%s" %param answer += ",%s" %param else: else: answer += closers[0] answer += closers[0] self.history.clean() return [answer.replace('@', '?'), answer] return [answer.replace('@', '?'), answer] def getspar(self, cmd_num, *params): def getspar(self, cmd_num, *params): Loading Loading @@ -164,6 +164,17 @@ class History(object): self.history.sort(key=operator.itemgetter(0)) self.history.sort(key=operator.itemgetter(0)) self.history = self.history[-2**15:] # Last 2**15 positions self.history = self.history[-2**15:] # Last 2**15 positions def clean(self, since=0): target_time = since if since else Servo.ctime() with History.lock: idx = len(self.history) self.history.sort(key=operator.itemgetter(0)) for idx, item in enumerate(self.history): timestamp = item[0] if timestamp > target_time: break self.history = self.history[:idx] def get(self, target_time=None): def get(self, target_time=None): """Return the position @target_time as [timestamp, axisA, ..., axisN]""" """Return the position @target_time as [timestamp, axisA, ..., axisN]""" if target_time is None: if target_time is None: Loading @@ -185,5 +196,4 @@ class History(object): continue continue else: else: return self.history[-size] return self.history[-size] pdb.set_trace() Loading
SRT/Servers/SRTMinorServo/src/SRTMinorServoTest/mscu/servo.py +12 −2 Original line number Original line Diff line number Diff line from __future__ import division, with_statement from __future__ import division, with_statement import pdb import time import time import shelve import shelve import operator import operator Loading Loading @@ -125,6 +124,7 @@ class Servo(object): answer += ",%s" %param answer += ",%s" %param else: else: answer += closers[0] answer += closers[0] self.history.clean() return [answer.replace('@', '?'), answer] return [answer.replace('@', '?'), answer] def getspar(self, cmd_num, *params): def getspar(self, cmd_num, *params): Loading Loading @@ -164,6 +164,17 @@ class History(object): self.history.sort(key=operator.itemgetter(0)) self.history.sort(key=operator.itemgetter(0)) self.history = self.history[-2**15:] # Last 2**15 positions self.history = self.history[-2**15:] # Last 2**15 positions def clean(self, since=0): target_time = since if since else Servo.ctime() with History.lock: idx = len(self.history) self.history.sort(key=operator.itemgetter(0)) for idx, item in enumerate(self.history): timestamp = item[0] if timestamp > target_time: break self.history = self.history[:idx] def get(self, target_time=None): def get(self, target_time=None): """Return the position @target_time as [timestamp, axisA, ..., axisN]""" """Return the position @target_time as [timestamp, axisA, ..., axisN]""" if target_time is None: if target_time is None: Loading @@ -185,5 +196,4 @@ class History(object): continue continue else: else: return self.history[-size] return self.history[-size] pdb.set_trace()