Skip to content

Commit

Permalink
* Correct missing connection inPLC subsystem, #77
Browse files Browse the repository at this point in the history
  • Loading branch information
MBaranskiEBC committed May 11, 2020
1 parent 3de3df2 commit f82985a
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions pyDMPC/ControlFramework/ControlledSystem.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
import Init
import pyads

class PLCSys:

def __init__(self):
import pyads
self.plc_typ = pyads.PLCTYPE_REAL
self.ads_id = Init.ads_id
self.ads_port = Init.ads_port
self.connect()

def connect(self):
import pyads
self.contr_sys = pyads.Connection(self.ads_id, self.ads_port)
self.contr_sys.open()

def close(self):
self.contr_sys.close()

def read(self, datapoint):
return self.contr_sys.read_by_name(datapoint, self.plc_typ)
val = self.contr_sys.read_by_name(datapoint, self.plc_typ)
print(datapoint + str(val))
return val

def write(self, datapoint, value):
self.contr_sys.write_by_name(datapoint, value, self.plc_typ)
Expand Down

0 comments on commit f82985a

Please sign in to comment.