read Excel every second for changes

All topics on coding 4Dscript in Enterprise Dynamics.
Post Reply
Rens
Posts: 4
Joined: Thursday 24 April, 2014 - 15:44

read Excel every second for changes

Post by Rens »

Hi all,

I have a question about my project, I want to read my excel file every second or by a push message. But I don't know what I need to enter in the red marked field (see attachment).

What is the 4DS syntax for every second?

Rens
Rens
Posts: 4
Joined: Thursday 24 April, 2014 - 15:44

Re: read Excel every second for changes

Post by Rens »

Nick
Posts: 48
Joined: Saturday 15 February, 2014 - 01:52

Re: read Excel every second for changes

Post by Nick »

Hi Rens,

Could you please explain me a little more about your model / approach. I don't know whether it is a good idea to update your model data every second from excel.

Regards, Nick
Rens
Posts: 4
Joined: Thursday 24 April, 2014 - 15:44

Re: read Excel every second for changes

Post by Rens »

Hi,

Thanks for your interest and reaction,

I use my ED in combination with Microsoft Visual Studio. Visual Studio is my user interface, so you can change some objects or product flows in the model.

I have a production of goods some buffers and packing machines. My goal is to find out if one big packers is better than more smaller packers. So I can select in Visual Studio which packer I want to use and what his capacity is (products/hour).

I can not set up a direct connection between Visual Studio and ED, therefor I use 'database' in Excel. I put my settings in the database and want to read them in ED. Now I have a connection but ED reads my Excel only on resets, now I want to receive data every second or if there are changes in Excel.

Best Regard,

Rens
Nick
Posts: 48
Joined: Saturday 15 February, 2014 - 01:52

Re: read Excel every second for changes

Post by Nick »

Hi Rens,

You can use the User Events atom to create a function (User Event) which executes the function 'ExcelActiveX_Read()' at specified intervals, i.e. every 1 second. Refer to this user event function in the capacity field of the buffer/packer atoms.

Regards, Nick
Rens
Posts: 4
Joined: Thursday 24 April, 2014 - 15:44

Re: read Excel every second for changes

Post by Rens »

Hi Nick,

In the HELP I can not find information over 'ExcelActiveX_Read()'. Do you know where I can find this information over this function. E.g. parameters.

I want to update every second my excel table, with the red marked button in the Annex I reach this. But how can i do this by 4d Script?

Rens
Attachments
Capture2.PNG
Capture2.PNG (39.18 KiB) Viewed 6553 times
SimonvdW
Posts: 47
Joined: Thursday 06 January, 2011 - 09:52

Re: read Excel every second for changes

Post by SimonvdW »

Hi Rens,

Attached the example model (incl. Excel file) for the ExcelActiveX atom with some minor modifications to read the Excel file every x seconds.
I added a User Event atom which defines a function that calls the Excel file every minute (you can change that to 1 second if you want). If you alter a value in the Excel inbetween (for example the Queue dimension) you will see that after the next call, the capacity attribute is changed.

Regards,
Simon
Attachments
ExcelActiveX.xls
the input file
(17 KiB) Downloaded 282 times
ExcelActiveX_Topic.mod
The model
(21.05 KiB) Downloaded 285 times
Post Reply