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 07-30-2012
naren nataraj naren nataraj is offline
Flexsim User
 
Join Date: Aug 2011
Location: INDIA
Posts: 28
Downloads: 20
Uploads: 0
Thanks: 36
Thanked 1 Time in 1 Post
Rep Power: 108
naren nataraj is on a distinguished road
Default How to automate the process of writing the same logics/codes in many objects in a model

Hi everyone,


I have created a simple task sequence and I need to use it in "pick operator " section in all processors in my model. Since my model is big and it has more than 30 processors, I want to automate this rather than manually going to each object and copy-pasting it.

Any suggestions/ideas to do this ?

I have the same problem for any common logics or code, which I will be using in many objects.

Intially I tried to save the code as an "user command" and the names( path of the nodes ) of objects in a table, then to write a code that will assign this "user command" to the respective nodes in the tree.
But I dont know how to do it.

Please share your thoughts/ideas on this ..

Thanks in advance.
Good day.
Naren
  #2  
Old 07-30-2012
Sebastian Hemmann's Avatar
Sebastian Hemmann Sebastian Hemmann is offline
Flexsim User
 
Join Date: Sep 2009
Location: Braunschweig (Germany)
Posts: 439
Downloads: 52
Uploads: 0
Thanks: 472
Thanked 217 Times in 154 Posts
Rep Power: 319
Sebastian Hemmann is a splendid one to beholdSebastian Hemmann is a splendid one to beholdSebastian Hemmann is a splendid one to beholdSebastian Hemmann is a splendid one to beholdSebastian Hemmann is a splendid one to beholdSebastian Hemmann is a splendid one to beholdSebastian Hemmann is a splendid one to behold
Default

Did you try the "Edit Selected Objects" menu? Can find it under "View/Modelling Utilities"
Only have to select (red box) all objects without the function. And than highlight (yellow box) the object with needed functions.
In first row of options you can use "Copy from Highlighted". Now just look for the needed variables ;-)
Attention, in a strange way they sometimes got different names than in Properties window of Objects.
__________________
Hemmi
The Following 2 Users Say Thank You to Sebastian Hemmann For This Useful Post:
naren nataraj (07-30-2012)
  #3  
Old 07-30-2012
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

As Sebastian says - you can copy variables (variables include the triggers you edit) using the "Edit Selected Objects" modelling utility. In this case you're looking for the 'processdispatcher' variable. So I'd place the user command in the processdispatcher code and then copy it so that all objects are calling your user command. Then if you make changes to the command you don't need to update any of the objects.


A quick recap for those that haven't used user commands in this way:

Call the user command from each object passing in the pointer to the object as the first parameter:

myusercommand(current);

or if it's to replace a trigger that needs a return value:

return myusercommand(current);

Current is usually defined for you and is mostly ownerobject(c).

Often you'll need more parameters e.g.:

mycommonexit(current,item,port)

In your user command you need to access the parameters - e.g.:

treenode current=parnode(1);
treenode item=parnode(2);
int port=parval(3);
The Following 3 Users Say Thank You to Jason Lightfoot For This Useful Post:
Sebastian Hemmann (07-30-2012)
  #4  
Old 07-31-2012
naren nataraj naren nataraj is offline
Flexsim User
 
Join Date: Aug 2011
Location: INDIA
Posts: 28
Downloads: 20
Uploads: 0
Thanks: 36
Thanked 1 Time in 1 Post
Rep Power: 108
naren nataraj is on a distinguished road
Default

Hi Sebastian & Jason,

Thanks a lot for replying.

I too agree that using "edit selected objects " is an useful option.

But I would like to even automate selecting the objects. Because in one my model for a machining line, there are more than 100 machines, in that case using " edit selected object" option also can become tedious.

And more over I want to change the "user command" or codes that is given to an objects dynamically.

For example, if I have 100 processors and I have 5 different "user commands". I want to have a condition, and based on the condition it should choose which "user command " to be assigned to all these 100 processors during the model run.

Thats why I was trying to have all the nodes path ( ex: /processor1/variables/cycletime/ ) in a table and thought will write a code to assign the "user command" at that particular nodes for all 100 processors.

But I dont know how to assign/write a "usercommand" in a node in the tree. Is there a command for it ?

Are there any other ways to do it ?

I think I have explained my question clearly.
Thanks in advance.
Good day.
Naren
  #5  
Old 07-31-2012
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

the example to executefsnode(..) executes in the command help a string code in a table cell.
Code:
executefsnode(gettablecell("GlobalTable1",2,3),NULL,NULL,NULL,0)
Now you can build various codes at different cells and execute it.

To write code in a tablecell, change it to string data. Explore the table as tree. Select the column cell and write your code on the right side. Beware of that your code isn't checked. You see errors only on model run in the system console.


Jörg

Last edited by Jörg Vogel; 07-31-2012 at 02:48 AM. Reason: some more informations to write code in a cell
The Following User Says Thank You to Jörg Vogel For This Useful Post:
naren nataraj (08-02-2012)
  #6  
Old 07-31-2012
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 could create a group using the Groups modelling utility and add the machines to that. Then selecting them all is just a press of a button.

Pass your condition into the one user command and let it choose how to behave (or call other user commands).
The Following 2 Users Say Thank You to Jason Lightfoot For This Useful Post:
Phil BoBo (07-31-2012)
  #7  
Old 08-02-2012
naren nataraj naren nataraj is offline
Flexsim User
 
Join Date: Aug 2011
Location: INDIA
Posts: 28
Downloads: 20
Uploads: 0
Thanks: 36
Thanked 1 Time in 1 Post
Rep Power: 108
naren nataraj is on a distinguished road
Default

Thank you Jorg & Jason,

Jorg, as far as I understand, I should write codes in table cells and use the command "executefsnode" in the "/processor1/variables/cycletime/" node and it will read the command from table & execute it.

Jason, I have started using the "groups modelling utility", it is very useful.

Using "executefsnode" command in one processor and then using the "groups modelling utility" to copy the same in all processors, is a good solution.

Thanks once again Jorg & Jason.
Good day
Naren.


Thread Thread Starter Forum Replies Last Post
How can I search for written codes in a model? shafizad Q&A 2 05-16-2012 12:40 AM
Understanding Flexsim Network Error Codes Jorge Toucet Installation 0 11-02-2008 05:46 PM
Writing to a CSV Gavin Douglas Q&A 2 07-18-2008 10:19 AM
How to select all objects of a class in your model Brenton King Tips and Tricks 3 04-03-2008 11:25 PM
potential objects in railyard model Vinay Mehendiratta Q&A 1 10-29-2007 12:01 PM


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.