Command with 2 argments using POGO and C++
|
|
---|---|
Hi all, I develop a device server in C++ using POGO , I have one methods to control my hardware which need 2 args ex: SetLevel( int channel , float value). I have 8 channels to control separatly , I created 8 commands to do this. Somebody has an idea to make it with only one command ? Regards MTQ |
|
|
---|---|
Hello, The recommended way would be to use attributes instead of commands. If I were you, I would probably make your device server export 8 devices (1 per channel). Each channel device would have a Read/Write attribute named level. The channel number would be a property of this device and eventually a ReadOnly attribute too. You could also have one device managing all the channels. You could then use one spectrum (array) Levels attribute to control all the levels or create 8 attributes named Channel1_Level, Channel2_Level, …, Channel8_Level for instance if you know there will be always 8 channels. Please keep in mind that Tango is based on object oriented programming concepts and that Tango attributes are great! You should use them as much as possible because Tango will provide you tools to monitor live attribute values, archive attributes values, trigger alarms on attributes values and so on. Hoping this helps, Reynald
Rosenberg's Law: Software is easy to make, except when you want it to do something new.
Corollary: The only software that's worth making is software that does something new. |
|
|
---|---|
Hi, I agree fully with Reynald. I just wanted to add that if you need a high level class which can control all 8 channels then why not use an array for the SetLevel command. The array would be made up of 2 floats : element[0] = channel number , element[1] = value. You would need to cast the channel number to an integer in order to use it as an index. This is common practice and very simple. Philosophical answer : sometimes we are asked why not allow multiple arguments to a command to solve this use case. Our experience is that allowing multiple arguments to a command is more difficult to maintain for generic applications and for implementing hooks to the API for implementing all the Tango features in a library. It is the old discussion of "narrow" (a few api calls) versus "broad" (many api calls). Tango has opted for a narrow interface but with a rich set of data types. You should try to exploit those first before using the possibility of creating your own data types and then packaging them using DevEncoded to send them. This is more adapted for exotic or your specific data types. Andy |
|
|
---|---|
Thank for yours answers, It's my first Device server ,I think that the use of attributs instead of command will be the solution. MTQ |