In [1]:
from bsread import source
from bsread import SUB
from bsread import PULL

In [2]:
with source(channels=['UInt16Waveform'], dispatcher_url='http://localhost:8080', mode=PULL) as stream:
    for i in range(10):
        message = stream.receive()
        print(message.data.data['UInt16Waveform'].value[0])
        print(message.data.__dict__)
print('done')


12730
{'format_changed': True, 'pulse_id': 147557593530, 'global_timestamp': 1475575935, 'global_timestamp_offset': 303593534, 'data': OrderedDict([('UInt16Waveform', <bsread.handlers.compact.Value object at 0x10913c4a8>)])}
12731
{'format_changed': False, 'pulse_id': 147557593531, 'global_timestamp': 1475575935, 'global_timestamp_offset': 313593535, 'data': OrderedDict([('UInt16Waveform', <bsread.handlers.compact.Value object at 0x1091277f0>)])}
12732
{'format_changed': False, 'pulse_id': 147557593532, 'global_timestamp': 1475575935, 'global_timestamp_offset': 323593536, 'data': OrderedDict([('UInt16Waveform', <bsread.handlers.compact.Value object at 0x109133128>)])}
12733
{'format_changed': False, 'pulse_id': 147557593533, 'global_timestamp': 1475575935, 'global_timestamp_offset': 333593537, 'data': OrderedDict([('UInt16Waveform', <bsread.handlers.compact.Value object at 0x109133198>)])}
12734
{'format_changed': False, 'pulse_id': 147557593534, 'global_timestamp': 1475575935, 'global_timestamp_offset': 343593538, 'data': OrderedDict([('UInt16Waveform', <bsread.handlers.compact.Value object at 0x109133cc0>)])}
12735
{'format_changed': False, 'pulse_id': 147557593535, 'global_timestamp': 1475575935, 'global_timestamp_offset': 353593539, 'data': OrderedDict([('UInt16Waveform', <bsread.handlers.compact.Value object at 0x109133c88>)])}
12736
{'format_changed': False, 'pulse_id': 147557593536, 'global_timestamp': 1475575935, 'global_timestamp_offset': 363593540, 'data': OrderedDict([('UInt16Waveform', <bsread.handlers.compact.Value object at 0x109133c50>)])}
12737
{'format_changed': False, 'pulse_id': 147557593537, 'global_timestamp': 1475575935, 'global_timestamp_offset': 373593541, 'data': OrderedDict([('UInt16Waveform', <bsread.handlers.compact.Value object at 0x109133128>)])}
12738
{'format_changed': False, 'pulse_id': 147557593538, 'global_timestamp': 1475575935, 'global_timestamp_offset': 383593542, 'data': OrderedDict([('UInt16Waveform', <bsread.handlers.compact.Value object at 0x1091276a0>)])}
12739
{'format_changed': False, 'pulse_id': 147557593539, 'global_timestamp': 1475575935, 'global_timestamp_offset': 393593543, 'data': OrderedDict([('UInt16Waveform', <bsread.handlers.compact.Value object at 0x10914a400>)])}
done

In [3]:
import numpy

xar = numpy.arange(50)
yar = numpy.random.rand(50)
yar.dtype


Out[3]:
dtype('float64')

In [4]:
%matplotlib
import matplotlib.pyplot as plt
import time
import random

fig = plt.figure()
ax1 = fig.add_subplot(1,1,1)

# line1 = ax1.plot(xar, yar)
# plt.show()

# plt.axis([0, 10, 0, 1])
# plt.ion()


Using matplotlib backend: MacOSX

In [5]:
count = 0
with source(channels=['Float64Waveform'], dispatcher_url='http://localhost:8080', mode=PULL) as stream:
    for i in range(1000):
        message = stream.receive()
        value = message.data.data['Float64Waveform'].value[0]
#         line1.append(value)
#         print(value)
        yar[(count%50)] = value
#         if (count % 200) == 0:
#             print('plot')
#             ax1.clear()
#             ax1.plot(xar, yar)
        count += 1
#         plt.scatter(count, value)
        ax1.scatter(count,value)
        if count % 100 == 0:
            plt.pause(0.001)
#         if count % 200 == 0:
#             ax1.clear()
#         line1.set_data(message.data.data['UInt16Waveform'].value)
print('done')


'type' channel field not found. Parse as 64-bit floating-point number (default).
done

In [ ]:
from bsread import source
with source(channels=['SINEG01-RGUN-PUP10:SIG-AMPLT-AVG', 'SINEG01-RGUN-PUP20:SIG-AMPLT-AVG']) as stream:
    for i in range(10):
        message = stream.receive()
        print(message)
print('done')


tcp://sf-daqbuf-23.psi.ch:52928

In [5]:
line1.append


Out[5]:
[<matplotlib.lines.Line2D at 0x10f35b198>]

In [29]:
plt.gca()


Out[29]:
<matplotlib.axes._subplots.AxesSubplot at 0x113220be0>

In [53]:
axis = ax1.plot(yar+30)

In [54]:
ax1.clear()

In [47]:
plt.pause(0.01)

In [9]:


In [ ]: