--- a/PLCControler.py Mon Mar 27 10:19:14 2023 +0200
+++ b/PLCControler.py Fri Oct 28 12:39:15 2022 +0800
@@ -24,8 +24,8 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-from __future__ import absolute_import
-from __future__ import division
+
+
from copy import deepcopy
import os
import re
@@ -74,7 +74,7 @@
self.MinIndex = 0
self.MaxIndex = 0
# Initialising buffer with currentstate at the first place
- for i in xrange(UNDO_BUFFER_LENGTH):
+ for i in range(UNDO_BUFFER_LENGTH):
if i == 0:
self.Buffer.append(currentstate)
else:
@@ -1184,7 +1184,7 @@
for _sectioname, blocktype in self.TotalTypesDict.get(typename, []):
if inputs is not None and inputs != "undefined":
block_inputs = tuple([var_type for _name, var_type, _modifier in blocktype["inputs"]])
- if reduce(lambda x, y: x and y, map(lambda x: x[0] == "ANY" or self.IsOfType(*x), zip(inputs, block_inputs)), True):
+ if reduce(lambda x, y: x and y, [x[0] == "ANY" or self.IsOfType(*x) for x in zip(inputs, block_inputs)], True):
return blocktype
else:
if result_blocktype:
@@ -1247,7 +1247,7 @@
if project is not None and words[0] in ["P", "T", "A"]:
name = words[1]
blocktypes = []
- for blocks in self.TotalTypesDict.itervalues():
+ for blocks in self.TotalTypesDict.values():
for _sectioname, block in blocks:
if block["type"] == "functionBlock":
blocktypes.append(block["name"])
@@ -1302,7 +1302,7 @@
result = project.getpou(typename)
if result is not None:
return result
- for standardlibrary in StdBlckLibs.values():
+ for standardlibrary in list(StdBlckLibs.values()):
result = standardlibrary.getpou(typename)
if result is not None:
return result
@@ -1455,7 +1455,7 @@
# Return Subrange types
def GetSubrangeBaseTypes(self, exclude, debug=False):
- subrange_basetypes = DataTypeRange.keys()
+ subrange_basetypes = list(DataTypeRange.keys())
project = self.GetProject(debug)
if project is not None:
subrange_basetypes.extend(
@@ -1970,9 +1970,9 @@
new_pos[0] -= width // 2
new_pos[1] -= height // 2
else:
- new_pos = map(lambda x: x + 30, new_pos)
+ new_pos = [x + 30 for x in new_pos]
if scaling[0] != 0 and scaling[1] != 0:
- min_pos = map(lambda x: 30 / x, scaling)
+ min_pos = [30 / x for x in scaling]
minx = round(min_pos[0])
if int(min_pos[0]) == round(min_pos[0]):
minx += 1
@@ -2118,7 +2118,7 @@
self.ChangeEditedElementPouVar(tagname, old_type, old_name, new_type, new_name)
elif new_name != old_name:
self.ChangeEditedElementPouVar(tagname, old_type, old_name, new_type, new_name)
- for param, value in infos.items():
+ for param, value in list(infos.items()):
if param == "name":
if value != "":
block.setinstanceName(value)
@@ -2179,7 +2179,7 @@
variable = element.getinstance(id)
if variable is None:
return
- for param, value in infos.items():
+ for param, value in list(infos.items()):
if param == "name":
variable.setexpression(value)
elif param == "executionOrder" and variable.getexecutionOrderId() != value:
@@ -2232,7 +2232,7 @@
connection = element.getinstance(id)
if connection is None:
return
- for param, value in infos.items():
+ for param, value in list(infos.items()):
if param == "name":
connection.setname(value)
elif param == "height":
@@ -2264,7 +2264,7 @@
element = self.GetEditedElement(tagname)
if element is not None:
comment = element.getinstance(id)
- for param, value in infos.items():
+ for param, value in list(infos.items()):
if param == "content":
comment.setcontentText(value)
elif param == "height":
@@ -2291,7 +2291,7 @@
powerrail = element.getinstance(id)
if powerrail is None:
return
- for param, value in infos.items():
+ for param, value in list(infos.items()):
if param == "height":
powerrail.setheight(value)
elif param == "width":
@@ -2330,7 +2330,7 @@
contact = element.getinstance(id)
if contact is None:
return
- for param, value in infos.items():
+ for param, value in list(infos.items()):
if param == "name":
contact.setvariable(value)
elif param == "type":
@@ -2373,7 +2373,7 @@
coil = element.getinstance(id)
if coil is None:
return
- for param, value in infos.items():
+ for param, value in list(infos.items()):
if param == "name":
coil.setvariable(value)
elif param == "type":
@@ -2419,7 +2419,7 @@
step = element.getinstance(id)
if step is None:
return
- for param, value in infos.items():
+ for param, value in list(infos.items()):
if param == "name":
step.setname(value)
elif param == "initial":
@@ -2469,7 +2469,7 @@
transition = element.getinstance(id)
if transition is None:
return
- for param, value in infos.items():
+ for param, value in list(infos.items()):
if param == "type" and value != "connection":
transition.setconditionContent(value, infos["condition"])
elif param == "height":
@@ -2529,7 +2529,7 @@
divergence = element.getinstance(id)
if divergence is None:
return
- for param, value in infos.items():
+ for param, value in list(infos.items()):
if param == "height":
divergence.setheight(value)
elif param == "width":
@@ -2580,7 +2580,7 @@
jump = element.getinstance(id)
if jump is None:
return
- for param, value in infos.items():
+ for param, value in list(infos.items()):
if param == "target":
jump.settargetName(value)
elif param == "height":
@@ -2610,7 +2610,7 @@
actionBlock = element.getinstance(id)
if actionBlock is None:
return
- for param, value in infos.items():
+ for param, value in list(infos.items()):
if param == "actions":
actionBlock.setactions(value)
elif param == "height":