def topic_update(client, userdata, message):
log.debug('[topic_update] received topic:{0} ts:{1}'.format(
message.topic, dt.datetime.utcnow()))
topic_cache[message.topic] = message.payload
msg = json.loads(message.payload)
if 'data' in msg:
global last_hz
global current_hz
global current_hz_time
count_telemetry(msg['data'])
elapsed = dt.datetime.utcnow() - current_hz_time
if elapsed > second: # if a second has passed rollover Hz
with rollover_lock:
last_hz = current_hz
current_hz_time = dt.datetime.utcnow()
current_hz = 0
history(msg)
评论列表
文章目录