status_history.py
Go to the documentation of this file.
1 # status_history.py
2 
3 class StatusHistory():
4  def __init__(self, max_length=10):
5  self.max_length = max_length
6  self.buffer = []
7  def add(self, status):
8  self.buffer.append(status)
9  if len(self.buffer) > self.max_length:
10  self.buffer = self.buffer[1:self.max_length+1]
11  def all(self, proc):
12  for status in self.buffer:
13  if not proc(status):
14  return False
15  return True
16  def latest(self):
17  if len(self.buffer) > 0:
18  return self.buffer[-1]
19  else:
20  return None
21  def length(self):
22  return len(self.buffer)
23  def new(self, status, attr):
24  if len(self.buffer) == 0:
25  return getattr(status, attr)
26  else:
27  return getattr(status, attr) and not getattr(self.latest(), attr)
jsk_teleop_joy.status_history.StatusHistory.latest
def latest(self)
Definition: status_history.py:16
jsk_teleop_joy.status_history.StatusHistory.all
def all(self, proc)
Definition: status_history.py:11
jsk_teleop_joy.status_history.StatusHistory
Definition: status_history.py:3
jsk_teleop_joy.status_history.StatusHistory.length
def length(self)
Definition: status_history.py:21
jsk_teleop_joy.status_history.StatusHistory.new
def new(self, status, attr)
Definition: status_history.py:23
jsk_teleop_joy.status_history.StatusHistory.buffer
buffer
Definition: status_history.py:6
jsk_teleop_joy.status_history.StatusHistory.add
def add(self, status)
Definition: status_history.py:7
jsk_teleop_joy.status_history.StatusHistory.max_length
max_length
Definition: status_history.py:5
jsk_teleop_joy.status_history.StatusHistory.__init__
def __init__(self, max_length=10)
Definition: status_history.py:4


jsk_teleop_joy
Author(s): Ryohei Ueda
autogenerated on Wed Jan 24 2024 04:05:49