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-2009
Joe Allen Joe Allen is offline
Flexsim User
 
Join Date: Jul 2008
Posts: 80
Downloads: 2
Uploads: 0
Thanks: 34
Thanked 5 Times in 3 Posts
Rep Power: 151
Joe Allen is on a distinguished road
Default Problem with Send to Output Port

I created a user command that loops through a certain set of Processor objects in the tree, and for each object looks up the appropriate value from a global table for the "sendtoport" return value. It then writes the following code (in this example the port number happens to be 9) into the "sendtoport" node using setnodestr() and executes the buildnodeflexscript() command on the node.
treenodecurrent = ownerobject(c);
/**Dynamically Assigned by Code On Reset */
/**
PortNumber: */

double value =
/**/9/**/;
return value;

After hitting the reset button when I look at the "flow" tab in the GUI for the processor, my code is there. However, when I run the model the processor is sending flow items to all output ports, not to the one specified in the code above. Strangely enough, if I go into the GUI and change the value to a different number it works fine. The next time I hit the reset button my user command resets the code and value back to what it was (in the above example 9) but this time when I run the model, as if by magic it works and instead of sending flow items to all ports it only sends them to port 9!

My question is: is there something that happens in the background when I click on the OK button in the GUI that makes the model "accept" the code that my user command has written into the Flexscript Node in the tree that somehow allows it to work the next time the user commands writes the code into the tree again?

This is very strange behavior that I can't seem to make sense of. I've written user commands in the past that rebuild Flexscript Nodes in the tree without any problems. This is the first time it hasn't worked. I could just go into the GUI on all of the processors and click the OK button and never post this on the forum but I like to seek understanding and thought I could share this experience with the community in case someone else encounters the same issue. Any advice would be greatly appreciated.
  #2  
Old 05-14-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

Have you checked if the node itself is toggled as flexscript? Because if you build nodes that are no flexscript it will not be executed and that code returns a 0, which means for the port that they go to the first available. And yes the gui toggles the node as flexscript if you apply your code (or to c++ if you selected that)
The Following User Says Thank You to Steven Hamoen For This Useful Post:
Joe Allen (05-14-2009)
  #3  
Old 05-14-2009
Joe Allen Joe Allen is offline
Flexsim User
 
Join Date: Jul 2008
Posts: 80
Downloads: 2
Uploads: 0
Thanks: 34
Thanked 5 Times in 3 Posts
Rep Power: 151
Joe Allen is on a distinguished road
Default

You were right. I just checked for that and some of the nodes were not toggled as Flexscript. I had only checked the first couple before and they were toggled as Flexscript but since you mentioned it I went and checked them all and some were not. Thanks for the advice!
  #4  
Old 05-14-2009
Joe Allen Joe Allen is offline
Flexsim User
 
Join Date: Jul 2008
Posts: 80
Downloads: 2
Uploads: 0
Thanks: 34
Thanked 5 Times in 3 Posts
Rep Power: 151
Joe Allen is on a distinguished road
Default

Adding this: switch_flexscript(TheNode, 1) before setnodestr() and buildnodeflexscript() prevents this problem from happening. Thanks again Mr. Hamoen.


Thread Thread Starter Forum Replies Last Post
Port Connection Problem Joe Allen Q&A 2 05-11-2009 10:56 AM
problem about "send to port " Vic Li Q&A 2 10-04-2008 12:42 AM
Print information into output console (Debugging) Tom David Q&A 11 09-04-2008 03:46 AM
Output high volume data Liu Bin Q&A 8 06-16-2008 09:18 AM
Problem with Processor Output avinash Q&A 2 03-26-2008 09:19 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.