Destinator: CreateEvent or PlaceAtom

All topics on the Atoms in any Enterprise Dynamics Library.
Post Reply
EDstudent
Posts: 5
Joined: Tuesday 10 June, 2014 - 09:36

Destinator: CreateEvent or PlaceAtom

Post by EDstudent »

Hi,
during modelling with ED I noticed this issue, which didn't seem plausible to me.

I want an Advanced Transporter to PickUp and Place products dynamically from different atoms by using the commands AdvancedTransporter_PickAtom and AdvancedTransporter_PlaceAtom. In the attached example I simulated a situation where the PlaceAtom-command in combination with a destinator doesn't use the right destination, as it is set in the command.
Another Advanced Transporter using createEvent and the event executes the PlaceAtom-command chooses the correct destination..
Both commands are triggered by "TriggerOnEntry" within the Advanced Transporters.

Thank you for answers,
Edstudent
destinatorProblem.mod
(31.15 KiB) Downloaded 321 times
More precisely: AdvancedTransporter_PlaceAtom(atombyname([Advanced Transporter2],Model),atombyname([Sink6],Model),First(atombyname([Advanced Transporter2],Model))) doesn't place the Atom at Sink6 !
SimonvdW
Posts: 47
Joined: Thursday 06 January, 2011 - 09:52

Re: Destinator: CreateEvent or PlaceAtom

Post by SimonvdW »

Hello ED student,

It seems indeed that both situations work the same, as you write code at the "TriggerOnEntry" in both cases, but the result is different.
Although it is a quite technical answer, I will try to explain the difference:
The simulation works event based and handles the events according to an event calander, which is sorted by time.
The code of the "TriggerOnEntry" is part of the Event that is executed as soon as the product is in the transporter. However the "TriggerOnEntry" code is evaluated before the destination of the transporter is assigned, based on "Send to". So, your code says "go to Sink6", but immediately after the "Send-to" statement of the transporter is checked, overrules your destination Sink6 and results in exit channel 1 (which is in your case Sink4).

If a CreateEvent command is used, it creates a new event as defined on the Controller atom. This new event is placed on the event calendar immediately (with 0 seconds delay) after the event that is executed once the product entered. In that case the destination is first set based on "Send to" and 0 seconds later overruled by the command in the new event.
That's why your second transporter goes to the correct destination and the first one doesn't.

Regards, Simon
EDstudent
Posts: 5
Joined: Tuesday 10 June, 2014 - 09:36

Re: Destinator: CreateEvent or PlaceAtom

Post by EDstudent »

Hello Simon,

thanks for your reply, I understand your explanation.
Nevertheless I cant find a solution for my initial problem which lead to the described issue:
In my scenario i want to control several Advanced Transporters from an external program by 4Dscript. Now I want to use CreateEvent-statements because of your explanation. The problem is that with AdvancedTransporter_PickAtom and AdvancedTrasnporter_PlaceAtom I can customize the parameters in a string like Transporter, Destination, Product easily. With the CreateEvent-command i can only set 1 parameter and the remaining ones are preset in the controller-atom OnEvent-Handler for example. How can I create these Events more dynamically?
EDstudent
Posts: 5
Joined: Tuesday 10 June, 2014 - 09:36

Re: Destinator: CreateEvent or PlaceAtom

Post by EDstudent »

I've got a different solutions, that works properly:
First I set a Label "NextDestination" in the desired Product with the name of the next destination as value.
Then I simply let the AdvancedTrasnporter unload automatically and manipulate the SendTo-attribute this way:
icocno(1,AtomByName(i.NextDestination,Model))

This way the attribute SendTo will be set to the number of the outputchannel of the destinator, which is connected to the right destination atom. So no CreateEvent or PlaceAtom is needed..
SimonvdW
Posts: 47
Joined: Thursday 06 January, 2011 - 09:52

Re: Destinator: CreateEvent or PlaceAtom

Post by SimonvdW »

Great that you found a solution for your issue.

I did not know your exact rasons for using this construction with PichUpAtom and PlaceAtom, that's why I just explained what is the logic of these functions.

Now that I see your solution, I'm wondering whether it is not just possible to assign the channel number in the SendTo, based on a distribution or assignment.
If you write value 3 in the SendTo of the Advanced Transporter connected to a Destinator it will travel to the destination attached to the third output channel of the Destinator.
As you can also write code in the SendTo you can assign the destination straightforward.
Post Reply