TU Darmstadt » MB » Deparment DiK » Education » Simulation of production systems and processes using Tecnomatix Plant Simulation 11

Method

Methods are used to programm automations. They are executed manually or automatically through Tecnomatix Plant Simulation on pre-assigned events such as an entry of an element or the reset of the simulation. Please note thate SimTalk methods are interpreted line-by-line on execution!

There are two special methods (based on their name) (see figure 1):



Figure 1: Special method "Reset" and "Init" and normal method.
  1. The method "Reset" is executes when you reset your simulation using for example the event controller (see figure 2).



    Figure 2: Reset your simulation model

  2. The method "Init" is executes on a reset model as soon as you start your simulation.

 

Every methods is programmed using the programming language "SimTalk". SimTalk is a simplified language with a lots of common known elements from other programming languages such as:

  • Control flow statements:
    • if-then
    • if-then-else
    • if-then-elseif-then-else
    • when-then-else
  • Loops:
    • from-until-loop
    • while-loop
    • repeat-loop
    • for-loop

  • Keywords:
    • exitLoop
    • next
    • return
    • void
  • Anonymous identifieres:
    • @
    • ?
    • self
For a complete reference open the help and select the chapter "Reference Help > SimTalk > Control Flow Statements".

 

In the following chapter we will only use simple sequences without any control flow statements, loops or keywords to provide you a short introduction to automation. Feel free to more explore the possibilites of automation for yourselves.

Enhance your simulation model

Task:

  1. Create a method to toggle all boolean variables of the previous chapter.
  2. Reset the quantity of delivered housing bases based on the variable "DeliveredHousingBase".
  3. Reset the event controller speed to 20%.
  4. Activate or deactive the following stations based on your boolean variables of the previous chapter on init and reset of your model. Do not model it twice!
  5. Add each completed and delivered container to the new queue file "OrderCompleted". Write down the name, the included quantity of pnematic cyclinders and the delivery time. Clear the list on reset.

 

Step-by-Step:

  1. Create four methods on your main frame.
  2. Right-click each method and select the menu entry "Rename..." or press "F2" to rename them:
    • Reset
    • Init
    • ToggleAll
    • OnEntrance
  3. Open the method "ToogleAll".
  4. Between the "do" and the "end" insert your SimTalk programm code.
  5. To toogle a boolean variable overwrite it with its statement in the "inverted" form. For programming that means: "a := NOT a".
  6. Invert the four boolean variables (see figure 3).




    Figure 3: ToggleAll method

  7. Close the method, right-click the method and select "Run". Look at your variables. Each variable should toggle between the values "true" and "false".
  8. Similar to variables you can manipulate each writable attribute by overwriting it with a different value. Now open the method "Reset".
  9. Input the programm code as shown in figure 4. You can put the controller speed to 20% and reset the amount of delivered housing bases.



    Figure 4: Reset your simulation model


  10. Run the method. Try to put different values for example for your event controller.
  11. Now open the method "Init".
  12. Use the global variables to activate or deactivate the material unit sources. Therefore use the failed state of the stations (see figure 5). Try to understand the programm code shown in the figure 2.




    Figure 5: Init method
  13. Run the method. Do you notice the orange icons at the right side of your source objects?
  14. To reuse the init method add the following programm code to your reset method: ".Models.Frame.Init();". This will execute the init method at the end of the reset method.
     
  15. Add a QueueFile object into your main frame and name it "OrderCompleted".
  16. Open the drain in your main frame.
  17. Select the tab "Controls". Input the name of the method or select the method "OnEntrance" (see figure 6). Every time a material unit enters the drain the method "OnEntrance" will be executed.
  18. Open the method "OnEntrance".
  19. Input the following program code: ".Models.Frame.OrderCompleted.push(@.Name + " with 4 Pnematic Cylinders (" + num_to_str(.Models.Frame.EventController.SimTime) + ")");".
  20. This line will add an entry for every material unit. Run your simulation and try to understand the program code.
    Notice: The symbol "@" referes to the entered material unit.
  21. Try to clear the queue file on every reset. Therefore open the reset method and input the following line: ".Models.Frame.OrderCompleted.delete();".