article

Paul Toone avatar image
0 Likes"
Paul Toone posted

Tutorial - Linking Process Flows to 3D Models   

The purpose of this tutorial is to demonstrate how you can link a process flow to a simple simulation model using an event-listening activity. It will also cover how to make a sub process flow for tasks that will be repeated multiple times during a simulation run.

In this scenario, you want to be able to easily change the process time for flowitems in a processor on a repeating pattern. The first three flowitems that enter the processor should have a fast processing time of 2 seconds. The next two flowitems will have a slower processing time of about 10 seconds. Then this pattern will repeat itself indefinitely for the all subsequent flowitems.

To create this kind of logic, you'll build a process flow that will loop in an indefinite pattern. And then you will create a sub flow with an event-listening activity that will override the processor's process time.

Each time the sequence needs to override the processor's process time, it runs the sub flow, shown in the preceding image. The token that's moving through Sequence of Process Times creates a child token, dispatches it to the Start activity of the Sub Flow, and then waits for the sub flow to finish before moving to its next activity.

Tasks Covered

This tutorial will cover the following tasks:

  1. Building a simple 3D model
  2. Building a looping process flow
  3. Setting labels to control the process time
  4. Building and linking a sub flow
  5. Linking the process flow to the simulation model
  6. Running the model

For More Information

For more in-depth information about the concepts covered in this tutorial, refer to the following topics:

Step 1 - Build a Simple 3D Model

Since the focus in this tutorial is going to be on the process flow, you'll just build a very simple 3D simulation model in this step.

  1. Create a new model.
  2. From the Library, add:
    • 1 Source
    • 1 Queue
    • 1 Processor
    • 1 Sink
  3. Create port connections (A connects) between the objects in the order that you dragged them out, as shown in the following image:

Step 2 - Build a Looping Process Flow

Now you will create the process flow that will control the processing time logic in the Processor. Because you want the processing times to loop in a sequence (3 fast processing times followed by 2 slow processing times), you'll create single process flow and then make it loop indefinitely.

NOTE: This step will include a brief review of the concepts covered in the Process Flow Basics Tutorial. It will also discuss the purpose of each activity for this process flow. If you don't need these step-by-step instructions for building a process flow, you can skip to the end of this step and view the final image to see how the final process flow should look. You can create your process flow based off that image if it is faster for you.

  1. Click the ProcessFlow button on the main toolbar to open a menu. Select General to create a general process flow and open it as a separate tab in the center pane. You might want to split the center pane between the model view and the process flow view for your convenience.
  2. Click a Schedule Source in the Library and add it to the process flow. This source will create the first (and only) token that will loop through the process flow as soon as the simulation begins.
  3. Now you'll create a sequence of activities that will make the process time run quickly for the first three flowitems that enter the Processor. The first activity will assign a label to the token and trigger a sub flow three times (one for each of the fast processing times). Using your preferred method for adding activities, create a stacked block with 1 Assign Labels activity and 3 Run Sub Flow activities, as shown in the following image:

  4. Create a connection between the Source and the Assign Labels activity. Point your mouse on the edge of the Source. The mouse icon will change to a chain link. Click the edge of the block and, while holding down the mouse, drag it to the edge of the Assign Labels activity. Release your mouse to create the connection.

  5. Now you'll create a similar stacked block for the two flowitems that will make the process time run slowly. Using your preferred method for adding activities, create a stacked block with 1 Assign Labels activity and 2 Run Sub Flow activities, as shown in the following image:

  6. Create a connection going from the first stacked block to the second stacked block. Lastly, create a connection going from the second stacked block back to the first stacked block, creating a loop, as shown in the following image:

  7. Lastly, you'll want to rename the activities for clarification. To rename an activity, double-click an activity name and type in a new name. Rename the activities as follows:
    Which Block? Current Name New Name
    First Assign Labels Set to Fast Time
    First Run Sub Flow Fast Time 1
    First Run Sub Flow Fast Time 2
    First Run Sub Flow Fast Time 3
    Second Assign Labels Set to Slow Time
    Second Run Sub Flow Slow Time 1
    Second Run Sub Flow Slow Time 2
  8. If needed, you can resize the activities.

When you're finished, your process flow should look similar to the following image:

Step 3 - Set Labels to Control the Process Time

In this step, you'll edit the properties for the Assign Label activities so that they set the process time that will be given to the Processor. For this example, static numbers will be used but these numbers could be replaced with a statistical distribution, pull data from a global table or perform other logical operations.

  1. Click the Set to Fast Time (Assign Label) activity in the first stacked block to select it.
  2. In Quick Properties, click the Add button under Labels to add a new label.
  3. In the new label's Name box, delete the existing text and type processTime.
  4. Click in the Value box and type 2 to represent 2 simulation time units.

  5. Repeat these steps for the Set to Slow Time (Assign Label) activity, except this time change the Value box to 10 to represent 10 simulation time units.

Step 4 - Build and Link a Sub Flow

In this step, you'll create a sub process flow (also called a sub flow for short). A sub flow is a separate process flow that begins running when it is triggered by another activity or event in the main process flow. You can possibly use sub flows for tasks that will be repeated multiple times during a simulation run. In this case, you'll create a sub flow with an event-listening activity that will get triggered every time a flowitem is processed by the processor.

For the purposes of this tutorial, you'll create an internal sub flow, which is a sub flow inside of an existing process flow. Internal sub flows are basically an independent block of activities that begin with a Start activity and end with a Finish activity. (See Sub Process Flows for more information.)

NOTE: This tutorial model relies on a useful process flow feature that allows child tokens to inherit labels from their parent tokens. In this tutorial, you'll set the labels on a parent token in the main process flow. Every time the main process flow runs a sub flow, it will create a child token that will move through the sub flow itself. The child token will automatically inherit the processsTime label from its parent token. It will then use that label as the override value for the process time in the child token. (See Sub Process Flows - Linking Parent and Child Labels for more information.)

  1. Using your preferred method for adding activities, create a stacked block with a Start activity, a Wait for Event activity, and a Finish activity.

  2. Rename the activities in this block for clarification. Rename the activities as follows:
    Current Name New Name
    Wait for Event Wait for Process Time
    Finish Finish and Override Process Time
  3. Now it's time to link the Run Sub Flow activities to the Start activity on the sub flow. Click on the first stacked block to select it. You'll notice that each of the Run Sub Flow activities have an Exclamation icon next to them, which indicates they are not linked to a sub flow. Click the Exclamation icon to enter sampling mode, then click the Start activity on the sub flow. A blue line will appear to show they are linked.
  4. Repeat this process until all five of the Run Sub Flow activities are connected to the sub flow.

When you're finished, your process flow should look similar to the following image:

Step 5 - Link the Process Flow to the Simulation Model

In this step, you'll link the event-listening activity on the sub flow (Wait for Process Time) to the processor so that it will override its process time. You'll also get to experiment with a Universal Edit keyword. (See About the Universal Edit Feature for more information.) NOTE: You might want to split the center pane between the simulation model and the process flow view before you start this step.

  1. Click the Wait for Process Time (Wait for Event) activity to select it. You'll notice that the Wait for Process Time activity has an Exclamation icon next to it it, which indicates it is not linked to an event in the simulation model yet.
  2. Click the Exclamation icon to enter sampling mode, then click the Processor in the simulation model. NOTE: If you didn't split the center pane, point your mouse to the Model tab while in sampling mode to switch to the 3D view.
  3. Clicking on the Processor in sampling mode will open a menu listing all the events that might occur on the processor. Select the Processor: ProcessTime event. NOTE: The exact name display of the processor might differ in your model.
  4. Notice that the Wait for Process Time (Wait for Event) activity now displays the name of the processor next to it. In Quick Properties, the Object box also displays the name of the processor and the Event box displays the name of the event you selected, as shown in the following image:

  5. Now you will change the settings so that the current value of the token's processTime label will override the processor's process time. In Quick Properties, check the Will Override Return Value checkbox.

  6. Lastly, you'll get a chance to see how a property that uses the Universal Edit feature works. The Universal Edit feature is designed to make it easy to add complex functionality to certain properties without needing to know FlexScript. Using keywords, you can set a property to access data that could possibly change dynamically during a simulation run such as labels, groups, variables, and more. In the Quick Properties for the Finish activity, click in the Return Value box. Type the keyword Label: to open a menu of all the available labels in your process flow, as shown in the following image:

  7. Double-click processTime to select that label. Now, the sub flow will automatically override the process time of the processor with the value of this label.

Step 6 - Run the Model

Reset and run the model. You'll notice that Source creates a token at time 0, the token enters the Set to Fast Time activity and its processTime label is set to 2. The token then moves to the first Fast Time 1 activity where a child token is created and sits at the Wait for Process Timeactivity in the sub flow.

As soon as the processor in the model receives an item, its Process Time will be evaluated and instead of using the value defined by the token, the child token will be released from its activity and move to the Finish activity evaluating the Return Value which will be returned to the Process Time. The child token is then destroyed and the parent token moves to the next Run Sub Flow activity to start sub flow over again.

This will continue as each item enters the processor. Once the token finishes Slow Time 2, it will move back to the top to continue the pattern again. Not only was the logic easily created without any coding, but you can also visibily see where the processor is in its set of process times. This can be a valuable debugging tool or it can be useful for collecting statistics. Statistics could be gathered separately or collectively for an an activity or area to record how long the processor spent in any given state.

flexsim users manualuser manuals
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