98 def GetUneditableNames(): |
98 def GetUneditableNames(): |
99 _ = lambda x: x |
99 _ = lambda x: x |
100 return [_("User-defined POUs"), _("Functions"), _("Function Blocks"), |
100 return [_("User-defined POUs"), _("Functions"), _("Function Blocks"), |
101 _("Programs"), _("Data Types"), _("Transitions"), _("Actions"), |
101 _("Programs"), _("Data Types"), _("Transitions"), _("Actions"), |
102 _("Configurations"), _("Resources"), _("Properties")] |
102 _("Configurations"), _("Resources"), _("Properties")] |
|
103 |
|
104 |
103 UNEDITABLE_NAMES = GetUneditableNames() |
105 UNEDITABLE_NAMES = GetUneditableNames() |
104 [USER_DEFINED_POUS, FUNCTIONS, FUNCTION_BLOCKS, PROGRAMS, |
106 [USER_DEFINED_POUS, FUNCTIONS, FUNCTION_BLOCKS, PROGRAMS, |
105 DATA_TYPES, TRANSITIONS, ACTIONS, CONFIGURATIONS, |
107 DATA_TYPES, TRANSITIONS, ACTIONS, CONFIGURATIONS, |
106 RESOURCES, PROPERTIES] = UNEDITABLE_NAMES |
108 RESOURCES, PROPERTIES] = UNEDITABLE_NAMES |
107 |
109 |
133 #------------------------------------------------------------------------------- |
135 #------------------------------------------------------------------------------- |
134 # Helpers functions for translating list of arguments |
136 # Helpers functions for translating list of arguments |
135 # from xslt to valid arguments |
137 # from xslt to valid arguments |
136 #------------------------------------------------------------------------------- |
138 #------------------------------------------------------------------------------- |
137 |
139 |
|
140 |
138 _StringValue = lambda x: x |
141 _StringValue = lambda x: x |
139 _BoolValue = lambda x: x in ["true", "0"] |
142 _BoolValue = lambda x: x in ["true", "0"] |
140 |
143 |
141 |
144 |
142 def _translate_args(translations, args): |
145 def _translate_args(translations, args): |
294 self.TagName = self.Controller.ComputePouTransitionName(args[0][0], args[0][1]) |
297 self.TagName = self.Controller.ComputePouTransitionName(args[0][0], args[0][1]) |
295 |
298 |
296 #------------------------------------------------------------------------------- |
299 #------------------------------------------------------------------------------- |
297 # Helpers object for generating pou block instances list |
300 # Helpers object for generating pou block instances list |
298 #------------------------------------------------------------------------------- |
301 #------------------------------------------------------------------------------- |
|
302 |
299 |
303 |
300 _Point = namedtuple("Point", ["x", "y"]) |
304 _Point = namedtuple("Point", ["x", "y"]) |
301 |
305 |
302 _BlockInstanceInfos = namedtuple("BlockInstanceInfos", |
306 _BlockInstanceInfos = namedtuple("BlockInstanceInfos", |
303 ["type", "id", "x", "y", "width", "height", "specific_values", "inputs", "outputs"]) |
307 ["type", "id", "x", "y", "width", "height", "specific_values", "inputs", "outputs"]) |
437 def AddAction(self, context, *args): |
441 def AddAction(self, context, *args): |
438 if len(self.SpecificValues) == 0: |
442 if len(self.SpecificValues) == 0: |
439 self.SpecificValues.append([[]]) |
443 self.SpecificValues.append([[]]) |
440 translated_args = _translate_args([_StringValue] * 5, args) |
444 translated_args = _translate_args([_StringValue] * 5, args) |
441 self.SpecificValues[0][0].append(_ActionInfos(*translated_args)) |
445 self.SpecificValues[0][0].append(_ActionInfos(*translated_args)) |
|
446 |
442 |
447 |
443 pou_block_instances_xslt = etree.parse( |
448 pou_block_instances_xslt = etree.parse( |
444 os.path.join(ScriptDirectory, "plcopen", "pou_block_instances.xslt")) |
449 os.path.join(ScriptDirectory, "plcopen", "pou_block_instances.xslt")) |
445 |
450 |
446 #------------------------------------------------------------------------------- |
451 #------------------------------------------------------------------------------- |