ATTENTIONThis 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 |
#1
|
|||
|
|||
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
|
||||
|
||||
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); 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
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
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
|
|||
|
|||
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
|
||||
|
||||
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
|
|||
|
|||
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
|
||||
|
||||
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
|
|||
|
|||
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
|
||||
|
||||
Darryl,
Yes you are correct you could use the the pick list options you mentioned to what you are asking.
__________________
thats not normal. |
#12
|
|||
|
|||
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
|
||||
|
||||
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
|
|||
|
|||
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); } (my purpose is to create some flowitems in my rack before I press RUN in my model (way before 0 time).) |
#15
|
|||
|
|||
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 |
The Following 3 Users Say Thank You to Jason Lightfoot For This Useful Post: | ||
RalfGruber (04-16-2012) |
#16
|
|||
|
|||
Quote:
|
The Following User Says Thank You to Jens Mühlheimer For This Useful Post: | ||
shafizad (04-17-2012) |
#17
|
|||
|
|||
Quote:
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
|
||||
|
||||
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 |