- oscilloscope screen labels added
- artifacts on the edge of the scope screen fixed
This commit is contained in:
		
							parent
							
								
									3b09caaeb0
								
							
						
					
					
						commit
						73a903b976
					
				@ -16,13 +16,14 @@ MultiStreamOscilloscope::MultiStreamOscilloscope() {
 | 
				
			|||||||
    mFIFOBlockCnt = 0;
 | 
					    mFIFOBlockCnt = 0;
 | 
				
			||||||
    mCaptureLength = 0;
 | 
					    mCaptureLength = 0;
 | 
				
			||||||
    mPreTriggerSamples = 0;
 | 
					    mPreTriggerSamples = 0;
 | 
				
			||||||
 | 
					    mDrawMarginSamples = DRAW_WINDOW_MARGIN_DEF;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void MultiStreamOscilloscope::setup(const std::vector<in_addr_t> &nodes, const AcquisitionFormat &acqFmt) {
 | 
					void MultiStreamOscilloscope::setup(const std::vector<in_addr_t> &nodes, const AcquisitionFormat &acqFmt) {
 | 
				
			||||||
    MultiStreamProcessor::setup(nodes, acqFmt);
 | 
					    MultiStreamProcessor::setup(nodes, acqFmt);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // calculate buffer parameters
 | 
					    // calculate buffer parameters
 | 
				
			||||||
    mCaptureLength = ceil(mCapturePeriod_ns / 1E+09 * acqFmt.sampling_rate_Hz); // calculate draw window period in samples
 | 
					    mCaptureLength = ceil(mCapturePeriod_ns / 1E+09 * acqFmt.sampling_rate_Hz) + 2 * mDrawMarginSamples; // calculate draw window period in samples
 | 
				
			||||||
    mFIFOBlockCnt = 10 * ceil(mCaptureLength / acqFmt.mch_samples_per_packet); // TODO magic...
 | 
					    mFIFOBlockCnt = 10 * ceil(mCaptureLength / acqFmt.mch_samples_per_packet); // TODO magic...
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // setup channel buffers
 | 
					    // setup channel buffers
 | 
				
			||||||
@ -215,9 +216,6 @@ std::vector<std::vector<MultiStreamOscilloscope::SamplePoint>> MultiStreamOscill
 | 
				
			|||||||
        mTrigState.samplesReady = false;
 | 
					        mTrigState.samplesReady = false;
 | 
				
			||||||
        return mCaptureBuffers;
 | 
					        return mCaptureBuffers;
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
        if (mTrigState.autoTrigger) {
 | 
					 | 
				
			||||||
            mTrigState.trigd = true; // trigger if auto-trigger is enabled
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        return {};
 | 
					        return {};
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -17,6 +17,7 @@ public:
 | 
				
			|||||||
    static constexpr size_t DRAW_WINDOW_PERIOD_NS_DEF = 50E+06; // default window length (50ms)
 | 
					    static constexpr size_t DRAW_WINDOW_PERIOD_NS_DEF = 50E+06; // default window length (50ms)
 | 
				
			||||||
    static constexpr double VOLT_PER_BIN_DEF = 42.80E-06; // default vertical resolution
 | 
					    static constexpr double VOLT_PER_BIN_DEF = 42.80E-06; // default vertical resolution
 | 
				
			||||||
    static constexpr size_t TRIGGER_POS_PERCENT_DEF = 50; // trigger position is defaulted to the screen center
 | 
					    static constexpr size_t TRIGGER_POS_PERCENT_DEF = 50; // trigger position is defaulted to the screen center
 | 
				
			||||||
 | 
					    static constexpr ssize_t DRAW_WINDOW_MARGIN_DEF = 10; // size of margin on each end of the sample capture buffer
 | 
				
			||||||
public:
 | 
					public:
 | 
				
			||||||
    struct SamplePoint {
 | 
					    struct SamplePoint {
 | 
				
			||||||
        int64_t t; // time
 | 
					        int64_t t; // time
 | 
				
			||||||
@ -46,6 +47,7 @@ public: // graphical displaying related things
 | 
				
			|||||||
    size_t mTriggerPosition_percent; // trigger position on the screen
 | 
					    size_t mTriggerPosition_percent; // trigger position on the screen
 | 
				
			||||||
    size_t mTriggerProbeBlock_idx; // index of block on which trigger will run
 | 
					    size_t mTriggerProbeBlock_idx; // index of block on which trigger will run
 | 
				
			||||||
    size_t mPreTriggerSamples; // samples displayed before the trigger point
 | 
					    size_t mPreTriggerSamples; // samples displayed before the trigger point
 | 
				
			||||||
 | 
					    ssize_t mDrawMarginSamples; // margin to avoid artifacts on the screen's edge
 | 
				
			||||||
    size_t mCapturePeriod_ns; // (drawing window) screen period
 | 
					    size_t mCapturePeriod_ns; // (drawing window) screen period
 | 
				
			||||||
public:
 | 
					public:
 | 
				
			||||||
    std::shared_ptr<TriggerSettings> trigger; // trigger settings
 | 
					    std::shared_ptr<TriggerSettings> trigger; // trigger settings
 | 
				
			||||||
 | 
				
			|||||||
@ -1,6 +1,8 @@
 | 
				
			|||||||
import time
 | 
					import time
 | 
				
			||||||
import sys
 | 
					import sys
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import matplotlib.ticker
 | 
				
			||||||
 | 
					
 | 
				
			||||||
sys.path.extend(['../module'])
 | 
					sys.path.extend(['../module'])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import pywfs
 | 
					import pywfs
 | 
				
			||||||
@ -11,8 +13,9 @@ from matplotlib import pyplot as plt
 | 
				
			|||||||
from matplotlib import animation as anim
 | 
					from matplotlib import animation as anim
 | 
				
			||||||
import time
 | 
					import time
 | 
				
			||||||
 | 
					
 | 
				
			||||||
LOCAL_ADDR = "192.168.1.204"
 | 
					#LOCAL_ADDR = "192.168.1.204"
 | 
				
			||||||
nodes = [ "192.168.1.180" ]
 | 
					LOCAL_ADDR = "10.42.0.1"
 | 
				
			||||||
 | 
					nodes = [ "10.42.0.106" ]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# ---------- CONNECT TO AND PREPARE SAMPLING SYSTEM -----------
 | 
					# ---------- CONNECT TO AND PREPARE SAMPLING SYSTEM -----------
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -44,7 +47,7 @@ osc = pywfs.MultiStreamOscilloscope.create()
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
# create a slope trigger
 | 
					# create a slope trigger
 | 
				
			||||||
edge_trigger = pywfs.EdgeTrigger()
 | 
					edge_trigger = pywfs.EdgeTrigger()
 | 
				
			||||||
edge_trigger.level = 0.1
 | 
					edge_trigger.level = 0.5
 | 
				
			||||||
edge_trigger.edge = pywfs.FALLING
 | 
					edge_trigger.edge = pywfs.FALLING
 | 
				
			||||||
#edge_trigger.ch = 0 + index
 | 
					#edge_trigger.ch = 0 + index
 | 
				
			||||||
edge_trigger.ch = 0
 | 
					edge_trigger.ch = 0
 | 
				
			||||||
@ -123,6 +126,8 @@ def init():
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
fig, ax = plt.subplots()
 | 
					fig, ax = plt.subplots()
 | 
				
			||||||
lines = list()
 | 
					lines = list()
 | 
				
			||||||
 | 
					ax.xaxis.set_major_formatter(matplotlib.ticker.EngFormatter(unit='s'))
 | 
				
			||||||
 | 
					ax.yaxis.set_major_formatter(matplotlib.ticker.EngFormatter(unit='V'))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# trigger mark
 | 
					# trigger mark
 | 
				
			||||||
screen_period = osc.getScreenPeriod() * 1E-09
 | 
					screen_period = osc.getScreenPeriod() * 1E-09
 | 
				
			||||||
@ -131,10 +136,11 @@ trig_t = [-trig_mark_halflen * screen_period, trig_mark_halflen * screen_period
 | 
				
			|||||||
trig_y = [ edge_trigger.level, edge_trigger.level ]
 | 
					trig_y = [ edge_trigger.level, edge_trigger.level ]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
for k in range(0, ch_n):
 | 
					for k in range(0, ch_n):
 | 
				
			||||||
    lines.append(ax.plot([], [], lw=2))
 | 
					    lines.append(ax.plot([], [], label="CH" + str(k), lw=2))
 | 
				
			||||||
    t, y = list(), list()
 | 
					    t, y = list(), list()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
ax.plot(trig_t, trig_y, color = 'r')
 | 
					ax.plot(trig_t, trig_y, color = 'r')
 | 
				
			||||||
 | 
					ax.legend()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def run(data):
 | 
					def run(data):
 | 
				
			||||||
    T, Y = data
 | 
					    T, Y = data
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user