source: pvrrd/src/pvrrd/rrd_pv.py @ 619

Last change on this file since 619 was 619, checked in by jemian, 12 years ago

relocate to more standard layout

  • Property :svn_eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Date Author Revision Url Id
File size: 1.3 KB
Line 
1#!/usr/bin/env python
2
3'''
4log EPICS data into RRD files
5'''
6
7########### SVN repository information ###################
8# $Date: 2011-08-21 13:24:14 +0000 (Sun, 21 Aug 2011) $
9# $Author: jemian $
10# $Revision: 619 $
11# $HeadURL$
12# $Id: rrd_pv.py 619 2011-08-21 13:24:14Z jemian $
13########### SVN repository information ###################
14
15#-------------------------------------------------------------
16
17import os
18import time
19import sys
20import pprint
21import rrdtool      # direct calls to rrd tools
22import pvwatch      # local support to monitor EPICS PVs
23
24#-------------------------------------------------------------
25
26
27class rrd_pv:
28    '''coordination between an EPICS PV and a RRD database'''
29
30    rrd = None         # corresponding rrd database for this channel
31    name = None        # EPICS PV name
32    pv = None          # EPICS channel object
33
34    def __init__(self, name, rrd_database_file):
35        # define the RRD database file name
36        self.rrd = rrd_database_file
37
38        # start the connection with the EPICS process variable
39        self.pv = pvwatch.pvwatch(name)
40
41    def update(self):
42        '''write the current EPICS value to the RRD database'''
43        s = 'N:'+repr(self.pv.value).strip()
44        rrdtool.update(self.rrd, s)
45
46    def __str__(self):
47        p = "%s" % self.pv
48        r = ""
49        if not self.rrd == None:
50            r = "%s" % rrdtool.info(self.rrd)['last_update']
51        return "%s %s" % (p, r)
Note: See TracBrowser for help on using the repository browser.