Work in progress.

merge-requests/1/head
Teuniz 2015-06-07 21:34:20 +02:00
rodzic 2e16678bba
commit d19a946c75
6 zmienionych plików z 476 dodań i 76 usunięć

Wyświetl plik

@ -181,18 +181,272 @@ void UI_Mainwindow::navDialReleased()
void UI_Mainwindow::acqButtonClicked()
{
QMenu menu,
submenuacquisition;
int chn,
chns_on=0;
submenuacquisition.setTitle("Acquisition");
QMenu menu,
submenuacquisition,
submenumemdepth;
for(chn=0; chn<MAX_CHNS; chn++)
{
if(devparms.chandisplay[chn])
{
chns_on++;
}
}
submenuacquisition.setTitle("Mode");
submenuacquisition.addAction("Normal", this, SLOT(set_acq_normal()));
submenuacquisition.addAction("Average", this, SLOT(set_acq_average()));
menu.addMenu(&submenuacquisition);
submenumemdepth.setTitle("Mem Depth");
submenumemdepth.addAction("Auto", this, SLOT(set_memdepth_auto()));
if(devparms.modelserie == 6)
{
if(chns_on < 2)
{
submenumemdepth.addAction("14K", this, SLOT(set_memdepth_14k()));
submenumemdepth.addAction("140K", this, SLOT(set_memdepth_140k()));
submenumemdepth.addAction("1.4M", this, SLOT(set_memdepth_1400k()));
submenumemdepth.addAction("14M", this, SLOT(set_memdepth_14m()));
submenumemdepth.addAction("140M", this, SLOT(set_memdepth_140m()));
}
else
{
submenumemdepth.addAction("7K", this, SLOT(set_memdepth_7k()));
submenumemdepth.addAction("70K", this, SLOT(set_memdepth_70k()));
submenumemdepth.addAction("700K", this, SLOT(set_memdepth_700k()));
submenumemdepth.addAction("7M", this, SLOT(set_memdepth_7m()));
submenumemdepth.addAction("70M", this, SLOT(set_memdepth_70m()));
}
}
else if(devparms.modelserie == 1)
{
if(chns_on < 2)
{
submenumemdepth.addAction("12K", this, SLOT(set_memdepth_12k()));
submenumemdepth.addAction("120K", this, SLOT(set_memdepth_120k()));
submenumemdepth.addAction("1.2M", this, SLOT(set_memdepth_1200k()));
submenumemdepth.addAction("12M", this, SLOT(set_memdepth_12m()));
submenumemdepth.addAction("24M", this, SLOT(set_memdepth_24m()));
}
else if(chns_on < 3)
{
submenumemdepth.addAction("6K", this, SLOT(set_memdepth_6k()));
submenumemdepth.addAction("60K", this, SLOT(set_memdepth_60k()));
submenumemdepth.addAction("600K", this, SLOT(set_memdepth_600k()));
submenumemdepth.addAction("6M", this, SLOT(set_memdepth_6m()));
submenumemdepth.addAction("12M", this, SLOT(set_memdepth_12m()));
}
else
{
submenumemdepth.addAction("3K", this, SLOT(set_memdepth_3k()));
submenumemdepth.addAction("30K", this, SLOT(set_memdepth_30k()));
submenumemdepth.addAction("300K", this, SLOT(set_memdepth_300k()));
submenumemdepth.addAction("3M", this, SLOT(set_memdepth_3m()));
submenumemdepth.addAction("6M", this, SLOT(set_memdepth_6m()));
}
}
menu.addMenu(&submenumemdepth);
menu.exec(acqButton->mapToGlobal(QPoint(0,0)));
}
void UI_Mainwindow::set_memdepth_auto()
{
statusLabel->setText("Memory depth: auto");
tmcdev_write(device, ":ACQ:MDEP AUTO");
}
void UI_Mainwindow::set_memdepth_12k()
{
statusLabel->setText("Memory depth: 12k");
tmcdev_write(device, ":ACQ:MDEP 12000");
}
void UI_Mainwindow::set_memdepth_120k()
{
statusLabel->setText("Memory depth: 120k");
tmcdev_write(device, ":ACQ:MDEP 120000");
}
void UI_Mainwindow::set_memdepth_1200k()
{
statusLabel->setText("Memory depth: 1.2M");
tmcdev_write(device, ":ACQ:MDEP 1200000");
}
void UI_Mainwindow::set_memdepth_12m()
{
statusLabel->setText("Memory depth: 12M");
tmcdev_write(device, ":ACQ:MDEP 12000000");
}
void UI_Mainwindow::set_memdepth_24m()
{
statusLabel->setText("Memory depth: 24M");
tmcdev_write(device, ":ACQ:MDEP 24000000");
}
void UI_Mainwindow::set_memdepth_3k()
{
statusLabel->setText("Memory depth: 3K");
tmcdev_write(device, ":ACQ:MDEP 3000");
}
void UI_Mainwindow::set_memdepth_30k()
{
statusLabel->setText("Memory depth: 30K");
tmcdev_write(device, ":ACQ:MDEP 30000");
}
void UI_Mainwindow::set_memdepth_300k()
{
statusLabel->setText("Memory depth: 300K");
tmcdev_write(device, ":ACQ:MDEP 300000");
}
void UI_Mainwindow::set_memdepth_3m()
{
statusLabel->setText("Memory depth: 3M");
tmcdev_write(device, ":ACQ:MDEP 3000000");
}
void UI_Mainwindow::set_memdepth_6m()
{
statusLabel->setText("Memory depth: 6M");
tmcdev_write(device, ":ACQ:MDEP 6000000");
}
void UI_Mainwindow::set_memdepth_6k()
{
statusLabel->setText("Memory depth: 6K");
tmcdev_write(device, ":ACQ:MDEP 6000");
}
void UI_Mainwindow::set_memdepth_60k()
{
statusLabel->setText("Memory depth: 60K");
tmcdev_write(device, ":ACQ:MDEP 60000");
}
void UI_Mainwindow::set_memdepth_600k()
{
statusLabel->setText("Memory depth: 600K");
tmcdev_write(device, ":ACQ:MDEP 600000");
}
void UI_Mainwindow::set_memdepth_7k()
{
statusLabel->setText("Memory depth: 7k");
tmcdev_write(device, ":ACQ:MDEP 7000");
}
void UI_Mainwindow::set_memdepth_70k()
{
statusLabel->setText("Memory depth: 70k");
tmcdev_write(device, ":ACQ:MDEP 70000");
}
void UI_Mainwindow::set_memdepth_700k()
{
statusLabel->setText("Memory depth: 700K");
tmcdev_write(device, ":ACQ:MDEP 700000");
}
void UI_Mainwindow::set_memdepth_7m()
{
statusLabel->setText("Memory depth: 7M");
tmcdev_write(device, ":ACQ:MDEP 7000000");
}
void UI_Mainwindow::set_memdepth_70m()
{
statusLabel->setText("Memory depth: 70M");
tmcdev_write(device, ":ACQ:MDEP 70000000");
}
void UI_Mainwindow::set_memdepth_14k()
{
statusLabel->setText("Memory depth: 14k");
tmcdev_write(device, ":ACQ:MDEP 14000");
}
void UI_Mainwindow::set_memdepth_140k()
{
statusLabel->setText("Memory depth: 140k");
tmcdev_write(device, ":ACQ:MDEP 140000");
}
void UI_Mainwindow::set_memdepth_1400k()
{
statusLabel->setText("Memory depth: 1.4M");
tmcdev_write(device, ":ACQ:MDEP 1400000");
}
void UI_Mainwindow::set_memdepth_14m()
{
statusLabel->setText("Memory depth: 14M");
tmcdev_write(device, ":ACQ:MDEP 14000000");
}
void UI_Mainwindow::set_memdepth_140m()
{
statusLabel->setText("Memory depth: 140M");
tmcdev_write(device, ":ACQ:MDEP 140000000");
}
void UI_Mainwindow::set_acq_normal()
{
if(devparms.acquiretype == 0)
@ -241,7 +495,7 @@ void UI_Mainwindow::saveButtonClicked()
QMenu menu;
menu.addAction("Save screen waveform", this, SLOT(save_screen_waveform()));
// menu.addAction("Save memory waveform", this, SLOT(save_memory_waveform()));
menu.addAction("Save memory waveform", this, SLOT(save_memory_waveform()));
menu.addAction("Save screenshot", this, SLOT(save_screenshot()));
menu.exec(saveButton->mapToGlobal(QPoint(0,0)));
@ -308,7 +562,7 @@ void UI_Mainwindow::set_grid_type_dots()
devparms.displaytype = 1;
statusLabel->setText("Display type: dotss");
statusLabel->setText("Display type: dots");
tmcdev_write(device, ":DISP:TYPE DOTS");
}

Wyświetl plik

@ -214,6 +214,12 @@ void UI_Mainwindow::open_connection()
devparms.screen_timer_ival = 50;
}
else
{
devparms.status_timer_ival = 500;
devparms.screen_timer_ival = 2000;
}
connect(adjDial, SIGNAL(valueChanged(int)), this, SLOT(adjDialChanged(int)));
connect(trigAdjustDial, SIGNAL(valueChanged(int)), this, SLOT(trigAdjustDialChanged(int)));

Wyświetl plik

@ -61,6 +61,7 @@
#include <QDial>
#include <QSettings>
#include <QProcess>
#include <QProgressDialog>
#include <stdio.h>
#include <stdlib.h>
@ -313,6 +314,31 @@ private slots:
void set_acq_normal();
void set_acq_average();
void set_memdepth_auto();
void set_memdepth_12k();
void set_memdepth_120k();
void set_memdepth_1200k();
void set_memdepth_12m();
void set_memdepth_24m();
void set_memdepth_6k();
void set_memdepth_60k();
void set_memdepth_600k();
void set_memdepth_6m();
void set_memdepth_3k();
void set_memdepth_30k();
void set_memdepth_300k();
void set_memdepth_3m();
void set_memdepth_7k();
void set_memdepth_70k();
void set_memdepth_700k();
void set_memdepth_7m();
void set_memdepth_70m();
void set_memdepth_14k();
void set_memdepth_140k();
void set_memdepth_1400k();
void set_memdepth_14m();
void set_memdepth_140m();
protected:
void closeEvent(QCloseEvent *);

Wyświetl plik

@ -73,9 +73,9 @@ UI_Mainwindow::UI_Mainwindow()
devparms.hordivisions = 14;
devparms.status_timer_ival = 200;
devparms.status_timer_ival = 500;
devparms.screen_timer_ival = 500;
devparms.screen_timer_ival = 2000;
menubar = menuBar();

Wyświetl plik

@ -19,7 +19,7 @@ There are some peculiarities when testing with the DS6104 and the DS1054Z:
DS6104:
======
Full-speed USB (12MBit)
USB connection: full speed (12MBit)
Reading screen data is pretty fast, 20 waveforms per second is easily possible.
Reading a screenshot in BMP format is slow, approx. 3 seconds.
Needs a usbtmc driver patch, needs to add an udev rule.
@ -27,8 +27,9 @@ Needs a usbtmc driver patch, needs to add an udev rule.
DS1054Z: (softversion 00.04.02.SP4, boardversion 0.1.1)
=======
High-speed USB (480 Mbit)
Reading screen data is slow, maximum 7 waveforms per second.
USB connection: high speed (480 Mbit)
Reading screen data is slow, maximum 7 waveforms per second with one channel.
With all channels switched on, screen updates are very slow.
Reading a screenshot in BMP format is faster, less than one second.
No need to patch the usbtmc driver, no need to add an udev rule. It's plug and play.
@ -82,11 +83,12 @@ What's implemented so far:
- acquire normal
- acquire average
- acquire memory depth
- save screenshot
- save display data (raw waveform, the part that is visible on the screen)
saving deep memory is not yet implemented
- save display data
- save memory data
fileformat for waveform data is EDF, these files can be read by lots
of viewers and analyzing software like EDFbrowser, Scilab, Octave, Matlab, Labview, etc.

Wyświetl plik

@ -26,6 +26,8 @@
*/
#define SAV_MEM_BSZ (250000)
void UI_Mainwindow::save_screenshot()
@ -157,14 +159,25 @@ OUT_ERROR:
void UI_Mainwindow::save_memory_waveform()
{
int i, j, k, n=0, chns=0, hdl=-1, yoffset[MAX_CHNS], bytes_rcvd, blocksz;
int i, j, k,
n=0,
chn,
chns=0,
hdl=-1,
bytes_rcvd,
mempnts,
yref[MAX_CHNS],
yor[MAX_CHNS],
smps_per_record,
datrecs=1;
char str[128],
opath[MAX_PATHLEN];
short *wavbuf[4];
double rec_len = 0;
double rec_len = 0,
yinc[MAX_CHNS];
if(device == NULL)
{
@ -176,11 +189,46 @@ void UI_Mainwindow::save_memory_waveform()
wavbuf[2] = NULL;
wavbuf[3] = NULL;
rec_len = devparms.memdepth / devparms.samplerate;
mempnts = devparms.memdepth;
QApplication::setOverrideCursor(Qt::WaitCursor);
smps_per_record = mempnts;
qApp->processEvents();
QProgressDialog progress("Downloading data...", "Abort", 0, mempnts, this);
progress.setWindowModality(Qt::WindowModal);
progress.setMinimumDuration(100);
statusLabel->setText("Downloading data...");
for(i=0; i<MAX_CHNS; i++)
{
if(!devparms.chandisplay[i])
{
continue;
}
chns++;
}
if(!chns)
{
strcpy(str, "No active channels.");
goto OUT_ERROR;
}
while(smps_per_record >= (5000000 / chns))
{
smps_per_record /= 2;
datrecs *= 2;
}
if(mempnts < 1)
{
strcpy(str, "Can not save waveform when memory depth is set to \"Auto\".");
goto OUT_ERROR;
}
rec_len = mempnts / devparms.samplerate;
if(rec_len < 1e-6)
{
@ -195,20 +243,12 @@ void UI_Mainwindow::save_memory_waveform()
continue;
}
wavbuf[i] = (short *)malloc(devparms.memdepth * sizeof(short));
wavbuf[i] = (short *)malloc(mempnts * sizeof(short));
if(wavbuf[i] == NULL)
{
strcpy(str, "Malloc error.");
goto OUT_ERROR;
}
chns++;
}
if(!chns)
{
strcpy(str, "No active channels.");
goto OUT_ERROR;
}
scrn_timer->stop();
@ -217,16 +257,14 @@ void UI_Mainwindow::save_memory_waveform()
tmcdev_write(device, ":STOP");
blocksz = 1000000;
for(i=0; i<MAX_CHNS; i++)
for(chn=0; chn<MAX_CHNS; chn++)
{
if(!devparms.chandisplay[i]) // Download data only when channel is switched on
if(!devparms.chandisplay[chn]) // Download data only when channel is switched on
{
continue;
}
sprintf(str, ":WAV:SOUR CHAN%i", i + 1);
sprintf(str, ":WAV:SOUR CHAN%i", chn + 1);
tmcdev_write(device, str);
@ -234,21 +272,67 @@ void UI_Mainwindow::save_memory_waveform()
tmcdev_write(device, ":WAV:MODE RAW");
tmcdev_write(device, ":WAV:YINC?");
tmcdev_read(device);
yinc[chn] = atof(device->buf);
if(yinc[chn] < 1e-6)
{
strcpy(str, "Error, parameter \"YINC\" out of range.");
goto OUT_ERROR;
}
tmcdev_write(device, ":WAV:YREF?");
tmcdev_read(device);
yref[chn] = atoi(device->buf);
if((yref[chn] < 1) || (yref[chn] > 255))
{
strcpy(str, "Error, parameter \"YREF\" out of range.");
goto OUT_ERROR;
}
tmcdev_write(device, ":WAV:YOR?");
tmcdev_read(device);
yor[chn] = atoi(device->buf);
if((yor[chn] < -255) || (yor[chn] > 255))
{
strcpy(str, "Error, parameter \"YOR\" out of range.");
goto OUT_ERROR;
}
bytes_rcvd = 0;
for(j=0; ; j++)
{
sprintf(str, ":WAV:STAR %i", (j * blocksz) + 1);
progress.setValue(bytes_rcvd);
qApp->processEvents();
if(progress.wasCanceled())
{
strcpy(str, "Canceled");
goto OUT_ERROR;
}
sprintf(str, ":WAV:STAR %i", (j * SAV_MEM_BSZ) + 1);
tmcdev_write(device, str);
if(((j + 1) * blocksz) > devparms.memdepth)
if(((j + 1) * SAV_MEM_BSZ) > mempnts)
{
sprintf(str, ":WAV:STOP %i", devparms.memdepth);
sprintf(str, ":WAV:STOP %i", mempnts);
}
else
{
sprintf(str, ":WAV:STOP %i", (j + 1) * blocksz);
sprintf(str, ":WAV:STOP %i", (j + 1) * SAV_MEM_BSZ);
}
tmcdev_write(device, str);
@ -265,7 +349,7 @@ void UI_Mainwindow::save_memory_waveform()
printf("received %i bytes\n", n);
if(n > blocksz)
if(n > SAV_MEM_BSZ)
{
strcpy(str, "Datablock too big for buffer.");
goto OUT_ERROR;
@ -278,33 +362,38 @@ void UI_Mainwindow::save_memory_waveform()
bytes_rcvd += n;
if(bytes_rcvd >= devparms.memdepth)
for(k=0; k<n; k++)
{
wavbuf[chn][(j * SAV_MEM_BSZ) + k] = (int)(((unsigned char *)device->buf)[k]) - yref[chn];
}
if(bytes_rcvd >= mempnts)
{
break;
}
// yoffset[i] = ((devparms.chanoffset[i] / devparms.chanscale[i]) * 25.0);
for(k=0; k<n; k++)
{
wavbuf[i][(j * blocksz) + k] = (int)(((unsigned char *)device->buf)[k]) - 127;
// wavbuf[i][k] -= yoffset[k];
}
}
}
progress.reset();
tmcdev_write(device, ":WAV:MODE NORM");
tmcdev_write(device, ":WAV:STAR 1");
tmcdev_write(device, ":WAV:STOP 1200");
if(devparms.modelserie == 1)
{
tmcdev_write(device, ":WAV:STOP 1200");
}
else
{
tmcdev_write(device, ":WAV:STOP 1400");
}
stat_timer->start(devparms.status_timer_ival);
scrn_timer->start(devparms.screen_timer_ival);
QApplication::restoreOverrideCursor();
statusLabel->setText("Downloading finished");
opath[0] = 0;
if(recent_savedir[0]!=0)
@ -330,7 +419,7 @@ void UI_Mainwindow::save_memory_waveform()
goto OUT_ERROR;
}
if(edf_set_double_datarecord_duration(hdl, rec_len))
if(edf_set_double_datarecord_duration(hdl, rec_len / datrecs))
{
strcpy(str, "Can not set datarecord duration of EDF file.");
goto OUT_ERROR;
@ -338,29 +427,29 @@ void UI_Mainwindow::save_memory_waveform()
j = 0;
for(i=0; i<MAX_CHNS; i++)
for(chn=0; chn<MAX_CHNS; chn++)
{
if(!devparms.chandisplay[i])
if(!devparms.chandisplay[chn])
{
continue;
}
edf_set_samplefrequency(hdl, j, devparms.memdepth);
edf_set_samplefrequency(hdl, j, smps_per_record);
edf_set_digital_maximum(hdl, j, 32767);
edf_set_digital_minimum(hdl, j, -32768);
if(devparms.chanscale[i] > 2)
if(devparms.chanscale[chn] > 2)
{
edf_set_physical_maximum(hdl, j, (devparms.chanscale[i] / 25) * 32767);
edf_set_physical_minimum(hdl, j, (devparms.chanscale[i] / 25) * 32767);
edf_set_physical_maximum(hdl, j, yinc[chn] * 32767);
edf_set_physical_minimum(hdl, j, yinc[chn] * 32767);
edf_set_physical_dimension(hdl, j, "V");
}
else
{
edf_set_physical_maximum(hdl, j, 1000 * (devparms.chanscale[i] / 25) * 32767);
edf_set_physical_minimum(hdl, j, 1000 * (devparms.chanscale[i] / 25) * -32768);
edf_set_physical_maximum(hdl, j, 1000 * yinc[chn] * 32767);
edf_set_physical_minimum(hdl, j, 1000 * yinc[chn] * -32768);
edf_set_physical_dimension(hdl, j, "mV");
}
sprintf(str, "CHAN%i", i + 1);
sprintf(str, "CHAN%i", chn + 1);
edf_set_label(hdl, j, str);
j++;
@ -368,17 +457,20 @@ void UI_Mainwindow::save_memory_waveform()
edf_set_equipment(hdl, devparms.modelname);
for(i=0; i<MAX_CHNS; i++)
for(i=0; i<datrecs; i++)
{
if(!devparms.chandisplay[i])
for(chn=0; chn<MAX_CHNS; chn++)
{
continue;
}
if(!devparms.chandisplay[chn])
{
continue;
}
if(edfwrite_digital_short_samples(hdl, wavbuf[i]))
{
strcpy(str, "A write error occurred.");
goto OUT_ERROR;
if(edfwrite_digital_short_samples(hdl, wavbuf[chn] + (i * smps_per_record)))
{
strcpy(str, "A write error occurred.");
goto OUT_ERROR;
}
}
}
@ -389,32 +481,50 @@ OUT_NORMAL:
edfclose_file(hdl);
}
for(i=0; i<MAX_CHNS; i++)
for(chn=0; chn<MAX_CHNS; chn++)
{
free(wavbuf[i]);
free(wavbuf[chn]);
}
return;
OUT_ERROR:
QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Critical);
msgBox.setText(str);
msgBox.exec();
progress.reset();
tmcdev_write(device, ":WAV:MODE NORM");
tmcdev_write(device, ":WAV:STAR 1");
if(devparms.modelserie == 1)
{
tmcdev_write(device, ":WAV:STOP 1200");
}
else
{
tmcdev_write(device, ":WAV:STOP 1400");
}
statusLabel->setText("Downloading aborted");
if(progress.wasCanceled() == false)
{
QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Critical);
msgBox.setText(str);
msgBox.exec();
}
if(hdl >= 0)
{
edfclose_file(hdl);
}
for(i=0; i<MAX_CHNS; i++)
for(chn=0; chn<MAX_CHNS; chn++)
{
free(wavbuf[i]);
free(wavbuf[chn]);
}
QApplication::restoreOverrideCursor();
stat_timer->start(devparms.status_timer_ival);
scrn_timer->start(devparms.screen_timer_ival);
@ -556,6 +666,8 @@ void UI_Mainwindow::save_screen_waveform()
QApplication::setOverrideCursor(Qt::WaitCursor);
qApp->processEvents();
n = tmcdev_read(device);
QApplication::restoreOverrideCursor();