Untitled

mail@pastecode.io avatar
unknown
python
2 years ago
845 B
6
Indexable
Never
import time
import pyads

CLIENT_NETID = "192.168.178.151.1.1"
CLIENT_IP = "192.168.178.151"
TARGET_IP = "192.168.199.221"
TARGET_USERNAME = "Administrator"
TARGET_PASSWORD = "1"

#ADD ROUTE ONLY ONCE
#pyads.add_route_to_plc(CLIENT_NETID, CLIENT_IP, TARGET_IP, TARGET_USERNAME, TARGET_PASSWORD, route_name="Test2")

#CHANGE PORT ACCORDINGLY (TC2 - 801 | TC3 - 851)
plc = pyads.Connection(pyads.ads.adsGetNetIdForPLC(TARGET_IP), 851, TARGET_IP)

plc.__dict__

plc.open()

time.sleep(5)
i = plc.read_by_name("MAIN.i")
print(i)

time.sleep(10)
i = plc.read_by_name("MAIN.i")
print(i)

time.sleep(15)
i = plc.read_by_name("MAIN.i")
print(i)

time.sleep(20)
i = plc.read_by_name("MAIN.i")
print(i)

time.sleep(25)
i = plc.read_by_name("MAIN.i")
print(i)

time.sleep(30)
i = plc.read_by_name("MAIN.i")
print(i)