|
Re: Howto use Adapters [message #1749757 is a reply to message #1749637] |
Sun, 11 December 2016 11:31 |
|
Hi,
yes I'm using adapters quite a lot. The Traffic Light example which is coming with 4diac show some usage of adapters. In principle it depends what kind of FB you are using. The easiest way of using adapters is in Composite FBs. There the plugs and sockets appear in the internal FB network of the composite FB and you can wire events and data connections to it as with any other FB.
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.
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.
|
|
|
Re: Howto use Adapters [message #1750385 is a reply to message #1749757] |
Tue, 20 December 2016 15:03 |
Ernst Murnleitner Messages: 19 Registered: December 2016 |
Junior Member |
|
|
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 21:00 |
|
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.04052 seconds