diff --git a/requirements.txt b/requirements.txt index c792309..a8048b9 100644 --- a/requirements.txt +++ b/requirements.txt @@ -9,9 +9,9 @@ enum34==1.1.10 \ --hash=sha256:c3858660960c984d6ab0ebad691265180da2b43f07e061c0f8dca9ef3cffd328 \ --hash=sha256:cce6a7477ed816bd2542d03d53db9f0db935dd013b70f336a95c73979289f248 # via -r requirements.in -java-api==17.26.0 \ - --hash=sha256:a797a9695e712c9499a900d0376cd56dd49658b5f5cea58dbc49b01c4112249e \ - --hash=sha256:c1ed6087588b3487983d77f20040378a4cab442780a7be3efd094e26d052aabf +java-api==17.26.5 \ + --hash=sha256:9bb74897b0838d6e87a8dc118a56c284fdf660f9db2f2dfbe5b95b672af9cf1e \ + --hash=sha256:bf68ebcd91e9c8ea222fed6e13e989745eecc2ae8679984b9a9a3b03c1a64edb # via -r requirements.in typing==3.10.0.0 \ --hash=sha256:12fbdfbe7d6cca1a42e485229afcb0b0c8259258cfb919b8a5e2a5c953742f89 \ diff --git a/src/com/inductiveautomation/historian/__init__.py b/src/com/inductiveautomation/historian/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/com/inductiveautomation/historian/common/__init__.py b/src/com/inductiveautomation/historian/common/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/com/inductiveautomation/historian/common/model/__init__.py b/src/com/inductiveautomation/historian/common/model/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/com/inductiveautomation/historian/common/model/data/__init__.py b/src/com/inductiveautomation/historian/common/model/data/__init__.py new file mode 100644 index 0000000..8076d1d --- /dev/null +++ b/src/com/inductiveautomation/historian/common/model/data/__init__.py @@ -0,0 +1,274 @@ +from __future__ import print_function + +__all__ = [ + "Annotation", + "AnnotationPoint", + "AtomicPoint", + "DataPoint", + "MetadataPoint", + "SnapshotCapable", + "StandardComplexPointType", + "TemporalPoint", +] + +from typing import Any, List, Optional, Union + +from java.lang import Class, Comparable, Enum, Object, Record +from java.time import Instant +from java.util import UUID + +from com.inductiveautomation.ignition.common import QualifiedPath +from com.inductiveautomation.ignition.common.config import PropertySet, PropertyValue +from com.inductiveautomation.ignition.common.model.values import QualityCode + + +class SnapshotCapable(object): + def isSnapshot(self): + # type: () -> bool + pass + + def snapshotTime(self): + # type: () -> Optional[Instant] + pass + + def withSnapshot(self, timestamp=None): + # type: (Optional[Instant]) -> SnapshotCapable + pass + + +class TemporalPoint(Comparable): + def compareTo(self, other): + # type: (TemporalPoint) -> int + pass + + def source(self): + # type: () -> QualifiedPath + pass + + def timestamp(self): + # type: () -> Instant + pass + + def type(self): + # type: () -> Any + pass + + def value(self): + # type: () -> Any + pass + + +class DataPoint(SnapshotCapable, TemporalPoint): + def quality(self): + # type: () -> QualityCode + pass + + def valueClass(self): + # type: () -> Any + pass + + +class AtomicPoint(DataPoint): + pass + + +class Annotation(Record): + def __init__( + self, + notes, # type: Union[str, unicode] + type_, # type: Union[str, unicode] + author, # type: Union[str, unicode] + ): + # type: (...) -> None + super(Annotation, self).__init__() + + def author(self): + # type: () -> Union[str, unicode] + pass + + def notes(self): + # type: () -> Union[str, unicode] + pass + + def type(self): + # type: () -> Union[str, unicode] + pass + + +class AnnotationPoint(Record): + class Builder(Object): + def __init__(self): + # type: () -> None + super(AnnotationPoint.Builder, self).__init__() + + def annotationType(self, annotationType): + # type: (Union[str, unicode]) -> AnnotationPoint.Builder + pass + + def author(self, author): + # type: (Union[str, unicode]) -> AnnotationPoint.Builder + pass + + def build(self): + # type: () -> AnnotationPoint + pass + + def endTime(self, endTime): + # type: (Instant) -> AnnotationPoint.Builder + pass + + def identifier( + self, + identifier, # type: Union[UUID, str, unicode] + ): + # type: (...) -> AnnotationPoint.Builder + pass + + def lastUpdated(self, lastUpdated): + # type: (Instant) -> AnnotationPoint.Builder + pass + + def notes(self, notes): + # type: (Union[str, unicode]) -> AnnotationPoint.Builder + pass + + def source(self, source): + # type: (QualifiedPath) -> AnnotationPoint.Builder + pass + + def startTime(self, startTime): + # type: (Instant) -> AnnotationPoint.Builder + pass + + def __init__( + self, + identifier, # type: UUID + source, # type: QualifiedPath + value, # type: Annotation + startTime, # type: Instant + endTime=None, # type: Optional[Instant] + lastUpdated=None, # type: Optional[Instant] + ): + # type: (...) -> None + super(AnnotationPoint, self).__init__() + print(identifier, source, value, startTime, endTime, lastUpdated) + + @staticmethod + def builder(): + # type: () -> AnnotationPoint.Builder + pass + + def endTime(self): + # type: () -> Optional[Instant] + pass + + def identifier(self): + # type: () -> UUID + pass + + def lastUpdated(self): + # type: () -> Optional[Instant] + pass + + def source(self): + # type: () -> QualifiedPath + pass + + def startTime(self): + # type: () -> Instant + pass + + def timestamp(self): + # type: () -> Instant + pass + + def type(self): + # type: () -> StandardComplexPointType + pass + + def value(self): + # type: () -> Annotation + pass + + def withSource(self, source): + # type: (QualifiedPath) -> AnnotationPoint + pass + + +class MetadataPoint(Record, TemporalPoint): + class Builder(Object): + def __init__(self): + # type: () -> None + super(MetadataPoint.Builder, self).__init__() + + def addValue(self, value): + # type: (PropertyValue) -> MetadataPoint.Builder + pass + + def build(self): + # type: () -> MetadataPoint + pass + + def quality(self, quality): + # type: (QualityCode) -> MetadataPoint.Builder + pass + + def source(self, source): + # type: (QualifiedPath) -> MetadataPoint.Builder + pass + + def timestamp(self, timestamp): + # type: (Instant) -> MetadataPoint.Builder + pass + + def values(self, values): + # type: (PropertySet) -> MetadataPoint.Builder + pass + + def __init__( + self, + value, # type: PropertySet + quality, # type: QualityCode + timestamp, # type: Instant + source, # type: QualifiedPath + ): + # type: (...) -> None + super(MetadataPoint, self).__init__() + print(value, quality, timestamp, source) + + @staticmethod + def builder(metadataPoint=None): + # type: (Optional[MetadataPoint]) -> MetadataPoint.Builder + pass + + @staticmethod + def empty(source): + # type: (QualifiedPath) -> MetadataPoint + pass + + def quality(self): + # type: () -> QualityCode + pass + + def withSource(self, source): + # type: (QualifiedPath) -> MetadataPoint + pass + + +class StandardComplexPointType(Enum): + ANNOTATION = None # type: StandardComplexPointType + GENERIC = None # type: StandardComplexPointType + METADATA = None # type: StandardComplexPointType + + def getPointClass(self): + # type: () -> Class + pass + + def getQueryOptionsClass(self): + # type: () -> Class + pass + + @staticmethod + def values(): + # type: () -> List[StandardComplexPointType] + pass diff --git a/src/system/historian.py b/src/system/historian/__init__.py similarity index 100% rename from src/system/historian.py rename to src/system/historian/__init__.py diff --git a/src/system/historian/types.py b/src/system/historian/types.py new file mode 100644 index 0000000..0d1436b --- /dev/null +++ b/src/system/historian/types.py @@ -0,0 +1,104 @@ +"""Historian types.""" + +__all__ = ["annotationPoint", "dataPoint", "metadataPoint"] + +from typing import Any, Dict, Optional, Union + +from java.util import Date + +from com.inductiveautomation.historian.common.model.data import ( + AnnotationPoint, + AtomicPoint, + MetadataPoint, +) + + +def annotationPoint( + source, # type: Union[str, unicode] + startTime, # type: Date + endTime=None, # type: Optional[Date] + annotationType=None, # type: Optional[Union[str, unicode]] + data=None, # type: Optional[Union[str, unicode]] + identifier=None, # type: Optional[Union[str, unicode]] +): + # type: (...) -> AnnotationPoint + """Creates an annotation point that can be stored to a historian. + + Annotation points represent time-based context, such as operator + notes, events, or system-generated markers associated with a + historical path. + + Args: + source: The historical path where the annotation point will be + stored. + startTime: The start time associated with the annotation. + endTime: The end time associated with the annotation. If + omitted, the annotation has no end time. Optional. + annotationType: A string used to categorize the annotation + (for example, "marker", "note", or "event"). If omitted, + "marker" is used. Optional. + data: A string payload associated with the annotation. This can + contain plain text or structured data, such as JSON. If + omitted, an empty string is used. Optional. + identifier: An identifier used to indicate that an existing + annotation should be updated. Optional. + + Returns: + An annotation point object that can be passed to + system.historian.storeAnnotations. + """ + builder = AnnotationPoint.builder() + return builder.build() + + +def dataPoint( + source, # type: Union[str, unicode] + value, # type: object + timestamp=None, # type: Optional[Date] + quality=None, # type: Optional[int] +): + # type: (...) -> AtomicPoint + """Creates a data point that can be stored to a historian. + + Data points represent individual values associated with a historical + path, timestamp, and quality. + + Args: + source: The historical path where the data point will be stored. + value: The value to be stored in the historian. + timestamp: The timestamp when the data point was recorded. If + omitted, the current time is used. Optional. + quality: The quality code of the data point. If omitted, a + "good" quality is used. Optional. + + Returns: + A data point object that can be passed to + system.historian.storeDataPoints. + """ + return AtomicPoint() + + +def metadataPoint( + source, # type: Union[str, unicode] + properties, # type: Dict[Union[str, unicode], Any] + timestamp, # type: Date +): + # type: (...) -> MetadataPoint + """Creates a metadata point that can be stored to a historian. + + Metadata points allow you to store additional properties associated + with a historical path at a specific point in time. + + Args: + source: The historical path where the metadata point will be + stored. + properties: A dictionary of properties to be stored as + historical metadata. + timestamp: The timestamp when the metadata point was recorded. + + Returns: + A metadata point object that can be passed to + system.historian.storeMetadata. + """ + builder = MetadataPoint.builder() + return builder.build() diff --git a/stubs/requirements.txt b/stubs/requirements.txt index 35c3a2e..5b495c5 100644 --- a/stubs/requirements.txt +++ b/stubs/requirements.txt @@ -1,6 +1,6 @@ # This file was autogenerated by uv via the following command: # uv pip compile --config-file=uv.toml pyproject.toml -java-api-stubs==17.26.0 +java-api-stubs==17.26.5 # via ignition-api-stubs (pyproject.toml) types-enum34==1.1.8 # via ignition-api-stubs (pyproject.toml) diff --git a/stubs/stubs/com/inductiveautomation/historian/__init__.pyi b/stubs/stubs/com/inductiveautomation/historian/__init__.pyi new file mode 100644 index 0000000..e69de29 diff --git a/stubs/stubs/com/inductiveautomation/historian/common/__init__.pyi b/stubs/stubs/com/inductiveautomation/historian/common/__init__.pyi new file mode 100644 index 0000000..e69de29 diff --git a/stubs/stubs/com/inductiveautomation/historian/common/model/__init__.pyi b/stubs/stubs/com/inductiveautomation/historian/common/model/__init__.pyi new file mode 100644 index 0000000..e69de29 diff --git a/stubs/stubs/com/inductiveautomation/historian/common/model/data/__init__.pyi b/stubs/stubs/com/inductiveautomation/historian/common/model/data/__init__.pyi new file mode 100644 index 0000000..1c19bc4 --- /dev/null +++ b/stubs/stubs/com/inductiveautomation/historian/common/model/data/__init__.pyi @@ -0,0 +1,110 @@ +from typing import Any, List, Optional, Union + +from com.inductiveautomation.ignition.common import QualifiedPath +from com.inductiveautomation.ignition.common.config import PropertySet, PropertyValue +from com.inductiveautomation.ignition.common.model.values import QualityCode +from java.lang import Class, Comparable, Enum, Object, Record +from java.time import Instant +from java.util import UUID + +class SnapshotCapable: + def isSnapshot(self) -> bool: ... + def snapshotTime(self) -> Optional[Instant]: ... + def withSnapshot(self, timestamp: Optional[Instant] = ...) -> SnapshotCapable: ... + +class TemporalPoint(Comparable): + def compareTo(self, other: TemporalPoint) -> int: ... + def source(self) -> QualifiedPath: ... + def timestamp(self) -> Instant: ... + def type(self) -> Any: ... + def value(self) -> Any: ... + +class DataPoint(SnapshotCapable, TemporalPoint): + def quality(self) -> QualityCode: ... + def valueClass(self) -> Any: ... + +class AtomicPoint(DataPoint): ... + +class Annotation(Record): + def __init__( + self, + notes: Union[str, unicode], + type_: Union[str, unicode], + author: Union[str, unicode], + ) -> None: ... + def author(self) -> Union[str, unicode]: ... + def notes(self) -> Union[str, unicode]: ... + def type(self) -> Union[str, unicode]: ... + +class AnnotationPoint(Record): + class Builder(Object): + def __init__(self) -> None: ... + def annotationType( + self, annotationType: Union[str, unicode] + ) -> AnnotationPoint.Builder: ... + def author(self, author: Union[str, unicode]) -> AnnotationPoint.Builder: ... + def build(self) -> AnnotationPoint: ... + def endTime(self, endTime: Instant) -> AnnotationPoint.Builder: ... + def identifier( + self, identifier: Union[UUID, str, unicode] + ) -> AnnotationPoint.Builder: ... + def lastUpdated(self, lastUpdated: Instant) -> AnnotationPoint.Builder: ... + def notes(self, notes: Union[str, unicode]) -> AnnotationPoint.Builder: ... + def source(self, source: QualifiedPath) -> AnnotationPoint.Builder: ... + def startTime(self, startTime: Instant) -> AnnotationPoint.Builder: ... + + def __init__( + self, + identifier: UUID, + source: QualifiedPath, + value: Annotation, + startTime: Instant, + endTime: Optional[Instant] = ..., + lastUpdated: Optional[Instant] = ..., + ) -> None: ... + @staticmethod + def builder() -> AnnotationPoint.Builder: ... + def endTime(self) -> Optional[Instant]: ... + def identifier(self) -> UUID: ... + def lastUpdated(self) -> Optional[Instant]: ... + def source(self) -> QualifiedPath: ... + def startTime(self) -> Instant: ... + def timestamp(self) -> Instant: ... + def type(self) -> StandardComplexPointType: ... + def value(self) -> Annotation: ... + def withSource(self, source: QualifiedPath) -> AnnotationPoint: ... + +class MetadataPoint(Record, TemporalPoint): + class Builder(Object): + def __init__(self) -> None: ... + def addValue(self, value: PropertyValue) -> MetadataPoint.Builder: ... + def build(self) -> MetadataPoint: ... + def quality(self, quality: QualityCode) -> MetadataPoint.Builder: ... + def source(self, source: QualifiedPath) -> MetadataPoint.Builder: ... + def timestamp(self, timestamp: Instant) -> MetadataPoint.Builder: ... + def values(self, values: PropertySet) -> MetadataPoint.Builder: ... + + def __init__( + self, + value: PropertySet, + quality: QualityCode, + timestamp: Instant, + source: QualifiedPath, + ) -> None: ... + @staticmethod + def builder( + metadataPoint: Optional[MetadataPoint] = ..., + ) -> MetadataPoint.Builder: ... + @staticmethod + def empty(source: QualifiedPath) -> MetadataPoint: ... + def quality(self) -> QualityCode: ... + def withSource(self, source: QualifiedPath) -> MetadataPoint: ... + +class StandardComplexPointType(Enum): + ANNOTATION: StandardComplexPointType + GENERIC: StandardComplexPointType + METADATA: StandardComplexPointType + def getPointClass(self) -> Class: ... + def getQueryOptionsClass(self) -> Class: ... + @staticmethod + def values() -> List[StandardComplexPointType]: ... diff --git a/stubs/stubs/system/historian/__init__.pyi b/stubs/stubs/system/historian/__init__.pyi new file mode 100644 index 0000000..500c296 --- /dev/null +++ b/stubs/stubs/system/historian/__init__.pyi @@ -0,0 +1,50 @@ +from typing import Any, List, Optional, Union + +from com.inductiveautomation.ignition.common import BasicDataset +from com.inductiveautomation.ignition.common.browsing import Results +from com.inductiveautomation.ignition.common.model.values import BasicQualifiedValue +from java.util import Date + +def browse(rootPath: Union[str, unicode], *args: Any, **kwargs: Any) -> Results: ... +def deleteAnnotations( + paths: List[Union[str, unicode]], storageIds: List[Union[str, unicode]] +) -> List[BasicQualifiedValue]: ... +def queryAggregatedPoints( + paths: List[Union[str, unicode]], + startTime: Optional[Date] = ..., + endTime: Optional[Date] = ..., + aggregates: Optional[List[Union[str, unicode]]] = ..., + fillModes: Optional[List[Union[str, unicode]]] = ..., + columnNames: Optional[List[Union[str, unicode]]] = ..., + returnFormat: str = ..., + returnSize: int = ..., + includeBounds: bool = ..., + excludeObservations: bool = ..., +) -> BasicDataset: ... +def queryAnnotations( + paths: List[Union[str, unicode]], + startDate: Optional[Date] = ..., + endDate: Optional[Date] = ..., + allowedTypes: Optional[List[Union[str, unicode]]] = ..., +) -> Results: ... +def queryMetadata( + paths: List[Union[str, unicode]], + startDate: Optional[Date] = ..., + endDate: Optional[Date] = ..., +) -> Results: ... +def queryRawPoints( + paths: List[Union[str, unicode]], + startTime: Optional[Date] = ..., + endTime: Optional[Date] = ..., + columnNames: Optional[List[Union[str, unicode]]] = ..., + returnFormat: str = ..., + returnSize: int = ..., + includeBounds: bool = ..., + excludeObservations: bool = ..., +) -> BasicDataset: ... +def storeAnnotations(*args: Any, **kwargs: Any) -> List[BasicQualifiedValue]: ... +def storeDataPoints(*args: Any, **kwargs: Any) -> List[BasicQualifiedValue]: ... +def storeMetadata(*args: Any, **kwargs: Any) -> List[BasicQualifiedValue]: ... +def updateRegisteredNodePath( + previousPath: Union[str, unicode], currentPath: Union[str, unicode] +) -> List[BasicQualifiedValue]: ... diff --git a/stubs/stubs/system/historian/types.pyi b/stubs/stubs/system/historian/types.pyi new file mode 100644 index 0000000..d7cfa06 --- /dev/null +++ b/stubs/stubs/system/historian/types.pyi @@ -0,0 +1,28 @@ +from typing import Any, Dict, Optional, Union + +from com.inductiveautomation.historian.common.model.data import ( + AnnotationPoint, + AtomicPoint, + MetadataPoint, +) +from java.util import Date + +def annotationPoint( + source: Union[str, unicode], + startTime: Date, + endTime: Optional[Date] = ..., + annotationType: Optional[Union[str, unicode]] = ..., + data: Optional[Union[str, unicode]] = ..., + identifier: Optional[Union[str, unicode]] = ..., +) -> AnnotationPoint: ... +def dataPoint( + source: Union[str, unicode], + value: object, + timestamp: Optional[Date] = ..., + quality: Optional[int] = ..., +) -> AtomicPoint: ... +def metadataPoint( + source: Union[str, unicode], + properties: Dict[Union[str, unicode], Any], + timestamp: Date, +) -> MetadataPoint: ...