Set of questions
|
|
---|---|
Hi all, I have few questions, so I will list them down, I think it's better that way then oppening more topics: 1. read_attribute_hardware is called each time before atrribute(s) has been read, but I don't quite see its purpose. After it, functions for each attribute I wanted to read are called. What can I write in read_attribute_hardware method which I code in read_NameOfSomeAttribute methods? 2. When attribute is R/W or W type, I am able to check write hardware at init option, which will set attribute to specific value when starting server. Where I should type that start value? 3. I am able to execute commands by entering argin value in hex or decimal form. Can I enter them in binary format? 4. Even though if an attribute is write type, when I open class state maschine I have Attribute(Read) and Attribute(Write) for checking when is attribute allowed. Why is that? Thank you for your help. |
|
|
---|---|
Hi,Jelena As described in the Tango book, on page 20. The rule of this method is to read the hardware and to store the read values somewhere in the device object.When a client tries to read several attributes on your device (using read_attributes method from DeviceProxy class), read_attr_hardware will be invoked first, and then all the individual attributes read_XXX methods. (Please note that read_attributes is invoked by the Tango polling thread when you have several attributes polled at the same polling period.) It could be useful in some specific cases to do something in read_attr_hardware method to optimize performances because it will limit the number of accesses to the hardware and could help to get a consistent snapshot of the current state of your hardware. Let's take the example of a PLC which could be used to report the state of some hardware devices. You could read a range of memory/registers from this PLC from the read_attr_hardware method, then stores this into a variable and then use this variable directly to extract the relevant data in the read_XXX methods without having to access to the hardware one more time. All the attributes which are read at the same time will be using the same data taken from the hardware at the same time. It is not mandatory to implement something into read_attr_hardware method but in some specific cases as I just described, it could be useful. Jelena This is for memorized attributes. The attribute value will be stored in an attribute property named __value every time you write successfully this attribute. The first time you start your device server, there will not be any __value attribute property defined in the Tango database, so Tango will not write your attribute at init this first time. You simply need to write this attribute at least once and the next time your device server will be started, it will be able to write your memorized attribute during it's initialization phase with the memorized value (last successful write on your memorized attribute). Jelena Do you mean from the device panel (Test device on jive)? I don't think you can enter then in binary format… What kind of data would you like to pass? An image? Jelena It's because you can still read this kind of Write Only attributes. In this case, you will basically read the last set value. 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 Reynald, Thank you for your help and detailed answers, I appreciate your effort. You could read a range of memory/registers from this PLC from the read_attr_hardware method, then stores this into a variable and then use this variable directly to extract the relevant data in the read_XXX methods without having to access to the hardware one more time. All the attributes which are read at the same time will be using the same data taken from the hardware at the same time.Does read_XXX immediately access hardware again when it is called, or self.attr_LED_Value_read is necessary to read hardware again? In other words, what should I do so that I avoid accessing hardware again in read_XXX method? Do you mean from the device panel (Test device on jive)? I don't think you can enter then in binary format…Yeah, I am able to enter arguments in decimal and hexadecimal format, I was wondering if it is possible to enter them in binary format. |
|
|
---|---|
Jelena When a client read several attributes, using read_attributes() method or when you have several attributes polled at the same polling frequency:
If a client invokes read_attribute() to read only one attribute named YYY,
Knowing that, you can put your real hardware accesses where it is more convenient for your specific use case. I hope it clarifies a bit. About TestPanel, arguments in binary format are currently not supported.
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. |
|
|
---|---|
I have one more question, and that would be all. Situation below is what started confusing me in first place about read_attr_hardware. I've made simple program with two attributes with same polling frequency (1 second). I edit generated code like below (all counters are initialized at start as 0): We have three counters, end each is increased by 1 when specific method is called. I was expecting that output will be something like: counterH = 1 counter1 = 1 counter2 = 1 counterH = 2 counter1 = 2 counter2 = 2 … Which is also expected from your post: when you have several attributes polled at the same polling frequency: Instead, this is what I get counterH = 1 counter2 = 1 counterH = 2 counter1 = 1 counterH = 3 counter2 = 2 counterH = 4 counter1 = 2 … Why is output like this, it means that read_attr_hardware is called twice, one time for every read_Att method? Thank you for your patience. :) |
|
|
---|---|
Hi, I just tried with a recent version of PyTango/Tango and I got the expected output. Maybe you are using an old version of PyTango which was using Tango 8. The polling is using read_attributes only since Tango 9. Kind regards, 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. |
|
|
---|---|
I am using Tango 9.2.5a, and PyTango 9.2.1. Can you attach your code y?ou have used for testing? |
|
|
---|---|
Hi, Here is the code I used. Please note that I am clearly no pyTango expert. How did you install PyTango?
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. |
|
|
---|---|
Again I have that counterH is twice as big as other two counters. I installed by running script:
Also, from terminal I am getting this:
Can there be some other reasons why read_attr_hardware is called like this? |
|
|
---|---|
P.S Did you generate code with Pogo? Because my generated code is a bit different. |