c++ - Continuous check in the main loop in Qt 5.5 -


i have device moves on linear path, linear actuator. when device reaches physical ends, hits limit contact sends signal software. need continually check if signal online. i'm having difficulties implementing logic in qt5.5.

i've been reading on qtconcurrent , seems viable solution after implementing on test drive found out cannot solve problem without sort of while(true) loop. implementing while(true) loop seems slow down else on code therefore rendering solution useless.

i post code given uses libraries , nomenclature of devices of specific niche spare pain if can guide me towards reading on grateful. prefer steer clear of qtthread , manually setting threads since not feel comfortable working them @ point, , have time limit on project best if don't experiment much.

tldr: need put code somehow within main loop of program checks boolean value change. said change sent program externally device communicating through ethernet.

class checker : public qobject {     q_object public:     checker(void)     {         timer.setinterval(100);// give interval, 100ms?         connect(timer, signal(timeout()), this, slot(checkhw()));     }     void start(void)     {         timer.start();// although can start timer in constructor                        // guess want start later, after hw                          // ready.     } private q_slots:     void checkhw()     {         bool hit = false;         // check hardware here         if(hit){             emit hitend();// tell others event         }     } signals:     void hitend(void); private:     qtimer timer; } 

if checking hardware switch doesn't take time, don't need thread. however, if checkhw() takes lot of time, helps if class moved out of main thread.


Comments

Popular posts from this blog

dns - How To Use Custom Nameserver On Free Cloudflare? -

python - Pygame screen.blit not working -

c# - Web API response xml language -