Labrador/Desktop_Interface/daqform.cpp

85 lines
2.8 KiB
C++
Raw Normal View History

#include "daqform.h"
#include "ui_daqform.h"
2017-12-27 01:44:49 +00:00
#include "siprint.h"
#include "desktop_settings.h"
2017-12-27 01:44:49 +00:00
daqForm::daqForm(QWidget *parent, int initialAverage, qulonglong initialMaxFileSize) :
QDialog(parent),
ui(new Ui::daqForm)
{
ui->setupUi(this);
2017-12-27 01:44:49 +00:00
//Set the Initial Average settings
if(initialAverage != 1){
ui->sampleAveragingGroup->setChecked(true);
ui->numberOfPointsSpinBox->setValue(initialAverage);
}
//Initialise the file size box
if(initialMaxFileSize == 0){
ui->limitFileSizeGroupBox->setChecked(false);
} else {
ui->limitFileSizeGroupBox->setChecked(true);
ui->fileSizeSpinBox->setValue(initialMaxFileSize/1000000);
}
updateLabels();
//Internal Signal Connect
//Changed values
connect(ui->fileSizeSpinBox, SIGNAL(valueChanged(int)), this, SLOT(updateValues()));
connect(ui->numberOfPointsSpinBox, SIGNAL(valueChanged(int)), this, SLOT(updateValues()));
connect(ui->limitFileSizeGroupBox, SIGNAL(toggled(bool)), this, SLOT(updateValues()));
connect(ui->sampleAveragingGroup, SIGNAL(toggled(bool)), this, SLOT(updateValues()));
//Label
connect(ui->numberOfPointsSpinBox, SIGNAL(valueChanged(int)), this, SLOT(updateLabels()));
connect(ui->fileSizeSpinBox, SIGNAL(valueChanged(int)), this, SLOT(updateLabels()));
//Save Button
connect(ui->saveAsDefaultsButton, SIGNAL(clicked(bool)), this, SLOT(trigger_saveButtonPressed()));
}
daqForm::~daqForm()
{
delete ui;
}
2017-12-27 01:44:49 +00:00
void daqForm::updateLabels(){
double effective_sample_rate_single = 375000/((double)ui->numberOfPointsSpinBox->value());
double effective_sample_rate_double = 750000/((double)ui->numberOfPointsSpinBox->value());
int num_samples_stored = (ui->fileSizeSpinBox->value() * 1000000) / NUM_BYTES_STORED_PER_DAQ_SAMPLE;
//Print in SI units
2017-12-30 01:44:08 +00:00
char units[3] = "Hz";
siprint label_single_siprint(&units[0], effective_sample_rate_single);
siprint label_double_siprint(&units[0], effective_sample_rate_double);
2017-12-27 01:44:49 +00:00
//Shove commas in there, or decimal points if you're European!
QString label_numSamples = QLocale().toString(num_samples_stored);
ui->sampleRateLabel_val->setText(label_single_siprint.printVal());
ui->sampleRateLabel_Double_val->setText(label_double_siprint.printVal());
ui->numSamplesStoredLabel_Value->setText(label_numSamples);
}
void daqForm::updateValues(){
qDebug() << "daqForm::updateValues()";
//Averaging
if(ui->sampleAveragingGroup->isChecked()){
updatedAveraging(ui->numberOfPointsSpinBox->value());
} else updatedAveraging(1);
//File Size
if(ui->limitFileSizeGroupBox->isChecked()){
updatedMaxFileSize(ui->fileSizeSpinBox->value() * 1000000);
} else updatedMaxFileSize(0);
}
void daqForm::trigger_saveButtonPressed(){
saveButtonPressed();
}