#include "qmlinterface.h" QmlInterface::QmlInterface(QObject *parent) : QObject(parent) { m_plot_x = 0; m_thread = new QThread(parent); m_serialPortinterface = new SerialPortInterface(m_thread); connect(m_thread,&QThread::finished,m_thread,&QObject::deleteLater); connect(m_thread,&QThread::finished,m_serialPortinterface,&QObject::deleteLater); connect(this,&QmlInterface::initSerializerPort,m_serialPortinterface,&SerialPortInterface::onInitSerializerPort); connect(m_serialPortinterface,&SerialPortInterface::startedSerializerPort,this,&QmlInterface::onStartedSerializerPort); connect(this,&QmlInterface::sendingData,m_serialPortinterface,&SerialPortInterface::onSendingData); connect(m_serialPortinterface,&SerialPortInterface::sentData,this,&QmlInterface::onSentData); connect(m_serialPortinterface,&SerialPortInterface::heartbeatDataRecieved,this,&QmlInterface::onheartBeatDataRecieved); connect(m_serialPortinterface,&SerialPortInterface::statusDataRecieved,this,&QmlInterface::onStatusDataRecieved); connect(m_serialPortinterface,&SerialPortInterface::chartDataRecieved,this,&QmlInterface::onChartDataRecieved); connect(this, &QmlInterface::plotDataChanged, this, &QmlInterface::onPlotDataChanged); } QVariant QmlInterface::hashPassword(QVariant password) { m_password = QString(QCryptographicHash::hash((password.toByteArray()),QCryptographicHash::Md5).toHex()); qDebug()<<"CPP: Password: "<isRunning()) emit initSerializerPort(); else { m_thread->start(); emit initSerializerPort(); } } QVariantList QmlInterface::getChartData() { // Return the QvariantList data for plotting return m_plotData; } void QmlInterface::takeMeasurements(bool status) { m_isTakingMeasurents = status; if(!m_isTakingMeasurents) { // m_plotData.clear(); m_firstOverflow = false; qDebug()<<"Measuring stopped ..."; m_plot_x = 0; emit clearChart(); } } bool QmlInterface::isMeasuring() { return m_isTakingMeasurents; } void QmlInterface::onStatusDataRecieved(QString data) { qDebug()<<"data: "<= 2000) { if(!m_firstOverflow) { m_firstOverflow = true; emit firstOverflow(); } m_plot_x = 0; emit clearChart(); } else m_plot_x ++; emit emitChartData(m_plot_x * 0.01, data); } } void QmlInterface::onPlotDataChanged() { emit emitPlotDataChanged(m_plotData); }