Commit 5dc9de5c authored by MVManyakhin's avatar MVManyakhin
Browse files

Update Coordinate_transmission.py, Get_and_graph.py files

parent fc31b621
import pika
import json
coords = {
'latitude': -3.36266,
'longtitude': 147.16691
}
credentials = pika.PlainCredentials('admin', '11111')
parameters = pika.ConnectionParameters('217.9.89.211',5672,'vh2',credentials)
connection = pika.BlockingConnection(parameters)
channel = connection.channel()
channel.queue_declare(queue = 'queue')
channel.basic_publish(exchange='',
routing_key= 'queue',
body=json.dumps(coordinates))
print(" [x] Sent data")
connection.close()
# -*- coding: utf-8 -*-
import pika
import json
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation
fig = plt.figure()
ax1 = fig.add_subplot(1,1, 1)
xs = []
ys = []
Coords = {
'Latitude': 0,
'Longtitude': 0,
}
credentials = pika.PlainCredentials('admin', '11111')
parameters = pika.ConnectionParameters('217.9.89.211',5672,'vh2',credentials)
connection = pika.BlockingConnection(parameters)
channel = connection.channel()
channel.queue_declare(queue = 'queue')
plt.ion()
def callback(ch, method, properties, body):
data = json.loads(body)
print (data)
print("значение",data['current_latitude'],"значение",data['current_longtitude'])
plt.clf()
xs.append(float(data['current_latitude']))
ys.append(float(data['current_longtitude']))
plt.xlabel('Latitude')
plt.ylabel('Longtitude')
plt.title('График движения')
plt.plot(xs,ys,linestyle='dashed', color='xkcd:red')
plt.ylim((-35.3, -35.4))
plt.xlim((149.1, 149.2))
print("значение1",xs,"значение2",ys)
plt.draw()
plt.gcf().canvas.flush_events()
channel.basic_consume('queue', callback, auto_ack=True)
print("значение3",xs,"значение4",ys)
print(' [*] Waiting for messages. To exit press CTRL+C')
print("значение5",xs,"значение6",ys)
plt.show()
channel.start_consuming()
plt.ioff()
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment