epmwebapi 6.50.38__tar.gz → 7.50.11__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. {epmwebapi-6.50.38 → epmwebapi-7.50.11}/PKG-INFO +1 -1
  2. epmwebapi-7.50.11/epmwebapi/_version.py +1 -0
  3. {epmwebapi-6.50.38 → epmwebapi-7.50.11}/epmwebapi/basicvariable.py +13 -0
  4. {epmwebapi-6.50.38 → epmwebapi-7.50.11}/epmwebapi/customtypedefinition.py +14 -0
  5. {epmwebapi-6.50.38 → epmwebapi-7.50.11}/epmwebapi/dataobjectattributes.py +2 -0
  6. {epmwebapi-6.50.38 → epmwebapi-7.50.11}/epmwebapi/epmconnection.py +197 -28
  7. {epmwebapi-6.50.38 → epmwebapi-7.50.11}/epmwebapi/epmdataobject.py +2 -0
  8. {epmwebapi-6.50.38 → epmwebapi-7.50.11}/epmwebapi/epmmodelobject.py +32 -41
  9. {epmwebapi-6.50.38 → epmwebapi-7.50.11}/epmwebapi.egg-info/PKG-INFO +1 -1
  10. {epmwebapi-6.50.38 → epmwebapi-7.50.11}/pyproject.toml +1 -1
  11. {epmwebapi-6.50.38 → epmwebapi-7.50.11}/setup.py +1 -1
  12. epmwebapi-6.50.38/epmwebapi/_version.py +0 -1
  13. {epmwebapi-6.50.38 → epmwebapi-7.50.11}/LICENSE.txt +0 -0
  14. /epmwebapi-6.50.38/Readme.md → /epmwebapi-7.50.11/README.md +0 -0
  15. {epmwebapi-6.50.38 → epmwebapi-7.50.11}/epmwebapi/__init__.py +0 -0
  16. {epmwebapi-6.50.38 → epmwebapi-7.50.11}/epmwebapi/advancedevent.py +0 -0
  17. {epmwebapi-6.50.38 → epmwebapi-7.50.11}/epmwebapi/aggregatedetails.py +0 -0
  18. {epmwebapi-6.50.38 → epmwebapi-7.50.11}/epmwebapi/annotationvaluejson.py +0 -0
  19. {epmwebapi-6.50.38 → epmwebapi-7.50.11}/epmwebapi/attributeoperand.py +0 -0
  20. {epmwebapi-6.50.38 → epmwebapi-7.50.11}/epmwebapi/authorizationservice.py +0 -0
  21. {epmwebapi-6.50.38 → epmwebapi-7.50.11}/epmwebapi/autostarttimer.py +0 -0
  22. {epmwebapi-6.50.38 → epmwebapi-7.50.11}/epmwebapi/basicvariablepropertymask.py +0 -0
  23. {epmwebapi-6.50.38 → epmwebapi-7.50.11}/epmwebapi/browsedirection.py +0 -0
  24. {epmwebapi-6.50.38 → epmwebapi-7.50.11}/epmwebapi/browseitemmodeljson.py +0 -0
  25. {epmwebapi-6.50.38 → epmwebapi-7.50.11}/epmwebapi/browsemodeljson.py +0 -0
  26. {epmwebapi-6.50.38 → epmwebapi-7.50.11}/epmwebapi/browseresultitemmodeljson.py +0 -0
  27. {epmwebapi-6.50.38 → epmwebapi-7.50.11}/epmwebapi/browseresultmodeljson.py +0 -0
  28. {epmwebapi-6.50.38 → epmwebapi-7.50.11}/epmwebapi/dataobjectsfilter.py +0 -0
  29. {epmwebapi-6.50.38 → epmwebapi-7.50.11}/epmwebapi/datasetconfig.py +0 -0
  30. {epmwebapi-6.50.38 → epmwebapi-7.50.11}/epmwebapi/datasetpen.py +0 -0
  31. {epmwebapi-6.50.38 → epmwebapi-7.50.11}/epmwebapi/datavaluejson.py +0 -0
  32. {epmwebapi-6.50.38 → epmwebapi-7.50.11}/epmwebapi/diagnosticmodeljson.py +0 -0
  33. {epmwebapi-6.50.38 → epmwebapi-7.50.11}/epmwebapi/dll_references/Elipse.Epm.AddressSpaceModel.dll +0 -0
  34. {epmwebapi-6.50.38 → epmwebapi-7.50.11}/epmwebapi/dll_references/ElipseLoggerInterface.dll +0 -0
  35. {epmwebapi-6.50.38 → epmwebapi-7.50.11}/epmwebapi/dll_references/EpmData.dll +0 -0
  36. {epmwebapi-6.50.38 → epmwebapi-7.50.11}/epmwebapi/dll_references/Microsoft.Extensions.Logging.Abstractions.dll +0 -0
  37. {epmwebapi-6.50.38 → epmwebapi-7.50.11}/epmwebapi/domainfilter.py +0 -0
  38. {epmwebapi-6.50.38 → epmwebapi-7.50.11}/epmwebapi/downloadtype.py +0 -0
  39. {epmwebapi-6.50.38 → epmwebapi-7.50.11}/epmwebapi/elementoperand.py +0 -0
  40. {epmwebapi-6.50.38 → epmwebapi-7.50.11}/epmwebapi/epmconnectioncontext.py +0 -0
  41. {epmwebapi-6.50.38 → epmwebapi-7.50.11}/epmwebapi/epmnodeids.py +0 -0
  42. {epmwebapi-6.50.38 → epmwebapi-7.50.11}/epmwebapi/epmobject.py +0 -0
  43. {epmwebapi-6.50.38 → epmwebapi-7.50.11}/epmwebapi/epmproperty.py +0 -0
  44. {epmwebapi-6.50.38 → epmwebapi-7.50.11}/epmwebapi/epmsession.py +0 -0
  45. {epmwebapi-6.50.38 → epmwebapi-7.50.11}/epmwebapi/epmutils.py +0 -0
  46. {epmwebapi-6.50.38 → epmwebapi-7.50.11}/epmwebapi/epmvariable.py +0 -0
  47. {epmwebapi-6.50.38 → epmwebapi-7.50.11}/epmwebapi/epmwebapi.py +0 -0
  48. {epmwebapi-6.50.38 → epmwebapi-7.50.11}/epmwebapi/eventfiltermodel.py +0 -0
  49. {epmwebapi-6.50.38 → epmwebapi-7.50.11}/epmwebapi/exporttype.py +0 -0
  50. {epmwebapi-6.50.38 → epmwebapi-7.50.11}/epmwebapi/filtermodel.py +0 -0
  51. {epmwebapi-6.50.38 → epmwebapi-7.50.11}/epmwebapi/filteroperand.py +0 -0
  52. {epmwebapi-6.50.38 → epmwebapi-7.50.11}/epmwebapi/folder.py +0 -0
  53. {epmwebapi-6.50.38 → epmwebapi-7.50.11}/epmwebapi/historyeventmodeljson.py +0 -0
  54. {epmwebapi-6.50.38 → epmwebapi-7.50.11}/epmwebapi/historyprocessedmodeljson.py +0 -0
  55. {epmwebapi-6.50.38 → epmwebapi-7.50.11}/epmwebapi/historyrawmodeljson.py +0 -0
  56. {epmwebapi-6.50.38 → epmwebapi-7.50.11}/epmwebapi/historyresultitemmodeljson.py +0 -0
  57. {epmwebapi-6.50.38 → epmwebapi-7.50.11}/epmwebapi/historyresultmodeljson.py +0 -0
  58. {epmwebapi-6.50.38 → epmwebapi-7.50.11}/epmwebapi/historyupdatedataitemmodeljson.py +0 -0
  59. {epmwebapi-6.50.38 → epmwebapi-7.50.11}/epmwebapi/historyupdatedatamodeljson.py +0 -0
  60. {epmwebapi-6.50.38 → epmwebapi-7.50.11}/epmwebapi/historyupdateresultmodeljson.py +0 -0
  61. {epmwebapi-6.50.38 → epmwebapi-7.50.11}/epmwebapi/historyupdatetype.py +0 -0
  62. {epmwebapi-6.50.38 → epmwebapi-7.50.11}/epmwebapi/itempathandcontinuationpointjson.py +0 -0
  63. {epmwebapi-6.50.38 → epmwebapi-7.50.11}/epmwebapi/itempathjson.py +0 -0
  64. {epmwebapi-6.50.38 → epmwebapi-7.50.11}/epmwebapi/literaloperand.py +0 -0
  65. {epmwebapi-6.50.38 → epmwebapi-7.50.11}/epmwebapi/mimetype.py +0 -0
  66. {epmwebapi-6.50.38 → epmwebapi-7.50.11}/epmwebapi/nodeattributes.py +0 -0
  67. {epmwebapi-6.50.38 → epmwebapi-7.50.11}/epmwebapi/nodeclassmask.py +0 -0
  68. {epmwebapi-6.50.38 → epmwebapi-7.50.11}/epmwebapi/numpyextras.py +0 -0
  69. {epmwebapi-6.50.38 → epmwebapi-7.50.11}/epmwebapi/performupdatetype.py +0 -0
  70. {epmwebapi-6.50.38 → epmwebapi-7.50.11}/epmwebapi/portalresources.py +0 -0
  71. {epmwebapi-6.50.38 → epmwebapi-7.50.11}/epmwebapi/processorresources.py +0 -0
  72. {epmwebapi-6.50.38 → epmwebapi-7.50.11}/epmwebapi/queryfiltercontent.py +0 -0
  73. {epmwebapi-6.50.38 → epmwebapi-7.50.11}/epmwebapi/queryfilterelement.py +0 -0
  74. {epmwebapi-6.50.38 → epmwebapi-7.50.11}/epmwebapi/querymodelfilterJSON.py +0 -0
  75. {epmwebapi-6.50.38 → epmwebapi-7.50.11}/epmwebapi/querymodeljson.py +0 -0
  76. {epmwebapi-6.50.38 → epmwebapi-7.50.11}/epmwebapi/queryperiod.py +0 -0
  77. {epmwebapi-6.50.38 → epmwebapi-7.50.11}/epmwebapi/queryresultitemmodeljson.py +0 -0
  78. {epmwebapi-6.50.38 → epmwebapi-7.50.11}/epmwebapi/queryresultmask.py +0 -0
  79. {epmwebapi-6.50.38 → epmwebapi-7.50.11}/epmwebapi/queryresultmodeljson.py +0 -0
  80. {epmwebapi-6.50.38 → epmwebapi-7.50.11}/epmwebapi/readitemmodeljson.py +0 -0
  81. {epmwebapi-6.50.38 → epmwebapi-7.50.11}/epmwebapi/readmodeljson.py +0 -0
  82. {epmwebapi-6.50.38 → epmwebapi-7.50.11}/epmwebapi/readresultitemmodeljson.py +0 -0
  83. {epmwebapi-6.50.38 → epmwebapi-7.50.11}/epmwebapi/readresultmodeljson.py +0 -0
  84. {epmwebapi-6.50.38 → epmwebapi-7.50.11}/epmwebapi/report.py +0 -0
  85. {epmwebapi-6.50.38 → epmwebapi-7.50.11}/epmwebapi/resource.py +0 -0
  86. {epmwebapi-6.50.38 → epmwebapi-7.50.11}/epmwebapi/resourcesmanager.py +0 -0
  87. {epmwebapi-6.50.38 → epmwebapi-7.50.11}/epmwebapi/simpleattributeoperand.py +0 -0
  88. {epmwebapi-6.50.38 → epmwebapi-7.50.11}/epmwebapi/statuscodes.py +0 -0
  89. {epmwebapi-6.50.38 → epmwebapi-7.50.11}/epmwebapi/typeevent.py +0 -0
  90. {epmwebapi-6.50.38 → epmwebapi-7.50.11}/epmwebapi/writeitemmodeljson.py +0 -0
  91. {epmwebapi-6.50.38 → epmwebapi-7.50.11}/epmwebapi/writemodeljson.py +0 -0
  92. {epmwebapi-6.50.38 → epmwebapi-7.50.11}/epmwebapi.egg-info/SOURCES.txt +0 -0
  93. {epmwebapi-6.50.38 → epmwebapi-7.50.11}/epmwebapi.egg-info/dependency_links.txt +0 -0
  94. {epmwebapi-6.50.38 → epmwebapi-7.50.11}/epmwebapi.egg-info/requires.txt +0 -0
  95. {epmwebapi-6.50.38 → epmwebapi-7.50.11}/epmwebapi.egg-info/top_level.txt +0 -0
  96. {epmwebapi-6.50.38 → epmwebapi-7.50.11}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: epmwebapi
3
- Version: 6.50.38
3
+ Version: 7.50.11
4
4
  Home-page: https://github.com/elipsesoftware/epmwebapi
5
5
  Author: Elipse Software Ltda
6
6
  License-Expression: GPL-3.0-only
@@ -0,0 +1 @@
1
+ __version__ = '7.50.11'
@@ -96,6 +96,7 @@ class BasicVariable(EpmDataObject):
96
96
  self._storeMillisecondsEnabled = storeMillisecondsEnabled
97
97
  self._storageSet = storageSet
98
98
  self._active = active
99
+ self._source = None
99
100
 
100
101
  @property
101
102
  def name(self) -> str:
@@ -140,6 +141,16 @@ class BasicVariable(EpmDataObject):
140
141
  self._tagType = value.value
141
142
  self._changeMask = self._changeMask | BasicVariablePropertyMask.TagType.value
142
143
 
144
+ @property
145
+ def source(self) -> str:
146
+ """
147
+ Gets the source path of this Basic Variable.
148
+
149
+ :return: A `str` representing the source path of this Basic Variable.
150
+ :rtype: str
151
+ """
152
+ return self._source
153
+
143
154
  @property
144
155
  def realTimeEnabled(self) -> bool:
145
156
  """
@@ -405,6 +416,8 @@ class BasicVariable(EpmDataObject):
405
416
  self._active = value
406
417
  elif attributeId == DataObjectAttributes.TagType:
407
418
  self._tagType = value
419
+ elif attributeId == DataObjectAttributes.Source:
420
+ self._source = value
408
421
 
409
422
  #Public Methods
410
423
 
@@ -18,6 +18,20 @@ class SimpleProperty:
18
18
  def initialValue(self):
19
19
  return self._initialValue
20
20
 
21
+ class ExpressionProperty:
22
+
23
+ def __init__(self, name, expression = None):
24
+ self._name = name
25
+ self._expression = expression
26
+
27
+ @property
28
+ def name(self):
29
+ return self._name
30
+
31
+ @property
32
+ def expression(self):
33
+ return self._expression
34
+
21
35
 
22
36
  class ObjectProperty:
23
37
 
@@ -25,5 +25,7 @@ class DataObjectAttributes(IntFlag):
25
25
 
26
26
  TagType = 256
27
27
 
28
+ Source = 512
29
+
28
30
  All = 65535
29
31
 
@@ -408,7 +408,14 @@ class EpmConnection(object):
408
408
 
409
409
  url = self._webApi + '/epm/v1/BV'
410
410
 
411
- jsonRequest = {'Items': names}
411
+ escapedNames = []
412
+ if type(names) is str:
413
+ escapedNames.append(self._escapeOpcUaBrowseName(names))
414
+ else:
415
+ for name in names:
416
+ escapedNames.append(self._escapeOpcUaBrowseName(name))
417
+
418
+ jsonRequest = {'Items': escapedNames}
412
419
 
413
420
  session = self._authorizationService.getEpmSession()
414
421
  response = session.delete(url, json=jsonRequest, verify=False)
@@ -1331,13 +1338,15 @@ class EpmConnection(object):
1331
1338
 
1332
1339
  properties = collections.OrderedDict()
1333
1340
 
1334
- from .customtypedefinition import AliasProperty, ObjectProperty, SimpleProperty
1341
+ from .customtypedefinition import AliasProperty, ObjectProperty, SimpleProperty, ExpressionProperty
1335
1342
  for dic in json_response['items']:
1336
1343
  if dic['type'] == "AliasProperty":
1337
1344
  if 'source' in dic:
1338
1345
  properties[dic['name']] = AliasProperty(dic['name'], dic['source'])
1339
1346
  else:
1340
1347
  properties[dic['name']] = AliasProperty(dic['name'], '')
1348
+ elif dic['type'] == "ExpressionProperty":
1349
+ properties[dic['name']] = ExpressionProperty(dic['name'], dic['expression'])
1341
1350
  elif dic['type'] == "Property":
1342
1351
  properties[dic['name']] = SimpleProperty(dic['name'])
1343
1352
  else:
@@ -1346,6 +1355,56 @@ class EpmConnection(object):
1346
1355
  return properties
1347
1356
 
1348
1357
 
1358
+ def getDataModelObjectPropertiesV2(self, objectPath:str) -> OrderedDict:
1359
+ """
1360
+ Returns all object properties from specific address space paths inside an **Elipse Data Model** folder.
1361
+
1362
+ Uses a query parameter instead of a path segment to safely handle object names with special characters.
1363
+
1364
+ :param objectPath: Path to start after the **Elipse Data Model** node.
1365
+ :type objectPath: str
1366
+ :return: An Ordered Dictionary with all properties from the target object.
1367
+ :rtype: collections.OrderedDict[property]
1368
+ :raises InvalidObjectNameException: Object not found.
1369
+ """
1370
+ from urllib.parse import urlencode
1371
+ url = self._webApi + '/epm/v1/datamodel/properties?' + urlencode({'path': self._escapeOpcUaPath(objectPath)})
1372
+
1373
+ session = self._authorizationService.getEpmSession()
1374
+ response = session.get(url, verify=False)
1375
+
1376
+ if response.status_code == 200:
1377
+ responseCode = response.json()['diagnostic']['code']
1378
+ if responseCode != 0:
1379
+ if responseCode == 2154758144:
1380
+ raise InvalidObjectNameException('Object not found')
1381
+ else:
1382
+ raise Exception(response.json()['diagnostic']['message'])
1383
+ else:
1384
+ raise Exception("getDataModelObjectPropertiesV2 call error + '" + str(response.status_code) + "'. Reason: " +
1385
+ response.reason + ". Text: " + response.text)
1386
+
1387
+ json_response = json.loads(response.text)
1388
+
1389
+ properties = collections.OrderedDict()
1390
+
1391
+ from .customtypedefinition import AliasProperty, ObjectProperty, SimpleProperty, ExpressionProperty
1392
+ for dic in json_response['items']:
1393
+ if dic['type'] == "AliasProperty":
1394
+ if 'source' in dic:
1395
+ properties[dic['name']] = AliasProperty(dic['name'], dic['source'])
1396
+ else:
1397
+ properties[dic['name']] = AliasProperty(dic['name'], '')
1398
+ elif dic['type'] == "ExpressionProperty":
1399
+ properties[dic['name']] = ExpressionProperty(dic['name'], dic['expression'])
1400
+ elif dic['type'] == "Property":
1401
+ properties[dic['name']] = SimpleProperty(dic['name'])
1402
+ else:
1403
+ properties[dic['name']] = ObjectProperty(dic['name'], dic['type'])
1404
+
1405
+ return properties
1406
+
1407
+
1349
1408
  def getEpmModelObjectProperties(self, objectPath:str) -> OrderedDict:
1350
1409
  """
1351
1410
  Returns all object properties from specific address space paths inside an **EPM Model** folder.
@@ -1376,25 +1435,80 @@ class EpmConnection(object):
1376
1435
 
1377
1436
  properties = collections.OrderedDict()
1378
1437
 
1379
- from .customtypedefinition import AliasProperty, ObjectProperty, SimpleProperty
1438
+ from .customtypedefinition import AliasProperty, ObjectProperty, SimpleProperty, ExpressionProperty
1380
1439
  for dic in json_response['items']:
1381
1440
  if dic['type'] == "AliasProperty":
1382
1441
  if 'source' in dic:
1383
1442
  properties[dic['name']] = AliasProperty(dic['name'], dic['source'])
1384
1443
  else:
1385
1444
  properties[dic['name']] = AliasProperty(dic['name'], '')
1445
+ elif dic['type'] == "ExpressionProperty":
1446
+ properties[dic['name']] = ExpressionProperty(dic['name'], dic['expression'])
1386
1447
  elif dic['type'] == "Property":
1387
1448
  properties[dic['name']] = SimpleProperty(dic['name'])
1388
1449
  else:
1389
1450
  properties[dic['name']] = ObjectProperty(dic['name'], dic['type'])
1390
1451
 
1391
1452
  return properties
1453
+
1454
+
1455
+ def getEpmModelObjectPropertiesV2(self, objectPath:str) -> OrderedDict:
1456
+ """
1457
+ Returns all object properties from specific address space paths inside an **EPM Model** folder.
1458
+
1459
+ Uses a query parameter instead of a path segment to safely handle object names with special characters.
1460
+
1461
+ :param objectPath: Path to start after the **EPM Model** node.
1462
+ :type objectPath: str
1463
+ :return: An Ordered Dictionary with all properties from the target object.
1464
+ :rtype: collections.OrderedDict[property]
1465
+ :raises InvalidObjectNameException: Object not found.
1466
+ """
1467
+ from urllib.parse import urlencode
1468
+ url = self._webApi + '/epm/v1/epmmodel/properties?' + urlencode({'path': self._escapeOpcUaPath(objectPath)})
1469
+
1470
+ session = self._authorizationService.getEpmSession()
1471
+ response = session.get(url, verify=False)
1472
+
1473
+ if response.status_code == 200:
1474
+ responseCode = response.json()['diagnostic']['code']
1475
+ if responseCode != 0:
1476
+ if responseCode == 2154758144:
1477
+ raise InvalidObjectNameException('Object not found')
1478
+ else:
1479
+ raise Exception(response.json()['diagnostic']['message'])
1480
+ else:
1481
+ raise Exception("getEpmModelObjectPropertiesV2 call error + '" + str(response.status_code) + "'. Reason: " +
1482
+ response.reason + ". Text: " + response.text)
1483
+
1484
+ json_response = json.loads(response.text)
1485
+
1486
+ properties = collections.OrderedDict()
1487
+
1488
+ from .customtypedefinition import AliasProperty, ObjectProperty, SimpleProperty, ExpressionProperty
1489
+ for dic in json_response['items']:
1490
+ if dic['type'] == "AliasProperty":
1491
+ if 'source' in dic:
1492
+ properties[dic['name']] = AliasProperty(dic['name'], dic['source'])
1493
+ else:
1494
+ properties[dic['name']] = AliasProperty(dic['name'], '')
1495
+ elif dic['type'] == "Property":
1496
+ properties[dic['name']] = SimpleProperty(dic['name'])
1497
+ elif dic['type'] == "ExpressionProperty":
1498
+ properties[dic['name']] = ExpressionProperty(dic['name'], dic['expression'])
1499
+
1500
+ else:
1501
+ properties[dic['name']] = ObjectProperty(dic['name'], dic['type'])
1502
+
1503
+ return properties
1504
+
1505
+
1392
1506
 
1393
1507
  def _setBindedVariables(self, objectPath, aliasProperties, variablesNames, isEpmModel=True):
1394
1508
  if isEpmModel:
1395
1509
  url = self._webApi + '/epm/v1/epmmodel/' + objectPath
1396
1510
  else:
1397
- raise BadArgumentException('Invalid isEpmModel argument')
1511
+ url = self._webApi + '/epm/v1/datamodel/' + objectPath
1398
1512
 
1399
1513
  session = self._authorizationService.getEpmSession()
1400
1514
  response = session.get(url, verify=False)
@@ -1442,6 +1556,9 @@ class EpmConnection(object):
1442
1556
 
1443
1557
  response = session.patch(url, json=jsonRequest, verify=False)
1444
1558
 
1559
+ if response.status_code == 405 and not isEpmModel:
1560
+ raise Exception("SetBindedVariables on Elipse Data Model objects is not supported by this EPM Server version")
1561
+
1445
1562
  if response.status_code == 200:
1446
1563
  responseCode = response.json()['code']
1447
1564
  if responseCode != 0:
@@ -1999,11 +2116,11 @@ class EpmConnection(object):
1999
2116
 
2000
2117
 
2001
2118
  def getParents(self, objects:List[EpmModelObject]) -> collections.OrderedDict[str, EpmModelObject]:
2002
- """Gets the parent object from all provided objects.
2119
+ """Gets the parent object of each provided object.
2003
2120
 
2004
2121
  :param objects: List of EpmModelObject instances.
2005
2122
  :type objects: List[EpmModelObject]
2006
- :return: An ordered dictionary mapping object paths (strings) to their corresponding parent EpmModelObject instances.
2123
+ :return: An ordered dictionary mapping each provided object's path to its parent EpmModelObject, or None when the object has no parent.
2007
2124
  :rtype: collections.OrderedDict[str, EpmModelObject]
2008
2125
  """
2009
2126
 
@@ -2013,8 +2130,6 @@ class EpmConnection(object):
2013
2130
 
2014
2131
  batchSize = 1000
2015
2132
 
2016
- i = 0
2017
-
2018
2133
  from itertools import islice
2019
2134
  iterador = iter(objects)
2020
2135
 
@@ -2023,23 +2138,31 @@ class EpmConnection(object):
2023
2138
  if not batch:
2024
2139
  break
2025
2140
  hasComponentResult = self._browse([item._itemPath for item in batch], EpmNodeIds.HasComponent.value, NodeClassMask.Object, BrowseDirection.Inverse).references()
2026
- result = hasComponentResult
2027
- if len(result) < 1:
2028
- return None
2029
-
2030
- identities = [ItemPathJSON('OPCUA.NodeId', '', item[0]._identity) for item in result]
2031
-
2032
- typesResults = self._browse(identities, EpmNodeIds.HasTypeDefinition.value).references()
2033
2141
 
2034
- for index in range(0, len(hasComponentResult)):
2035
- if result[index][0]._nodeClass == 4: # Method is ignored
2142
+ for item in batch:
2143
+ parentObjects[item._path] = None
2144
+
2145
+ withParent = []
2146
+ identities = []
2147
+ for index in range(0, len(batch)):
2148
+ refs = hasComponentResult[index] if index < len(hasComponentResult) else []
2149
+ if len(refs) < 1 or refs[0]._nodeClass == 4: # Method is ignored
2036
2150
  continue
2037
- path = objects[i]._path + '/' + result[index][0]._displayName
2038
- parentObjects[path] = EpmModelObject(self, identities[index],
2039
- path, result[index][0]._displayName,
2040
- typesResults[index][0]._displayName)
2041
- i = i + 1
2042
-
2151
+ withParent.append(index)
2152
+ identities.append(ItemPathJSON('OPCUA.NodeId', '', refs[0]._identity))
2153
+
2154
+ if len(identities) < 1:
2155
+ continue
2156
+
2157
+ typesResults = self._browse(identities, EpmNodeIds.HasTypeDefinition.value).references()
2158
+
2159
+ for pos in range(0, len(withParent)):
2160
+ index = withParent[pos]
2161
+ parentPath = '/'.join(batch[index]._path.rstrip('/').split('/')[:-1])
2162
+ parentObjects[batch[index]._path] = EpmModelObject(self, identities[pos],
2163
+ parentPath, hasComponentResult[index][0]._displayName,
2164
+ typesResults[pos][0]._displayName)
2165
+
2043
2166
  return parentObjects
2044
2167
 
2045
2168
  def _historyUpdate(self, updateType, itemPaths, numpyArrays, dataTypeId=None):
@@ -2530,15 +2653,15 @@ class EpmConnection(object):
2530
2653
  continuationPoint = json_result['continuationPoint']
2531
2654
 
2532
2655
  resultTypes = self._browse(
2533
- [ItemPathJSON('OPCUA.NodeId', '', item['identity']) for item in json_result['items']],
2656
+ [ItemPathJSON('OPCUA.NodeId', '', item['identity']['path']) for item in json_result['items']],
2534
2657
  EpmNodeIds.HasTypeDefinition.value).references()
2535
2658
 
2536
2659
  index = 0
2537
2660
  for item in json_result['items']:
2538
2661
  if resultTypes[index][0]._identity == EpmNodeIds.BasicVariableType.value:
2539
- dataObject = BasicVariable(self, ItemPathJSON('OPCUA.NodeId', None, item['identity']), item['name'])
2662
+ dataObject = BasicVariable(self, ItemPathJSON('OPCUA.NodeId', None, item['identity']['path']), item['name'])
2540
2663
  else:
2541
- dataObject = EpmDataObject(self, item['name'], ItemPathJSON('OPCUA.NodeId', None, item['identity']))
2664
+ dataObject = EpmDataObject(self, item['name'], ItemPathJSON('OPCUA.NodeId', None, item['identity']['path']))
2542
2665
  items[item['name']] = dataObject
2543
2666
  index = index + 1
2544
2667
  if continuationPoint is None:
@@ -2589,17 +2712,59 @@ class EpmConnection(object):
2589
2712
 
2590
2713
  return epmVariables
2591
2714
 
2715
+ @staticmethod
2716
+ def _escapeOpcUaBrowseName(name: str) -> str:
2717
+ """Escapes special characters in an OPC-UA browse name for use inside a RelativePath.
2718
+
2719
+ In OPC-UA browse path syntax, '&' is the escape character for the following
2720
+ special characters: / . < > : # ! &
2721
+ The '&' itself must be escaped first to avoid double-escaping.
2722
+ """
2723
+ name = name.replace('&', '&&')
2724
+ for ch in ['/', '.', '<', '>', ':', '#', '!']:
2725
+ name = name.replace(ch, '&' + ch)
2726
+ return name
2727
+
2728
+ @staticmethod
2729
+ def _escapeOpcUaPath(path: str) -> str:
2730
+ """Escapes special OPC-UA characters in each segment of a display path.
2731
+
2732
+ The path separators '/' (hierarchical) and '.' (property) are preserved as-is.
2733
+ Special characters within each individual segment name are escaped using
2734
+ :meth:`_escapeOpcUaBrowseName`.
2735
+
2736
+ Example::
2737
+
2738
+ _escapeOpcUaPath('Folder/Object!Name.Property#1')
2739
+ # returns 'Folder/Object&!Name.Property&#1'
2740
+
2741
+ :param path: Display path with '/' and '.' as segment separators.
2742
+ :type path: str
2743
+ :return: Path with each segment name properly escaped for OPC-UA.
2744
+ :rtype: str
2745
+ """
2746
+ result = []
2747
+ segment_start = 0
2748
+ for i, ch in enumerate(path):
2749
+ if ch in ('/', '.'):
2750
+ segment = path[segment_start:i]
2751
+ result.append(EpmConnection._escapeOpcUaBrowseName(segment))
2752
+ result.append(ch)
2753
+ segment_start = i + 1
2754
+ result.append(EpmConnection._escapeOpcUaBrowseName(path[segment_start:]))
2755
+ return ''.join(result)
2756
+
2592
2757
  def _getDataObjects(self, names, attributes, rootNode='/1:DataObjects') -> OrderedDict[str, EpmDataObject]:
2593
2758
  epmVariables = collections.OrderedDict()
2594
2759
  doNames = []
2595
2760
  paths = []
2596
2761
  if type(names) is str:
2597
2762
  doNames.append(names)
2598
- paths.append(ItemPathJSON('OPCUA.BrowsePath', '', rootNode + '/1:' + names))
2763
+ paths.append(ItemPathJSON('OPCUA.BrowsePath', '', rootNode + '/1:' + self._escapeOpcUaBrowseName(names)))
2599
2764
  else:
2600
2765
  doNames = names
2601
2766
  for item in names:
2602
- paths.append(ItemPathJSON('OPCUA.BrowsePath', '', rootNode + '/1:' + item))
2767
+ paths.append(ItemPathJSON('OPCUA.BrowsePath', '', rootNode + '/1:' + self._escapeOpcUaBrowseName(item)))
2603
2768
 
2604
2769
  # Verifica se todos os itens existem
2605
2770
  epmVariables = collections.OrderedDict()
@@ -2677,6 +2842,10 @@ class EpmConnection(object):
2677
2842
  propertyPaths.append((variable, DataObjectAttributes.TagType, ItemPathJSON('OPCUA.NodeId', None,
2678
2843
  variable._encodePropertyIdentity(
2679
2844
  EpmDataObjectAttributeIds.TagType.value))))
2845
+ if DataObjectAttributes.Source in attributes:
2846
+ propertyPaths.append((variable, DataObjectAttributes.Source, ItemPathJSON('OPCUA.NodeId', None,
2847
+ variable._encodePropertyIdentity(
2848
+ EpmDataObjectAttributeIds.Source.value))))
2680
2849
 
2681
2850
  chunks = [propertyPaths[x:x + 1000] for x in range(0, len(propertyPaths), 1000)]
2682
2851
 
@@ -47,6 +47,8 @@ class EpmDataObjectAttributeIds(Enum):
47
47
 
48
48
  TagType = 3
49
49
 
50
+ Source = 5
51
+
50
52
  LowLimit = 15
51
53
 
52
54
  HighLimit = 16
@@ -3,6 +3,7 @@ from .browsedirection import BrowseDirection
3
3
  from .nodeclassmask import NodeClassMask
4
4
  from .epmobject import EpmObject
5
5
  import collections
6
+ import re
6
7
 
7
8
  from typing import List, OrderedDict
8
9
 
@@ -16,29 +17,25 @@ class EpmModelObject(EpmObject):
16
17
 
17
18
  # Public Methods
18
19
  def getParent(self) -> EpmModelObject:
19
-
20
+ """
21
+ :return: The parent object of this object, or None if it has no parent.
22
+ :rtype: EpmModelObject
23
+ """
20
24
  from .epmnodeids import EpmNodeIds
21
25
  from .itempathjson import ItemPathJSON
22
- parentObjects = collections.OrderedDict()
23
26
  hasComponentResult = self._epmConnection._browse([self._itemPath], EpmNodeIds.HasComponent.value, NodeClassMask.Object, BrowseDirection.Inverse).references()[0]
24
- #organizesResult = self._epmConnection._browse([self._itemPath], EpmNodeIds.Organizes.value).references()[0]
25
- result = hasComponentResult[0] #+ organizesResult
26
- #if len(result) < 1:
27
- # return None
28
-
29
- #identities = [ItemPathJSON('OPCUA.NodeId', '', item._identity) for item in hasComponentResult]
30
- identity = ItemPathJSON('OPCUA.NodeId', '', result._identity)
31
- typesResults = self._epmConnection._browse([identity], EpmNodeIds.HasTypeDefinition.value).references()
32
-
33
- #for index in range(0, len(hasComponentResult)):
27
+ if len(hasComponentResult) < 1:
28
+ return None
29
+ result = hasComponentResult[0]
34
30
  if result._nodeClass == 4: # Method is ignored
35
31
  return None
32
+ identity = ItemPathJSON('OPCUA.NodeId', '', result._identity)
33
+ typesResults = self._epmConnection._browse([identity], EpmNodeIds.HasTypeDefinition.value).references()
34
+ parentPath = '/'.join(self._path.rstrip('/').split('/')[:-1])
36
35
  return EpmModelObject(self._epmConnection, identity,
37
- self._path + '/' + result._displayName, result._displayName,
36
+ parentPath, result._displayName,
38
37
  typesResults[0][0]._displayName)
39
38
 
40
- return parentObjects
41
-
42
39
 
43
40
 
44
41
  def enumObjects(self) -> collections.OrderedDict:
@@ -79,12 +76,7 @@ class EpmModelObject(EpmObject):
79
76
  :return: An Ordered Dictionary with all objects created.
80
77
  :rtype: collections.OrderedDict[EpmObject]
81
78
  """
82
- splitPath = self._path.split("/")
83
-
84
- if splitPath[0] == "":
85
- addPath = "/".join(splitPath[3:])
86
- else:
87
- addPath = "/".join(splitPath[2:])
79
+ _, addPath = self._splitModelPath()
88
80
 
89
81
  return self._epmConnection._addInstancesEpmModel(addPath, names, objTypes)
90
82
 
@@ -97,12 +89,7 @@ class EpmModelObject(EpmObject):
97
89
  :return: True / False depending of the operation result.
98
90
  :rtype: bool
99
91
  """
100
- splitPath = self._path.split("/")
101
-
102
- if splitPath[0] == "":
103
- addPath = "/".join(splitPath[3:])
104
- else:
105
- addPath = "/".join(splitPath[2:])
92
+ _, addPath = self._splitModelPath()
106
93
 
107
94
  return self._epmConnection._addReferencesEpmModel(addPath, obj)
108
95
 
@@ -113,15 +100,9 @@ class EpmModelObject(EpmObject):
113
100
  :param name: Name of an object to remove.
114
101
  :type name: str
115
102
  """
116
- splitPath = self._path.split("/")
103
+ _, objectPath = self._splitModelPath()
117
104
 
118
- if splitPath[0] == "":
119
- removePath = "/".join(splitPath[3:]) + "/" + name
120
- else:
121
- removePath = "/".join(splitPath[2:]) + "/" + name
122
-
123
- if removePath[0] == "/":
124
- removePath = removePath[1:]
105
+ removePath = objectPath + "/" + name if objectPath else name
125
106
 
126
107
  self._epmConnection._removeInstanceEpmModel(removePath)
127
108
 
@@ -129,20 +110,30 @@ class EpmModelObject(EpmObject):
129
110
  def setBindedVariables(self, aliasProperties:List[str], variablesNames:List[str]):
130
111
  """
131
112
  Sets the bind variable from a list of Alias Properties.
113
+ Works for objects of the **EPM Model** and of the **Elipse Data Model**.
132
114
 
133
115
  :param aliasProperties: List with Alias Properties.
134
116
  :type aliasProperties: List[str]
135
117
  :param variablesNames: List of Data Objects to bind.
136
118
  :type variablesNames: List[str]
137
119
  """
138
- splitPath = self._path.split("/")
120
+ modelName, objectPath = self._splitModelPath()
121
+
122
+ self._epmConnection._setBindedVariables(objectPath, aliasProperties, variablesNames,
123
+ modelName != 'ElipseDataModel')
139
124
 
140
- if splitPath[0] == "":
141
- objectPath = "/".join(splitPath[3:])
142
- else:
143
- objectPath = "/".join(splitPath[2:])
144
125
 
145
- self._epmConnection._setBindedVariables(objectPath, aliasProperties, variablesNames, True)
126
+ def _splitModelPath(self):
127
+ """
128
+ Splits the object path ("/Models/<model>/<path>") into the model name and the path inside
129
+ the model. Paths with namespace indexes ("1:Models/1:ElipseDataModel/1:Obj", as returned by
130
+ queries) have the indexes removed, as the Web API adds them again.
131
+ """
132
+ segments = [s for s in self._path.split("/") if s]
133
+ if segments and re.match(r"^\d+:Models$", segments[0]):
134
+ segments = [re.sub(r"^\d+:", "", s) for s in segments]
135
+ modelName = segments[1] if len(segments) > 1 else ""
136
+ return modelName, "/".join(segments[2:])
146
137
 
147
138
 
148
139
  class ObjectDependenciesException(Exception):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: epmwebapi
3
- Version: 6.50.38
3
+ Version: 7.50.11
4
4
  Home-page: https://github.com/elipsesoftware/epmwebapi
5
5
  Author: Elipse Software Ltda
6
6
  License-Expression: GPL-3.0-only
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "epmwebapi"
3
- version = '6.50.38'
3
+ version = '7.50.11'
4
4
  license = "GPL-3.0-only"
5
5
  license-files = ["LICENSE.txt"]
6
6
  readme = "README.md"
@@ -7,7 +7,7 @@ with open(path.join(this_directory, 'Readme.md'), encoding='utf-8') as f:
7
7
  long_description = f.read()
8
8
 
9
9
  setup(name = 'epmwebapi',
10
- version = '6.50.38',
10
+ version = '7.50.11',
11
11
  author = 'Elipse Software Ltda',
12
12
  packages = ['epmwebapi'],
13
13
  include_package_data=True,
@@ -1 +0,0 @@
1
- __version__ = '6.50.38'
File without changes
File without changes