##// END OF EJS Templates
update from graphics branch
Juan C. Valdez -
r864:4e043a910377
parent child
Show More
@@ -6,7 +6,6 import time
6 import json
6 import json
7 import numpy
7 import numpy
8 import paho.mqtt.client as mqtt
8 import paho.mqtt.client as mqtt
9 from pymongo import MongoClient
10
9
11 from schainpy.model.proc.jroproc_base import Operation
10 from schainpy.model.proc.jroproc_base import Operation
12
11
@@ -66,9 +65,8 class PublishData(Operation):
66 print "MQTT Conection error."
65 print "MQTT Conection error."
67 self.client = False
66 self.client = False
68
67
69 def setup(self, host, port=1883, username=None, password=None, mongo=0, clientId="user", **kwargs):
68 def setup(self, host, port=1883, username=None, password=None, clientId="user", **kwargs):
70
69
71 self.mongo = mongo
72 self.topic = kwargs.get('topic', 'schain')
70 self.topic = kwargs.get('topic', 'schain')
73 self.delay = kwargs.get('delay', 0)
71 self.delay = kwargs.get('delay', 0)
74 self.plottype = kwargs.get('plottype', 'spectra')
72 self.plottype = kwargs.get('plottype', 'spectra')
@@ -77,9 +75,6 class PublishData(Operation):
77 self.clientId = clientId
75 self.clientId = clientId
78 self.cnt = 0
76 self.cnt = 0
79 setup = []
77 setup = []
80 if (self.mongo):
81 self.MongoClient = MongoClient("mongodb://127.0.0.1:3003")
82 self.MongoDB = self.MongoClient['meteor']
83 for plot in self.plottype:
78 for plot in self.plottype:
84 setup.append({
79 setup.append({
85 'plot': plot,
80 'plot': plot,
@@ -159,12 +154,7 class PublishData(Operation):
159 }
154 }
160 print 'Publishing data to {}'.format(self.host)
155 print 'Publishing data to {}'.format(self.host)
161 print '*************************'
156 print '*************************'
162 print self.client
163 self.client.publish(self.topic + plottype, json.dumps(payload), qos=0)
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 def run(self, dataOut, host, **kwargs):
160 def run(self, dataOut, host, **kwargs):
General Comments 0
You need to be logged in to leave comments. Login now