write different Times to Excel

All topics on coding 4Dscript in Enterprise Dynamics.
Post Reply
LoesClephas
Posts: 1
Joined: Friday 04 November, 2011 - 16:56

write different Times to Excel

Post by LoesClephas »

We have a production line, with two sources (with two different products arriving with a different processing times), one queue, one processor and one sink. We made the following:

Trigger on exit (Source1):


Do(
SetLabel([servicetime],NegExp(36),i),
Label([Type],i) :=1,
i.starttimesource1=Time
)

Trigger on creation (sink):


Do(
ExcelWrite(Output(c),1,starttimesource1),
ExcelWrite(Output(c),2,starttimesource2),
ExcelWrite(Output(c),3,starttimequeue),
ExcelWrite(Output(c),4,endtimequeue),
ExcelWrite(Output(c),5,LabelName),
ExcelWrite(Output(c),6,starttimeserver),
ExcelWrite(Output(c),7,endtimeserver),
ExcelWrite(Output(c),8,Time)
)

We would like to find out all the times between de sources PER PRODUCT 1 AND 2 and write this to excel. Does anyone know how? Because now it says that starttimesource1, starttimesource 2, etc. are no valid expressions. Please help!

Kind regards,

Geoffrey, Wesley and Loes
MarvinH
Posts: 93
Joined: Tuesday 25 January, 2011 - 11:07
Contact:

Re: write different Times to Excel

Post by MarvinH »

Hello!

First of all, to be able to write data to Excel, a Excel-atom should be included in your model. This can be done by dragging it into the model from the library, under DATA. Then open the form of the Excel-atom (by double clicking it) to specify what Excel file should be written to and press the Connect button. Now the file will be opened in Excel.

Second, please make sure your actions in the model actually set the labels. For example, in the code you execute on the source, you "check" the label StartTimeSource1, setting is done by using := (instead of just =). Please check this on other places in your model as well.

Finally, on the sink you refer to the labels just by using the name. In case you refer to the labels as you have done on the source (so either using Label([StartTimeSource1], i) or i.StartTimeSource1), it will be valid expressions. Further you have to use input(c) instead of output(c) as the atoms only enter the sink and do not leave anymore!

When you have changed your model as described above, you should see your data in Excel immediately.

Please return to the forum in case you have any other questions, or to tell us that your model works perfectly! :)

Good luck!

Kind regards,

Marvin
Natascha
Posts: 6
Joined: Thursday 19 January, 2012 - 10:37

Re: write different Times to Excel

Post by Natascha »

I have a question to the Cycletime in a multiserviceatom?

Is it possible to analyze all the different cycletimes from products which entered the multiserviceatom?
MarvinH
Posts: 93
Joined: Tuesday 25 January, 2011 - 11:07
Contact:

Re: write different Times to Excel

Post by MarvinH »

Hello!

The function Time returns the current time in the simulation model. The function EntryTime(i) returns the time instance the involved atom entered the atom it is currently in. So you can put the following code on the exit trigger of the MultiServer:

Code: Select all

Trace(String(Time - EntryTime(i)))
This will fill the tracer window with the cycle times of the MultiServer. You can analyze this data for example with Excel. Another option is to write the times to a table in Enterprise Dynamics and analyze the data in there.

Regards,

Marvin
Natascha
Posts: 6
Joined: Thursday 19 January, 2012 - 10:37

Re: write different Times to Excel

Post by Natascha »

Thanks :) The tracerwindow is working.

How can I write this Data into an excel-sheet?

Think I have to use an excel-atom in my programm. I have never worked before with it and I don´t know which things I have to adjust.
Natascha
Posts: 6
Joined: Thursday 19 January, 2012 - 10:37

Re: write different Times to Excel

Post by Natascha »

I need a listing at which simulation time the products come to the multiservice and which cycletime they have in the multiservice.

Is it possible to create these in excel? :shock:
MarvinH
Posts: 93
Joined: Tuesday 25 January, 2011 - 11:07
Contact:

Re: write different Times to Excel

Post by MarvinH »

Hello!
Natascha wrote:Thanks :) The tracerwindow is working.
Great!
Natascha wrote:I need a listing at which simulation time the products come to the multiservice and which cycletime they have in the multiservice.

Is it possible to create these in excel? :shock:
Yes, of course this is possible. To connect to Excel, please refer to Re: write different Times to Excel and the Help file. The data you need to write can be created by the following code OnExit of the MultiServer:

Code: Select all

Do(
  ExcelWrite(Output(c), 1, Output(c)),
  ExcelWrite(Output(c), 2, EntryTime(i)),
  ExcelWrite(Output(c), 3, Time - EntryTime(i))
)
This code writes the output index (i.e. how many products have exited the the MultiServer) in column 1, the entry time of the specific product in column 2 and the cycle time in column 3.

Good luck!

Marvin
Post Reply