Exemple #1
0
def main():
    input_layer = prt.InputLayer(gen_dummy_data, rate=RATE, name="dummy input", print_fps=True)
    split_layer = prt.TransformLayer(input_layer, transformer=decoder, name="transformer", multi_output=True)

    fm = prt.FigureManager(create_fig=create_fig, fps=40)
    prt.TimePlotLayer(split_layer.get_port('x1'), plot_key='x1', window_size=1000, plot_config=plot_config, fig_manager=fm)
    prt.TimePlotLayer(split_layer.get_port('x2'), plot_key='x2', window_size=1000, n_channels=3, plot_config=plot_config, fig_manager=fm, legend=True)
    prt.TimePlotLayer(split_layer.get_port('x3'), plot_key='x3', window_size=1000, plot_config=plot_config, fig_manager=fm)
    prt.TimePlotLayer(split_layer.get_port('x4'), plot_key='x4', window_size=1000, plot_config=plot_config, fig_manager=fm)
    prt.TimePlotLayer(split_layer.get_port('x5'), plot_key='x5', window_size=1000, plot_config=plot_config, fig_manager=fm)

    prt.LayerManager.session().run()
def get_device_data(show_plot=True, buffer_size=BUFFER_SIZE):
    serial_port = serial.Serial(prt.find_serial_port(PORT), BAUD, timeout=5)
    serial_buffer = prt.FixedBuffer(buffer_size,
                                    use_np=True,
                                    shape=(RX_CHANNELS + 2, ),
                                    axis=0)
    raw_data = prt.ByteSerialReadLayer.from_port(serial=serial_port,
                                                 decoder=process,
                                                 print_fps=True,
                                                 preamble=b'UW',
                                                 num_bytes=17,
                                                 buffer=serial_buffer,
                                                 multi_output=False)
    split_data = split(raw_data)
    # prt.PrintLayer(raw_data)
    if show_plot:
        fm = prt.FigureManager(fps=10000)
        if DEMO:
            filtered = prt.ExponentialFilter(split_data.get_port("adc"),
                                             alpha=.1,
                                             batch=True)
            prt.TimePlotLayer(filtered,
                              window_size=5000,
                              n_channels=RX_CHANNELS,
                              ylim=(0, 0.2),
                              lw=3,
                              fig_manager=fm)
        else:
            # import scipy.signal
            # # filtered = prt.ExponentialFilter(split_data.get_port("adc"), alpha=1, batch=True)
            # prt.TimePlotLayer(split_data.get_port("adc"), window_size=5000, n_channels=RX_CHANNELS, ylim=(0, 1), lw=1, fig_manager=fm)
            # sos = scipy.signal.butter(5, [25,55], fs=472, btype="bandpass", output='sos')
            # filtered = prt.SOSFilter(split_data.get_port("adc"), sos, axis=0, shape=(9,))
            # energy = get_energy(filtered)
            #
            # prt.TimePlotLayer(energy, window_size=1000, n_channels=1, ylim=(0, .00005), lw=1)#, fig_manager=fm)
            # filtered2 = prt.ExponentialFilter(energy, alpha=.3, batch=True)
            # prt.TimePlotLayer(filtered2, window_size=1000, n_channels=1, ylim=(0, .00005), lw=1)#, fig_manager=fm)
            # # prt.Spectrogram(get_channel(filtered))
            # taps = get_taps(filtered2)
            # prt.TextPlotLayer(taps)

            prt.TimePlotLayer(split_data.get_port("adc"),
                              window_size=5000,
                              n_channels=RX_CHANNELS,
                              ylim=(-0.1, 1),
                              lw=1,
                              fig_manager=fm)
            # prt.TimePlotLayer(diff(split_data.get_port("frame_num")), window_size=5000, n_channels=2, ylim=(0, 5), lw=1)

    return raw_data, split_data.get_port("adc")
def main():
    # Set up TCP server on port 9903
    reader, writer = prt.make_tcp_server(local_host='0.0.0.0', local_port=9903)

    # Parse data coming from the client
    parsed = parse_data(reader)

    # Create figure with two subplots
    fm = prt.FigureManager(create_fig=create_fig)

    # Add two plots to figure, using .get_port to access a specific element of the dictionary
    prt.TimePlotLayer(parsed.get_port("p1"),
                      plot_key="ax1",
                      fig_manager=fm,
                      ylim=(0, 10))
    prt.TimePlotLayer(parsed.get_port("p2"),
                      plot_key="ax2",
                      fig_manager=fm,
                      ylim=(0, 10))

    prt.LayerManager.session().run()
Exemple #4
0
def main():
    raw_data = prt.InputLayer(gen_dummy_data, rate=5000, name="dummy input")
    decode_layer = prt.TransformLayer(raw_data,
                                      transformer=decode,
                                      name="decode_layer",
                                      multi_output=True)

    fig_manager = prt.FigureManager(create_fig=create_fig)
    prt.TimePlotLayer(decode_layer.get_port('x1'),
                      plot_key='x1',
                      window_size=1000,
                      ylim=(0, 100),
                      fig_manager=fig_manager)
    prt.BarPlotLayer(decode_layer.get_port('x2'),
                     plot_key='x2',
                     ylim=(0, 100),
                     fig_manager=fig_manager)
    prt.LayerManager.session().run()
def playback_device_data(key, show_plot=True, strip_frame_num=True):
    filename = os.path.join(DATA_ROOT, "recordings", f"mag_{key}.txt")
    if not os.path.exists(filename):
        filename = f"mag_{key}.txt"
    data = prt.PlaybackLayer(filename,
                             rate=59,
                             decoder=decode_mag_file,
                             print_fps=True,
                             loop=True)
    if strip_frame_num:
        split_data = split(data)
        adc = split_data.get_port("adc")
    else:
        adc = data

    if show_plot:
        fm = prt.FigureManager(fps=10000)
        prt.TimePlotLayer(split_data.get_port("adc"),
                          window_size=5000,
                          n_channels=RX_CHANNELS,
                          ylim=(-0.1, 1),
                          lw=1,
                          fig_manager=fm)
    return data, adc
Exemple #6
0
def main():
    serial_layer = prt.InputLayer(gen_dummy_data, rate=30, name="dummy input")
    # serial_layer = prt.SerialReadLayer(device_name='KitProg', baud_rate=115200)
    prt.TimePlotLayer(serial_layer, buffer_size=100, ylim=(0, 100))
    prt.LayerManager.session().run()
Exemple #7
0
import pyrealtime as prt

if __name__ == '__main__':
    s = prt.SerialReadLayer(device_name='COM3', baud_rate=115200)
    prt.TimePlotLayer(s, window_size=50, ylim=(-10, 500))
    prt.LayerManager.session().run()
Exemple #8
0
def main():
    for target in [20, 40, 60]:
        in_layer = CounterLayer(target=target)
        prt.PrintLayer(in_layer)
        prt.TimePlotLayer(in_layer, buffer_size=10, ylim=(0, 100))
        prt.LayerManager.session().run()
Exemple #9
0
def main():
    serial_layer = prt.InputLayer(gen_dummy_data)
    prt.PrintLayer(serial_layer)
    prt.TimePlotLayer(serial_layer, buffer_size=10, ylim=(0, 1000))
    prt.LayerManager.session().run()
Exemple #10
0
def main():
    raw_data = prt.UDPReadLayer(name="input")
    prt.TimePlotLayer(raw_data, buffer_size=5, ylim=(0, 100))
    prt.LayerManager.session().run()