PLCControler.py
changeset 1096 c9ace6a881c9
parent 901 ab43f3e40b9d
child 1122 84de51ab40d2
equal deleted inserted replaced
1095:a73fde048749 1096:c9ace6a881c9
  1490     def GetConfNodeGlobalInstances(self):
  1490     def GetConfNodeGlobalInstances(self):
  1491         return []
  1491         return []
  1492 
  1492 
  1493     def GetConfigurationExtraVariables(self):
  1493     def GetConfigurationExtraVariables(self):
  1494         global_vars = []
  1494         global_vars = []
  1495         for var_name, var_type in self.GetConfNodeGlobalInstances():
  1495         for var_name, var_type, var_initial in self.GetConfNodeGlobalInstances():
  1496             tempvar = plcopen.varListPlain_variable()
  1496             tempvar = plcopen.varListPlain_variable()
  1497             tempvar.setname(var_name)
  1497             tempvar.setname(var_name)
  1498             
  1498             
  1499             tempvartype = plcopen.dataType()
  1499             tempvartype = plcopen.dataType()
  1500             if var_type in self.GetBaseTypes():
  1500             if var_type in self.GetBaseTypes():
  1501                 if var_type == "STRING":
  1501                 if var_type == "STRING":
  1502                     var_type.setcontent({"name" : "string", "value" : plcopen.elementaryTypes_string()})
  1502                     tempvartype.setcontent({"name" : "string", "value" : plcopen.elementaryTypes_string()})
  1503                 elif var_type == "WSTRING":
  1503                 elif var_type == "WSTRING":
  1504                     var_type.setcontent({"name" : "wstring", "value" : plcopen.elementaryTypes_wstring()})
  1504                     tempvartype.setcontent({"name" : "wstring", "value" : plcopen.elementaryTypes_wstring()})
  1505                 else:
  1505                 else:
  1506                     var_type.setcontent({"name" : var_type, "value" : None})
  1506                     tempvartype.setcontent({"name" : var_type, "value" : None})
  1507             else:
  1507             else:
  1508                 tempderivedtype = plcopen.derivedTypes_derived()
  1508                 tempderivedtype = plcopen.derivedTypes_derived()
  1509                 tempderivedtype.setname(var_type)
  1509                 tempderivedtype.setname(var_type)
  1510                 tempvartype.setcontent({"name" : "derived", "value" : tempderivedtype})
  1510                 tempvartype.setcontent({"name" : "derived", "value" : tempderivedtype})
  1511             tempvar.settype(tempvartype)
  1511             tempvar.settype(tempvartype)
       
  1512             
       
  1513             if var_initial != "":
       
  1514                 value = plcopen.value()
       
  1515                 value.setvalue(var_initial)
       
  1516                 tempvar.setinitialValue(value)
  1512             
  1517             
  1513             global_vars.append(tempvar)
  1518             global_vars.append(tempvar)
  1514         return global_vars
  1519         return global_vars
  1515 
  1520 
  1516     # Function that returns the block definition associated to the block type given
  1521     # Function that returns the block definition associated to the block type given