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 09-24-2009
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 Using OnStateChange

Since 4.5 there is this nice option to use the OnStateChange trigger. We have used this now in a project but found some problems with it. What happens now is (at least this is our idea after working with it):
1 The OnStateChange is called
2 The calculation is done
3 The original to state is set.

The problem is that if you want to change the state into a different one (e.g. change allocated_idle into waiting for transporter) you have to create a senddelayedmessage to change the state after the action 3. And that triggers the onstatechange again so you also have to use a flag to prevent it executing again. This is slow and cumbersome. And is even more problematic if multiple state changes happen at the same time (e.g. allocated_idle and then travel_empty) because then you want to change the allocated idle but before your message comes it is already the new status travel_empty that you don't want to change.

So our idea (Ralf, DJ and mine) is to call the trigger at the end and the user should be able to have a return value that set the new state. That way one can prevent the extra delayedmessage and prevent to trigger the OnStateChange again.

Is this a possible change for the next release?

Last edited by Steven Hamoen; 09-24-2009 at 11:21 AM.
The Following User Says Thank You to Steven Hamoen For This Useful Post:
RalfGruber (09-24-2009)
  #2  
Old 09-24-2009
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

The feature you need is already in version 4.5. Flexsim uses the return value of OnStateChange to decide what, if anything, to do. If you return 0 from OnStateChange, it goes on its merry way and changes the state. If you return > 0, it will change to the state that you return (if you return STATE_IDLE, it will change to the idle state instead of whatever it was originally going to change to). If you return -1, it will do nothing, leaving the object in its original state.
The Following 12 Users Say Thank You to Anthony Johnson For This Useful Post:
Tom David (09-24-2009)
  #3  
Old 09-25-2009
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

Anthony, thanks a lot for the answer. Unfortunately this has costed us at least 2 days programming and testing

May I repeat an earlier proposal and put this trigger in the basicFR, TE and conveyor for version 5.0. That way it can also be neatly described in the helpfile and I think that this is mainly used by library builders anyway.
The Following 5 Users Say Thank You to Steven Hamoen For This Useful Post:
Tom David (09-25-2009)
  #4  
Old 09-25-2009
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'll put it on the dev list.
The Following User Says Thank You to Anthony Johnson For This Useful Post:
Steven Hamoen (09-25-2009)
  #5  
Old 03-07-2015
RalfGruber's Avatar
RalfGruber RalfGruber is offline
FlexSim Software Products
 
Join Date: Jul 2007
Location: Orem, UT, USA
Posts: 195
Downloads: 37
Uploads: 0
Thanks: 518
Thanked 294 Times in 124 Posts
Rep Power: 345
RalfGruber is a splendid one to beholdRalfGruber is a splendid one to beholdRalfGruber is a splendid one to beholdRalfGruber is a splendid one to beholdRalfGruber is a splendid one to beholdRalfGruber is a splendid one to beholdRalfGruber is a splendid one to behold
Default

Anthony,

this one hasn't made it into the release yet. Are you planning to add the State Change Trigger to the BasicFR, BasicTE, and maybe BasicConveyor as suggested?

Thanks

Ralf
FlexSim
  #6  
Old 03-09-2015
Jörg Vogel's Avatar
Jörg Vogel Jörg Vogel is offline
Flexsim User
 
Join Date: Sep 2007
Location: Hannover, Germany
Posts: 643
Downloads: 35
Uploads: 0
Thanks: 802
Thanked 665 Times in 410 Posts
Rep Power: 642
Jörg Vogel has a reputation beyond reputeJörg Vogel has a reputation beyond reputeJörg Vogel has a reputation beyond reputeJörg Vogel has a reputation beyond reputeJörg Vogel has a reputation beyond reputeJörg Vogel has a reputation beyond reputeJörg Vogel has a reputation beyond reputeJörg Vogel has a reputation beyond reputeJörg Vogel has a reputation beyond reputeJörg Vogel has a reputation beyond reputeJörg Vogel has a reputation beyond repute
Default

Since Version 4.5 the method has changed a bit. Here is a summary:
You still have to build this trigger on your own under the node behaviour+eventfunctions. After highlighting the node eventfunctions insert a node into the eventfunctions by pressing the return button. By a clic on the plus sign next to the eventfunctions node the new node is shown in the tree. Rename the node to "OnStateChange". In the context menu right mouse button over the node choose Build>Toggle Node as FlexScript. The Node changes from a circle to a square and a red "S" is visible in it. Still you can't add any code to the node. Use again the context menu and choose Node> Add Text Data or highlight the node and press "t" on the keyboard.
Now there is on the right side a text editor.
The pointer current is here just "c".
Code:
treenode current = c;
A return value in the code changes the state number.
After reseting the model the red S turns black.
All this you can found in the forum at different places, too.
/threads/thread1727
https://www.flexsim.com/community/fo...ead.php?t=1416
therein:
https://www.flexsim.com/community/fo...0&postcount=12
Click image for larger version
Name:	OnStateChange.jpg
Views:	358
Size:	98.7 KB
ID:	2775


Jörg
  #7  
Old 03-09-2015
RalfGruber's Avatar
RalfGruber RalfGruber is offline
FlexSim Software Products
 
Join Date: Jul 2007
Location: Orem, UT, USA
Posts: 195
Downloads: 37
Uploads: 0
Thanks: 518
Thanked 294 Times in 124 Posts
Rep Power: 345
RalfGruber is a splendid one to beholdRalfGruber is a splendid one to beholdRalfGruber is a splendid one to beholdRalfGruber is a splendid one to beholdRalfGruber is a splendid one to beholdRalfGruber is a splendid one to beholdRalfGruber is a splendid one to behold
Default

Joerg,

yes, I know how to do it as an experienced user.
I just wanted to see, if the developers plan to make it accessible on the trigger's tab of the GUIs for BasicFR, BasicTE, and BasicConveyor for less experienced users...the reason is that I had a user currently asking for this functionality not knowing, it is already available...in the tree.

Any feedback from the development team?

Thanks

Ralf
FlexSim
  #8  
Old 03-09-2015
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 will put this on the BasicFR and BasicTE, but we have no plans of making improvements to the legacy conveyor objects.
The Following User Says Thank You to Anthony Johnson For This Useful Post:
RalfGruber (03-10-2015)

Tags
onstatechange



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.