##// 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 189 self.kwargs = kwargs
190 190 self.sender = None
191 191 self.receiver = None
192 self.i = 0
192 193 self.name = BaseClass.__name__
193 194 if 'plot' in self.name.lower() and not self.name.endswith('_'):
194 195 self.name = '{}{}'.format(self.CODE.upper(), 'Plot')
@@ -205,6 +206,9 def MPDecorator(BaseClass):
205 206 self.project_id = args[1]
206 207 self.typeProc = "Operation"
207 208
209 def fix_publish(self,valor,multiple1):
210 return True if valor%multiple1 ==0 else False
211
208 212 def subscribe(self):
209 213 '''
210 214 This function create a socket to receive objects from the
@@ -221,8 +225,11 def MPDecorator(BaseClass):
221 225 '''
222 226 This function waits for objects and deserialize using pickle
223 227 '''
224
228 try:
225 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 234 return data
228 235
@@ -240,7 +247,14 def MPDecorator(BaseClass):
240 247 def publish(self, data, id):
241 248 '''
242 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 258 self.sender.send_multipart([str(id).encode(), pickle.dumps(data)])
245 259
246 260 def runReader(self):
General Comments 0
You need to be logged in to leave comments. Login now