Utilization of the server into a table

All topics on coding 4Dscript in Enterprise Dynamics.
Post Reply
Jojo
Posts: 5
Joined: Monday 12 August, 2013 - 13:06

Utilization of the server into a table

Post by Jojo »

Hello,
i need help with a little problem. I want to write the current utilization (which is displayed) of a server atom into a table.
I am not sure about the 4D code.

Hope you guys can help me. Thanks
menno
Posts: 45
Joined: Tuesday 29 March, 2011 - 16:01

Re: Utilization of the server into a table

Post by menno »

Hello Jojo,

I assume you want to write it in a Table atom. If you want to write something in a Excel table, then take a look at the example model ExcelActiveX.mod.

For writing into an Table atom, you can do the following (it depends a bit when exactly you want to write into the table):

Say you have named the table to write in UtilizationTable, and you are interested in the utilization everytime a product has left a server, then you must put the following code on the ExitTrigger of the server:

Code: Select all

Do(
  cell(input(c), 1, ref UtilizationTable) := 
  String ( 
    100 * ((att([TotalBusy],c) - Max( 0, att([EndBusy],c) - Time))/Time),
    0,
    1
  )
)

Now, every time a product leaves the server, the utilization at that moment is written on a new row of the table (if the table has enough rows).

Hopefully this will help!

Kind regards,

Menno
Jojo
Posts: 5
Joined: Monday 12 August, 2013 - 13:06

Re: Utilization of the server into a table

Post by Jojo »

Oh thanks, works fine!

Kind regards, jojo
Jojo
Posts: 5
Joined: Monday 12 August, 2013 - 13:06

Re: Utilization of the server into a table

Post by Jojo »

I have one more question, because i am a beginner in ED and 4dscript. So can you tell me what the attributes "att([TotalBusy],c)" and "att([EndBusy],c)" in

Code: Select all

100 * ((att([TotalBusy],c) - Max( 0, att([EndBusy],c) - Time))/Time)
mean?

Are these predefinied variables?

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

Re: Utilization of the server into a table

Post by menno »

Hello Jojo,

Attributes are standard variables of an atom. These attributes I mentioned are used within the Server atom. If you open the Library tree, select the atom Server and press F9, then select the tab 'Attributes', then you can see which attributes the Server has. Under the tab 'Events', you can find the code on the different events that the Server undergoes. In these events and thus the code, its attributes are used.

Kind regards,

Menno
Jojo
Posts: 5
Joined: Monday 12 August, 2013 - 13:06

Re: Utilization of the server into a table

Post by Jojo »

Oh great, thanks a lot!

Kind regards, Jojo
Post Reply