39 lines
786 B
Python
39 lines
786 B
Python
|
|
'''
|
||
|
|
Created on 05.12.2013
|
||
|
|
|
||
|
|
@author: Philipp Rauch
|
||
|
|
'''
|
||
|
|
from pymodbus.client.sync import ModbusTcpClient
|
||
|
|
|
||
|
|
def setup(conf):
|
||
|
|
PACS = []
|
||
|
|
|
||
|
|
### INITIALIZE ###
|
||
|
|
PACS.append(ModbusTcpClient('10.2.6.5'))
|
||
|
|
PACS.append(ModbusTcpClient('10.2.6.6'))
|
||
|
|
PACS.append(ModbusTcpClient('10.2.6.7'))
|
||
|
|
PACS.append(ModbusTcpClient('10.2.6.8'))
|
||
|
|
|
||
|
|
### CONNECT ###
|
||
|
|
for PAC in PACS:
|
||
|
|
PAC.connect()
|
||
|
|
|
||
|
|
return PACS
|
||
|
|
|
||
|
|
|
||
|
|
def loop(PACS, item):
|
||
|
|
# PAC[0].write_coil(213, 100,2)
|
||
|
|
# result = PAC[0].read_coils(213,1,unit=2)
|
||
|
|
#
|
||
|
|
# ans = PAC[0].write_registers(213,(1,0),unit=2)
|
||
|
|
# print "Antwort: %s" % ans
|
||
|
|
|
||
|
|
res = PACS[0].read_holding_registers(213,4,unit=2)
|
||
|
|
print "Werte: %s" % res.registers
|
||
|
|
|
||
|
|
|
||
|
|
def close(PACS):
|
||
|
|
### CLOSE ###
|
||
|
|
for PAC in PACS:
|
||
|
|
PAC.close()
|