Create Source Object and Assign Global Table by Code

Create Source Object and Assign Global Table by Code

bryan_suharik
Not applicable
14 Views
3 Replies
Message 1 of 4

Create Source Object and Assign Global Table by Code

bryan_suharik
Not applicable

[ FlexSim 16.0.6 ]

Hello, first time on the forum and hoping for some help. I'm new to C++ and flexsim. So far i've stumbled through being able to build my model from the click of a GUI button. The next task is to assign the various parameters/attributes of the objects i've created.

I need to build a Source object, and point that newly created Source to a global table value "GlobalTable20", row 1, column 1, as the interarrival value.

So far i can create the object, but i'm having trouble setting the interarrival value via code once it's been created. Through the GUI, the user selects how many sources he'd like which is why it needs to create the source and point at a global table value all in the same code block.

any help is most appreciated!!! Thanks!

createinstance(node("/Source",library),model());

treenode Source=last(model());

setloc(Source,-70,10,0);

treenode current = ownerobject(c); /***popup:GlobalTableLookup*/ node(">tags/Description",c); /***tag:Description*//**Using Global Lookup Table ( GlobalTable20 )*/ string tablename = /**\nTable: *//***tag:TableName*//**/"GlobalTable20"/**/; int row = /**\nRow: *//***tag:row*//**/1/**/; int col = /**\nColumn: *//***tag:col*//**/1/**/; return gettablenum(tablename, row, col);

0 Likes
Accepted solutions (1)
15 Views
3 Replies
Replies (3)
Message 2 of 4

arunTTT2P
Explorer
Explorer
Accepted solution
treenode Source = last(model());
string InterArrivalTime = "treenode current =ownerobject(c); return gettablenum(tablename,rownumber,coloumnnumber);" 

setvarstr(Source,"interarrivaltime",InterArrivalTime);

Hi

Bryan Suharik, You can use the above mentioned script.

Regards,

Arun KR

Message 3 of 4

bryan_suharik
Not applicable

HI Arun, Thanks so much. That worked well! Is that strategy of using the setvarstr the best way to fill in other attributes such as setting the itemtype or the processing time on a processor?

Bryan

0 Likes
Message 4 of 4

arunTTT2P
Explorer
Explorer

Hi,

For setting the processing time the setvarstr() can be used and for the item type use setvarnum() command.

Regards,

Arun KR

0 Likes