コード例 #1
0
    def search(self, query, source=None):
        """search

        Search PIPoints on the PIServer

        Args:
            query (str or [str]): String or list of strings with queries
            source (str, optional): Defaults to None. Point source to limit the results

        Returns:
            list: A list of :class:`PIPoint` objects as a result of the query

        .. todo::

            Reject searches while not connected
        """
        if isinstance(query, list):
            return [y for x in query for y in self.search(x, source)]
        # elif not isinstance(query, str):
        #     raise TypeError('Argument query must be either a string or a list of strings,' +
        #                     'got type ' + str(type(query)))
        return [
            PIPoint(pi_point)
            for pi_point in AF.PI.PIPoint.FindPIPoints(
                self.connection, BuiltinStr(query), source, None
            )
        ]
コード例 #2
0
ファイル: _operators.py プロジェクト: tangethan79/PIconnect
    def build_operator_method(method, operator, docstring, cls):
        """Return a method definition for a numerical operator.

        Keyword arguments:
        method -- name of the operator method of a subclass of *cls*, will used for
                  <operator>.__name__ for clean output in the class documentation.
        operator -- function of two arguments that is applied to the original function
                    result and a given operand.
        docstring -- docstring for the new operator method.
        cls -- class of which the new dynamic class will be subclassed.
        """
        def patch_members(self, other):
            """Return new object of class *newclassname* with patched members.

               Creates a new virtual class with the members in *members* patched to apply
               the given *operator* to the original function definition.
            """
            newmembers = {
                member: decorate(decorator=operate,
                                 base=getattr(self, member),
                                 operator=operator,
                                 operand=other)
                for member in members
            }
            newclass = type(BuiltinStr(newclassname), (cls, ), newmembers)
            return newclass(*[getattr(self, attr) for attr in attributes])

        patch_members.__name__ = BuiltinStr(method)
        patch_members.__doc__ = docstring
        return patch_members
コード例 #3
0
ファイル: _operators.py プロジェクト: tangethan79/PIconnect
        def patch_members(self, other):
            """Return new object of class *newclassname* with patched members.

               Creates a new virtual class with the members in *members* patched to apply
               the given *operator* to the original function definition.
            """
            newmembers = {
                member: decorate(decorator=operate,
                                 base=getattr(self, member),
                                 operator=operator,
                                 operand=other)
                for member in members
            }
            newclass = type(BuiltinStr(newclassname), (cls, ), newmembers)
            return newclass(*[getattr(self, attr) for attr in attributes])
コード例 #4
0
    def search(self, query, source=None):
        """Search for tags on the connected PI server

           PI Points are matched to *query*, which can be provided as a string or
           a list of strings. In either case a single, unnested, list of
           PIconnect.PI.PIPoints is returned.
        """
        if isinstance(query, list):
            return [y for x in query for y in self.search(x, source)]
        # elif not isinstance(query, str):
        #     raise TypeError('Argument query must be either a string or a list of strings,' +
        #                     'got type ' + str(type(query)))
        return [
            PIPoint(pi_point) for pi_point in AF.PI.PIPoint.FindPIPoints(
                self.connection, BuiltinStr(query), source, None)
        ]
コード例 #5
0
    str,
    super,
    zip,
)
from datetime import datetime

# pragma pylint: enable=unused-import

try:
    from abc import ABC, abstractmethod
except ImportError:
    from abc import ABCMeta, abstractmethod

    from __builtin__ import str as BuiltinStr

    ABC = ABCMeta(BuiltinStr("ABC"), (object, ), {"__slots__": ()})

from pandas import DataFrame, Series

from PIconnect.AFSDK import AF
from PIconnect.PIConsts import (
    BufferMode,
    CalculationBasis,
    ExpressionSampleType,
    RetrievalMode,
    SummaryType,
    TimestampCalculation,
    UpdateMode,
    get_enumerated_value,
)
from PIconnect.time import timestamp_to_index, to_af_time_range, to_af_time