Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
MVManyakhin
Практика 4С
Commits
5dc9de5c
Commit
5dc9de5c
authored
Oct 18, 2021
by
MVManyakhin
Browse files
Update Coordinate_transmission.py, Get_and_graph.py files
parent
fc31b621
Changes
2
Hide whitespace changes
Inline
Side-by-side
Coordinate_transmission.py
0 → 100644
View file @
5dc9de5c
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
()
Get_and_graph.py
0 → 100644
View file @
5dc9de5c
# -*- 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
()
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment