Ejemplo n.º 1
0
    def __init__(self, host, sim=True, rate=50):
        """
            :param host: Contains the IP adress of the modbus server
            :type host: string
            :param rate: How often the registers on the modbusserver should be read per second
            :type rate: float
            :param reset_registers: Defines if the holding registers should be reset to 0 after they have been read. Only possible if they are writeable
            :type reset_registers: bool
        """
        print(
            "Use the appropriate Cognex Insight Project to enable the Modbus Server"
        )
        self.sim = sim
        ModbusWrapperClient.__init__(self,
                                     host,
                                     502,
                                     rate,
                                     reset_registers=False)
        # All registers
        self.write_start = 50000
        self.setReadingRegisters(30010, 30127 - 30010)
        # Use only a few registers for writing
        self.setWritingRegisters(self.write_start, 2)

        # Note: Listener not started as reading is requested manually, but a heartbeat is required to keep the modbus server alive
        self.startHeartbeat()
Ejemplo n.º 2
0
 def __init__(self, host, port=502, rate=50, reset_registers=True):
     """
         :param host: Contains the IP adress of the modbus server
         :type host: string
         :param rate: How often the registers on the modbusserver should be read per second
         :type rate: float
         :param reset_registers: Defines if the holding registers should be reset to 0 after they have been read. Only possible if they are writeable
         :type reset_registers: bool
     """
     #         print("Use the appropriate Step7 Project to enable the Modbus Server on your Siemens S1200 PLC")
     ModbusWrapperClient.__init__(self, host, port, rate, reset_registers)
     self.setReadingRegisters(0, 8)
     self.setWritingRegisters(8, 9)
Ejemplo n.º 3
0
 def __init__(self,host,port=502,rate=50,reset_registers=True):
     """
         :param host: Contains the IP adress of the modbus server
         :type host: string
         :param rate: How often the registers on the modbusserver should be read per second
         :type rate: float
         :param reset_registers: Defines if the holding registers should be reset to 0 after they have been read. Only possible if they are writeable
         :type reset_registers: bool
     """
     print("Use the appropriate Step7 Project to enable the Modbus Server on your Siemens S1200 PLC")
     ModbusWrapperClient.__init__(self,host,port,rate,reset_registers)
     self.setReadingRegisters(0,8)
     self.setWritingRegisters(8,6)
     self.startListening()
Ejemplo n.º 4
0
    def __init__(self,host,sim=True,rate=50):
        """
            :param host: Contains the IP adress of the modbus server
            :type host: string
            :param rate: How often the registers on the modbusserver should be read per second
            :type rate: float
            :param reset_registers: Defines if the holding registers should be reset to 0 after they have been read. Only possible if they are writeable
            :type reset_registers: bool
        """
        print("Use the appropriate Cognex Insight Project to enable the Modbus Server")
        self.sim = sim
        ModbusWrapperClient.__init__(self,host,502,rate,reset_registers=False)
        # All registers
        self.write_start = 50000
        self.setReadingRegisters(30010,30127-30010)
        # Use only a few registers for writing
        self.setWritingRegisters(self.write_start,2)

        # Note: Listener not started as reading is requested manually, but a heartbeat is required to keep the modbus server alive
        self.startHeartbeat()
Ejemplo n.º 5
0
 def __init__(self,
              host,
              port=502,
              rate=50,
              reset_registers=True,
              disable_topics=False):
     """
         :param host: Contains the IP adress of the modbus server
         :type host: string
         :param rate: How often the registers on the modbusserver should be read per second
         :type rate: float
         :param reset_registers: Defines if the holding registers should be reset to 0 after they have been read. Only possible if they are writeable
         :type reset_registers: bool
         :param disable_topics: Disables ROS subscriber/publisher if True, disabling automatic reading and writing. Voids startListening and stopListening, will raise exception if called.
         :type disable_topics: bool
     """
     #         print("Use the appropriate Step7 Project to enable the Modbus Server on your Siemens S1200 PLC")
     ModbusWrapperClient.__init__(self, host, port, rate, reset_registers,
                                  disable_topics)
     self.setReadingRegisters(0, 8)
     self.setWritingRegisters(8, 9)