question

Christopher S2 avatar image
3 Likes"
Christopher S2 asked Matthew Gillespie edited

How to pass the processor name to a getstream() command in a table cell

I have the following Global Table being used to provide cycle times for my processors.

The Row name is the name of the processor.

I pull the Cycle Time using the standard "Global Lookup Table" procedure:

  1. Object current = ownerobject(c);
  2. Object item = param(1);
  3. /***popup:GlobalTableLookupNew*/
  4. /***tag:Description*//**Using Global Lookup Table ( CycleTimes )*/
  5. Variant tableID = /**\nTable: *//***tag:TableName*//**/"CycleTimes"/**/;
  6.  
  7.  
  8. Table table;
  9. switch (tableID.type) {
  10. case VAR_TYPE_NODE: table = tableID; break;
  11. case VAR_TYPE_STRING: table = Table(tableID.as(string)); break;
  12. default:
  13. table = reftable(tableID.as(int));
  14. break;
  15. }
  16.  
  17.  
  18. Variant row = /**\nRow: *//***tag:row*//**/current.name/**/;
  19. Variant col = /**\nColumn: *//***tag:col*//**/"CycleTime"/**/;
  20.  
  21.  
  22. return table[row][col];

Is there a more efficient/elegant way to pass the processor name into the getstream() without hardcoding the processor name value? Thanks.

@Matthew Gillespie

FlexSim 18.2.2
global tablecommandsvariables
1.png (2.3 KiB)
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

Matthew Gillespie avatar image
2 Likes"
Matthew Gillespie answered Matthew Gillespie edited

The best way I can think of right now is to change the last line of code in the Global Table lookup code. Here are two options:

1) Pass the object into the table cell

If you change the last line to

  1. return table.cell(row,col).evaluate(current);

You can change "getstream(current)" to "getstream(param(1))" so it looks like

  1. beta(138.3, 200, 2, 10, getstream(param(1)))

2) Use a global variable

Or alternatively, add a treenode global variable (lets call it callingObj) and insert a line before the last

  1. callingObj = current;
  2. return table[row][col];

Then change "getstream(current)" to "getstream(callingObj)" so it looks like

  1. beta(138.3, 200, 2, 10, getstream(callingObj))


Use a user command to avoid code duplication

In order to avoid having to change that line of code in every block of code, I would recommend adding a user command with the modified table look up code. Then you can copy the user command into the Process Time field of each processor. I've attached a sample model where I've done this.

passobjecttotable.fsm

gettablevalue uses the first method and is used by Processors 1 and 2

gettablevalue2 uses the second method and is used by Processors 10 and 11


· 4
5 |100000

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