Browse Source

Fix generation tool to use differents ids

pull/1/head
rozetko 6 years ago
parent
commit
9637bfa0b5
  1. 1
      analytics/tools/push
  2. 80
      analytics/tools/send_zmq_message.py

1
analytics/tools/push

@ -1 +0,0 @@
{"method": "DATA", "payload": {"_id": "rVn4L3eNqqo2mgsE", "analyticUnitId": "JyC4BrVGQ2kZjuSH", "type": "PUSH", "payload": {"data": [[1552652025000, 12.499999999999998], [1552652040000, 12.500000000000002], [1552652055000, 12.499999999999996], [1552652070000, 12.500000000000002], [1552652085000, 12.499999999999998], [1552652100000, 12.5], [1552652115000, 12.83261113785909]], "from": 1552652025001, "to": 1552652125541, "analyticUnitType": "GENERAL", "detector": "pattern", "cache": {"pattern_center": [693], "pattern_model": [1.7763568394002505e-15, 5.329070518200751e-15, 1.7763568394002505e-15, 1.7763568394002505e-15, 1.7763568394002505e-15, 3.552713678800501e-15, 1.7763568394002505e-15, 3.552713678800501e-15, 3.552713678800501e-15, 1.7763568394002505e-15, 1.7763568394002505e-15, 0, 1.7763568394002505e-15, 1.7763568394002505e-15, 0], "convolve_max": 7.573064690121713e-29, "convolve_min": 7.573064690121713e-29, "WINDOW_SIZE": 7, "conv_del_min": 7, "conv_del_max": 7}}}}

80
analytics/tools/send_zmq_message.py

@ -1,11 +1,88 @@
import zmq
import zmq.asyncio
import asyncio
import json
from uuid import uuid4
context = zmq.asyncio.Context()
socket = context.socket(zmq.PAIR)
socket.connect('tcp://0.0.0.0:8002')
def create_message():
message = {
"method": "DATA",
"payload": {
"_id": uuid4().hex,
"analyticUnitId": uuid4().hex,
"type": "PUSH",
"payload": {
"data": [
[
1552652025000,
12.499999999999998
],
[
1552652040000,
12.500000000000002
],
[
1552652055000,
12.499999999999996
],
[
1552652070000,
12.500000000000002
],
[
1552652085000,
12.499999999999998
],
[
1552652100000,
12.5
],
[
1552652115000,
12.83261113785909
]
],
"from": 1552652025001,
"to": 1552652125541,
"analyticUnitType": "GENERAL",
"detector": "pattern",
"cache": {
"pattern_center": [
693
],
"pattern_model": [
1.7763568394002505e-15,
5.329070518200751e-15,
1.7763568394002505e-15,
1.7763568394002505e-15,
1.7763568394002505e-15,
3.552713678800501e-15,
1.7763568394002505e-15,
3.552713678800501e-15,
3.552713678800501e-15,
1.7763568394002505e-15,
1.7763568394002505e-15,
0,
1.7763568394002505e-15,
1.7763568394002505e-15,
0
],
"convolve_max": 7.573064690121713e-29,
"convolve_min": 7.573064690121713e-29,
"WINDOW_SIZE": 7,
"conv_del_min": 7,
"conv_del_max": 7
}
}
}
}
return json.dumps(message)
async def handle_loop():
while True:
received_bytes = await socket.recv()
@ -14,8 +91,7 @@ async def handle_loop():
print(text)
async def send_detect():
f = open('push', 'rb')
data = f.read()
data = create_message().encode('utf-8')
await socket.send(data)
if __name__ == "__main__":

Loading…
Cancel
Save