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



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


  • Moderators

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



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


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.