I'm trying to contain a ref to N replicated actors. The actor contained in the replicated ref has a port defined, but when I look at the container actor expecting to see a replicated port I can refer to, I find no replicated port.
I went through the code examples but was unable to find any example using replicated ports and/or replicated actor references. Does anyone have a small snippet showing this missing link, please?
Maybe it's just me, or maybe it's some interaction between replicated ports and replicated refs. I would love to peek at a working example to help me past this.
Deleting the replicated actor ref and recreating it caused the replicated port to appear as expected.
Initial diagram issue solved.
Now that I have a replicated port, this raises many questions:
- Is the index zero based?
- How do I specify a broadcast? Or do I need to explictly walk all?
- How do I know how many are bound?
- How do I know which are bound? Do they have to be contiguous or can we have ,, bound with , unbound?
yes we know that we have more features than tutorials. I have attached a small model with a replicated actor and a replicated port.
Actors may have a fixed replication factor. This will generate as much actor instances as specified.
Ports may have a fixed replication factor. If there are less connected than specified, there will be just as many generated as connected.
Therefore Ports may have a variable replication factor (see model). In this case eTrice will calculate the replication factor for you. You have to make sure that you always have a distinct situation so that eTrice is able to calculate the correct replication.
Ports will allways be bound from 0 to N.
For the ports you will get the replication with portName.getReplication() (see model)
You will get the portindex with portName.getIndexOf(ifitem) (see model)
You may send a message to a dedicated peer with portName[idx].message() (the generated code looks different).
portName.message() (without specified index) will broadcast the message to all connected peers.
You will find the methods to get the index and replication in the generated protocoll classes.
Other than in OT you will not get an indication that a port is not connected.
The attached model is a java model. Please let me know if you need a simmilar example for C.
Thank you Thomas. This is a most helpful response.
Yes, I'm largely working in Java these days, so your model example is perfect for my needs. I plan on sharing this with some of my colleagues when I meet with them, as I am sure understanding how port replication works will be very important.