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 > Tips and Tricks
Downloads

Tips and Tricks Share helpful modeling ideas

  #1  
Old 09-21-2007
Cliff King's Avatar
Cliff King Cliff King is offline
Vice President Technical Services
 
Join Date: Jul 2007
Location: Utah
Posts: 272
Downloads: 158
Uploads: 14
Thanks: 102
Thanked 304 Times in 110 Posts
Rep Power: 412
Cliff King has much to be proud ofCliff King has much to be proud ofCliff King has much to be proud ofCliff King has much to be proud ofCliff King has much to be proud ofCliff King has much to be proud ofCliff King has much to be proud ofCliff King has much to be proud ofCliff King has much to be proud of
Default How to display dynamic text next to an object

There is an attribute (node) on every object named objectinfo that contains subnodes. The names of these subnodes become the text that is displayed next to an object when "Show Names" is checked for the view. The names of these subnodes (i.e. %Processing: 89) are updated with every screen refresh with code in the OnPreDraw event of the class object. The user may overwrite these names with their own names with code in the Custom Draw Code trigger found in the object's Properties Window. In fact there is a picklist option titled "Draw Test near Object's Name" that is available to help you do this. Adding and deleting the number of subnodes to increase or decrease the number of lines of text displayed is allowed.

Some people have asked how to query the values associated with these text displays. Although this is probably not the most direct way to do this, the following code shows you how this could be done:

treenode displaynodes = objectinfo(current);
string utilizationtext = getnodename(rank(displaynodes,3));
int totalstringlength = stringlen(utilizationtext);
int textstringlength = stringlen("%Processing: ");
int numstringlength = totalstringlength - textstringlength;
string numstring = stringpart(utilizationtext, textstringlength, numstringlength);
double utilizationnumber = stringtonum(numstring);

A more direct way to query the processing time of an object would be to query the value of the associated statelist node with code such as this:

treenode stateprofile = state_profile(current);
treenode processingnode = rank(stateprofile, STATE_PROCESSING);
double processingtime = getnodenum(processingnode);

If you prefer a percentage then add this:

double processingpercent = 100 * processingtime / time();

Last edited by Cliff King; 11-26-2007 at 08:20 PM.
The Following User Says Thank You to Cliff King For This Useful Post:
Congshi Wang (11-11-2010)
  #2  
Old 11-11-2010
Congshi Wang Congshi Wang is offline
Student
 
Join Date: May 2010
Location: Germany
Posts: 58
Downloads: 2
Uploads: 0
Thanks: 48
Thanked 0 Times in 0 Posts
Rep Power: 124
Congshi Wang is on a distinguished road
Default

Hi Cliff,

could you please tell me how to change (add or delete) stats in objectinfo. For example I'd like to have average content and not maximum content for a queue.

Thanks!
  #3  
Old 11-11-2010
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

You can update it's name to the value you want in code in the OnDraw trigger:

setname(rank(objectinfo(current),2),concat("AvgContent: ",numtostring(get(stats_contentavg(current)),0,1)));

Note also that you can override the entire box that is displayed, including the name, using setdrawnamefunction() for which there is a good example in the Command Help. This is a version to show how to get multiple lines since you can't just place \n in the text:

if (parval(2) == 0)
setdrawnamefunction(120, 32, c, parval(1), 1);
else
{
glTranslated(-58, -15, 0);
drawflattext("Hello World");
glTranslated(0, -15, 0);
drawflattext("It's a beautiful day");
}

Last edited by Jason Lightfoot; 11-13-2010 at 09:44 AM.
The Following User Says Thank You to Jason Lightfoot For This Useful Post:
Congshi Wang (11-11-2010)
  #4  
Old 11-11-2010
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

There is also a pick option called "Change Object's Stats Display" in the OnDraw trigger of each object that has the AvgContent code Jason pasted.
The Following User Says Thank You to Phil BoBo For This Useful Post:
Jason Lightfoot (11-11-2010)
  #5  
Old 11-11-2010
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

I didn't see that!



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.