--- a/ProjectController.py Thu Nov 04 12:00:50 2021 +0100
+++ b/ProjectController.py Thu Nov 04 12:02:08 2021 +0100
@@ -797,7 +797,12 @@
IECCodeContent += open(self._getIECgeneratedcodepath(), "r").read()
- with open(self._getIECcodepath(), "w") as plc_file:
+ IECcodepath = self._getIECcodepath() + if not os.path.exists(IECcodepath): + self.LastBuiltIECcodeDigest = None + with open(IECcodepath, "w") as plc_file: plc_file.write(IECCodeContent)
--- a/opc_ua/client.py Thu Nov 04 12:00:50 2021 +0100
+++ b/opc_ua/client.py Thu Nov 04 12:02:08 2021 +0100
@@ -49,12 +49,15 @@
EditorType = OPCUAClientEditor
- self.modeldata = OPCUAClientModel()
+ self.modeldata = OPCUAClientModel(self.Log) filepath = self.GetFileName()
if os.path.isfile(filepath):
self.modeldata.LoadCSV(filepath)
+ self.GetCTRoot().logger.write(msg) --- a/opc_ua/opcua_client_maker.py Thu Nov 04 12:00:50 2021 +0100
+++ b/opc_ua/opcua_client_maker.py Thu Nov 04 12:02:08 2021 +0100
@@ -99,36 +99,9 @@
- v = dict(zip(lstcolnames, value))
- if type(v["IEC"]) != int:
- if len(self.data) == 0:
- iecnums = set(zip(*self.data)[lstcolnames.index("IEC")])
- greatest = max(iecnums)
- holes = set(range(greatest)) - iecnums
- v["IEC"] = min(holes) if holes else greatest+1
- if v["IdType"] not in UA_NODE_ID_types:
- self.log("Unknown IdType\n".format(value))
- for t,n in zip(lstcoltypess, lstcolnames):
- self.log("Variable {} (Id={}) has invalid type\n".format(v["Name"],v["Id"]))
- if len(self.data)>0 and v["Id"] in zip(*self.data)[lstcolnames.index("Id")]:
- self.log("Variable {} (Id={}) already in list\n".format(v["Name"],v["Id"]))
- self.data.append([v[n] for n in lstcolnames])
+ if self.data.append(value): self.Reset(len(self.data))
@@ -201,7 +174,7 @@
nodes = ClientPanel.GetSelectedNodes()
cname = node.get_node_class().name
- dname = node.get_display_name().to_string()
+ dname = node.get_display_name().Text self.log("Node {} ignored (not a variable)".format(dname))
@@ -445,20 +418,57 @@
self.selected_models[direction].ResetData()
+class OPCUAClientList(list): + def __init__(self, log = lambda m:None): + super(OPCUAClientList, self).__init__(self) + def append(self, value): + v = dict(zip(lstcolnames, value)) + if type(v["IEC"]) != int: + iecnums = set(zip(*self)[lstcolnames.index("IEC")]) + greatest = max(iecnums) + holes = set(range(greatest)) - iecnums + v["IEC"] = min(holes) if holes else greatest+1 + if v["IdType"] not in UA_NODE_ID_types: + self.log("Unknown IdType\n".format(value)) + for t,n in zip(lstcoltypess, lstcolnames): + self.log("Variable {} (Id={}) has invalid type\n".format(v["Name"],v["Id"])) + if len(self)>0 and v["Id"] in zip(*self)[lstcolnames.index("Id")]: + self.log("Variable {} (Id={}) already in list\n".format(v["Name"],v["Id"])) + list.append(self, [v[n] for n in lstcolnames]) class OPCUAClientModel(dict):
+ def __init__(self, log = lambda m:None): + super(OPCUAClientModel, self).__init__() for direction in directions:
- self[direction] = list()
+ self[direction] = OPCUAClientList(log) with open(path, 'rb') as csvfile:
reader = csv.reader(csvfile, delimiter=',', quotechar='"')
buf = {direction:[] for direction, _model in self.iteritems()}
+ for direction, model in self.iteritems(): + self[direction][:] = [] - buf[direction].append(row[1:])
- for direction, model in self.iteritems():
- self[direction][:] = buf[direction]
+ self[direction].append(row[1:]) with open(path, 'wb') as csvfile:
@@ -587,7 +597,7 @@
test_sizer.AddGrowableCol(0)
test_sizer.AddGrowableRow(0)
- modeldata = OPCUAClientModel()
+ modeldata = OPCUAClientModel(print) opcuatestpanel = OPCUAClientPanel(test_panel, modeldata, print, lambda:uri)