PLCControler.py
changeset 552 a387f258814a
parent 549 b0d6819119c3
child 555 b6f9d08fd69f
equal deleted inserted replaced
551:ad74e44f55d9 552:a387f258814a
  1296         if project is not None:
  1296         if project is not None:
  1297             blocktypes.extend(project.GetCustomBlockResource())
  1297             blocktypes.extend(project.GetCustomBlockResource())
  1298         return blocktypes
  1298         return blocktypes
  1299 
  1299 
  1300     # Return Data Types checking for recursion
  1300     # Return Data Types checking for recursion
  1301     def GetDataTypes(self, tagname = "", basetypes = True, debug = False):
  1301     def GetDataTypes(self, tagname = "", basetypes = True, only_locatables = False, debug = False):
  1302         if basetypes:
  1302         if basetypes:
  1303             datatypes = self.GetBaseTypes()
  1303             datatypes = self.GetBaseTypes()
  1304         else:
  1304         else:
  1305             datatypes = []
  1305             datatypes = []
  1306         project = self.GetProject(debug)
  1306         project = self.GetProject(debug)
  1307         if project is not None:
  1307         if project is not None:
  1308             name = ""
  1308             name = ""
  1309             words = tagname.split("::")
  1309             words = tagname.split("::")
  1310             if words[0] in ["D"]:
  1310             if words[0] in ["D"]:
  1311                 name = words[1]
  1311                 name = words[1]
  1312             datatypes.extend(project.GetCustomDataTypes(name))
  1312             datatypes.extend(project.GetCustomDataTypes(name, only_locatables))
  1313         return datatypes
  1313         return datatypes
  1314 
  1314 
  1315     # Return Base Type of given possible derived type
  1315     # Return Base Type of given possible derived type
  1316     def GetBaseType(self, type, debug = False):
  1316     def GetBaseType(self, type, debug = False):
  1317         project = self.GetProject(debug)
  1317         project = self.GetProject(debug)
  1343     def IsEndType(self, type):
  1343     def IsEndType(self, type):
  1344         if type is not None:
  1344         if type is not None:
  1345             return not type.startswith("ANY")
  1345             return not type.startswith("ANY")
  1346         return True
  1346         return True
  1347 
  1347 
       
  1348     def IsLocatableType(self, type, debug = False):
       
  1349         project = self.GetProject(debug)
       
  1350         if project is not None:
       
  1351             datatype = project.getdataType(type)
       
  1352             if datatype is not None:
       
  1353                 return project.IsLocatableType(datatype)
       
  1354         return True
       
  1355     
       
  1356     def IsEnumeratedType(self, type, debug = False):
       
  1357         project = self.GetProject(debug)
       
  1358         if project is not None:
       
  1359             datatype = project.getdataType(type)
       
  1360             if datatype is not None:
       
  1361                 basetype_content = datatype.baseType.getcontent()
       
  1362                 return basetype_content["name"] == "enum"
       
  1363         return False
       
  1364 
  1348     def GetDataTypeRange(self, type, debug = False):
  1365     def GetDataTypeRange(self, type, debug = False):
  1349         project = self.GetProject(debug)
  1366         project = self.GetProject(debug)
  1350         if project is not None:
  1367         if project is not None:
  1351             return project.GetDataTypeRange(type)
  1368             return project.GetDataTypeRange(type)
  1352         elif type in DataTypeRange:
  1369         elif type in DataTypeRange:
  1359         if project is not None:
  1376         if project is not None:
  1360             return project.GetSubrangeBaseTypes(exclude)
  1377             return project.GetSubrangeBaseTypes(exclude)
  1361         return []
  1378         return []
  1362     
  1379     
  1363     # Return Enumerated Values
  1380     # Return Enumerated Values
  1364     def GetEnumeratedDataValues(self, debug = False):
  1381     def GetEnumeratedDataValues(self, type = None, debug = False):
  1365         project = self.GetProject(debug)
  1382         project = self.GetProject(debug)
  1366         if project is not None:
  1383         if project is not None:
  1367             return project.GetEnumeratedDataTypeValues()
  1384             return project.GetEnumeratedDataTypeValues(type)
  1368         return []
  1385         return []
  1369 
  1386 
  1370 #-------------------------------------------------------------------------------
  1387 #-------------------------------------------------------------------------------
  1371 #                   Project Element tag name computation functions
  1388 #                   Project Element tag name computation functions
  1372 #-------------------------------------------------------------------------------
  1389 #-------------------------------------------------------------------------------
  1438                     infos["type"] = "Array"
  1455                     infos["type"] = "Array"
  1439                     infos["dimensions"] = []
  1456                     infos["dimensions"] = []
  1440                     for dimension in basetype_content["value"].getdimension():
  1457                     for dimension in basetype_content["value"].getdimension():
  1441                         infos["dimensions"].append((dimension.getlower(), dimension.getupper()))
  1458                         infos["dimensions"].append((dimension.getlower(), dimension.getupper()))
  1442                     base_type = basetype_content["value"].baseType.getcontent()
  1459                     base_type = basetype_content["value"].baseType.getcontent()
  1443                     if base_type["value"] is None or element_type["name"] in ["string", "wstring"]:
  1460                     if base_type["value"] is None or base_type["name"] in ["string", "wstring"]:
  1444                         infos["base_type"] = base_type["name"].upper()
  1461                         infos["base_type"] = base_type["name"].upper()
  1445                     else:
  1462                     else:
  1446                         infos["base_type"] = base_type["value"].getname()
  1463                         infos["base_type"] = base_type["value"].getname()
  1447                 elif basetype_content["name"] == "struct":
  1464                 elif basetype_content["name"] == "struct":
  1448                     infos["type"] = "Structure"
  1465                     infos["type"] = "Structure"