Search
my simulation login
the simulation centre

product information

product news

product support

hints and tips

home : simulation centre : product support: hints and tips: Witness
related links

Witness hints and tips

HINT 1

Ever wanted to dynamically change a decision rule on an element in Witness?

This example shows how you can create functions to change any aspect of your Witness simulation model, as it runs. This increases flexibility and gives you the ability to control aspects of the simulation model which its is currently not possible to change as the simulation is runing.

WARNING – this additional modelling flexibility needs to be used with caution as it actually changes the logic which appears in your Witness simulation models!

The following example creates a function, which will allow you to specify the conveyor name and input position, which a part will flow to when exiting a machine (on any other element utliliosing a push rule).

Firstly define a function called CONVEYOROUTPUT
Give it two parameters
CONVEYNAME which should be type Name
CONVEYPOS which should be type Integer

Within the body of the function enter the following three lines of code (Note: type the line beginning STRVAR on a complete line with no carriage returns in the middle):-

DIM STRVAR AS STRING
STRVAR = "DETAIL\nSELECT\n" + LEFTSTR (ELEMENT,STRSTR (ELEMENT,"(") - 1) + "\nOUTPUT RULE: PUSH to " + CONVEYNAME + " at (" + CONVEYPOS + ")\n!Model generated rule -See conveyoroutput;\n END" + LEFTSTR (ELEMENT,STRSTR (ELEMENT,"(") - 1) + "\n END SELECT\nEND DETAIL"
RETURN SETINFO (STRVAR)

On the actions on finish for the machine pushing to the conveyor you can call the CONVEYOROUTPUT function passing in the name of the conveyor which is being pushed to and the position along the conveyor.
e.g.

XX = CONVEYOROUTPUT (CONVEYOR1,3)

NOTE: YOU DO NOT NEED TO SPECIFY AN OUTPUT RULE ON THE MACHINE – THIS WILL BE CREATED AUTOMATICALLY !

Run the simulation model and then examine the machines output rule you will see the push rule has been created.

You can now enhance this logic by passing in a name variable as the conveyor name and an integer as the position.?

So how does it work?

The string contains the exact information which is contained in the list file format, which this information is passed into the model using the SETINFO command the new code is inserted.

The command LEFTSTR (ELEMENT,STRSTR (ELEMENT,"(") - 1) actually takes the name of the current element in this case the machine calling the function but without the parenthesis. It then adds the other information to create a push rule. The '!Model generated rule -See conveyoroutput' is simply warning text put after the output rule in order to explain how it was created

This same principle can be used to even create your own elements, maybe if you are reading information out of an excel worksheet into Witness

Please feel free to contact the Saker Solutions support line on 01789 762255 if you have any questions.
 

Back to top

visit the Witness product page here

©Copyright Saker Solutions 2007. All rights reserved.
Saker Solutions Limited, registered in England No 4819820.
Registered office: Warren Farmhouse, Sambourne Lane, Astwood Bank, Worcestershire.

Privacy Statement. Terms of use. Contact the Webmaster

Last modified on Monday, February 12, 2007