plcopen/plcopen.py
changeset 1339 6adf05c4508d
parent 1338 c1e6c712cc35
child 1346 92efd8fe3120
equal deleted inserted replaced
1338:c1e6c712cc35 1339:6adf05c4508d
    47 VarOrder = ["Local","Temp","Input","Output","InOut","External","Global","Access"]
    47 VarOrder = ["Local","Temp","Input","Output","InOut","External","Global","Access"]
    48 
    48 
    49 """
    49 """
    50 Define which action qualifier must be associated with a duration 
    50 Define which action qualifier must be associated with a duration 
    51 """
    51 """
    52 QualifierList = {"N" : False, "R" : False, "S" : False, "L" : True, "D" : True, 
    52 QualifierList = OrderedDict([("N", False), ("R", False), ("S", False), 
    53     "P" : False, "P0" : False, "P1" : False, "SD" : True, "DS" : True, "SL" : True}
    53     ("L", True), ("D", True), ("P", False), ("P0", False), 
       
    54     ("P1", False), ("SD", True), ("DS", True), ("SL", True)])
    54 
    55 
    55 
    56 
    56 FILTER_ADDRESS_MODEL = "(%%[IQM](?:[XBWDL])?)(%s)((?:\.[0-9]+)*)" 
    57 FILTER_ADDRESS_MODEL = "(%%[IQM](?:[XBWDL])?)(%s)((?:\.[0-9]+)*)" 
    57 
    58 
    58 def update_address(address, address_model, new_leading):
    59 def update_address(address, address_model, new_leading):
   216                                     text += "%dms"%(time_values[3] / 1000)
   217                                     text += "%dms"%(time_values[3] / 1000)
   217                             task.set("interval", text)
   218                             task.set("interval", text)
   218                 
   219                 
   219                 # Update resources pou instance attributes
   220                 # Update resources pou instance attributes
   220                 for pouInstance in ResourceInstancesXpath(resource):
   221                 for pouInstance in ResourceInstancesXpath(resource):
   221                     type_name = pouInstance.get("type")
   222                     type_name = pouInstance.attrib.pop("type")
   222                     if type_name is not None:
   223                     if type_name is not None:
   223                         pouInstance.set("typeName", type_name)
   224                         pouInstance.set("typeName", type_name)
   224             
   225             
   225             # Update transitions condition
   226             # Update transitions condition
   226             for transition_condition in TransitionsConditionXPath(tree):
   227             for transition_condition in TransitionsConditionXPath(tree):
  2146     def setactions(self, actions):
  2147     def setactions(self, actions):
  2147         self.action = []
  2148         self.action = []
  2148         for params in actions:
  2149         for params in actions:
  2149             action = PLCOpenParser.CreateElement("action", "actionBlock")
  2150             action = PLCOpenParser.CreateElement("action", "actionBlock")
  2150             self.appendaction(action)
  2151             self.appendaction(action)
  2151             action.setqualifier(params["qualifier"])
  2152             action.setqualifier(params.qualifier)
  2152             if params["type"] == "reference":
  2153             if params.type == "reference":
  2153                 action.addreference()
  2154                 action.addreference()
  2154                 action.setreferenceName(params["value"])
  2155                 action.setreferenceName(params.value)
  2155             else:
  2156             else:
  2156                 action.addinline()
  2157                 action.addinline()
  2157                 action.setinlineContent(params["value"])
  2158                 action.setinlineContent(params.value)
  2158             if params.has_key("duration"):
  2159             if params.duration != "":
  2159                 action.setduration(params["duration"])
  2160                 action.setduration(params.duration)
  2160             if params.has_key("indicator"):
  2161             if params.indicator != "":
  2161                 action.setindicator(params["indicator"])
  2162                 action.setindicator(params.indicator)
  2162     setattr(cls, "setactions", setactions)
  2163     setattr(cls, "setactions", setactions)
  2163 
  2164 
  2164     def getactions(self):
  2165     def getactions(self):
  2165         actions = []
  2166         actions = []
  2166         for action in self.action:
  2167         for action in self.action: