PLCControler.py
changeset 1339 6adf05c4508d
parent 1338 c1e6c712cc35
child 1341 0923e602c603
equal deleted inserted replaced
1338:c1e6c712cc35 1339:6adf05c4508d
   417     ["name", "negated", "edge", "position", "links"])
   417     ["name", "negated", "edge", "position", "links"])
   418 
   418 
   419 _ConnectionLinkInfos = namedtuple("ConnectionLinkInfos",
   419 _ConnectionLinkInfos = namedtuple("ConnectionLinkInfos",
   420     ["refLocalId", "formalParameter", "points"])
   420     ["refLocalId", "formalParameter", "points"])
   421 
   421 
   422 _ActionInfos = namedtuple("ActionInfos",
   422 class _ActionInfos:
   423     ["qualifier", "type", "value", "duration", "indicator"])
   423     __slots__ = ["qualifier", "type", "value", "duration", "indicator"]
       
   424     def __init__(self, *args):
       
   425         for attr, value in zip(self.__slots__, args):
       
   426             setattr(self, attr, value if value is not None else "")
       
   427     def copy(self):
       
   428         return _ActionInfos(*[getattr(self, attr) for attr in self.__slots__])
   424 
   429 
   425 def _translate_args(translations, args):
   430 def _translate_args(translations, args):
   426     return [translate(arg[0]) if len(arg) > 0 else None 
   431     return [translate(arg[0]) if len(arg) > 0 else None 
   427             for translate, arg in
   432             for translate, arg in
   428             zip(translations, args)]
   433             zip(translations, args)]
   488     
   493     
   489     def AddAction(self, context, *args):
   494     def AddAction(self, context, *args):
   490         if len(self.SpecificValues) == 0:
   495         if len(self.SpecificValues) == 0:
   491             self.SpecificValues.append([[]])
   496             self.SpecificValues.append([[]])
   492         translated_args = _translate_args([str] * 5, args)
   497         translated_args = _translate_args([str] * 5, args)
   493         if translated_args[0] is None:
       
   494             translated_args[0] = ""
       
   495         self.SpecificValues[0][0].append(_ActionInfos(*translated_args))
   498         self.SpecificValues[0][0].append(_ActionInfos(*translated_args))
   496     
   499     
   497 pou_block_instances_xslt = etree.parse(
   500 pou_block_instances_xslt = etree.parse(
   498     os.path.join(ScriptDirectory, "plcopen", "pou_block_instances.xslt"))
   501     os.path.join(ScriptDirectory, "plcopen", "pou_block_instances.xslt"))
   499 
   502