Last change
on this file since 206 was
206,
checked in by jemian, 13 years ago
|
indentation
|
-
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 | ''' |
---|
4 | log EPICS data into RRD files |
---|
5 | ''' |
---|
6 | |
---|
7 | ########### SVN repository information ################### |
---|
8 | # $Date: 2010-08-18 20:28:25 +0000 (Wed, 18 Aug 2010) $ |
---|
9 | # $Author: jemian $ |
---|
10 | # $Revision: 206 $ |
---|
11 | # $HeadURL$ |
---|
12 | # $Id: rrd_pv.py 206 2010-08-18 20:28:25Z jemian $ |
---|
13 | ########### SVN repository information ################### |
---|
14 | |
---|
15 | #------------------------------------------------------------- |
---|
16 | |
---|
17 | import os |
---|
18 | import time |
---|
19 | import sys |
---|
20 | import pprint |
---|
21 | import rrdtool # direct calls to rrd tools |
---|
22 | import pvwatch # local support to monitor EPICS PVs |
---|
23 | |
---|
24 | #------------------------------------------------------------- |
---|
25 | |
---|
26 | |
---|
27 | class 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.