Work in progress.

merge-requests/1/head
Teuniz 2015-06-03 20:16:59 +02:00
rodzic 443a53cc4e
commit 9142382a61
6 zmienionych plików z 221 dodań i 45 usunięć

Wyświetl plik

@ -121,6 +121,9 @@ struct device_settings
int displaygrid; // 0=none, 1=half, 2=full int displaygrid; // 0=none, 1=half, 2=full
int countersrc; // 0=off, 1=ch1, 2=ch2, 3=ch3, 4=ch4
double counterfreq; // Value of frequency counter
char *screenshot_buf; char *screenshot_buf;
char *wavebuf[MAX_CHNS]; char *wavebuf[MAX_CHNS];

Wyświetl plik

@ -1609,6 +1609,73 @@ void UI_Mainwindow::horScaleDialClicked(QPoint)
} }
void UI_Mainwindow::measureButtonClicked()
{
QMenu menu,
submenucounter;
submenucounter.setTitle("Counter");
submenucounter.addAction("OFF", this, SLOT(counter_off()));
submenucounter.addAction("CH1", this, SLOT(counter_ch1()));
if(devparms.channel_cnt > 1)
{
submenucounter.addAction("CH2", this, SLOT(counter_ch2()));
}
if(devparms.channel_cnt > 2)
{
submenucounter.addAction("CH3", this, SLOT(counter_ch3()));
}
if(devparms.channel_cnt > 3)
{
submenucounter.addAction("CH4", this, SLOT(counter_ch4()));
}
menu.addMenu(&submenucounter);
menu.exec(measureButton->mapToGlobal(QPoint(0,0)));
}
void UI_Mainwindow::counter_off()
{
devparms.countersrc = 0;
tmcdev_write(device, ":MEAS:COUN:SOUR OFF");
}
void UI_Mainwindow::counter_ch1()
{
devparms.countersrc = 1;
tmcdev_write(device, ":MEAS:COUN:SOUR CHAN1");
}
void UI_Mainwindow::counter_ch2()
{
devparms.countersrc = 2;
tmcdev_write(device, ":MEAS:COUN:SOUR CHAN2");
}
void UI_Mainwindow::counter_ch3()
{
devparms.countersrc = 3;
tmcdev_write(device, ":MEAS:COUN:SOUR CHAN3");
}
void UI_Mainwindow::counter_ch4()
{
devparms.countersrc = 4;
tmcdev_write(device, ":MEAS:COUN:SOUR CHAN4");
}
void UI_Mainwindow::trigModeButtonClicked() void UI_Mainwindow::trigModeButtonClicked()
{ {
devparms.triggersweep++; devparms.triggersweep++;

Wyświetl plik

@ -216,6 +216,13 @@ UI_Mainwindow::UI_Mainwindow()
horPosDial->setMinimum(0); horPosDial->setMinimum(0);
horPosDial->setContextMenuPolicy(Qt::CustomContextMenu); horPosDial->setContextMenuPolicy(Qt::CustomContextMenu);
quickGrpBox = new QGroupBox("Quick", DPRwidget);
quickGrpBox->setGeometry(195, 190, 70, 90);
measureButton = new QPushButton(quickGrpBox);
measureButton->setGeometry(15, 30, 40, 18);
measureButton->setText("MEAS");
verticalGrpBox = new QGroupBox("Vertical", DPRwidget); verticalGrpBox = new QGroupBox("Vertical", DPRwidget);
verticalGrpBox->setGeometry(5, 290, 140, 255); verticalGrpBox->setGeometry(5, 290, 140, 255);
@ -621,6 +628,7 @@ void UI_Mainwindow::open_connection()
connect(dispButton, SIGNAL(clicked()), this, SLOT(dispButtonClicked())); connect(dispButton, SIGNAL(clicked()), this, SLOT(dispButtonClicked()));
connect(utilButton, SIGNAL(clicked()), this, SLOT(utilButtonClicked())); connect(utilButton, SIGNAL(clicked()), this, SLOT(utilButtonClicked()));
connect(helpButton, SIGNAL(clicked()), this, SLOT(helpButtonClicked())); connect(helpButton, SIGNAL(clicked()), this, SLOT(helpButtonClicked()));
connect(measureButton, SIGNAL(clicked()), this, SLOT(measureButtonClicked()));
connect(horPosDial, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(horPosDialClicked(QPoint))); connect(horPosDial, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(horPosDialClicked(QPoint)));
connect(vertOffsetDial, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(vertOffsetDialClicked(QPoint))); connect(vertOffsetDial, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(vertOffsetDialClicked(QPoint)));
@ -707,6 +715,7 @@ void UI_Mainwindow::close_connection()
disconnect(dispButton, SIGNAL(clicked()), this, SLOT(dispButtonClicked())); disconnect(dispButton, SIGNAL(clicked()), this, SLOT(dispButtonClicked()));
disconnect(utilButton, SIGNAL(clicked()), this, SLOT(utilButtonClicked())); disconnect(utilButton, SIGNAL(clicked()), this, SLOT(utilButtonClicked()));
disconnect(helpButton, SIGNAL(clicked()), this, SLOT(helpButtonClicked())); disconnect(helpButton, SIGNAL(clicked()), this, SLOT(helpButtonClicked()));
disconnect(measureButton, SIGNAL(clicked()), this, SLOT(measureButtonClicked()));
disconnect(horPosDial, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(horPosDialClicked(QPoint))); disconnect(horPosDial, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(horPosDialClicked(QPoint)));
disconnect(vertOffsetDial, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(vertOffsetDialClicked(QPoint))); disconnect(vertOffsetDial, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(vertOffsetDialClicked(QPoint)));
@ -1648,6 +1657,44 @@ int UI_Mainwindow::get_device_settings()
goto OUT_ERROR; goto OUT_ERROR;
} }
if(tmcdev_write(device, ":MEAS:COUN:SOUR?") != 16)
{
line = __LINE__;
goto OUT_ERROR;
}
if(tmcdev_read(device) < 1)
{
line = __LINE__;
goto OUT_ERROR;
}
if(!strcmp(device->buf, "OFF"))
{
devparms.countersrc = 0;
}
else if(!strcmp(device->buf, "CHAN1"))
{
devparms.countersrc = 1;
}
else if(!strcmp(device->buf, "CHAN2"))
{
devparms.countersrc = 2;
}
else if(!strcmp(device->buf, "CHAN3"))
{
devparms.countersrc = 3;
}
else if(!strcmp(device->buf, "CHAN4"))
{
devparms.countersrc = 4;
}
else
{
line = __LINE__;
goto OUT_ERROR;
}
return 0; return 0;
OUT_ERROR: OUT_ERROR:

Wyświetl plik

@ -142,7 +142,8 @@ private:
QGroupBox *verticalGrpBox, QGroupBox *verticalGrpBox,
*horizontalGrpBox, *horizontalGrpBox,
*triggerGrpBox, *triggerGrpBox,
*menuGrpBox; *menuGrpBox,
*quickGrpBox;
QPushButton *ch1Button, QPushButton *ch1Button,
*ch2Button, *ch2Button,
@ -166,7 +167,8 @@ private:
*helpButton, *helpButton,
*playpauseButton, *playpauseButton,
*stopButton, *stopButton,
*recordButton; *recordButton,
*measureButton;
QDial *adjDial, QDial *adjDial,
*horScaleDial, *horScaleDial,
@ -238,9 +240,16 @@ private slots:
void dispButtonClicked(); void dispButtonClicked();
void utilButtonClicked(); void utilButtonClicked();
void helpButtonClicked(); void helpButtonClicked();
void measureButtonClicked();
void horizontal_delayed(); void horizontal_delayed();
void counter_off();
void counter_ch1();
void counter_ch2();
void counter_ch3();
void counter_ch4();
void trigger_source_ch1(); void trigger_source_ch1();
void trigger_source_ch2(); void trigger_source_ch2();
void trigger_source_ch3(); void trigger_source_ch3();

Wyświetl plik

@ -427,6 +427,39 @@ void SignalCurve::drawWidget(QPainter *painter, int curve_w, int curve_h)
} }
} }
if(devparms->countersrc)
{
char str[128];
QPainterPath path;
path.addRoundedRect(600, 20, 122, 20, 3, 3);
painter->fillPath(path, Qt::black);
painter->setPen(Qt::darkGray);
painter->drawRoundedRect(600, 20, 122, 20, 3, 3);
path = QPainterPath();
path.addRoundedRect(604, 23, 14, 14, 3, 3);
painter->fillPath(path, SignalColor[devparms->countersrc - 1]);
painter->setPen(Qt::black);
painter->drawLine(607, 26, 615, 26);
painter->drawLine(611, 26, 611, 34);
painter->setPen(Qt::white);
sprintf(str, "%.3f Hz", devparms->counterfreq);
painter->drawText(622, 20, 100, 20, Qt::AlignCenter, str);
}
// clk_end = clock(); // clk_end = clock();
// //
// cpu_time_used += ((double) (clk_end - clk_start)) / CLOCKS_PER_SEC; // cpu_time_used += ((double) (clk_end - clk_start)) / CLOCKS_PER_SEC;

Wyświetl plik

@ -219,6 +219,23 @@ void UI_Mainwindow::stat_timer_handler()
devparms.memdepth = atoi(device->buf); devparms.memdepth = atoi(device->buf);
if(devparms.countersrc)
{
if(tmcdev_write(device, ":MEAS:COUN:VAL?") != 15)
{
line = __LINE__;
goto OUT_ERROR;
}
if(tmcdev_read(device) < 1)
{
line = __LINE__;
goto OUT_ERROR;
}
devparms.counterfreq = atof(device->buf);
}
// if(old_stat != devparms.triggerstatus) // if(old_stat != devparms.triggerstatus)
// { // {
// printf("Status change: %i\n", devparms.triggerstatus); // printf("Status change: %i\n", devparms.triggerstatus);