article

Paul Toone avatar image
0 Likes"
Paul Toone posted Brandon Peterson edited

Global Modeling Tools Step-By-Step Model Construction   

Building Global Modeling Tools Model

Begin a new model by clicking the button on the toolbar. Click OK on the Model Units window; we will use the default units for our model.

If at any time you encounter difficulties while building this model, a fully functional tutorial model can be found at http://www.flexsim.com/tutorials

Step 1: Create the Objects

  • Drag objects from your Library Icon Grid onto the 3D View to create the model shown below.
  • Rename the objects as shown as we will refer to these objects by name throughout the tutorial.

Step 2: Connect the ports

Connect all of the objects as shown below.

  • Connect Source to partqueue.
  • Connect partqueue to Processor1 and Processor2
  • Connect Processor1 to Queue1 and Processor2 to Queue2
  • Connect PalletSource to PalletConveyor
  • Connect PalletConveyor to Combiner

Note: It is required to have PalletConveyor attached to the 1st input port of Combiner.

  • Connect Queue1 and Queue2 to Combiner
  • Connect Combiner to painter1 and Painter2
  • Connect painter1 and Painter2 to Separator
  • Connect Separator to Conveyor1 and Conveyor2
  • Connect Conveyor1 and Conveyor2 to Sink
  • Notice that we did not make any center connections to Operator or Forklift. We will tie those in using Global Variables.

    Step 3: Set the Source Properties

    Set up the source to create two item types.

    • Leave the default Inter-Arrival Time of Source at exponential(0, 10, 0).
    • Set the OnCreation trigger to Set Itemtype and Color with an itemtype of duniform(1,2).
    • Click OK to apply and close the Properties window.

    Step 4: Set the PalletSource Properties

    Our pallets are going to act as dummy objects that will hold our other parts as they go through the Combiner and Painter. Setting the FlowItem Class to a pallet will cause the Combiner to neatly stack our other flowitems on top of the pallet item.

    Our pallet is also going to be used to determine what items are combined in the Combiner. This is specified by setting the itemtype of each pallet. This will be explained later on.

    • Set the FlowItem Class of PalletSource to Pallet (this can be done through the Source's properties under the Source tab or through the Quick Properties).
    • To have an infinite supply of pallets, set the Inter-Arrival Time to 0.
    • Go to the Triggers tab and add a trigger to the OnCreation of Set Type, Name or Label.
    • Change the Type to duniform(1,6).
    • Click OK to apply and close the Properties window.

    At this point, feel free to try your model out. You should see your flowitems run through the entire model, combining a pallet with one item from Queue1 and one item from Queue2 at the Combiner, and then separating those items at the Separator.

    Step 5: Add the Operators

    To show another way of connecting objects together, we are not going to connect our operators using center ports. Instead, we're going to create Global Variables that point to our operators.

    We will also set up a Global Macro to define the processing time of our two processors.

    See the Global Variables Window reference to learn more about Global Variables.

    • Add a new Global Variable from the Toolbox (View > Toolbox or click on the Tools button in the main toolbar).

    • Click and set the Variable Name to Operator.
    • Select Tree Node for the Type.
    • Click next to the Value field and select the Operator as the value then click Select.

    • Repeat the previous steps to create another variable for Forklift.
    • Next, click on the Global Macros tab and enter the follow code:
    #define PROCESS_TIME lognormal2(0.0, 15, 0.2, 0)

    • Click OK to apply and close the Global Variables window.

    Step 6: Setup the Queues

    Processor1 is going to handle all items of itemtype 1 and Processor2 will handle all items of itemtype 2.

    • Set the Maximum Content of partqueue to 25.
    • Under the Flow tab, select By Expression in the pick list for Send To Port. This will default to getitemtype(item).
    • Check the Use Transport button and replace centerobject(current, 1) with Operator.

    • Click OK to apply and close the Properties window.
    • Set the Maximum Content of Queue1 and Queue2 to 100.

    Step 7: Setup the Processors

    We just defined a Global Macro that can be used for the process time of our processors.

    • Open Processor1 and type PROCESS_TIME into the Process Time box.

    • Click the Right Arrow button at the bottom of the properties window to move to the next processor.
    • Set the Process Time of Processor2 to PROCESS_TIME.
    • Click OK to apply and close the Properties window.

    Step 8: Setup a Global Table

    We will now set up a Global Table for use with our combiner.

    The Combiner is used to group multiple flowitems together. The process by which this works is as follows:

    • The Combiner will first accept a single flowitem through input port 1. This becomes the container flowitem into which all the other flowitems will be combined with.
    • Once the first flowitem is accepted, the combiner collects a batch of flowitems from the remaining input parts based on its component list.

    • Once the batch is complete, the Combiner goes through its setup and process time before sending the combined flowitems on to the next step of the model.

    For this model we're going to have different component lists to represent different orders or assemblies that are being created. Since we connected the pallet to input port 1 it can be used to determine which component list is to be used.

    We can create a Global Table that will store all of the different orders (component lists) for use with the Combiner.

    • Add a new Global Table from the Toolbox (View > Toolbox or click on the Tools button in the main toolbar).
    • Rename your table to PartsList.
    • Set the number of rows to 2 and the number of columns to 6.
    • Enter the following numbers into your table.

    • Close the Global Table window.

    Step 9: Setup the Combiner

    • Open the Combiner properties window and click on the Combiner tab.
    • Select Convey Items Across Combiner Length.
    • Click on the Flow tab and select Use Transport.
    • Replace centerobject(current,1) with Forklift.

    We want the Combiner's Component List to update each time a new pallet comes into port 1.

    • Click on the Triggers tab and add a new operation to the OnEntry trigger.
    • Select the Update Combiner Component List from the pick list.
    • Replace "tablename" with "PartsList".
    • Click OK to apply and close the Properties window.

    The Update Combiner Component List pulls data from a Global Table based on the itemtype of the incoming flowitem on port 1. So, if the pallet is of itemtype 4, it will pull the two row values from column 4 of our Global Table PartsList.

    Step 10: Write Custom User Commands

    FlexSim allows you to write your own custom User Commands, or functions, that can be used throughout your model.

    The first command we will write will return the time it takes to paint all of the items on our pallet. This code could be written directly into the process time of the painter1 and Painter2 processors, but as we have multiple painters all utilizing the same processing time, writing a custom command makes it easier to make changes to that processing time.

    • Add a new User Command from the Toolbox (View > Toolbox or click on the Tools button in the main toolbar).
    • Click Add to create a new command.
    • Set the Name of the command to painttime.
    • Set the Parameters to (node obj).
    • Set the Return Type to num.
    • The command's Description is: Returns the amount of time to paint all the items on the given node.
    • Set the Example to painttime(current).

    For the code, we want our command to pass the Painter processor, cycle through all of the items on the pallet, and return a total time for the painting where items with itemtype 1 take 20 seconds to paint and items of itemtype 2 take 14 seconds to paint.

    • Click on the button to open the code for our command.
    • Enter the following code:
    treenode object = parnode(1);  int painttime = 0;  for(int index = 1; index < content(first(object)); index++) {  if(getitemtype(rank(object,index)) == 1) {  painttime += exponential(0.0, 20.0, 0);  } else {  painttime += exponential(0.0, 14.0, 0);  }  }  return painttime;
    • Click the OK button to apply and close the code window.

    Next we will create a command that will change the color of all items on the pallet to be blue once they've gone through the painter.

    • Add a new user command and set the Name to paintitems.
    • Set the Parameters to (node obj).
    • Set the Return Type to null.
    • The command's Description is: Changes the colors of all items on a pallet to blue.
    • Set the Example to paintitems(current).

    For the code, we will cycle through all of the items on the pallet and change the color to blue.

    • Click on the button to open the code for our command.
    • Enter the following code:
    treenode object = parnode(1);  for(int index = 1; index <= content(first(object)); index++) {  colorblue(rank(first(object),index));  }
    • Click the OK button to apply and close the code window.
    • Click Apply and then Close on the User Commands window.

    Step 11: Setup the Painters

    • Open painter1's properties window.
    • Set the Process Time to painttime(current).

    • Click the Flow tab and check the Use Transport button.
    • Set the transport to be Forklift.
    • Click on the Triggers tab and click on the next to the OnProcessFinish trigger to edit the code of that trigger.
    • Add the following line to the bottom of the code:
    paintitems(current);
    • Click OK to apply and close to the code window.
    • Click OK to apply and close the Properties window.

    Set up the same properties for Painter2. For a fast way to copy properties from one object to another, see the Edit Selected Objects Utility.

    Step 12: The Separator

    As the Separator currently stands, we do not need to make any changes to its properties. By default, when the Separator receives a flowitem, it separates the container from the contents and then sends the container (pallet) through output port 1 and the contents through output port 2. If you wish to change these settings, go to the Flow tab of the Separator and change the Send To Port option.

    We are now ready to run the model.

    Step 13: Reset and Run the Model

    • Remember to hit the button to reset model parameters to their initial state.
    • Click the button to start the simulation.

    You should see flowitems entering the queue and then being moved by the Operator to one of the two processors. Red items will move to Processor1 and green items will move to Processor2.

    Pallets will be place on the Combiner and then wait until it receives its full batch of items from Queue1 and Queue2. The Forklift will then move the pallet to painter1 or Painter2. Before exiting the painters, all of the items will turn blue. The pallet will then be moved to the Separator where the pallet will be separated from the items. The pallet will travel across Conveyor1 and the blue items will travel across Conveyor2 to the Sink.


    This completes the Global Modeling Tools lesson. Congratulations!

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

brandon.peterson contributed to this article paul.t contributed to this article

Navigation

FlexSim 2016.1