Help: Fuction depend on circle time

All topics on coding 4Dscript in Enterprise Dynamics.
Post Reply
remix568
Posts: 8
Joined: Thursday 09 January, 2014 - 10:35

Help: Fuction depend on circle time

Post by remix568 »

Hi,

I am a new user. I just read the tutorials and know how to creat a basic models.
I need to creat variable functions which depends on the time. For examples, the product need A minutes to go through the maschine 1 and B minutes for maschine 2. And I need a Simulation that I can get a result with a function like C=A*2+B*3. A and B can be changed anytime or insert from a excel Table.
Can you please help me how can I do that?

Remix
SimonvdW
Posts: 47
Joined: Thursday 06 January, 2011 - 09:52

Re: Help: Fuction depend on circle time

Post by SimonvdW »

Hi,

If you want to have variable or flexible assignments of process times, an easy way is using labels. You can assign a label to a product. This is possible in any atom in a trigger. From that moment this label can be read again to decide about routing, process times and more. You can use the labels to create evaluations with variables.

A good location to set them is the Source. In the OnCreation or OnExit use for example the assignment code:

label([producttype],i) := Bernoulli (60 , 1, 2). So, 60% of the products gets value 1, the other 40% value 2.

In the Cycle time of a Server you can now refer to this label [producttype], for example in an If statement:

if( label([producttype],first(c)) = 1, 7 , negexp(10) )

{if the label value = 1 a cycle time of 7 seconds is assigned, otherwise (value 2) the distribution NegExp(10) is assigned as cycle time.

Note: labels are case sensitive!
An example is shown in the Tutorial ED Annexes - Chapter 2 Source atom, under Trigger on exit.

Regards,
Simon
remix568
Posts: 8
Joined: Thursday 09 January, 2014 - 10:35

Re: Help: Fuction depend on circle time

Post by remix568 »

Hi Simon,

Thank you for your quickly answer.
I think I have understood your solution. I think what I need exactly is a variable label.

I need to do following:
In the Souce I will set a label for the product.
such like: label([producttype],i) := i ( i =1,2,3..)

The Cycle time of a server will then refer to this label.
such like: if( label([producttype],first(c)) = i, i*2) (Cycletime = label value*2)

And the label should be set again on the trigger on exit of the server. It should now refer to the Cycle time.
such like: the new label = Cycletime* old label value.

With this new label goes the product to a second server and the Cycle time will then refer to this new label.

Is that possible to realize that with using labels?

I´d really appreciate if you can also make a easy example like that.

Thank you very much!

Best Regards
Remix
SimonvdW
Posts: 47
Joined: Thursday 06 January, 2011 - 09:52

Re: Help: Fuction depend on circle time

Post by SimonvdW »

Remix,

Attached an example model.
I set the label using a value from an Emperical Distribution. This is a very flexible way.

The label value is used in the cycle time and afterwards the label is reused by assigning a new value for the second Server in the exit trigger.
In the attached model I added some comments to clarify what I did.

Good luck,
Simon
Attachments
community_test.mod
(18.72 KiB) Downloaded 328 times
remix568
Posts: 8
Joined: Thursday 09 January, 2014 - 10:35

Re: Help: Fuction depend on circle time

Post by remix568 »

Hi Simon,

thanks for the attachment. It helps me a lot. That is exactly what I need.

And a last question to this Label-Function.

How can I get the Label information from each product? Like in your attachment each product get a different variable value at the end. Can the Values also write in to a Excel or other possible form? How can I do that.

Thanks a lot.

Best Regards
Remix
SimonvdW
Posts: 47
Joined: Thursday 06 January, 2011 - 09:52

Re: Help: Fuction depend on circle time

Post by SimonvdW »

Hi,

An easy way of using an Excel table to write data to (for example the label values) is using the ExcelActiveX atom.
Create an Excel document with a worksheet named for example 'Output'. Drag in the ExcelActiveX atom from the Data-group. Refer to this Excel document by browsing to this file and chosse the worksheet Output as default sheet in the 'General' tab of the atom. Now click connect to establish a connection between the model and Excel.

In the trigger code of an atom you can use code to write a specific value to the correct row and column in the correct worksheet of Excel through Active X.
I attached a sample model again with the following code on the entry of the sink:

ExcelActiveX_Write(Input(c) + 2, 1, label([producttype],i), [Output], atmExcelActiveX)

Input(c) is the number of products received and is automatically increased. It refers to the row number (starts with 3, so I can use row 1 to write a header and 2 to leave blank). The 1 is the first column and [output] is the sheet name.

Regards, Simon
Attachments
community_test02.mod
(19.94 KiB) Downloaded 312 times
Post Reply