Results 1 to 17 of 17

Thread: Plotting of QProcess output taking about 5 minutes to plot single value.

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2017
    Posts
    13
    Thanks
    4
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Symbian S60 Android

    Default Plotting of QProcess output taking about 5 minutes to plot single value.

    Hello all ,
    I am new to Qt , i am designing a system which will receive values from sensors and Plot in GUI. I have complete C code for serial port setting and data Processing . By using Q Process i am running this C program and Plotting the Processed values .
    My GUI contain a text Edit for displaying Proceeded output readings and widget for plotting processed values with respect to time . Output values and Plot are as expected . Device sending with 4800 Baud rate and with odd parity , which is set in C program .But its taking more than 5 Minutes to read and plot one value and taking more than 30 minutes to read and plot about 6 values . why it taking this much time to read ?

    My Code is attached ...

    Qt Code:
    1. ui->setupUi(this);
    2. QVector<double> data_x(101), data_y(101);
    3. timer.start();
    4. init_port();
    5. init_line_plot();
    6. x_position = 0;
    7. }
    8.  
    9. graphwidget::~graphwidget()
    10. {
    11. delete ui;
    12. }
    13. void graphwidget::init_port()
    14. {
    15. process = new QProcess(this);
    16. connect(process, SIGNAL(readyReadStandardOutput()), this, SLOT(receive()));
    17. process->start("./test2");
    18.  
    19. process->waitForStarted();
    20. qDebug()<<"process error code:" <<process->error();
    21.  
    22.  
    23. }
    24. void graphwidget::init_line_plot()
    25. {
    26.  
    27. ui->customPlot->addGraph();
    28. // ui->customPlot->setMinimumSize(500,500);
    29. ui->customPlot->xAxis->setLabel("t");
    30. ui->customPlot->yAxis->setLabel("V");
    31. ui->customPlot->axisRect()->setAutoMargins(QCP::msNone);
    32. ui->customPlot->axisRect()->setMargins(QMargins(0,0,0,0));
    33. }
    34.  
    35.  
    36. void graphwidget::receive()
    37. {
    38. // recieves data as ASCII string
    39. int datalength = 1000;
    40. char data [1000];
    41. int bytesRead =process->readLine(data, datalength);
    42. data[bytesRead]='\0';
    43.  
    44. ui->textEdit->append(QString(data));
    45.  
    46. QTextStream out(stdout);
    47. out << data << endl;
    48. addDataPoint(atof(data));
    49. }
    50.  
    51. void graphwidget::addDataPoint(double datapoint)
    52. {
    53. if (x_position>60)data_x.pop_front();
    54. double ms = timer.elapsed();
    55. data_x.push_back((double)ms/1000);
    56. x_position++;
    57. if (x_position>60) data_y.pop_front();
    58. data_y.push_back(datapoint);
    59.  
    60. ui->customPlot->graph(0)->setData(data_x,data_y);
    61. ui->customPlot->xAxis->grid()->setSubGridVisible(false);
    62. ui->customPlot->yAxis->grid()->setSubGridVisible(false);
    63. ui->customPlot->xAxis->grid()->setVisible(false);
    64. ui->customPlot->yAxis->grid()->setVisible(false);
    65. ui->customPlot->graph(0)->setPen(QPen(QColor(0,200,0)));
    66. ui->customPlot->setBackground(Qt::black);
    67.  
    68. ui->customPlot->graph(0)->rescaleAxes();
    69. ui->customPlot->replot();
    70. }
    To copy to clipboard, switch view to plain text mode 



    please suggest necessary changes ........
    Last edited by anda_skoa; 20th February 2017 at 12:46. Reason: missing [code] tags

Similar Threads

  1. How to Plot from QProcess output
    By suhairkp in forum Newbie
    Replies: 0
    Last Post: 31st January 2017, 15:12
  2. Can I read output of a single with the help of Mingw Compiler?
    By parulkalra14 in forum Qt Programming
    Replies: 1
    Last Post: 4th February 2014, 11:03
  3. Replies: 2
    Last Post: 28th January 2014, 10:02
  4. Problem in plotting 3D plot using QWT
    By johnMick in forum Newbie
    Replies: 1
    Last Post: 15th July 2011, 12:19
  5. Replies: 1
    Last Post: 9th September 2010, 11:22

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.