const NUM_CHANNELS = instrument.properties.channels.length; connection.acquire(); var displayedChannels = []; connection.command(`:KEY:LOCK ENABle`); for (var iChannel = 1; iChannel <= NUM_CHANNELS; ++iChannel) { //figure out active channels (MATH, DIGI and FFT not supported yet) var displayed = await connection.query(`:CHANnel${iChannel}:DISPlay?`); if (displayed) { displayedChannels.push(iChannel); } } if (displayedChannels.length > 0) { connection.command(`:STOP`); //measurement has to be stopped, otherwise only contents of screen can be read //connection.command(`:WAVeform:POINTs:MODE NORMal`); //read only contents of screen (600 points) connection.command(`:WAVeform:POINTs:MODE MAXimum`); //read whole memory (5k/10K) var timeScale = parseFloat(await connection.query(`:TIMebase:SCALe?`)); for (var iDisplayedChannel = 0; iDisplayedChannel < displayedChannels.length; ++iDisplayedChannel) { var iChannel = displayedChannels[iDisplayedChannel]; var samplingRate = await connection.query(`:ACQuire:SAMPlingrate? CHANnel${iChannel}`); var channelScale = parseFloat(await connection.query(`:CHANnel${iChannel}:SCALe?`)); var channelOffset = parseFloat(await connection.query(`:CHANnel${iChannel}:OFFSet?`)); var color = instrument.properties.channels[iChannel - 1].color; var colorInverse = instrument.properties.channels[iChannel - 1].colorInverse; var label = `Channel ${iChannel}`; var description = `Channel: ${iChannel}, Sampling rate: ${samplingRate}, Timebase: ${timeScale}s, Vertical scale: ${channelScale} V, Offset: ${channelOffset} V`; notify.info(description); var data = []; //var waveform = await connection.query(`:WAVeform:DATA? CHANnel${iChannel}`); //reads contents of screen var waveform = await connection.query(`:WAVeform:MEMORYDATA? CHANnel${iChannel}`); //reads contents of screen/memory, undocumented in prog. manual data.push(waveform.data); waveform.deleteLog(); channelScaleResized=10*channelScale/250; //data mangling for proper display of data - oscilloscope provides data in very strange format 0-199, inverted pixelHalfWidth=8*channelScale/200/2; channelOffsetResized=-4*channelScale-channelOffset;//+pixelHalfWidth; samplingRateResized=samplingRate/2; for (var i=0; i < data[0].length; ++i) { data[0][i]=199-data[0][i]; //invert data } //console.log(pixelHalfWidth); session.addChart({ description, data, samplingRate: samplingRateResized, offset: channelOffsetResized, scale: channelScaleResized, format: 2, unit: "Voltage", color, colorInverse, label }); } connection.command(`:RUN`); } connection.command(`:KEY:LOCK DISable`); connection.release();