@@ -6,7 +6,6 import time | |||
|
6 | 6 | import json |
|
7 | 7 | import numpy |
|
8 | 8 | import paho.mqtt.client as mqtt |
|
9 | from pymongo import MongoClient | |
|
10 | 9 | |
|
11 | 10 | from schainpy.model.proc.jroproc_base import Operation |
|
12 | 11 | |
@@ -66,9 +65,8 class PublishData(Operation): | |||
|
66 | 65 | print "MQTT Conection error." |
|
67 | 66 | self.client = False |
|
68 | 67 | |
|
69 |
def setup(self, host, port=1883, username=None, password=None, |
|
|
68 | def setup(self, host, port=1883, username=None, password=None, clientId="user", **kwargs): | |
|
70 | 69 | |
|
71 | self.mongo = mongo | |
|
72 | 70 | self.topic = kwargs.get('topic', 'schain') |
|
73 | 71 | self.delay = kwargs.get('delay', 0) |
|
74 | 72 | self.plottype = kwargs.get('plottype', 'spectra') |
@@ -77,9 +75,6 class PublishData(Operation): | |||
|
77 | 75 | self.clientId = clientId |
|
78 | 76 | self.cnt = 0 |
|
79 | 77 | setup = [] |
|
80 | if (self.mongo): | |
|
81 | self.MongoClient = MongoClient("mongodb://127.0.0.1:3003") | |
|
82 | self.MongoDB = self.MongoClient['meteor'] | |
|
83 | 78 | for plot in self.plottype: |
|
84 | 79 | setup.append({ |
|
85 | 80 | 'plot': plot, |
@@ -159,12 +154,7 class PublishData(Operation): | |||
|
159 | 154 | } |
|
160 | 155 | print 'Publishing data to {}'.format(self.host) |
|
161 | 156 | print '*************************' |
|
162 | print self.client | |
|
163 | 157 | self.client.publish(self.topic + plottype, json.dumps(payload), qos=0) |
|
164 | if (self.mongo): | |
|
165 | print 'Publishing data to Mongo' | |
|
166 | result = self.MongoDB.realtime.insert_one(payload) | |
|
167 | print result.inserted_id | |
|
168 | 158 | |
|
169 | 159 | |
|
170 | 160 | def run(self, dataOut, host, **kwargs): |
General Comments 0
You need to be logged in to leave comments.
Login now