question

Bryan Suharik avatar image
0 Likes"
Bryan Suharik asked Arun Kr edited

Create Source Object and Assign Global Table by Code

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);

FlexSim 16.0.6
global tablesourcecode
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

1 Answer

Arun Kr avatar image
1 Like"
Arun Kr answered Arun Kr edited
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

· 2
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Bryan Suharik avatar image Bryan Suharik commented ·

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 0 ·
Arun Kr avatar image Arun Kr Bryan Suharik commented ·

Hi,

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

Regards,

Arun KR

0 Likes 0 ·