Script for registering time

All topics on coding 4Dscript in Enterprise Dynamics.
Post Reply
ngsim
Posts: 10
Joined: Tuesday 19 April, 2011 - 20:42

Script for registering time

Post by ngsim »

Hello Incontrol

I am currently doing a model in which I have a table where I write the setup time and proces time. What i need is a script that can tell me the time in the model and not only just when an atom leaves an atom.

The Statusmonitor-atom is doing that but it does not allow me to see the data for every hour. I have tried to use the experimental wizzard with 1hr observation periods and 100 observations because I want to see the ratio between setup and processing time. But unfortunately I have found out that the wizzard resets all values to zero for each observation run.

I hope you can help me?
menno
Posts: 45
Joined: Tuesday 29 March, 2011 - 16:01

Re: Script for registering time

Post by menno »

With the code 'Time' you can retrieve the current elapsed simulation time.

A way to get the values you want, can be the following:

You can use labels on the Setup Time trigger and the Cycletime trigger of a Server to calculate the cumulative setup and cycle times, for instance:

Setup Time trigger:

Code: Select all

do(
 var([valSetupTime], vbValue),
 var([valReturn], vbValue),

 valSetupTime := negexp(9),
 label([CumulativeSetupTime],c) := label([CumulativeSetupTime],c) + valSetupTime ,

 valReturn := valSetupTime,

valReturn   
) 
You can do the same for the Cycle Time.

With help of the User Events atom, you can create events (for instance, every 3600 seconds), that will read the current values of these labels from the Server. You can can use the Table atom to store these values.

In this way, you have the setup times and cycle times for every hour, without resetting them to zero.
ngsim
Posts: 10
Joined: Tuesday 19 April, 2011 - 20:42

Re: Script for registering time

Post by ngsim »

Thank you for your proposal.

Unfortunately I cannot get the User Event atom to work. I have not used it before, so might be making beginners mistakes....

I have set the Time [s] = 3600 and set the following event trying to write the data to the table:


do(
Setdata(1,output(c),label([cumulativesetuptime],c)),
Setdata(1,output(c),Label([cumulativeprocestime],c))
)

However it keeps writing 0. I have been using output(c) to get it to count into a new row in the table, but Im affraid its doing something bad to my model. I cant get the nrows function to work.

Any suggestions?

Thanks
menno
Posts: 45
Joined: Tuesday 29 March, 2011 - 16:01

Re: Script for registering time

Post by menno »

Here are some suggestions:

Table Atom:
Use the 'create alias' function, when you use this atom. If you do, you can use the reference 'refData' in your code in the User Events atom. Use 2 columns if you want to write two different output parameters.

User Events:
You can use the Server as 'Involved Atom' in the settings. By connecting an input channel of the Server (2nd channel for instance) to the central channel of User Events atom, then you can enter in the field for 'Involved Atom' (User Events-> Settings): in(2,c)

Now we have all the references we need.

You can use 'Repeat time' instead of 'Time', so the event is rescheduled for every repeat time.

The event code can then be the following:

Code: Select all

do(
 settable(nrows(refdata) + 1, ncols(refdata), refdata), {refdata is the reference to the table}
 
 Setdata(nrows(refdata) ,1, label([cumulativesetuptime],i)), {i is the involved atom: the server}
 Setdata(nrows(refdata) ,2, label([cumulativeprocestime],i))
 
)

I hope that these suggestions can help you!
kanita
Posts: 1
Joined: Monday 22 December, 2014 - 10:51

Re: Script for registering time

Post by kanita »

Hi,

It is possible to use the Assembler - Unpack combination for such a problem.

The Bill of Material (BOM) table in the assembler defines how many products from each of the input channels have to be loaded on the container atom (the truck that must be connected to the first input channel). The rows in the table refer to Input channels 2 .. n.

The unpack can be a representaton of a shop where the truck has to deliver a number of goods. The number of products that will be loaded from the truck is entered in the Unpack quantity. This is by default everything: content(first(c)). But you can enter another amount, read a value from a label, read it from a line in a tabel, , ....
Keep in mind that the unpack will always take the products from the truck according to Last In First Out (just as in reality). If you want specific products to be unloaded at specific shops you have to control the order they are feeded to the assembler or rearrange the order once they are in the truck.
Post Reply