Skip to content

Instantly share code, notes, and snippets.

@merlin-quix
Last active February 28, 2023 17:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save merlin-quix/18598ca6a3ff77be7c0a5af8bf276cca to your computer and use it in GitHub Desktop.
Save merlin-quix/18598ca6a3ff77be7c0a5af8bf276cca to your computer and use it in GitHub Desktop.
OSS_announcement
# Open the producer topic where to publish data.
topic_producer = client.get_topic_producer("data")
# Create a new stream for each device.
stream = topic_producer.create_stream("bus-123AAAV")
stream.properties.name = "BUS 123 AAAV"
stream.timeseries.buffer.time_span_in_milliseconds = 100
print("Sending values for 30 seconds.")
for index in range(0, 3000):
stream.timeseries \
.buffer \
.add_timestamp(datetime.datetime.utcnow()) \
.add_value("Lat", math.sin(index / 100.0) + math.sin(index) / 5.0) \
.add_value("Long", math.sin(index / 200.0) + math.sin(index) / 5.0) \
.publish()
time.sleep(0.01)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment