@@ -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') | |
@@ -204,6 +205,9 def MPDecorator(BaseClass): | |||||
204 | self.inputId = args[0] |
|
205 | self.inputId = args[0] | |
205 | self.project_id = args[1] |
|
206 | self.project_id = args[1] | |
206 | self.typeProc = "Operation" |
|
207 | self.typeProc = "Operation" | |
|
208 | ||||
|
209 | def fix_publish(self,valor,multiple1): | |||
|
210 | return True if valor%multiple1 ==0 else False | |||
207 |
|
211 | |||
208 | def subscribe(self): |
|
212 | def subscribe(self): | |
209 | ''' |
|
213 | ''' | |
@@ -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