User now selects which channel they want to take a snapshot of.

This commit is contained in:
EspoTek 2017-11-07 13:08:25 +11:00
parent 38ba12d647
commit 6e8e03d4a4
6 changed files with 91 additions and 44 deletions

View File

@ -736,28 +736,32 @@ void isoDriver::frameActionGeneric(char CH1_mode, char CH2_mode) //0 for off, 1
axes->yAxis->setRange(topRange, botRange);
}
if(snapshotEnabled){
if(snapshotEnabled_CH1){
snapshotFile_CH1->open(QIODevice::WriteOnly);
snapshotFile_CH1->write("t, v\n");
snapshotFile_CH2->open(QIODevice::WriteOnly);
snapshotFile_CH2->write("t, v\n");
char tempchar[32];
for(int i=0; i<GRAPH_SAMPLES; i++){
sprintf(tempchar, "%f, %f\n", x.at(i), CH1.at(i));
snapshotFile_CH1->write(tempchar);
}
snapshotEnabled_CH1 = false;
snapshotFile_CH1->close();
delete(snapshotFile_CH1);
}
if(snapshotEnabled_CH2){
snapshotFile_CH2->open(QIODevice::WriteOnly);
snapshotFile_CH2->write("t, v\n");
char tempchar[32];
for(int i=0; i<GRAPH_SAMPLES; i++){
sprintf(tempchar, "%f, %f\n", x.at(i), CH2.at(i));
snapshotFile_CH2->write(tempchar);
}
snapshotEnabled = false;
snapshotFile_CH1->close();
delete(snapshotFile_CH1);
snapshotEnabled_CH2 = false;
snapshotFile_CH2->close();
delete(snapshotFile_CH2);
}
axes->replot();
@ -1179,22 +1183,18 @@ void isoDriver::setTimeWindow(double newWindow){
windowAtPause = window;
}
void isoDriver::takeSnapshot(QString *fileName){
snapshotEnabled = true;
void isoDriver::takeSnapshot(QString *fileName, unsigned char channel){
if(channel==1){
snapshotEnabled_CH1 = true;
QString fname_CH1 = *(fileName);
fname_CH1.append("_CH1.csv");
QString fname_CH2 = *(fileName);
fname_CH2.append("_CH2.csv");
qDebug() << fname_CH1;
qDebug() << fname_CH2;
snapshotFile_CH1 = new QFile(fname_CH1);
qDebug() << fname_CH1;
} else if(channel==2){
snapshotEnabled_CH2 = true;
QString fname_CH2 = *(fileName);
snapshotFile_CH2 = new QFile(fname_CH2);
qDebug() << fname_CH2;
}
}
double isoDriver::meanVoltageLast(double seconds, unsigned char channel, int TOP){

View File

@ -66,7 +66,8 @@ private:
bool serialDecodeEnabled_CH1 = false, serialDecodeEnabled_CH2 = false;
bool XYmode = false;
bool update_CH1 = true, update_CH2 = true;
bool snapshotEnabled = false;
bool snapshotEnabled_CH1 = false;
bool snapshotEnabled_CH2 = false;
bool firstFrame = true;
double triggerDelay;
bool singleShotEnabled = false;
@ -181,7 +182,7 @@ public slots:
void setTopRange(double newTop);
void setBotRange(double newBot);
void setTimeWindow(double newWindow);
void takeSnapshot(QString *fileName);
void takeSnapshot(QString *fileName, unsigned char channel);
void rSourceChanged(int newSource);
};

View File

@ -858,7 +858,8 @@ void MainWindow::initShortcuts(){
shortcut_cycleBaudRateBackwards_CH2 = new QShortcut(QKeySequence("Ctrl+Shift+Alt+B"), ui->menuBar);
shortcut_snapScopeToCursors = new QShortcut(QKeySequence("Z"), ui->menuBar);
shortcut_manualRange = new QShortcut(QKeySequence("M"), ui->menuBar);
shortcut_snapshot = new QShortcut(QKeySequence("c"), this);
shortcut_snapshot_CH1 = new QShortcut(QKeySequence("c"), this);
shortcut_snapshot_CH2 = new QShortcut(QKeySequence("v"), this);
shortcut_ArrowUp = new QShortcut(QKeySequence("Up"), ui->menuBar);
shortcut_ArrowDown = new QShortcut(QKeySequence("Down"), ui->menuBar);
@ -883,7 +884,8 @@ void MainWindow::initShortcuts(){
connect(shortcut_cycleBaudRateBackwards_CH1, SIGNAL(activated()), this, SLOT(cycleBaudRateBackwards_CH1()));
connect(shortcut_cycleBaudRate_CH2, SIGNAL(activated()), this, SLOT(cycleBaudRate_CH2()));
connect(shortcut_cycleBaudRateBackwards_CH2, SIGNAL(activated()), this, SLOT(cycleBaudRateBackwards_CH2()));
connect(shortcut_snapshot, SIGNAL(activated()), this, SLOT(on_actionTake_Snapshot_triggered()));
connect(shortcut_snapshot_CH1, SIGNAL(activated()), this, SLOT(on_actionSnapshot_CH1_triggered()));
connect(shortcut_snapshot_CH2, SIGNAL(activated()), this, SLOT(on_actionSnapshot_CH2_triggered()));
connect(shortcut_ArrowUp, SIGNAL(activated()), this, SLOT(arrowUpTriggered()));
connect(shortcut_ArrowDown, SIGNAL(activated()), this, SLOT(arrowDownTriggered()));
@ -1157,6 +1159,7 @@ void MainWindow::on_actionRecord_triggered(bool checked)
void MainWindow::on_actionTake_Snapshot_triggered()
{
/*
QString fileName;
showFileDialog(&fileName);
qDebug() << fileName;
@ -1168,6 +1171,7 @@ void MainWindow::on_actionTake_Snapshot_triggered()
fileName.remove(len-4, 4);
qDebug() << fileName;
ui->controller_iso->takeSnapshot(&fileName);
*/
}
void MainWindow::reinitUsb(void){
@ -1563,3 +1567,28 @@ void MainWindow::showFileDialog(QString *fileName){
*(fileName) = temp;
}
void MainWindow::on_actionSnapshot_CH1_triggered()
{
qDebug() << "on_actionSnapshot_CH1_triggered()";
QString fileName;
showFileDialog(&fileName);
qDebug() << fileName;
int len = fileName.length();
if(len==0) return; //User cancelled
ui->controller_iso->takeSnapshot(&fileName, 1);
}
void MainWindow::on_actionSnapshot_CH2_triggered()
{
qDebug() << "on_actionSnapshot_CH2_triggered()";
QString fileName;
showFileDialog(&fileName);
qDebug() << fileName;
int len = fileName.length();
if(len==0) return; //User cancelled
ui->controller_iso->takeSnapshot(&fileName, 2);
}

View File

@ -145,6 +145,10 @@ private slots:
void on_actionSingle_ep_async_triggered();
void on_actionSnapshot_CH1_triggered();
void on_actionSnapshot_CH2_triggered();
private:
//Generic Vars
Ui::MainWindow *ui;
@ -198,7 +202,8 @@ private:
QShortcut *shortcut_ArrowRight;
QShortcut *shortcut_snapScopeToCursors;\
QShortcut *shortcut_manualRange;
QShortcut *shortcut_snapshot;
QShortcut *shortcut_snapshot_CH1;
QShortcut *shortcut_snapshot_CH2;
QShortcut *shortcut_Debug;
QShortcut *shortcut_Esc;

View File

@ -1332,15 +1332,22 @@
<x>0</x>
<y>0</y>
<width>1440</width>
<height>21</height>
<height>31</height>
</rect>
</property>
<widget class="QMenu" name="menuFile">
<property name="title">
<string>File</string>
</property>
<widget class="QMenu" name="menuTake_Snapshot">
<property name="title">
<string>Take Snapshot</string>
</property>
<addaction name="actionSnapshot_CH1"/>
<addaction name="actionSnapshot_CH2"/>
</widget>
<addaction name="actionRecord"/>
<addaction name="actionTake_Snapshot"/>
<addaction name="menuTake_Snapshot"/>
</widget>
<widget class="QMenu" name="menuOscilloscope_2">
<property name="title">
@ -1419,8 +1426,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>135</width>
<height>116</height>
<width>183</width>
<height>151</height>
</rect>
</property>
<property name="title">
@ -2103,11 +2110,6 @@
<string>Enter Manually</string>
</property>
</action>
<action name="actionTake_Snapshot">
<property name="text">
<string>Take Snapshot</string>
</property>
</action>
<action name="actionAutoR">
<property name="checkable">
<bool>true</bool>
@ -2189,6 +2191,16 @@
<string>single-ep-async</string>
</property>
</action>
<action name="actionSnapshot_CH1">
<property name="text">
<string>CH1</string>
</property>
</action>
<action name="actionSnapshot_CH2">
<property name="text">
<string>CH2</string>
</property>
</action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<customwidgets>