Exemplo n.º 1
0
 def do_write(self, **kwargs):  # {{{
     try:
         kwargs = EModuleModbus.do(self, **kwargs)
     except:
         return
     result = []
     thread = threading.currentThread()
     for i in range(0x0000, 0x010000):
         if thread.name == 'Thread_WSC':
             kwargs['request'] = self.modbusRequest(
             ) / self.threadTarget[thread.name][0](
                 outputAddr=i, outputValue=random.choice([0x0000, 0xFF00]))
         else:
             kwargs['request'] = self.modbusRequest() / self.threadTarget[
                 thread.name][0](registerAddr=i,
                                 registerValue=random.choice(
                                     [0x0000, 0xFF00]))
         rp = self.sendmessagesocket(**kwargs)
         if rp.payload.__class__.__name__ == \
                 self.threadTarget[thread.name][1]:
             result.append(i)
         if self.options['PERIOD'][0] > 0:
             time.sleep(self.options['PERIOD'][0])
     if len(result) != 0:
         kwargs['result'] = result
         kwargs['target'] = self.threadTarget[thread.name][2]
         self.print_result(**kwargs)
Exemplo n.º 2
0
 def do_read(self, **kwargs):  # {{{
     try:
         kwargs = EModuleModbus.do(self, **kwargs)
     except:
         return
     result = []
     thread = threading.currentThread()
     for i in range(0x0000, 0x010000):
         kwargs['request'] = self.modbusRequest() / self.threadTarget[
             thread.name][0](startAddr=i)
         rp = self.sendmessagesocket(**kwargs)
         if rp.payload.__class__.__name__ == \
                 self.threadTarget[thread.name][1]:
             result.append(i)
         if self.options['PERIOD'][0] > 0:
             time.sleep(self.options['PERIOD'][0])
     kwargs['socket'].close()
     if len(result) != 0:
         kwargs['result'] = result
         kwargs['target'] = self.threadTarget[thread.name][2]
         self.print_result(**kwargs)
Exemplo n.º 3
0
 def run(self, **kwargs):
     EModuleModbus.run(self, **kwargs)
     if not self.succeded:
         kwargs['msg'] = 'No Modbus Device on %s' % self.options['HOST'][0]
         self.fail(**kwargs)
Exemplo n.º 4
0
 def __init__(self, **kwargs):
     EModuleModbus.__init__(self, **kwargs)
Exemplo n.º 5
0
 def run(self, **kwargs):
     t = time.time()
     EModuleModbus.run(self, **kwargs)
     kwargs['msg'] = 'Cartography Realised in %s seconds' % str(
         time.time() - t)
     self.success(**kwargs)