1 # stripchart - tools for quick and dirty data plotting.
3 # Copyright (C) 2008-2009 William Trevor King
5 # This program is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU General Public License as
7 # published by the Free Software Foundation; either version 3 of the
8 # License, or (at your option) any later version.
10 # This program is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 # See the GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
20 # The author may be contacted at <wking@drexel.edu> on the Internet, or
21 # write to Trevor King, Drexel University, Physics Dept., 3141 Chestnut St.,
22 # Philadelphia PA 19104, USA.
27 def __init__(self, pipename='strip_pipe', maxY=10, minY=-10,
28 npoints=100, title='chart', axes=True) :
29 self.pipename = pipename
32 self.npoints = npoints
35 self.status = 'closed'
39 def open(self, debug=False) :
40 if self.status == 'closed' :
41 os.mkfifo(self.pipename)
42 cmd = "stripchart -t '%s' -p '%s' -u -M '%g' -m '%g' -n '%d'" % \
43 (self.title, self.pipename, self.maxY, self.minY,
45 if self.axes == False :
51 self.pipe = open(self.pipename,'w')
54 if self.status == 'open' :
55 print >> self.pipe, "q"
58 self.status = 'closed'
59 def _add_point(self, point) :
60 print >> self.pipe, point
63 def add_point(self, point) :
64 self._add_point(point)