Se rendre au contenu
CTech Digital
  • Accueil
  • Services Odoo
  • Services d'IA
  • Contactez-nous
  • 0
  • Nederlands (BE) English (UK) Français
CTech Digital
  • 0
    • Accueil
    • Services Odoo
    • Services d'IA
    • Contactez-nous
  • Nederlands (BE) English (UK) Français

25/5/25

  • Tous les blogs
  • Daily blog
  • 25/5/25
  • 25 mai 2025 par
    CTech Metrology, Luc Wens

    The message responding works

    Now we need to implement/test a request.

    A request is done with MessageResponder::SendRequest and for this we need to set the send function with MessageResponder::SetSendFunction.

    Then we can launch a request in 2 ways with 
    std::future<Message>       SendRequest(const Message &, Handler = {});

    • We take the returned future and wait for it to become available and has a value
      wait_for and valid in case it is not set directly
    • give a callback as parameter, this function has as signature Handler which is std::function<Reply(const Message &)> 

    So the first choice gives the possibility to block and wait for a result for a certain amount of time, the second gives the possibility to go straight on and have a routine called when the reply message arrives.


    In which cases do we use this, some examples:

    1. Do a hardware/configuration detection : multiple options here, but we go for b.
      1. In the UI we just send the message with the detection command and we have a message with the same ID set as a responder. This is completely asynchronous. This will also respond to detections coming in without having requested one 
      2. We use sendrequest with a handler: this will set a one time handler in the requests_ map of MessageResponder. So it will be handled only once. If a request with the same ID is launched twice, we get an exception
      3. We use the returned future with Wait_for. If this is in the main UI thread, it blocks the UI interactions, so not option for this
    2. We have a lasertracker that has a list of operations, the next operation can only be started if the previous is completed.

    Laser tracker list of commands 


    We need to chain commands, so the callback of command 1 has to send command 2 and needs access to the list of commands to retrieve the next command.



    in Daily blog
    23/5/2025
    Droits d'auteur © CTech Solutions
    Nederlands (BE) | English (UK) | Français
    Généré par Odoo - Le #1 Open Source eCommerce