Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to solve the latency in a single-core CPU HMI(Human Machine Interface).....?

How to solve the latency in a single-core CPU HMI(Human Machine Interface).....?

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 476 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • LimerL Offline
    LimerL Offline
    Limer
    wrote on last edited by Limer
    #1

    There is a qgraphicsscene with 100~150 items in it, and about 50 items are dynamic. I set a qtimer in this scene to control the 50 dynamic items, because the frequency of the 50 items is same, so i can do this. The interval time of the qtimer is 100ms.

    Below is the picture that running in my pc,(the forum's server may has some problem, you can click the below link to see it.)
    https://github.com/Hapoa/_Repository/blob/master/images/3.gif

    But if i load the program into my single-core CPU HMI(Human Machine Interface with Linux system), I can obviously
    observe that the frequency of the 50 dynamic items is more than 100ms(I guess it's about 500ms).

    So I change my code by using QtConcurrent::map to update these items, but it didn't work, it was also about 500ms.

    class Scene : public QGraphicsScene
    {
        Q_OBJECT
    
    public:
        Scene(QObject* parent = 0) : QGraphicsScene(parent)
        {
            ......
            ......
            m_timer = new QTimer(this);
            connect(m_timer, SIGNAL(timeout()), this, SLOT(changeAll()));
            m_timer->start(100);
        }
    
    public slots:
        void changeAll()
        {
            // another way
            QtConcurrent::map(m_plList, stateChange1);
            QtConcurrent::map(m_fanList, stateChange2);
            QtConcurrent::map(m_svgList, stateChange3);
    
            // original way
            for (int i = 0; i < 18; i++)
                m_plItem[i].stateChange();
            for (int i = 0; i < 26; i++)
                m_fanItem[i].stateChange();
            for (int i = 0; i < 10; i++)
                m_svgItem[i].stateChange();
        }
    };
    

    Is there any some special ways to solve this? Or I can only only only use a higher configuration HMI.......

    jsulmJ 1 Reply Last reply
    0
    • LimerL Limer

      There is a qgraphicsscene with 100~150 items in it, and about 50 items are dynamic. I set a qtimer in this scene to control the 50 dynamic items, because the frequency of the 50 items is same, so i can do this. The interval time of the qtimer is 100ms.

      Below is the picture that running in my pc,(the forum's server may has some problem, you can click the below link to see it.)
      https://github.com/Hapoa/_Repository/blob/master/images/3.gif

      But if i load the program into my single-core CPU HMI(Human Machine Interface with Linux system), I can obviously
      observe that the frequency of the 50 dynamic items is more than 100ms(I guess it's about 500ms).

      So I change my code by using QtConcurrent::map to update these items, but it didn't work, it was also about 500ms.

      class Scene : public QGraphicsScene
      {
          Q_OBJECT
      
      public:
          Scene(QObject* parent = 0) : QGraphicsScene(parent)
          {
              ......
              ......
              m_timer = new QTimer(this);
              connect(m_timer, SIGNAL(timeout()), this, SLOT(changeAll()));
              m_timer->start(100);
          }
      
      public slots:
          void changeAll()
          {
              // another way
              QtConcurrent::map(m_plList, stateChange1);
              QtConcurrent::map(m_fanList, stateChange2);
              QtConcurrent::map(m_svgList, stateChange3);
      
              // original way
              for (int i = 0; i < 18; i++)
                  m_plItem[i].stateChange();
              for (int i = 0; i < 26; i++)
                  m_fanItem[i].stateChange();
              for (int i = 0; i < 10; i++)
                  m_svgItem[i].stateChange();
          }
      };
      

      Is there any some special ways to solve this? Or I can only only only use a higher configuration HMI.......

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @Limer Sounds like you need to optimize your code.
      What are you doing to update these 50 elements?

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      LimerL 1 Reply Last reply
      1
      • jsulmJ jsulm

        @Limer Sounds like you need to optimize your code.
        What are you doing to update these 50 elements?

        LimerL Offline
        LimerL Offline
        Limer
        wrote on last edited by Limer
        #3

        @jsulm Stress test. Yes, it need optimization, but i can't find ways to optimize it, 500ms is too large, 200ms is ok...

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved