21 # You should have received a copy of the GNU General Public License |
21 # You should have received a copy of the GNU General Public License |
22 # along with this program; if not, write to the Free Software |
22 # along with this program; if not, write to the Free Software |
23 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
23 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
24 |
24 |
25 |
25 |
26 |
|
27 |
|
28 import re |
26 import re |
29 from builtins import str as text |
|
30 |
27 |
31 import wx |
28 import wx |
32 import wx.grid |
29 import wx.grid |
33 import wx.lib.buttons |
30 import wx.lib.buttons |
34 from six import string_types |
|
35 from six.moves import xrange |
|
36 |
|
37 |
31 |
38 from plcopen.structures import LOCATIONDATATYPES, TestIdentifier, IEC_KEYWORDS, DefaultType |
32 from plcopen.structures import LOCATIONDATATYPES, TestIdentifier, IEC_KEYWORDS, DefaultType |
39 from plcopen.VariableInfoCollector import _VariableInfos |
33 from plcopen.VariableInfoCollector import _VariableInfos |
40 from graphics.GraphicCommons import REFRESH_HIGHLIGHT_PERIOD, ERROR_HIGHLIGHT |
34 from graphics.GraphicCommons import REFRESH_HIGHLIGHT_PERIOD, ERROR_HIGHLIGHT |
41 from dialogs.ArrayTypeDialog import ArrayTypeDialog |
35 from dialogs.ArrayTypeDialog import ArrayTypeDialog |
142 colname = "InitialValue" |
136 colname = "InitialValue" |
143 value = getattr(self.data[row], colname, "") |
137 value = getattr(self.data[row], colname, "") |
144 if colname == "Type" and isinstance(value, tuple): |
138 if colname == "Type" and isinstance(value, tuple): |
145 if value[0] == "array": |
139 if value[0] == "array": |
146 return "ARRAY [%s] OF %s" % (",".join(map("..".join, value[2])), value[1]) |
140 return "ARRAY [%s] OF %s" % (",".join(map("..".join, value[2])), value[1]) |
147 if not isinstance(value, string_types): |
141 if not isinstance(value, str): |
148 value = str(value) |
142 value = str(value) |
149 if colname in ["Class", "Option"]: |
143 if colname in ["Class", "Option"]: |
150 return _(value) |
144 return _(value) |
151 return value |
145 return value |
152 |
146 |
607 if row_content.Location != "" and LOCATION_MODEL_SET.match(row_content.Location): |
601 if row_content.Location != "" and LOCATION_MODEL_SET.match(row_content.Location): |
608 old_location = row_content.Location |
602 old_location = row_content.Location |
609 model = re.compile(r"%[IQM][XBWLD]?(.*\.|)") |
603 model = re.compile(r"%[IQM][XBWLD]?(.*\.|)") |
610 prefix = model.match(old_location).group(0) |
604 prefix = model.match(old_location).group(0) |
611 addr = int(re.split(model, old_location)[-1]) + 1 |
605 addr = int(re.split(model, old_location)[-1]) + 1 |
612 row_content.Location = prefix + text(addr) |
606 row_content.Location = prefix + str(addr) |
613 |
607 |
614 if not row_content.Class: |
608 if not row_content.Class: |
615 row_content.Class = self.DefaultTypes.get(self.Filter, self.Filter) |
609 row_content.Class = self.DefaultTypes.get(self.Filter, self.Filter) |
616 |
610 |
617 if self.Filter == "All" and len(self.Values) > 0: |
611 if self.Filter == "All" and len(self.Values) > 0: |