question

Murphy avatar image
0 Likes"
Murphy asked Andrew O commented

dispather

1671070871369.png

hi, I want have judgement according to source1 outputport when the dispatcher1 dispatched task execute.

eg: taskExecuter1 transport item to Queue1

taskExecuter2 transport item to Queue2

source1 output setting: random port.

how can I do to achieve that logic. thanks guys.

FlexSim 22.2.1
dispatcher
1671070871369.png (158.8 KiB)
· 4
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Jason Lightfoot avatar image Jason Lightfoot ♦ commented ·

There are many ways to do this - some don't involve a dispatcher - are you tied to having it?

0 Likes 0 ·
Murphy avatar image Murphy Jason Lightfoot ♦ commented ·

I get you ideal, but when numbers of task excuter have so many, we must use dispatcher, hence I what to know that did do it or not.

0 Likes 0 ·
Jason Lightfoot avatar image Jason Lightfoot ♦ Murphy commented ·
Why? You just need a reference to the te that should do the job. That could be on the destination object.
0 Likes 0 ·
Andrew O avatar image Andrew O commented ·

Hi @Murphy, was Joerg Vogel's answer helpful? If so, please click the "Accept" button at the bottom of their answer. Or if you still have questions, add a comment and we'll continue the conversation.

If we haven't heard back from you within 3 business days we'll auto-accept an answer, but you can always unaccept and comment back to reopen your question.

0 Likes 0 ·

1 Answer

·
Joerg Vogel avatar image
0 Likes"
Joerg Vogel answered Jason Lightfoot edited

You must collect data to make a decision. The source of this data is a tasksequence which you pass to a task executer. Pass To is a functional edit field in your dispatcher.

What you want to do is not standard anymore. You will do some coding to extract data of the tasksequence and decide on that which output port number you return in this function.
You need the references of the unload object, referred sometimes also as destination in tutorials.

This reference is a property in two tasks of a standard tasksequence which is created automatically, if you mark an option “Use Transport“.

You can get this reference from the property involved1 of the 4th task, which Task Type is Travel. And you can get this from the 5th task by involved2 property, too, this Task Type is Unload.
If you have extracted this data you decide in a comparison which output port number you return in your code.

Please try it on you own to extract data of a task of the tasks array from a Task Sequence by task order number and property. And add a filter of conditions to return a correct output port number.
You find in manual needed properties in:

https://docs.flexsim.com/en/22.2/Reference/CodingInFlexSim/FlexScriptAPIReference/TaskExecuter/TaskSequence.html#Property-tasks

https://docs.flexsim.com/en/22.2/Reference/CodingInFlexSim/FlexScriptAPIReference/TaskExecuter/TaskSequence.Task.html#Property-involved1

https://docs.flexsim.com/en/22.2/Reference/CodingInFlexSim/WritingLogic/WritingLogic.html#if

Sometimes it looks a little bit easier to compare names instead of treenode reference also called pointers, too. Then you can get a name of a treenode by property .name.
https://docs.flexsim.com/en/22.2/Reference/CodingInFlexSim/FlexScriptAPIReference/Tree/treenode.html#Property-name

Another filter structure is switch by case:

https://docs.flexsim.com/en/22.2/Reference/CodingInFlexSim/WritingLogic/WritingLogic.html#switch

· 1
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Jason Lightfoot avatar image Jason Lightfoot ♦ commented ·

I think a cleaner approach is to detect and override the return value of the transport dispatcher using an event triggered source, or in the transport dispatcher push the transport job directly to a list - both of these then tell you where the item needs to go. From that information the decision of which TE to use can be based on maps, lists, groups, and/or labels on the destination objects. It saves the user from code that tries to determine the destination from interpreting a sequence of tasks.

Transport dispatcher override example in this post.

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.