|
| 1 | +# This file is part of the SmuView project. |
| 2 | +# |
| 3 | +# Copyright (C) 2021 Frank Stettner <frank-stettner@gmx.net> |
| 4 | +# |
| 5 | +# Permission is hereby granted, free of charge, to any person obtaining a copy |
| 6 | +# of this software and associated documentation files (the "Software"), to deal |
| 7 | +# in the Software without restriction, including without limitation the rights |
| 8 | +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 9 | +# copies of the Software, and to permit persons to whom the Software is |
| 10 | +# furnished to do so, subject to the following conditions: |
| 11 | +# |
| 12 | +# The above copyright notice and this permission notice shall be included in all |
| 13 | +# copies or substantial portions of the Software. |
| 14 | +# |
| 15 | +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 16 | +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 17 | +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 18 | +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 19 | +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 20 | +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 21 | +# SOFTWARE. |
| 22 | + |
| 23 | +# |
| 24 | +# Test script to reproduce the bug fixed in PR #30 |
| 25 | +# |
| 26 | + |
| 27 | +import smuview |
| 28 | +import time |
| 29 | + |
| 30 | +# Add user device and 2 channels. |
| 31 | +user_device = Session.add_user_device() |
| 32 | +ch1 = user_device.add_user_channel("CH1", "") |
| 33 | +ch2 = user_device.add_user_channel("CH2", "") |
| 34 | + |
| 35 | +start_ts = time.time() |
| 36 | + |
| 37 | +# Push initial sample data. |
| 38 | +ch1.push_sample(1, start_ts+1, smuview.Quantity.Voltage, set(), smuview.Unit.Volt, 4, 2) |
| 39 | +ch1.push_sample(2, start_ts+3, smuview.Quantity.Voltage, set(), smuview.Unit.Volt, 4, 2) |
| 40 | +ch1.push_sample(3, start_ts+5, smuview.Quantity.Voltage, set(), smuview.Unit.Volt, 4, 2) |
| 41 | +ch1.push_sample(4, start_ts+7, smuview.Quantity.Voltage, set(), smuview.Unit.Volt, 4, 2) |
| 42 | +ch2.push_sample(10, start_ts+8, smuview.Quantity.Voltage, set(), smuview.Unit.Volt, 4, 2) |
| 43 | + |
| 44 | +# Add a xy-plot to get AnalogTimeSignal::combine_signals() called and force the error. |
| 45 | +# Without the fix from PR #30 SmuView will get stuck in an infinite loop! |
| 46 | +tab = UiProxy.add_device_tab(user_device) |
| 47 | +plot = UiProxy.add_xy_plot_view(tab, smuview.DockArea.TopDockArea) |
| 48 | +curve = UiProxy.add_curve_to_xy_plot_view(tab, plot, ch1.actual_signal(), ch2.actual_signal()) |
| 49 | + |
| 50 | +# Push more data. |
| 51 | +ch1.push_sample(5, start_ts+9, smuview.Quantity.Voltage, set(), smuview.Unit.Volt, 4, 2) |
| 52 | +ch2.push_sample(9, start_ts+10, smuview.Quantity.Voltage, set(), smuview.Unit.Volt, 4, 2) |
0 commit comments