‎03-11-2022 01:32 AM - edited ‎03-11-2022 01:33 AM
Hi everyone,
my labview project has several DQMH modules. One of these has a request and wait for reply event with a long timeout. i want to know what do you mean when you saiy:
"5. If the Request and Wait for Reply event is going to wait for a long time, make sure the code handling the request is registered to the stop module event and is able to abort the MHL case if the stop module event is received before the waiting period is over."
here
https://delacor.com/dqmh-documentation/dqmh-best- practices/#:~:text= WhenaDQMHModulehas, therequestwil....
how can i make sure that the code handling the request is registered to the stop module event and is able to abort the MHL case if the stop module event is received before the waiting period is over?
thank you
Michele
Solved! Go to Solution.
‎03-11-2022 02:28 AM
In this case I use a request only and as reply I send a broadcast. In this way the calling process isn't blocked. All you have to do is to register for the broadcasts and wait for it.
‎03-11-2022 02:44 AM
Hi Ludwig,
if i need to control how long it takes to do the task (the time between the request event and the broadcast event), i think that i need to develop a timer and integrate it into the main vi to do it, correct?
what is the meaning of:
"5. If the Request and Wait for Reply event is going to wait for a long time, make sure the code handling the request is registered to the stop module event and is able to abort the MHL case if the stop module event is received before the waiting period is over."
how do i implement it in the code?
thank you for the reply
‎03-11-2022 03:01 AM - edited ‎03-11-2022 03:04 AM
@Michele__ wrote:
if i need to control how long it takes to do the task (the time between the request event and the broadcast event), i think that i need to develop a timer and integrate it into the main vi to do it, correct?
I would implement a tick count vi at the target module when the request is called. When the task is done you can calculate the time difference and send it back with the broadcast.
@Michele__ wrote:
what is the meaning of:
"5. If the Request and Wait for Reply event is going to wait for a long time, make sure the code handling the request is registered to the stop module event and is able to abort the MHL case if the stop module event is received before the waiting period is over."
how do i implement it in the code?
The message handling loop (MHL) of each module handles any requests as well as the stop request. If you call request and wait for reply and it takes a long time for the reply, then the MHL can't handle any other requests and is blocked. In the worst case, this could mean that the entire framework no longer works because no internal requests can be handled. Normally each DQMH module has a timeout of 5 seconds to avoid such traps.
‎03-11-2022 10:15 AM
Hi Michele,
I'm not sure my solution is the right one because I never had a use case where I had to implement it.
Anyway, I would try to implement #5 of the document like this. Code is crapy, but the idea is to destroy the notifier if you receive the stop module event of the module calling the request.
To be tested, obviously.
‎03-11-2022 04:50 PM
Interesting solution Olivier, but the MHL will still be stuck processing the request?
When Fab says "make sure the code handling the request", is she referring to the calling code or the case in the MHL that owns the request?
It would make sense to me that the MHL ensures it doesn't take too long to carry out the request, and it completes (or aborts with error) the task within the timeout specified in the Request VI.
‎03-14-2022 03:20 AM
You're right, Chris. I read them the #5 too fast. You obviously need to handle the thing in the MHL that actually handles the request if you want the module to stop.
In my solution, I handle one part of the rare corner case where you would like to stop a module that waits for a reply that takes a long time to respond without stoping the module that handles the event. It could happen when you clone a module to address a specific task for a limited amount of time on a particular occasion.
As I said, I didn't come across this kind of use case so far, and it's a thing to think about for more than 5 minutes.
If I go back to the original question, I would probably try to implement the same kind of mechanism to know if a stop module has been sent and try to stop the code before completion in the MHL case that handles the request.
I'm curious to know if developers have come across this use case in an actual situation and how they are dealing with it.