Exemplo n.º 1
0
def sensor_update(client, sensor_topic, sensors, **kwargs):
    for sensor in sensors:
        for name, readings in sensor.items():
            for reading, value in readings.items():
                msg = str(value['value'])
                if 'units' in value:
                    msg += ' ' + value['units']
                client.publish(make_topic(sensor_topic, [name, reading]), msg)
Exemplo n.º 2
0
def race_stop(client, race_topic, raceEvent, RACE, **kwargs):
    msg = {'stopTime': RACE.end_time_epoch_ms}
    client.publish(make_topic(race_topic, [raceEvent, str(RACE.current_stage), str(RACE.current_heat), str(RACE.current_round)]), json.dumps(msg))
Exemplo n.º 3
0
 def _unsubscibe_from(self, node_topic):
     topic = make_topic(self.ann_topic,
                        [self.timer_id, '+', '+', node_topic])
     self.client.unsubscribe(topic)
     self.client.message_callback_remove(topic)
Exemplo n.º 4
0
def race_split(client, race_topic, raceEvent, RACE, node_index, split, location_id, **kwargs):
    pilot = RACE.node_pilots[node_index]
    msg = {'lap': split['lap_number'], 'timestamp': split['split_time_stamp'], 'location': location_id, 'seat': node_index}
    client.publish(make_topic(race_topic, [raceEvent, str(RACE.current_stage), str(RACE.current_heat), str(RACE.current_round), pilot.callsign]), json.dumps(msg))
Exemplo n.º 5
0
 def _subscribe_to(self, node_topic, handler):
     topic = make_topic(self.ann_topic,
                        [self.timer_id, '+', '+', node_topic])
     self.client.message_callback_add(topic, handler)
     self.client.subscribe(topic)