Howto use Adapters [message #1749637] |
Thu, 08 December 2016 17:05  |
Eclipse User |
|
|
|
I want to transfer 5 real values (parameter for a polynome). Therefore I have constructed an adapter. It is possible to add this adapter as a socket or a plug into the FB. But how can I use it?
In the type navigator, I open an FB and in the context menu, I can choose "create socket" and choose the existing adapter. Afterwards, the adapter is shown in the FB with a green symbol. But how can I access the variables of the plug? I only can see the variables of an adapter if I open the adapter in the type view. But I cannot use it together with a FB.
Does anybody use adapters?
Is there a tutorial?
Is there an example?
Kind regards,
Ernst
|
|
|
|
Re: Howto use Adapters [message #1750385 is a reply to message #1749757] |
Tue, 20 December 2016 10:03   |
Eclipse User |
|
|
|
Alois Zoitl wrote on Sun, 11 December 2016 11:31
yes I'm using adapters quite a lot. The Traffic Light example which is coming with 4diac show some usage of adapters.
Hmm. I can only see one adapter: ATraficLight. But this one does not have any variables. It has only events.
Alois Zoitl wrote on Sun, 11 December 2016 11:31
But I assume you are more interested in using adapters with basic FBs. There you can use the events and variables of an adapter by using the name of your plug or socket as prefix. E.g., myplug.Var1 or socket.Var3. The code completion provided for the algorithm and transition condition editors should give you these variables as suggestions.
Yes, in the meantime I used it this way and it works.
I used "REQ" and "CNF" in my two FB, where I want to transfer data from the first named "Interface" to the second named "Corrector". I used "REQ" and "CNF" also in the adapter (together with 5 REAL values on the left side of the adapter) and in the first FB, not only "CNF" is set, but also the CNF of the Adapter.
However, I tried not to set the "CNF" of the adapter and it still worked. Is this OK?
Is it possible to remove alle the signals from the adapter?
Alois Zoitl wrote on Sun, 11 December 2016 11:31
Finally I'm not sure if an adapter is the most suitable element for you. As in addition to your 5 values you would also need an event which would inform your FB about value changes of your polynome parameters. Maybe an array input can give you the same featuers with less effort. Not sure.
This is done automatically, because I have a "CNF" and a "Adapter.CNF" and also a "REQ" and a "Adapter.REQ"?
And yes, an array would be sufficient now as I need now only 5 identical parameters.
|
|
|
Re: Howto use Adapters [message #1750416 is a reply to message #1750385] |
Tue, 20 December 2016 16:00  |
Eclipse User |
|
|
|
Ernst Murnleitner wrote on Tue, 20 December 2016 15:03Alois Zoitl wrote on Sun, 11 December 2016 11:31
yes I'm using adapters quite a lot. The Traffic Light example which is coming with 4diac show some usage of adapters.
Hmm. I can only see one adapter: ATraficLight. But this one does not have any variables. It has only events.
There should also be a ATimeOut. This has a data element.
Ernst Murnleitner wrote on Tue, 20 December 2016 15:03
Alois Zoitl wrote on Sun, 11 December 2016 11:31
But I assume you are more interested in using adapters with basic FBs. There you can use the events and variables of an adapter by using the name of your plug or socket as prefix. E.g., myplug.Var1 or socket.Var3. The code completion provided for the algorithm and transition condition editors should give you these variables as suggestions.
Yes, in the meantime I used it this way and it works.
I used "REQ" and "CNF" in my two FB, where I want to transfer data from the first named "Interface" to the second named "Corrector". I used "REQ" and "CNF" also in the adapter (together with 5 REAL values on the left side of the adapter) and in the first FB, not only "CNF" is set, but also the CNF of the Adapter.
However, I tried not to set the "CNF" of the adapter and it still worked. Is this OK?
Is it possible to remove alle the signals from the adapter?
Unfortunately not. Adapters have their own with constructs. Without Adapter events the values would not be updated. Therefore as you did it arrays are in your case the better modelling element.
Ernst Murnleitner wrote on Tue, 20 December 2016 15:03
Alois Zoitl wrote on Sun, 11 December 2016 11:31
Finally I'm not sure if an adapter is the most suitable element for you. As in addition to your 5 values you would also need an event which would inform your FB about value changes of your polynome parameters. Maybe an array input can give you the same featuers with less effort. Not sure.
This is done automatically, because I have a "CNF" and a "Adapter.CNF" and also a "REQ" and a "Adapter.REQ"?
And yes, an array would be sufficient now as I need now only 5 identical parameters.
If you don't have the identical parameters then there would also be Structs. But the usage of structs in 4diac is currently very clumsy.
|
|
|
Powered by
FUDForum. Page generated in 0.07266 seconds