Parallel execution of commands for C++ device server

Hi All

Is it possible to define a command in a C++ device server which, when executed runs an infinite loop doing something, without halting the entire device server? It must be possible to execute other commands while the first command is still executing.
At present, I get a warning after 3 secs saying execution not complete and I am not able to execute any other commands while the first command is still being executed.

Thanks
Balkrishna
Edited 8 years ago
Dear Balkrishnna,

this is definitely possible but not in the way you describe it. Any command can start a thread or a process to execute an infinite loop. Once the thread is started the command should return otherwise you will block the device server. This is because the execution of commands is synchronous for each client. It will block until the command returns. The default timeout is 3 seconds. You can increase this to a higher value if needed. Device servers should always be responsive so it is not a good idea to have a command which takes an infinite time to execute. It is possible to configure a device server to have a separate thread for every client but this would not block the command for other clients. If you want to block the execution of a command then I would use the state machine to block the execution of the command when in specified state or use a flag to indicate that the command is blocked and return an exception in the always_executed_hook().

Andy
Hi Balkrishna,

As Andy said, you have to you use a thread to do the infinite loop without blocking others device commands. I invite
you to take a look on YAT which is a C++ library. It contains a set of tools including what you need to implement easily a thread.
You can find it here :
https://svn.code.sf.net/p/tango-cs/code/share/yat/tags (download the last release).

You will find a sample folder that will show you how to do the job you want.

Hope it helps.

Xavier
 
Register or login to create to post a reply.