Handling command failures
|
|
---|---|
Hi, I would like to know what is the proper way of handling an unsuccessful command call for a Tango device. Should I send a fail message to the client or throw an exception? Thank you. |
|
|
---|---|
Hi, this depends on what type of failure you mean. In most cases if the command failed to execute then you should throw an exception. In some cases failure might mean the command was executed correctly but the hardware responded differently to how it was expected to then the command could return successfully but the state of the device might change e.g. to FAULT. I would avoid returning the state of the command execution in a return argument except in very special cases e.g. status of a calibration command. But even then try to implement your commands so the client can assume they were successful i.e. return successfully, or failed i.e. throw an exception. Andy |
|
|
---|---|
Thank you Andy. In my case, I'm trying to execute a command which should be executed only when the device in is a particular state (for e.g. when the device is in an OFF state -> do not execute any other command other than command 'Turn_On'). |
|
|
---|---|
This is exactly the role of the state machine. You need to implement this restriction in the is_Allowed() method of your command. With Pogo it is only a case of clicking on some radioboxes to implement such a state machine. Pogo will generate the code you need. You can read more about using implementing a state machine pogo in section 1.14.3 State machine management of the Device Server Guidelines document : http://sourceforge.net/projects/tango-cs/files/doc/TangoDesignGuidelines-Revision-6.pdf/download Andy |