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).....?
Forum Updated to NodeBB v4.3 + New Features

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 491 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.
  • L Offline
    L Offline
    Limer
    wrote on 11 Jul 2018, 06:12 last edited by Limer 7 Nov 2018, 06:27
    #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.......

    J 1 Reply Last reply 11 Jul 2018, 07:05
    0
    • L Limer
      11 Jul 2018, 06:12

      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.......

      J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 11 Jul 2018, 07:05 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

      L 1 Reply Last reply 11 Jul 2018, 07:20
      1
      • J jsulm
        11 Jul 2018, 07:05

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

        L Offline
        L Offline
        Limer
        wrote on 11 Jul 2018, 07:20 last edited by Limer 7 Nov 2018, 07:22
        #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

        3/3

        11 Jul 2018, 07:20

        • Login

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