Error in stop model with 4D Script in Source

All topics on coding 4Dscript in Enterprise Dynamics.
Post Reply
Heimann
Posts: 17
Joined: Saturday 11 August, 2012 - 19:37

Error in stop model with 4D Script in Source

Post by Heimann »

This is a simple model, I have got problem for stop model & stop Entre product in source after specific time ,I write this 4D script in Trigger on exit:

if(Time>50,CloseInput(c))

Dont work correctly
Thanks for your Answer
Heimann
Attachments
2222.mod
Error Stop time
(15.46 KiB) Downloaded 330 times
MarvinH
Posts: 93
Joined: Tuesday 25 January, 2011 - 11:07
Contact:

Re: Error in stop model with 4D Script in Source

Post by MarvinH »

Hello Heimann,

Thanks for your question. Considering the creation of atoms by a Source, it would be better to close the output. The product connected to the input channel of the source does not actually enter the source, it is only used for referencing purposes. So in case you want to stop the creation of products after 50 seconds, please use the following code OnExit of the source:

Code: Select all

if(Time>50,CloseOutput(c))
Further note that the source has the option to provide the number of products to be created. As the inter-arrival time equals 3, you could also choose to create 17 products, which will result in the same behaviour.

As a final remark, I noticed that the code OnEntry of the sink contains a small error. To combine several statements, please use "do" instead of "and". The "and" function is used to evaluate whether several boolean expressions all return True. Please refer to the Help file (F1) for more information about "do" and "and".

Good luck!

Kind regards,

Marvin
Heimann
Posts: 17
Joined: Saturday 11 August, 2012 - 19:37

Re: Error in stop model with 4D Script in Source

Post by Heimann »

Hello Marvin,

Thanks for your Answers. I change, and don't have any error, model work good,this is a model without any probability, I needed to check it then use statistical Distribution in the model , in the sink needed to stop simulation after 60th seconds, but this model stop in 65th Seconds, why?why don't stop in 61 or 62?
and further note that result in the same behavior in the sink

do(if(time>60,msg([Finish])),if(time>60,Stop))
if(time>60,and(msg([Finish]),Stop))

Kind regards,

Heimann
Attachments
2222.mod
New model
(15.47 KiB) Downloaded 317 times
MarvinH
Posts: 93
Joined: Tuesday 25 January, 2011 - 11:07
Contact:

Re: Error in stop model with 4D Script in Source

Post by MarvinH »

Hello Heimann,
Heimann wrote:in the sink needed to stop simulation after 60th seconds, but this model stop in 65th Seconds, why?why don't stop in 61 or 62?
The EntryTrigger of the sink is only evaluated when a product enters. So in case the product enters after 65 seconds, then the simulation will stop after 65 seconds.

Please note it is possible to include a UserEvent in your model, in which you can define to stop after 60 seconds. Actually, you can define two user events, one for stopping the output of the source after 50 seconds and one for stopping the simulation after 60 seconds. I have added an example model to the post.

Good luck!

Kind regards,

Marvin
Attachments
2222_UserEvents.mod
User events added
(18.85 KiB) Downloaded 337 times
Heimann
Posts: 17
Joined: Saturday 11 August, 2012 - 19:37

Re: Error in stop model with 4D Script in Source

Post by Heimann »

I'm using Ed 8.1 , when i open last file(user event), I saw Error monitor with these result:


1 Compile error: "USEREVENTS__NOTIMESCHEDULE" is not a valid expression. Reference: do(var([strBegin],vbString),var([strAtt],vbString),var([strPointer],vbString),var([strNewPointer],vbString),var([strNewAtt],vbString),repeat(NrOfAttributes,do(if(cell(count,USEREVENTS__NOTIMESCHEDULE,c)=1,do(strAtt:=textatt(count,c),strBegin:=StringCopy(strAtt,0,4+StringPos([vtp(],strAtt)),strPointer:=StringCopy(strAtt,StringLength(strBegin),-1+StringPos([)],StringCopy(strAtt,StringLength(strBegin),StringLength(strAtt)-StringLength(strBegin)))),strNewPointer:=string(ptv(c)),strNewAtt:=StringReplace(strAtt,strPointer,strNewPointer),textatt(count,c):=strNewAtt)))),repeat(NrOfAttributes,Do(RegisterFunction(StringReplace(AttributeName(Count,c),[att_],[]),[Various],0,0,textatt(count,c),[],[],true))))
2 4DScript:error at "AddModel3D":File C:\Program Files\Enterprise Dynamics 8 Developer\Media\3DModels\source_Resized.wrl does not exist.
3 4DScript:error at "AddModel3D":File C:\Program Files\Enterprise Dynamics 8 Developer\Media\3DModels\sink_Resized.wrl does not exist.
4 4DScript:error at "AddModel3D":File C:\Program Files\Enterprise Dynamics 8 Developer\Media\3DModels\Server_Resized.wrl does not exist.
5 4DScript:error at "AddModel3D":File C:\Program Files\Enterprise Dynamics 8 Developer\Media\3DModels\Server2_Resized.wrl does not exist.
6 4DScript:error at "AddModel3D":File C:\Program Files\Enterprise Dynamics 8 Developer\Media\3DModels\Server_Resized.wrl does not exist.
7 4DScript:error at "AddModel3D":File C:\Program Files\Enterprise Dynamics 8 Developer\Media\3DModels\Server2_Resized.wrl does not exist.

Do these problem relate to Version of ED?
User avatar
Fred
Posts: 22
Joined: Wednesday 17 November, 2010 - 12:06

Re: Error in stop model with 4D Script in Source

Post by Fred »

Hi Heimann,

This is indeed caused by the version difference.

The model opens fine in version 8.2.5.

And in relation to the error messages, we indeed incorporated a number of updates which result in the error messages you receive.

Is it possible for you to upgrade to 8.2.5?

Anyway I quickly rebuild the model in 8.1.

Gr. Fred...
Attachments
user2222_81.mod
Model developed with version 8.1
(17.22 KiB) Downloaded 323 times
Heimann
Posts: 17
Joined: Saturday 11 August, 2012 - 19:37

Re: Error in stop model with 4D Script in Source

Post by Heimann »

Hello
And I have a problem
I need Use this Situation in time column in “user event” for “Sink”:
if(content(in(1,c))=1,att(in(1,c)+5,5)

this is for finish simulation with server without any atom
Thanks
Heimann D
MarvinH
Posts: 93
Joined: Tuesday 25 January, 2011 - 11:07
Contact:

Re: Error in stop model with 4D Script in Source

Post by MarvinH »

Hello Heimann,

Your problem is not quite clear to me.

I assume that you want to stop the simulation at a certain time, and you are using the User Event atom to do this. The code you included is not entirely clear to me.

By use of the User Event atom, you can define an event at a certain time. On the code of the event, you could simply use the code "Stop" to stop the simulation. If you want to perform other actions (like writing data to attributes or tables) you can execute these on the same event as well, by combining the statements within a "Do".

For more help on using the User Event atom, please refer to the ED Help file (F1).

In case of any questions, please return to this topic.

Kind regards,

Marvin
Post Reply