update doc
This commit is contained in:
parent
632421235f
commit
fd77446af7
@ -16,7 +16,12 @@ sys.modules['target_velocity'] = target_velocity
|
||||
|
||||
|
||||
class EventLogger:
|
||||
def __init__(self, redis, log_to_redis, verbose):
|
||||
def __init__(self, redis: StrictRedis, log_to_redis: bool, verbose: bool):
|
||||
"""
|
||||
:param redis:
|
||||
:param log_to_redis:
|
||||
:param verbose:
|
||||
"""
|
||||
self.redis = redis
|
||||
self.log_to_redis = log_to_redis
|
||||
self.verbose = verbose
|
||||
@ -30,36 +35,37 @@ class EventLogger:
|
||||
|
||||
def get_keys(self):
|
||||
"""
|
||||
Returns the available redis keys.
|
||||
:returns: the available redis keys.
|
||||
"""
|
||||
return json.dumps([key.decode() for key in self.redis.keys()])
|
||||
|
||||
def get_list_of(self, key):
|
||||
def get_list_of(self, key: str):
|
||||
"""
|
||||
Returns a list of all elements inside a key. Most recent elements are stored first.
|
||||
|
||||
@param key: DAF:<VIN> or TV:<VIN> for either DAF events or TV events
|
||||
:param key: DAF:<VIN> or TV:<VIN> for either DAF events or TV events
|
||||
:returns: list of elements
|
||||
"""
|
||||
key = self.redis.lrange(key, 0, -1)
|
||||
return key.decode() if key else json.dumps("")
|
||||
|
||||
def get_index_of(self, key, index):
|
||||
def get_index_of(self, key: str, index: int):
|
||||
"""
|
||||
Returns element matching index in key. Most recent elements are stored first.
|
||||
|
||||
@param key: DAF:<VIN> or TV:<VIN> for either DAF events or TV events
|
||||
@param index: 0 for most recent
|
||||
:param key: DAF:<VIN> or TV:<VIN> for either DAF events or TV events
|
||||
:param index: 0 for most recent
|
||||
"""
|
||||
key = self.redis.lindex(key, index)
|
||||
return key.decode() if key else json.dumps("")
|
||||
|
||||
def log(self, msg):
|
||||
def log(self, msg: bytes):
|
||||
"""
|
||||
Logging callback. Logs the msg depending on its type to the respective redis key.
|
||||
Types can be DAF, TrafficLightState or TargetVelocity. If type is unknown, message is still logged as key
|
||||
UNKNOWN.
|
||||
|
||||
:param msg: pickled msg binary to log
|
||||
:param bytes msg: pickled msg binary to log
|
||||
"""
|
||||
try:
|
||||
msg = pickle.loads(msg)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user