ATTENTION

This FlexSim Community Forum is read-only. Please post any new questions, ideas, or discussions to our new community (we call it Answers) at https://answers.flexsim.com/. Our new Question & Answer site brings a modern, mobile-friendly interface and more focus on getting answers quickly. There are a few differences between how our new Q&A community works vs. a classic, threaded-conversation-style forum like the one below, so be sure to read our Answers Best Practices.


flexsim.com

Go Back   FlexSim Community Forum > FlexSim Software > Q&A
Downloads

Q&A Using Flexsim and building models

  #1  
Old 05-14-2008
KelvinHo KelvinHo is offline
Flexsim User
 
Join Date: Jan 2008
Location: Hong Kong
Posts: 129
Downloads: 18
Uploads: 1
Thanks: 44
Thanked 23 Times in 7 Posts
Rep Power: 171
KelvinHo will become famous soon enough
Default Flow item in object in time 0

Hi,

I would like to make some flow items in some object at time 0. Beside I add source connected to the target object and set arrive once and arrive at time 0, is there any method to add Flow item in object in time 0?

Thanks,

Kelvin
  #2  
Old 05-14-2008
Tom David's Avatar
Tom David Tom David is offline
Flexsim User
 
Join Date: Aug 2007
Location: Schwaebisch Gmuend, Germany
Posts: 430
Downloads: 157
Uploads: 47
Thanks: 486
Thanked 450 Times in 233 Posts
Rep Power: 520
Tom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant future
Default

Kelvin,

I hope I understand you right. What I normally do if I like to have a flowitem in e.g. a Queue at the start of the simulation I just put a flow item into the Queue with the OnReset Trigger.

Code:
// CREATE ITEM IN MODEL
createcopy(node("/Tools/FlowItemBin/5/1",model()),model());
// MOVE ITEM FROM MODEL INTO OBJECT (FIRES THE TRIGGERS)
moveobject(last(model),current);
This code puts a Textured Colored Box into current. You can also set the name and add labels if you like. You just need to pointer to the item (first(current)) and use commands like setname() and addlabel().
I create the flowitem in the model first and than move it into the object, because so it will fire the OnEntry Trigger. If you do not want that the OnEntry Trigger gets fired you can use transfernode().

Good success
tom the (A)tom
__________________
tom the (A)tom: "We have solved our problems ... now we have to fight the solutions."
The Following 4 Users Say Thank You to Tom David For This Useful Post:
KelvinHo (05-15-2008)
  #3  
Old 05-14-2008
Brandon Peterson's Avatar
Brandon Peterson Brandon Peterson is offline
The Flexsim Consultant
 
Join Date: Jul 2007
Location: Salt Lake City, Utah
Posts: 382
Downloads: 29
Uploads: 6
Thanks: 192
Thanked 516 Times in 235 Posts
Rep Power: 490
Brandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant future
Default

Tom, Kelvin,

Just to stay on the safe side you might want to take the above code and put it in the OnMessage trigger and send a delayed message for 0 time in the OnReset trigger. This insures that you don't run into any funky problems that can occur when you do something in the middle of a a larger Flexsim function. This is the same reason we suggest that you don't do certain things on entry or exit but rather send a delayed message in zero time.

I'm sure Tom has used the above method many times with no bad effects but you just never know when that might bite you.

Brandon
__________________
thats not normal.
The Following 6 Users Say Thank You to Brandon Peterson For This Useful Post:
RalfGruber (12-03-2008)
  #4  
Old 05-14-2008
Anthony Johnson's Avatar
Anthony Johnson Anthony Johnson is offline
Manager of Product Development
 
Join Date: Jul 2007
Posts: 440
Downloads: 86
Uploads: 4
Thanks: 171
Thanked 899 Times in 288 Posts
Rep Power: 735
Anthony Johnson has a reputation beyond reputeAnthony Johnson has a reputation beyond reputeAnthony Johnson has a reputation beyond reputeAnthony Johnson has a reputation beyond reputeAnthony Johnson has a reputation beyond reputeAnthony Johnson has a reputation beyond reputeAnthony Johnson has a reputation beyond reputeAnthony Johnson has a reputation beyond reputeAnthony Johnson has a reputation beyond reputeAnthony Johnson has a reputation beyond reputeAnthony Johnson has a reputation beyond repute
Default

I agree with Brandon. The reset trigger should be used to reset the model to an initial state, not to begin the next run of the simulation. Hence you should do "resetting" functionality in the reset trigger, i.e. resetting labels to their initial value, resetting locations, etc., but send a delayed message in 0 time if you want to do stuff to start off the model run. As Brandon says, this is really just a "Best Practices" suggestion, so if you can get it to work using the reset trigger, so be it. Just a heads-up. I know that we have had issues in the past where models would not properly update to newer versions when there was model start-up logic in the reset triggers, although I don't remember exactly what the issue was, and it may have been fixed by now. That was way back in the Flexsim 2.x days. Anyway, as Brandon says, you never know when it may bite you.
The Following 3 Users Say Thank You to Anthony Johnson For This Useful Post:
KelvinHo (05-15-2008)
  #5  
Old 05-15-2008
Tom David's Avatar
Tom David Tom David is offline
Flexsim User
 
Join Date: Aug 2007
Location: Schwaebisch Gmuend, Germany
Posts: 430
Downloads: 157
Uploads: 47
Thanks: 486
Thanked 450 Times in 233 Posts
Rep Power: 520
Tom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant future
Default New triggers in Flexsim (OnInit, OnStateChange)?

Anthony,
Brandon,

I totally agree with you guys that doing the job in the OnReset trigger might be not a good idea, even if it seems to work. So you see, that even me, as a user who should know better, keeps forgetting these things.

I hope that Kelvin’s questions are answered, because I fear that I now will start to go off topic. But I also do not feel to start a new thread. Anyway, I hope it is fine for everybody to do so.

If I think about the OnReset trigger and as Anthony describes for what it should be used, I wonder if it would not be a good idea to have an OnInit trigger and an OnReset trigger.
OnInit Trigger will be fired at pressing the OnReset button and OnReset will be fired at time 0.

Maybe it is to late now to implement such a trigger because of downward compatible reasons. But this would prevent some issue we had and might get, right?


Another thing I like to add in this discussion speaking about triggers. Ralf added a trigger called OnStateChange in the development list. I personally think that would be a very nice trigger and gives a lot of more flexibility. Some people already comment this in the development list and I like to encourage more people to also add comments that the priority gets higher.
It is point number: 466 OnStateChange Trigger or at least node in the variables tree of each object

Take care
tom the (A)tom
__________________
tom the (A)tom: "We have solved our problems ... now we have to fight the solutions."
  #6  
Old 05-15-2008
Lars-Olof Leven Lars-Olof Leven is offline
Flexsim Distributor
 
Join Date: Aug 2007
Location: Sweden, Borlnge
Posts: 312
Downloads: 278
Uploads: 2
Thanks: 300
Thanked 256 Times in 139 Posts
Rep Power: 330
Lars-Olof Leven is a splendid one to beholdLars-Olof Leven is a splendid one to beholdLars-Olof Leven is a splendid one to beholdLars-Olof Leven is a splendid one to beholdLars-Olof Leven is a splendid one to beholdLars-Olof Leven is a splendid one to beholdLars-Olof Leven is a splendid one to behold
Default

Hi Tom,

I would not mind to have a trigger that is fired at time 0.
But I think that the trigger OnReset should be still fired when
pressing Reset and the new trigger should be called something
like OnTimeZero, OnSimulationStart etc.

For me OnInit and OnReset is almost the same name for the same thing.

Lars-Olof
  #7  
Old 05-15-2008
Steven Hamoen's Avatar
Steven Hamoen Steven Hamoen is offline
Talumis, Flexsim Distributor, The Netherlands
 
Join Date: Aug 2007
Location: Soest, NL
Posts: 854
Downloads: 43
Uploads: 0
Thanks: 391
Thanked 661 Times in 379 Posts
Rep Power: 684
Steven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond repute
Default

Tom,

I agree with Lars-Olof, the difference is so small that it would only be confusing. And then if you continue on this path, you would also get a trigger that is called "Just after entering" and "Just after exiting" because you have the same problems there as well.

May I misuse this thread to point to an option I just found out (thanks to Lolke) and that is the 4 triggers that can be found in the Tools menu option under "Model Triggers".


These might be helpfull in some cases. I just used them to close an open file I wrote data to, when the model stops. Very usefull.

Concerning the onstatechange trigger, I fully support this option.

Steven

Last edited by Steven Hamoen; 05-15-2008 at 05:40 AM.
  #8  
Old 12-02-2008
darryl siegwalt darryl siegwalt is offline
Flexsim User
 
Join Date: Dec 2008
Location: New Hampshire
Posts: 3
Downloads: 0
Uploads: 0
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
darryl siegwalt is on a distinguished road
Default Flow items in Queue at time 0

I'm new to Flexsim and not too familiar with programming. I have started a simulation of our factory repair process. My first question is: It looks like I can set the number of flow items in a queue using the OnReset and OnMessage code template, but not sure how?

Hopefully will be attending training this coming spring.
Darryl
  #9  
Old 12-02-2008
Nico Zahn's Avatar
Nico Zahn Nico Zahn is offline
Flexsim User
 
Join Date: Sep 2007
Location: Bingen am Rhein, Germany
Posts: 179
Downloads: 19
Uploads: 4
Thanks: 66
Thanked 60 Times in 32 Posts
Rep Power: 201
Nico Zahn has a spectacular aura aboutNico Zahn has a spectacular aura about
Default

Hi Darryl, yes you can do this, or simply use a source.
If you use the create copy command, be sure to set the 'same name' parameter. Otherwise Flexsim will append some numbers to each copys name and after a lot of copys you end up with very long names and an error message.
createcopy(node("/Tools/FlowItemBin/5/1",model()),model(),1);

We once had that case and we could remove the error message (the name gets to long) and could speed up the model up to 10X by setting this parameter. (usally you do not look at the flowitem names.....)
__________________
kind regards Nico.
  #10  
Old 12-04-2008
darryl siegwalt darryl siegwalt is offline
Flexsim User
 
Join Date: Dec 2008
Location: New Hampshire
Posts: 3
Downloads: 0
Uploads: 0
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
darryl siegwalt is on a distinguished road
Default

Nico,
Thanks, I added a separate source for this Queue that fills it at time 0. However, from the Queue parameters, can I use the Create Flow items from the pick list in the OnMessage trigger? This would have to be combined with Send Message from the OnReset trigger?
Darryl
  #11  
Old 12-04-2008
Brandon Peterson's Avatar
Brandon Peterson Brandon Peterson is offline
The Flexsim Consultant
 
Join Date: Jul 2007
Location: Salt Lake City, Utah
Posts: 382
Downloads: 29
Uploads: 6
Thanks: 192
Thanked 516 Times in 235 Posts
Rep Power: 490
Brandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant future
Default

Darryl,

Yes you are correct you could use the the pick list options you mentioned to what you are asking.
__________________
thats not normal.
  #12  
Old 12-04-2008
darryl siegwalt darryl siegwalt is offline
Flexsim User
 
Join Date: Dec 2008
Location: New Hampshire
Posts: 3
Downloads: 0
Uploads: 0
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
darryl siegwalt is on a distinguished road
Default

OK, i am still having trouble figuring out what goes in the send message code template in the onReset trigger to get flow items in the queue on reset?
Thanks,
Darryl
  #13  
Old 12-04-2008
Brandon Peterson's Avatar
Brandon Peterson Brandon Peterson is offline
The Flexsim Consultant
 
Join Date: Jul 2007
Location: Salt Lake City, Utah
Posts: 382
Downloads: 29
Uploads: 6
Thanks: 192
Thanked 516 Times in 235 Posts
Rep Power: 490
Brandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant future
Default

Darryl,

First, would you mind updating your user profile so that those of us who are willing to help you can know a little more about who you are? I would appreciate that a lot.

Second, You will need to change the to object in the reset trigger to "current" so that the message is sent to the queue itself and not somewhere else.

Third, If you look at the On Message template code you will see that it is going to look at the first message parameter for the number of items to create and at the second message parameter for the flow item bin rank (the rank of the flow item you want to use). So, you can either specify both of these parameters in the Reset code as msg parameters 1 and 2 or you can change the code in the On Message trigger so be specifically what you want instead of refering to the msg parameters.

*You can find the flow item rank by looking in the flow item bin and counting down until you find the flow item you want to use.

Good Luck,
Brandon
__________________
thats not normal.
  #14  
Old 04-13-2012
shafizad shafizad is offline
ProcSim Consulting
 
Join Date: Jul 2010
Location: Switzerland
Posts: 75
Downloads: 18
Uploads: 0
Thanks: 90
Thanked 2 Times in 2 Posts
Rep Power: 126
shafizad is on a distinguished road
Lightbulb Need some explanation

well, Just because this thread looks really similar to my question, I post it here. I am confused!

Why doesn't this piece of code work when written OnModelReset?
Code:
treenode item=node("/Tools/FlowItemBin/Box/1",model());
treenode rack1=node("/Rack1",model());
for (int i=0;i< getvarnum(rack1,"maxcontent");i++)
{
        createcopy(item, rack1,1);
}
whereas this piece of code works perfectly in script window!?
(my purpose is to create some flowitems in my rack before I press RUN in my model (way before 0 time).)
  #15  
Old 04-14-2012
Jason Lightfoot Jason Lightfoot is offline
Flexsim Consultant
 
Join Date: Aug 2007
Location: Somerset, UK
Posts: 719
Downloads: 20
Uploads: 0
Thanks: 123
Thanked 953 Times in 446 Posts
Rep Power: 773
Jason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond repute
Default

The reset of the object fires after the model reset, and deletes the flowitems.

The trigger sequence for the v5 simple model attached is this:
..
..
End of Replication 2
End of Scenario 1
Start of Scenario2
Model Reset
/Tools/MTBFMTTR/MTBFMTTR60 First Failure Sampled
Reset object rank 2 - /Source1
Reset object rank 3 - /Processor2
Reset object rank 4 - /Sink3
Start of Replication1
..
..

In version 6 you now get run start and stop firing for each replication where before it was only at the start and end of the experiment. There's no start of scenario trigger in version 6, although if your experiment is imported from v5 it still fires. Start of Scenario never fires for scenario 1 even if you selected scenario 2 in the experiment gui. The other scenarios' (>1) start triggers fire for every replication.

Typical replication trigger sequence:

Start of Scenario2
Model Reset
/Tools/MTBFMTTR/MTBFMTTR60 First Failure Sampled
Reset object rank 2 - /Source1
Reset object rank 3 - /Processor2
Reset object rank 4 - /Sink3
Start of Replication1
On Run Start
<model executes replication>
On Run Stop
End of Replication 1
Attached Files
File Type: fsm TriggerSeqeunce.fsm (49.1 KB, 99 views)
The Following 3 Users Say Thank You to Jason Lightfoot For This Useful Post:
RalfGruber (04-16-2012)
  #16  
Old 04-16-2012
Jens Mühlheimer Jens Mühlheimer is offline
Flexsim User
 
Join Date: Jul 2008
Location: Stuttgart, Germany
Posts: 140
Downloads: 8
Uploads: 0
Thanks: 40
Thanked 35 Times in 27 Posts
Rep Power: 174
Jens Mühlheimer will become famous soon enoughJens Mühlheimer will become famous soon enough
Default

Quote:
Originally Posted by shafizad View Post
well, Just because this thread looks really similar to my question, I post it here. I am confused!

Why doesn't this piece of code work when written OnModelReset?
Code:
treenode item=node("/Tools/FlowItemBin/Box/1",model());
treenode rack1=node("/Rack1",model());
for (int i=0;i< getvarnum(rack1,"maxcontent");i++)
{
        createcopy(item, rack1,1);
}
whereas this piece of code works perfectly in script window!?
(my purpose is to create some flowitems in my rack before I press RUN in my model (way before 0 time).)
You only will generate problems with this method. I would recommend using the mentioned method with sending 0 delayed messages to the objects.
The Following User Says Thank You to Jens Mühlheimer For This Useful Post:
shafizad (04-17-2012)
  #17  
Old 04-17-2012
shafizad shafizad is offline
ProcSim Consulting
 
Join Date: Jul 2010
Location: Switzerland
Posts: 75
Downloads: 18
Uploads: 0
Thanks: 90
Thanked 2 Times in 2 Posts
Rep Power: 126
shafizad is on a distinguished road
Default

Quote:
Originally Posted by Jens Mühlheimer View Post
You only will generate problems with this method. I would recommend using the mentioned method with sending 0 delayed messages to the objects.
I just wanted to have some flow items in my model VISUALLY before running the model. It was just a matter of visual appearance before running the model.

Finally, I had a VISUALTOOL filled with those flow items and onmodelrun I hid them. funny approach!

// OnModelreset
treenode VisualToolX = node("/X",model());
for (int i=1; i<=7; i++)
{
createcopy(node("/Tools/FlowItemBin/1/1",model()),VisualToolX,1);
treenode item= last(X);
setloc(item, (i-1)*xsize(item), yloc(item),zloc(item));
}
//OnRunStart
treenode VisualToolX = node("/X",model());
switch_hidecontents(VisualToolX , 1);

and OnRun I will create as many as objects (here 7) I need at that place.
  #18  
Old 04-17-2012
Phil BoBo's Avatar
Phil BoBo Phil BoBo is offline
Flexsim Development
 
Join Date: Jan 2008
Posts: 756
Downloads: 109
Uploads: 18
Thanks: 385
Thanked 1,483 Times in 525 Posts
Rep Power: 1174
Phil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond repute
Default

If you remove the itemtype nodes from the flowitems you created in the Visual Tool, they won't be destroyed OnReset.

Then you could just hide/show OnReset and OnRun instead of having to recreate the flowitems.


Thread Thread Starter Forum Replies Last Post
Displaying the simulation time with the various date/time formats. Regan Blackett Tips and Tricks 12 11-12-2012 08:01 AM
Inter Arrival Time by Time of Day Mod Brandon Peterson Tips and Tricks 0 04-23-2008 11:13 AM
change 3D shape of a packed flow item KelvinHo Q&A 2 02-27-2008 09:41 PM
Flow items with states AlanZhang Q&A 16 11-30-2007 10:32 AM


All times are GMT -6.
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2020, vBulletin Solutions Inc.
Copyright 1993-2018 FlexSim Software Products, Inc.