webapi.py 文件源码

python
阅读 47 收藏 0 点赞 0 评论 0

项目:osisoftpy 作者: dstcontrols 项目源码 文件源码
def subscribe(self, points, stream, startdatetime=None, enddatetime=None, callback=None):
        """Monitor whenever the PI point is read and an update has occurred. 
        Trigger the callback function when the value changes

        :param Points points: List of Point objects to start monitoring
        :param string stream: Name of the reading method used for monitoring the point. 
            Options are current, interpolatedattimes, recordedattime, end
        :param string startdatetime: Optional – Timestamp for when to start monitoring
        :param string enddatetime: Optional – Timestamp for when to stop monitoring
        :param func callback: Reference to the function to trigger when an update occurs
        """
        if not isinstance(points, Points):
            raise TypeError('The object "{}" is not of type "{}"'.format(
                points, Points))
        for p in points:
            formattedstartdate = self._parse_timestamp(startdatetime)
            formattedenddate = self._parse_timestamp(enddatetime)

            signalkey = '{}/{}/{}{}'.format(p.webid.__str__(), stream, formattedstartdate or '', formattedenddate or '')
            if signalkey not in self.signals:
                s = blinker.signal(signalkey)
                self.signals[signalkey] = s
                if callback:
                    self.signals[signalkey].connect(callback)
        return self.signals
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号