8 from time
import sleep, time_ns
13 parser = argparse.ArgumentParser(
"start_test_publisher")
18 help=
"Topic on which messages will be published",
25 help=
"Send timestamp as message part, requires topic to work properly",
30 args = parser.parse_args()
32 timestamp = args.timestamp
36 context = zmq.Context()
37 server_socket = context.socket(zmq.PUB)
38 server_socket.bind(
"tcp://*:" + str(PORT))
47 "cos": math.cos(ticks),
48 "sin": math.sin(ticks),
49 "floor": np.floor(np.cos(ticks)),
50 "ceil": np.ceil(np.cos(ticks)),
55 out_str.append(f
"[{topic}] - ")
56 packet.append(topic.encode())
58 out_str.append(json.dumps(data))
59 packet.append(out_str[-1].encode())
62 timestamp_s = str(time_ns() * 1e-9)
63 out_str.append(
" - timestamp: " + timestamp_s)
64 packet.append(timestamp_s.encode())
67 server_socket.send_multipart(packet)
74 if __name__ ==
"__main__":