Skip to content

Commit 9296542

Browse files
authored
Merge pull request #822 from Hugovdberg/pi_datacontainercollection
v1.0.0rc1
2 parents 0a051ca + 53d1ac9 commit 9296542

34 files changed

+732
-792
lines changed

PIconnect/AF.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,13 @@ def default_server(cls) -> dotnet.AF.PISystem | None:
3232
return None
3333

3434
def __init__(self, server: str | None = None, database: str | None = None) -> None:
35+
#: The PI AF server connection.
3536
self.server = self._initialise_server(server)
37+
#: The PI AF database connection.
3638
self.database = self._initialise_database(database)
37-
self.search = Search.Search(self.database)
39+
#: Search reference for searching objects in the database.
40+
#: See :class:`.Search.Search` for more information.
41+
self.search: Search.Search = Search.Search(self.database)
3842

3943
def _initialise_server(self, server: str | None) -> dotnet.AF.PISystem:
4044
"""Initialise the server connection."""
@@ -151,7 +155,11 @@ def event_frames(
151155

152156

153157
class PIAFDatabase(AFDatabase):
154-
"""Context manager for connections to the PI Asset Framework database."""
158+
"""Context manager for connections to the PI Asset Framework database.
159+
160+
.. deprecated:: 1.0.0
161+
Use :class:`AFDatabase` instead.
162+
"""
155163

156164
version = "0.3.0"
157165

PIconnect/Asset.py

Lines changed: 4 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""Mirror of the OSISoft.AF.Asset namespace."""
22

33
import dataclasses
4-
from typing import Generic, Self, TypeVar, overload
4+
from typing import Generic, Self, TypeVar
55

66
import pandas as pd # type: ignore
77

@@ -10,11 +10,12 @@
1010

1111
__all__ = [
1212
"AFDataReference",
13+
"AFElement",
14+
"AFElementList",
1315
"AFAttribute",
1416
"AFAttributeList",
1517
]
1618

17-
T = TypeVar("T")
1819
ElementType = TypeVar("ElementType", bound=dotnet.AF.Asset.AFBaseElement)
1920

2021

@@ -41,54 +42,6 @@ def pi_point(self) -> PI.PIPoint | None:
4142
return PI.PIPoint(self.data_reference.PIPoint)
4243

4344

44-
class AFEnumerationValue:
45-
"""Representation of an AF enumeration value."""
46-
47-
def __init__(self, value: dotnet.AF.Asset.AFEnumerationValue) -> None:
48-
self._value = value
49-
50-
def __str__(self) -> str:
51-
"""Return the string representation of the enumeration value."""
52-
return self._value.Name
53-
54-
def __int__(self) -> int:
55-
"""Return the integer representation of the enumeration value."""
56-
return self._value.Value
57-
58-
def __repr__(self):
59-
"""Return the string representation of the enumeration value."""
60-
return f"{self.__class__.__qualname__}({self._value.Name})"
61-
62-
@property
63-
def name(self) -> str:
64-
"""Return the name of the enumeration value."""
65-
return self._value.Name
66-
67-
@property
68-
def value(self) -> int:
69-
"""Return the integer value of the enumeration value."""
70-
return self._value.Value
71-
72-
@overload
73-
@staticmethod
74-
def wrap_enumeration_value(
75-
value: dotnet.AF.Asset.AFEnumerationValue,
76-
) -> "AFEnumerationValue": ...
77-
@overload
78-
@staticmethod
79-
def wrap_enumeration_value(
80-
value: T,
81-
) -> T: ...
82-
@staticmethod
83-
def wrap_enumeration_value(
84-
value: T | dotnet.AF.Asset.AFEnumerationValue,
85-
) -> "T | AFEnumerationValue":
86-
"""Wrap the value in an AFEnumerationValue if it is an enumeration value."""
87-
if isinstance(value, dotnet.lib.AF.Asset.AFEnumerationValue):
88-
return AFEnumerationValue(value)
89-
return value
90-
91-
9245
class AFAttribute(Data.DataContainer):
9346
"""Representation of an AF attribute."""
9447

@@ -158,7 +111,7 @@ def _normalize_filter_expression(self, filter_expression: str) -> str:
158111

159112
def _current_value(self) -> object:
160113
"""Return the current value of the attribute."""
161-
return AFEnumerationValue.wrap_enumeration_value(self.attribute.GetValue().Value)
114+
return self.attribute.GetValue().Value
162115

163116
def _filtered_summaries(
164117
self,

0 commit comments

Comments
 (0)