##// END OF EJS Templates
Se añade el metodo fix_publish y se editan los metodos listen y publish, en el ultimo se colocaun pequeño retardo aplicado exclusivamente durante la comunacion desde la unidad de lectura, las demas operaciones se realizan igual.
Alexander Valdez -
r1220:dd4695cf07ce
parent child
Show More
@@ -189,6 +189,7 def MPDecorator(BaseClass):
189 self.kwargs = kwargs
189 self.kwargs = kwargs
190 self.sender = None
190 self.sender = None
191 self.receiver = None
191 self.receiver = None
192 self.i = 0
192 self.name = BaseClass.__name__
193 self.name = BaseClass.__name__
193 if 'plot' in self.name.lower() and not self.name.endswith('_'):
194 if 'plot' in self.name.lower() and not self.name.endswith('_'):
194 self.name = '{}{}'.format(self.CODE.upper(), 'Plot')
195 self.name = '{}{}'.format(self.CODE.upper(), 'Plot')
@@ -205,6 +206,9 def MPDecorator(BaseClass):
205 self.project_id = args[1]
206 self.project_id = args[1]
206 self.typeProc = "Operation"
207 self.typeProc = "Operation"
207
208
209 def fix_publish(self,valor,multiple1):
210 return True if valor%multiple1 ==0 else False
211
208 def subscribe(self):
212 def subscribe(self):
209 '''
213 '''
210 This function create a socket to receive objects from the
214 This function create a socket to receive objects from the
@@ -221,8 +225,11 def MPDecorator(BaseClass):
221 '''
225 '''
222 This function waits for objects and deserialize using pickle
226 This function waits for objects and deserialize using pickle
223 '''
227 '''
224
228 try:
225 data = pickle.loads(self.receiver.recv_multipart()[1])
229 data = pickle.loads(self.receiver.recv_multipart()[1])
230 except zmq.ZMQError as e:
231 if e.errno == zmq.ETERM:
232 print (e.errno)
226
233
227 return data
234 return data
228
235
@@ -240,7 +247,14 def MPDecorator(BaseClass):
240 def publish(self, data, id):
247 def publish(self, data, id):
241 '''
248 '''
242 This function publish an object, to a specific topic.
249 This function publish an object, to a specific topic.
250 The fix method only affect inputId None which is Read Unit
251 Use value between 64 80, you should notice a little retard in processing
243 '''
252 '''
253 if self.inputId is None:
254 self.i+=1
255 if self.fix_publish(self.i,80) == True:# value n
256 time.sleep(0.01)
257
244 self.sender.send_multipart([str(id).encode(), pickle.dumps(data)])
258 self.sender.send_multipart([str(id).encode(), pickle.dumps(data)])
245
259
246 def runReader(self):
260 def runReader(self):
General Comments 0
You need to be logged in to leave comments. Login now