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 06-30-2008
david_white david_white is offline
Flexsim User
 
Join Date: Jun 2008
Posts: 18
Downloads: 1
Uploads: 1
Thanks: 1
Thanked 0 Times in 0 Posts
Rep Power: 145
david_white is on a distinguished road
Default I think an easy question... - how to pointer to objects

I can't figure out how to get a reference to an arbitrary object. For example, if I write a User Event function that needs to send a message to a particular object, how do I get the "object". For instance, the sendmessage() function wants the "toobject" and "fromobject"...I think I can put any number I want in for the "fromobject", but I need to know how to address the message to the "toobject". There's no "parnode()" to grab a hold of. I know what I named it, but I can't find a "getobject()" function or anything equivalent. I've looked thru the help and can't find any examples.

I don't think the first(), last(), inobject(), outobject(), centerobject(), or next() will do me any good because I'm in the middle of a user function that doesnt' have anything from which to reference those objects.

I can't believe there's no way to get a reference using the name of the object, but I can't seem to find anything.

Thanks for your help in advance.
  #2  
Old 06-30-2008
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

node("/objectnamehere",model())
The Following User Says Thank You to Phil BoBo For This Useful Post:
Xavier Jackson (07-21-2008)
  #3  
Old 06-30-2008
david_white david_white is offline
Flexsim User
 
Join Date: Jun 2008
Posts: 18
Downloads: 1
Uploads: 1
Thanks: 1
Thanked 0 Times in 0 Posts
Rep Power: 145
david_white is on a distinguished road
Default

That did the trick....I knew it had to be simple...thanks very much.
  #4  
Old 06-30-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

another simple solution (and faster in execution) is by going to global variables and define a global pointer to your object. Then you can reference that object anywhere within Flexsim with that variable.

Steven
The Following 2 Users Say Thank You to Steven Hamoen For This Useful Post:
Jörg Vogel (07-03-2008)
  #5  
Old 07-22-2008
Xavier Jackson's Avatar
Xavier Jackson Xavier Jackson is offline
Flexsim User
 
Join Date: Jun 2008
Posts: 20
Downloads: 11
Uploads: 0
Thanks: 21
Thanked 4 Times in 3 Posts
Rep Power: 147
Xavier Jackson is on a distinguished road
Default

Quote:
Originally Posted by Phil BoBo View Post
node("/objectnamehere",model())
Does this work for groups as well, because I want to have a visual tool display a group statistic.
__________________
Each morning after drudging through his morning routine the mild-mannered Xavier Jackson arrives at work and when he sits down at his computer it powers up and he becomes the great

Flexavier Jacksim

Optimizer Extraordinaire
  #6  
Old 07-22-2008
Alex Christensen Alex Christensen is offline
Flexsim Technical Support
 
Join Date: Nov 2007
Location: Provo, UT
Posts: 96
Downloads: 41
Uploads: 8
Thanks: 29
Thanked 141 Times in 56 Posts
Rep Power: 298
Alex Christensen is a splendid one to beholdAlex Christensen is a splendid one to beholdAlex Christensen is a splendid one to beholdAlex Christensen is a splendid one to beholdAlex Christensen is a splendid one to beholdAlex Christensen is a splendid one to beholdAlex Christensen is a splendid one to behold
Default

Here's a template for summing up something for each object in a group. Obviously, replace Group_1 with your group name, and you can do something different than adding up labels.
Code:
treenode group=node("MAIN:/project/model/Tools/Groups/Group_1");
//double sum=0;
forobjecttreeunder(group){
    treenode groupmember=ownerobject(tonode(getnodenum(a)));
    pt(getnodename(groupmember));pr();
    //update your calculation here
    //sum+=getlabelnum(groupmember,"labelname");
}
The Following 2 Users Say Thank You to Alex Christensen For This Useful Post:
Xavier Jackson (07-22-2008)
  #7  
Old 07-22-2008
Xavier Jackson's Avatar
Xavier Jackson Xavier Jackson is offline
Flexsim User
 
Join Date: Jun 2008
Posts: 20
Downloads: 11
Uploads: 0
Thanks: 21
Thanked 4 Times in 3 Posts
Rep Power: 147
Xavier Jackson is on a distinguished road
Default

Thanks but could you explain what the code does in a little simpler terms?
__________________
Each morning after drudging through his morning routine the mild-mannered Xavier Jackson arrives at work and when he sits down at his computer it powers up and he becomes the great

Flexavier Jacksim

Optimizer Extraordinaire
  #8  
Old 07-22-2008
Alex Christensen Alex Christensen is offline
Flexsim Technical Support
 
Join Date: Nov 2007
Location: Provo, UT
Posts: 96
Downloads: 41
Uploads: 8
Thanks: 29
Thanked 141 Times in 56 Posts
Rep Power: 298
Alex Christensen is a splendid one to beholdAlex Christensen is a splendid one to beholdAlex Christensen is a splendid one to beholdAlex Christensen is a splendid one to beholdAlex Christensen is a splendid one to beholdAlex Christensen is a splendid one to beholdAlex Christensen is a splendid one to behold
Default

When you set a group in the toolbar on the left side of an ortho or perspective view, it adds a node at the end of each object's attribute tree called "Groups", and it makes couplings with subnodes of the "Groups" node.

The couplings are stored in MAIN:/project/model/Tools/Groups. If you look there (and you have some groups set), you will see subnodes with your group names, and under those you will see subnodes with large numbers in their data. Those are the addresses of the nodes in the objects in the group under object>Groups. Calling tonode on these numbers converts the numbers into node pointers, in case you compile this code as c++ code. The ownerobjects of these nodes are the objects in the groups.

I guess that's a little simpler, but couplings are still a little confusing sometimes.
The Following 2 Users Say Thank You to Alex Christensen For This Useful Post:
Xavier Jackson (07-23-2008)
  #9  
Old 07-22-2008
Xavier Jackson's Avatar
Xavier Jackson Xavier Jackson is offline
Flexsim User
 
Join Date: Jun 2008
Posts: 20
Downloads: 11
Uploads: 0
Thanks: 21
Thanked 4 Times in 3 Posts
Rep Power: 147
Xavier Jackson is on a distinguished road
Default

will code like that allow me to make a connection to a group such as an input or output connection (assuming that each member of a group is capable of such a task) and central connections?
__________________
Each morning after drudging through his morning routine the mild-mannered Xavier Jackson arrives at work and when he sits down at his computer it powers up and he becomes the great

Flexavier Jacksim

Optimizer Extraordinaire
  #10  
Old 07-22-2008
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

You can use the side bar of the Ortho view to create connections to the selected objects. Use your groups to select objects, then in the Edit Selected Objects, select Connections from the combobox and create connections that way using the highlighted object and selected objects.
The Following User Says Thank You to Phil BoBo For This Useful Post:
Xavier Jackson (07-23-2008)
  #11  
Old 07-23-2008
Xavier Jackson's Avatar
Xavier Jackson Xavier Jackson is offline
Flexsim User
 
Join Date: Jun 2008
Posts: 20
Downloads: 11
Uploads: 0
Thanks: 21
Thanked 4 Times in 3 Posts
Rep Power: 147
Xavier Jackson is on a distinguished road
Default

Alright, lets see if i can ask the right question.

How can I use a visual tool to display the average, average process time of 16 separate processors.

I essentially need to know how say that the object I want statistics for is a group.

The experimenter can do it so I know it can be done but I have not been able to figure it out.
__________________
Each morning after drudging through his morning routine the mild-mannered Xavier Jackson arrives at work and when he sits down at his computer it powers up and he becomes the great

Flexavier Jacksim

Optimizer Extraordinaire
  #12  
Old 07-23-2008
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

Here's a little sample model to show how you can write custom code for the visual tool to display whatever you want.

The visual tool adds up all the staytime averages for its center ports and then divides that by the number of center ports it has.

double totaltime = 0;
for(int i = 1; i<=nrcp(current); i++)
{
totaltime += get(stats_staytimeavg(centerobject(current,i)));
}

string thetext = concat("Average Process Time: ",numtostring(totaltime/nrcp(current),0,2));

setnodestr(textnode,thetext);
Attached Files
File Type: zip avg_staytime.zip (57.1 KB, 292 views)
The Following 3 Users Say Thank You to Phil BoBo For This Useful Post:
Xavier Jackson (07-23-2008)
  #13  
Old 07-23-2008
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

Here's another little sample model to show how you can combine Alex's code with the Visual Tool's Text Display trigger to display group statistics.

The visual tool adds up all the staytime averages for the group and then divides that by the number of objects in the group.

treenode group=node("MAIN:/project/model/Tools/Groups/Group_1");

double totaltime = 0;
forobjecttreeunder(group)
{
treenode groupmember=ownerobject(tonode(getnodenum(a)));
totaltime += get(stats_staytimeavg(groupmember));
}

string thetext = concat("Average Process Time: ",numtostring(totaltime/content(group),0,2));

setnodestr(textnode,thetext);
Attached Files
File Type: zip avg_staytime2.zip (57.2 KB, 295 views)
The Following 3 Users Say Thank You to Phil BoBo For This Useful Post:
Xavier Jackson (07-23-2008)
  #14  
Old 08-01-2008
Yasemin Vatandas's Avatar
Yasemin Vatandas Yasemin Vatandas is offline
Flexsim User
 
Join Date: Jul 2008
Location: Hamburg, Germany
Posts: 36
Downloads: 9
Uploads: 0
Thanks: 29
Thanked 3 Times in 3 Posts
Rep Power: 146
Yasemin Vatandas is on a distinguished road
Question Time of operator request

Hello,
I have another simple question:

-When is the exact time point that a fixed resource requests a TE?
To state my question more clearly:
I'd like to measure the time between a TE-request by a queue and execution of the task by TE.

-does the queue request a TE as soon as an item enters it and queues up?
-or does the queue request the TE as soon as the downstream object is available?

Thanks
  #15  
Old 08-01-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

Yasemin,

The queue will request the TE when both the queue and the down stream object the flowitem is headed to are ready. To test this you could put a print statement in the Request Transport From trigger to print the current time.

I hope that this helped,
Brandon
__________________
thats not normal.
The Following User Says Thank You to Brandon Peterson For This Useful Post:
Yasemin Vatandas (08-02-2008)
  #16  
Old 08-16-2008
Yasemin Vatandas's Avatar
Yasemin Vatandas Yasemin Vatandas is offline
Flexsim User
 
Join Date: Jul 2008
Location: Hamburg, Germany
Posts: 36
Downloads: 9
Uploads: 0
Thanks: 29
Thanked 3 Times in 3 Posts
Rep Power: 146
Yasemin Vatandas is on a distinguished road
Question summing up labels

Quote:
Originally Posted by Alex Christensen View Post
Here's a template for summing up something for each object in a group. Obviously, replace Group_1 with your group name, and you can do something different than adding up labels.
Code:
treenode group=node("MAIN:/project/model/Tools/Groups/Group_1");
//double sum=0;
forobjecttreeunder(group){
    treenode groupmember=ownerobject(tonode(getnodenum(a)));
    pt(getnodename(groupmember));pr();
    //update your calculation here
    //sum+=getlabelnum(groupmember,"labelname");
}
Hello,
I wouldn't like to bother you with my unsuccessful attempts of code-writing, but once again I need help. This time, I am trying to write a script for the following situation:

the sum of label-values of items in a Queue-object are compared to an upper limit and the items, the sum of whose label values do not exceed that upper limit, are released to the processor. Let's say there are 3 items with label values 10, 15, 15 respectively and the upper limit is 30. So only the first two items with labels 10 and 15 should be released, since the inclusion of the third item would cause the sum of label values (40) to exceed the upper limit of 30.

I thought I could use the above template that Alex provided as a starting point, but my following attempt failed (it is written in OnMessage trigger of a Queue):

Code:
treenode current = ownerobject(c);
int sum = 0;
forobjecttreeunder(current){
sum = sum + getlabelnum(item,"PT");
if(sum<=120)
{
 releaseitem(item);
}
}
I am sure I'm doing something wrong in the logic.
I'd appreciate any idea, thanks.
  #17  
Old 08-16-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

Yasemin,

In your code is no pointer to item, so your releaseitem(item) does nothing and also the calculation of sum is always zero.
The pointer in forobjecttreeunder() is “a”. So it is like a for-loop and the pointer “a” changes to the different items depending on there rank in the tree.
I did not check the code, but I guess it has to be something like this:

Code:
treenodecurrent = ownerobject(c);
int sum = 0;
forobjecttreeunder(current)
{
      sum = sum + getlabelnum(a,"PT");
      if(sum <= 120)
      {
releaseitem(a);
      }
}
There is no pointer to the item in the OnMessage trigger, because this trigger can be fire from everywhere, even if there is no item.
Sometimes it is also a good idea to check if an item exists (objectexists()) before pointer to it.
In the above case this seems not to be necessary.

Good success!
__________________
tom the (A)tom: "We have solved our problems ... now we have to fight the solutions."
The Following User Says Thank You to Tom David For This Useful Post:
Yasemin Vatandas (08-17-2008)
  #18  
Old 08-17-2008
Yasemin Vatandas's Avatar
Yasemin Vatandas Yasemin Vatandas is offline
Flexsim User
 
Join Date: Jul 2008
Location: Hamburg, Germany
Posts: 36
Downloads: 9
Uploads: 0
Thanks: 29
Thanked 3 Times in 3 Posts
Rep Power: 146
Yasemin Vatandas is on a distinguished road
Default

Tom, Danke for the explanation. I wasn't aware of the "a".
Having replaced 'item' with 'a', function adds up the values for each item but I still have to work on the 'release' part of the function, since it doesn't work at all.
  #19  
Old 08-18-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

Yasemin,

You don't want to use the forobjecttreeunder command for what you are trying to do. You would be better off with the following code:

double sum = 0;
double target = 30;
for(int index = 1; index <= content(current); index++)
{
sum += getlabelnum(rank(curren, index), "PT");
if(sum <= target) releaseitem(rank(current, index));
}

You need to be aware that you could run into problems where you are trying to releas items more than once if you are not careful.

Good Luck,
Brandon
__________________
thats not normal.
The Following User Says Thank You to Brandon Peterson For This Useful Post:
Yasemin Vatandas (08-18-2008)
  #20  
Old 08-18-2008
Yasemin Vatandas's Avatar
Yasemin Vatandas Yasemin Vatandas is offline
Flexsim User
 
Join Date: Jul 2008
Location: Hamburg, Germany
Posts: 36
Downloads: 9
Uploads: 0
Thanks: 29
Thanked 3 Times in 3 Posts
Rep Power: 146
Yasemin Vatandas is on a distinguished road
Default

Brandon,
thank you for your answer.
Actually I had tried the 'for-loop' approach at first. Since it didn't work, I started to look for alternative ways. Now I see that I wasn't wrong in trying the for-loop, since you too suggest me to do so
The problem is that I haven't been able to make it work so far. Attached is a simple trial model. I can't see where my mistake is.
Attached Files
File Type: zip Test.zip (43.4 KB, 272 views)



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.