Changeset - aa93a4eacbb9
[Not reviewed]
default
0 1 0
Hasan Yavuz Ă–ZDERYA - 10 years ago 2015-06-22 05:53:23
hy@ozderya.net
fix pause not working with ASCII data
1 file changed with 7 insertions and 0 deletions:
0 comments (0 inline, 0 general)
mainwindow.cpp
Show inline comments
 
@@ -215,48 +215,55 @@ void MainWindow::onDataReady()
 
                for (unsigned int ci = 0; ci < numOfChannels; ci++)
 
                {
 
                    channelSamples[ci].replace(i, (this->*readSample)());
 
                }
 
                i++;
 
            }
 

	
 
            for (unsigned int ci = 0; ci < numOfChannels; ci++)
 
            {
 
                addChannelData(ci, channelSamples[ci]);
 
            }
 
        }
 
    }
 
    else
 
    {
 
        serialPort.clear(QSerialPort::Input);
 
    }
 
}
 

	
 
void MainWindow::onDataReadyASCII()
 
{
 
    while(serialPort.canReadLine())
 
    {
 
        QByteArray line = serialPort.readLine();
 

	
 
        // discard data if paused
 
        if (ui->actionPause->isChecked())
 
        {
 
            return;
 
        }
 

	
 
        line = line.trimmed();
 
        auto separatedValues = line.split(',');
 

	
 
        if (separatedValues.length() >= int(numOfChannels))
 
        {
 
            for (unsigned int ci = 0; ci < numOfChannels; ci++)
 
            {
 
                double channelSample = separatedValues[ci].toDouble();
 
                addChannelData(ci, DataArray({channelSample}));
 
            }
 
        }
 
        else // there is missing channel data
 
        {
 
            qWarning() << "Incoming data is missing data for some channels!";
 
            for (int ci = 0; ci < separatedValues.length(); ci++)
 
            {
 
                double channelSample = separatedValues[ci].toDouble();
 
                addChannelData(ci, DataArray({channelSample}));
 
            }
 
        }
 
    }
 
}
 

	
 
void MainWindow::onPortError(QSerialPort::SerialPortError error)
0 comments (0 inline, 0 general)