article

Paul Toone avatar image
0 Likes"
Paul Toone posted

Custom Built Task Sequences   

You can create custom task sequences using 3 simple commands:

createemptytasksequence()

inserttask()

dispatchtasksequence()

First, create a task sequence by using createemptytasksequence(). Then insert tasks into the task sequence by successive inserttask() commands. Finally dispatch the task sequence with dispatchtasksequence().

The following example tells a forklift to travel to an object, referenced as "station", then load a flow item, referenced as "item."

treenode newtasksequence = createemptytasksequence(forklift, 0 ,0 );  inserttask(newtasksequence, TASKTYPE_TRAVEL, station);  inserttask(newtasksequence, TASKTYPE_LOAD, item, station, 2);  dispatchtasksequence(newtasksequence);

If you are confused by the "treenode" syntax, refer the help on the FlexSim tree structure. In brief terms, "treenode newtasksequence" creates a reference, or pointer, to the task sequence as a FlexSim node so that it can be used later when tasks are added to the task sequence.

The createemptytasksequence command takes three parameters. The first parameter is the object that will handle the task sequence. This should be a Dispatcher or TaskExecuter object. The second and third parameters are numbers, and specify the task sequence's priority and preempting values, respectively. The command returns a reference to the task sequence that was created.

The inserttask command inserts a task onto the end of the task sequence. Each task that you insert has several values associated with it. First, it has a type value, which defines what type of task it is. It also has a reference to two involved objects for the task, referred to as involved1 and involved2. These involved objects and what they mean depend upon the task type. For some task types both involved parameters are needed and have meaning, whereas for others, the involved objects are not used. Some task types may use one involved object, and some have involved objects which are optional. Refer to the documentation on task types for information on what a specific task type's involved objects represent. The task can also have up to four number values. These are task variables, referred to as var1, var2, var3, and var4. Again, their meaning depends on the task type. For the load task below, notice that var1 was specified as 1. For a load task, this specifies the output port through which the item will leave the station.

The inserttask command takes two or more parameters, which specify the task's values. The first parameter is a reference to the task sequence into which the task is inserted. The second is the type of task. This can be chosen from an enumerated list of task types. The third and fourth parameters reference the two involved objects. If a specific involved object is not used or is optional for a task type, then you can simply pass NULL into the inserttask command, or even leave that parameter out if there are no number variables that you need to specify either. The fifth through ninth parameters are optional, and define var1-var4. By default, these values are zero.

Note on optional parameters: Even though many of the parameters of the inserttask command are technically optional, depending on the task type, you will still need to specify them. Also, parameters need to still be specified in their correct order. If, for example, you want to specify var1 of the task, but don't care what involved1 or involved2 are, you will still need to pass the NULL value into parameters 3 and 4, even though they are optional, in order to correctly pass var1 in as parameter 5.



flexsim users manual
5 |100000

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

Article

Contributors

paul.t contributed to this article

Navigation

FlexSim 2016.1