From daee9b48ac6bbc42e1bd406dc4a1c138cb19d257 Mon Sep 17 00:00:00 2001 From: Anthony LaTorre Date: Thu, 9 Jun 2011 20:46:59 -0400 Subject: you can now take data using sequence mode! also, updated the README file to include more examples. sock.py now replaces scope.py. sock.py is almost identical, but i renamed the class to Socket and fixed it so that data headers are properly received; previously, it was assumed that the 8 byte header was sent in a single recv() call, which is not always the case. draw.py is a new script to draw waveforms using matplotlib instead of root. --- lecroy.py | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) (limited to 'lecroy.py') diff --git a/lecroy.py b/lecroy.py index 31c282e..22e4f13 100644 --- a/lecroy.py +++ b/lecroy.py @@ -20,7 +20,7 @@ import array import StringIO import struct import numpy as np -import scope +import sock # data types in lecroy binary blocks, where: # length -- byte length of type @@ -123,21 +123,12 @@ wavedesc_template = ( ('descriptor_name' , 0 , String), ('acq_vert_offset' , 340 , Float), ('wave_source' , 344 , Enum) ) -class LeCroyScope(scope.Scope): +class LeCroyScope(sock.Socket): """ A class for triggering and fetching waveforms from the oscilloscope. - - .. note:: - - You must call connect() on the object before fetching waveforms. """ - def __init__(self, host, port=1861, timeout=2.0): - super(LeCroyScope, self).__init__(host, port, timeout) - - def connect(self): - """Connect to the oscilloscope.""" - super(LeCroyScope, self).connect() - # initialize some parameters + def __init__(self, *args, **kwargs): + super(LeCroyScope, self).__init__(*args, **kwargs) self.send('comm_header short') self.check_last_command() self.send('comm_format DEF9,BYTE,BIN') @@ -160,7 +151,7 @@ class LeCroyScope(scope.Scope): if channel not in range(1, 5): raise Exception('channel must be in %s.' % str(range(1, 5))) - self.send('c%s:wf? all' % str(channel)) + self.send('c%s:wf? desc' % str(channel)) msg = self.recv() if not int(msg[1]) == channel: @@ -207,8 +198,8 @@ class LeCroyScope(scope.Scope): def getwaveform(self, channel, wavedesc): """ - Request, process, and return the x and y arrays for channel number - *channel* from the oscilloscope. + Request, process, and return the voltage array for channel number + `channel` from the oscilloscope as a numpy array. """ if channel not in range(1, 5): -- cgit