Skip to content

Commit b37ed00

Browse files
authored
refactor(system): add historian.types submodule (#28)
* refactor(system): add historian.types submodule * feat(system): add return statement to [meta] dataPoint
1 parent fd2511d commit b37ed00

14 files changed

Lines changed: 570 additions & 4 deletions

File tree

requirements.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ enum34==1.1.10 \
99
--hash=sha256:c3858660960c984d6ab0ebad691265180da2b43f07e061c0f8dca9ef3cffd328 \
1010
--hash=sha256:cce6a7477ed816bd2542d03d53db9f0db935dd013b70f336a95c73979289f248
1111
# via -r requirements.in
12-
java-api==17.26.0 \
13-
--hash=sha256:a797a9695e712c9499a900d0376cd56dd49658b5f5cea58dbc49b01c4112249e \
14-
--hash=sha256:c1ed6087588b3487983d77f20040378a4cab442780a7be3efd094e26d052aabf
12+
java-api==17.26.5 \
13+
--hash=sha256:9bb74897b0838d6e87a8dc118a56c284fdf660f9db2f2dfbe5b95b672af9cf1e \
14+
--hash=sha256:bf68ebcd91e9c8ea222fed6e13e989745eecc2ae8679984b9a9a3b03c1a64edb
1515
# via -r requirements.in
1616
typing==3.10.0.0 \
1717
--hash=sha256:12fbdfbe7d6cca1a42e485229afcb0b0c8259258cfb919b8a5e2a5c953742f89 \

src/com/inductiveautomation/historian/__init__.py

Whitespace-only changes.

src/com/inductiveautomation/historian/common/__init__.py

Whitespace-only changes.

src/com/inductiveautomation/historian/common/model/__init__.py

Whitespace-only changes.
Lines changed: 274 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,274 @@
1+
from __future__ import print_function
2+
3+
__all__ = [
4+
"Annotation",
5+
"AnnotationPoint",
6+
"AtomicPoint",
7+
"DataPoint",
8+
"MetadataPoint",
9+
"SnapshotCapable",
10+
"StandardComplexPointType",
11+
"TemporalPoint",
12+
]
13+
14+
from typing import Any, List, Optional, Union
15+
16+
from java.lang import Class, Comparable, Enum, Object, Record
17+
from java.time import Instant
18+
from java.util import UUID
19+
20+
from com.inductiveautomation.ignition.common import QualifiedPath
21+
from com.inductiveautomation.ignition.common.config import PropertySet, PropertyValue
22+
from com.inductiveautomation.ignition.common.model.values import QualityCode
23+
24+
25+
class SnapshotCapable(object):
26+
def isSnapshot(self):
27+
# type: () -> bool
28+
pass
29+
30+
def snapshotTime(self):
31+
# type: () -> Optional[Instant]
32+
pass
33+
34+
def withSnapshot(self, timestamp=None):
35+
# type: (Optional[Instant]) -> SnapshotCapable
36+
pass
37+
38+
39+
class TemporalPoint(Comparable):
40+
def compareTo(self, other):
41+
# type: (TemporalPoint) -> int
42+
pass
43+
44+
def source(self):
45+
# type: () -> QualifiedPath
46+
pass
47+
48+
def timestamp(self):
49+
# type: () -> Instant
50+
pass
51+
52+
def type(self):
53+
# type: () -> Any
54+
pass
55+
56+
def value(self):
57+
# type: () -> Any
58+
pass
59+
60+
61+
class DataPoint(SnapshotCapable, TemporalPoint):
62+
def quality(self):
63+
# type: () -> QualityCode
64+
pass
65+
66+
def valueClass(self):
67+
# type: () -> Any
68+
pass
69+
70+
71+
class AtomicPoint(DataPoint):
72+
pass
73+
74+
75+
class Annotation(Record):
76+
def __init__(
77+
self,
78+
notes, # type: Union[str, unicode]
79+
type_, # type: Union[str, unicode]
80+
author, # type: Union[str, unicode]
81+
):
82+
# type: (...) -> None
83+
super(Annotation, self).__init__()
84+
85+
def author(self):
86+
# type: () -> Union[str, unicode]
87+
pass
88+
89+
def notes(self):
90+
# type: () -> Union[str, unicode]
91+
pass
92+
93+
def type(self):
94+
# type: () -> Union[str, unicode]
95+
pass
96+
97+
98+
class AnnotationPoint(Record):
99+
class Builder(Object):
100+
def __init__(self):
101+
# type: () -> None
102+
super(AnnotationPoint.Builder, self).__init__()
103+
104+
def annotationType(self, annotationType):
105+
# type: (Union[str, unicode]) -> AnnotationPoint.Builder
106+
pass
107+
108+
def author(self, author):
109+
# type: (Union[str, unicode]) -> AnnotationPoint.Builder
110+
pass
111+
112+
def build(self):
113+
# type: () -> AnnotationPoint
114+
pass
115+
116+
def endTime(self, endTime):
117+
# type: (Instant) -> AnnotationPoint.Builder
118+
pass
119+
120+
def identifier(
121+
self,
122+
identifier, # type: Union[UUID, str, unicode]
123+
):
124+
# type: (...) -> AnnotationPoint.Builder
125+
pass
126+
127+
def lastUpdated(self, lastUpdated):
128+
# type: (Instant) -> AnnotationPoint.Builder
129+
pass
130+
131+
def notes(self, notes):
132+
# type: (Union[str, unicode]) -> AnnotationPoint.Builder
133+
pass
134+
135+
def source(self, source):
136+
# type: (QualifiedPath) -> AnnotationPoint.Builder
137+
pass
138+
139+
def startTime(self, startTime):
140+
# type: (Instant) -> AnnotationPoint.Builder
141+
pass
142+
143+
def __init__(
144+
self,
145+
identifier, # type: UUID
146+
source, # type: QualifiedPath
147+
value, # type: Annotation
148+
startTime, # type: Instant
149+
endTime=None, # type: Optional[Instant]
150+
lastUpdated=None, # type: Optional[Instant]
151+
):
152+
# type: (...) -> None
153+
super(AnnotationPoint, self).__init__()
154+
print(identifier, source, value, startTime, endTime, lastUpdated)
155+
156+
@staticmethod
157+
def builder():
158+
# type: () -> AnnotationPoint.Builder
159+
pass
160+
161+
def endTime(self):
162+
# type: () -> Optional[Instant]
163+
pass
164+
165+
def identifier(self):
166+
# type: () -> UUID
167+
pass
168+
169+
def lastUpdated(self):
170+
# type: () -> Optional[Instant]
171+
pass
172+
173+
def source(self):
174+
# type: () -> QualifiedPath
175+
pass
176+
177+
def startTime(self):
178+
# type: () -> Instant
179+
pass
180+
181+
def timestamp(self):
182+
# type: () -> Instant
183+
pass
184+
185+
def type(self):
186+
# type: () -> StandardComplexPointType
187+
pass
188+
189+
def value(self):
190+
# type: () -> Annotation
191+
pass
192+
193+
def withSource(self, source):
194+
# type: (QualifiedPath) -> AnnotationPoint
195+
pass
196+
197+
198+
class MetadataPoint(Record, TemporalPoint):
199+
class Builder(Object):
200+
def __init__(self):
201+
# type: () -> None
202+
super(MetadataPoint.Builder, self).__init__()
203+
204+
def addValue(self, value):
205+
# type: (PropertyValue) -> MetadataPoint.Builder
206+
pass
207+
208+
def build(self):
209+
# type: () -> MetadataPoint
210+
pass
211+
212+
def quality(self, quality):
213+
# type: (QualityCode) -> MetadataPoint.Builder
214+
pass
215+
216+
def source(self, source):
217+
# type: (QualifiedPath) -> MetadataPoint.Builder
218+
pass
219+
220+
def timestamp(self, timestamp):
221+
# type: (Instant) -> MetadataPoint.Builder
222+
pass
223+
224+
def values(self, values):
225+
# type: (PropertySet) -> MetadataPoint.Builder
226+
pass
227+
228+
def __init__(
229+
self,
230+
value, # type: PropertySet
231+
quality, # type: QualityCode
232+
timestamp, # type: Instant
233+
source, # type: QualifiedPath
234+
):
235+
# type: (...) -> None
236+
super(MetadataPoint, self).__init__()
237+
print(value, quality, timestamp, source)
238+
239+
@staticmethod
240+
def builder(metadataPoint=None):
241+
# type: (Optional[MetadataPoint]) -> MetadataPoint.Builder
242+
pass
243+
244+
@staticmethod
245+
def empty(source):
246+
# type: (QualifiedPath) -> MetadataPoint
247+
pass
248+
249+
def quality(self):
250+
# type: () -> QualityCode
251+
pass
252+
253+
def withSource(self, source):
254+
# type: (QualifiedPath) -> MetadataPoint
255+
pass
256+
257+
258+
class StandardComplexPointType(Enum):
259+
ANNOTATION = None # type: StandardComplexPointType
260+
GENERIC = None # type: StandardComplexPointType
261+
METADATA = None # type: StandardComplexPointType
262+
263+
def getPointClass(self):
264+
# type: () -> Class
265+
pass
266+
267+
def getQueryOptionsClass(self):
268+
# type: () -> Class
269+
pass
270+
271+
@staticmethod
272+
def values():
273+
# type: () -> List[StandardComplexPointType]
274+
pass

src/system/historian/types.py

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
"""Historian types."""
2+
3+
__all__ = ["annotationPoint", "dataPoint", "metadataPoint"]
4+
5+
from typing import Any, Dict, Optional, Union
6+
7+
from java.util import Date
8+
9+
from com.inductiveautomation.historian.common.model.data import (
10+
AnnotationPoint,
11+
AtomicPoint,
12+
MetadataPoint,
13+
)
14+
15+
16+
def annotationPoint(
17+
source, # type: Union[str, unicode]
18+
startTime, # type: Date
19+
endTime=None, # type: Optional[Date]
20+
annotationType=None, # type: Optional[Union[str, unicode]]
21+
data=None, # type: Optional[Union[str, unicode]]
22+
identifier=None, # type: Optional[Union[str, unicode]]
23+
):
24+
# type: (...) -> AnnotationPoint
25+
"""Creates an annotation point that can be stored to a historian.
26+
27+
Annotation points represent time-based context, such as operator
28+
notes, events, or system-generated markers associated with a
29+
historical path.
30+
31+
Args:
32+
source: The historical path where the annotation point will be
33+
stored.
34+
startTime: The start time associated with the annotation.
35+
endTime: The end time associated with the annotation. If
36+
omitted, the annotation has no end time. Optional.
37+
annotationType: A string used to categorize the annotation
38+
(for example, "marker", "note", or "event"). If omitted,
39+
"marker" is used. Optional.
40+
data: A string payload associated with the annotation. This can
41+
contain plain text or structured data, such as JSON. If
42+
omitted, an empty string is used. Optional.
43+
identifier: An identifier used to indicate that an existing
44+
annotation should be updated. Optional.
45+
46+
Returns:
47+
An annotation point object that can be passed to
48+
system.historian.storeAnnotations.
49+
"""
50+
builder = AnnotationPoint.builder()
51+
return builder.build()
52+
53+
54+
def dataPoint(
55+
source, # type: Union[str, unicode]
56+
value, # type: object
57+
timestamp=None, # type: Optional[Date]
58+
quality=None, # type: Optional[int]
59+
):
60+
# type: (...) -> AtomicPoint
61+
"""Creates a data point that can be stored to a historian.
62+
63+
Data points represent individual values associated with a historical
64+
path, timestamp, and quality.
65+
66+
Args:
67+
source: The historical path where the data point will be stored.
68+
value: The value to be stored in the historian.
69+
timestamp: The timestamp when the data point was recorded. If
70+
omitted, the current time is used. Optional.
71+
quality: The quality code of the data point. If omitted, a
72+
"good" quality is used. Optional.
73+
74+
Returns:
75+
A data point object that can be passed to
76+
system.historian.storeDataPoints.
77+
"""
78+
return AtomicPoint()
79+
80+
81+
def metadataPoint(
82+
source, # type: Union[str, unicode]
83+
properties, # type: Dict[Union[str, unicode], Any]
84+
timestamp, # type: Date
85+
):
86+
# type: (...) -> MetadataPoint
87+
"""Creates a metadata point that can be stored to a historian.
88+
89+
Metadata points allow you to store additional properties associated
90+
with a historical path at a specific point in time.
91+
92+
Args:
93+
source: The historical path where the metadata point will be
94+
stored.
95+
properties: A dictionary of properties to be stored as
96+
historical metadata.
97+
timestamp: The timestamp when the metadata point was recorded.
98+
99+
Returns:
100+
A metadata point object that can be passed to
101+
system.historian.storeMetadata.
102+
"""
103+
builder = MetadataPoint.builder()
104+
return builder.build()

0 commit comments

Comments
 (0)