Timing sources

All topics on coding 4Dscript in Enterprise Dynamics.
Post Reply
Spaggio86
Posts: 12
Joined: Sunday 16 March, 2014 - 15:15

Timing sources

Post by Spaggio86 »

Just 2 questions:

1) I have 4 sources with a specific inter arrival time but I need one of this sources stops to dispence products after a specific time... For example: the source starts to work like the other sources, but after 4 hours it stops to dispence. This is possible? How to?

2) I can't find tha guide for 4D Script... Someone could say me where to find it? In the help window there is no voice about this... Perhaps it's because I have only the student version?

Thanks in advance!!!!
Nick
Posts: 48
Joined: Saturday 15 February, 2014 - 01:52

Re: Timing sources

Post by Nick »

Hi Spaggio86,

1.a For this you can use the User Events atom. This atom executes a certain function according to a certain time schedule. It can be found under the category '6 TIME' in the atom library.

1.b Connect the input channel of the User Events atom to the information channel of the Source atom. Give the event a name and add 'hr(4)' in the time field to let the event execute after 4 hours simulation time. On the edit event tab you can use the following code:

Code: Select all

 CloseOutput(in(1,c))
2. Additional study materials are available under:
http://academy.incontrolsim.com/documen ... ation.html

Regards, Nick
Spaggio86
Posts: 12
Joined: Sunday 16 March, 2014 - 15:15

Re: Timing sources

Post by Spaggio86 »

Great, it works.. but in 4D Script I'can to understand how to write more expressions than one. For example.. If in my User Events I write

hr(4) in time field

and

CloseOutput(in,c) in the edit

It close the output of the atom linked to the first input of the current atoms... Perfect... But, If I want to close the atom linket to the secont imput too? How can I write?

The seguents expression in Edit Event didn't work:

CloseOutput(in(1,c)),CloseOutput(in(2,c))
CloseOutput(in(1,c),in(2,c))
CloseOutput(And(in(1,c),in(2,c)))
CloseOutput(in(1,2,c))

How to write this?
Nick
Posts: 48
Joined: Saturday 15 February, 2014 - 01:52

Re: Timing sources

Post by Nick »

Hi Spaggio,

Your first solution was almost correct. However, whenever you want to execute multiple functions you always have to use the Do function. The Do function is the function to nest various other functions (See also ED Help).

How to use the function 'do':

Code: Select all

Do(
   CloseOutput(in(1,c)),
   CloseOutput(in(2,c))
)
How to use the function 'in':

Code: Select all

{first inputchannel}
In(1,c)

{second inputchannel}
In(2,c)

{atom connected to second input channel of the atom connected to the first input channel of atom c)  
In(2,in(1,c))
Regards, Nick
Spaggio86
Posts: 12
Joined: Sunday 16 March, 2014 - 15:15

Re: Timing sources

Post by Spaggio86 »

Thanks Nick for all your help. I didn't considerate the DO expression. It works perfeclty!!!
Post Reply