question

SudheerReddy avatar image
0 Likes"
SudheerReddy asked Logan Gold commented

Bundle Data in global table

As shown in below image, In Global table one cell is assigned as Bundle data. And writing to that cell, but not able to achieve as bundle data

How to create bundle data in global table any feedback on this. I am attaching model where I am trying.

BundleData.fsm

FlexSim 20.1.2
flexsim 20.1.2bundle data
bundledata.png (20.0 KiB)
bundledata1.png (20.5 KiB)
bundledata.fsm (29.5 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

Logan Gold avatar image
1 Like"
Logan Gold answered Logan Gold commented

@Sudheer Reddy, are you wanting the entire Global Table, GlobalTable1, to be a bundle table? Or are you trying to store a bundle table in cell (1,1) of GlobalTable1 - a table within a table?

If it's the first option, then you'll want to check the box called "Use Bundle" in the Quick Properties for GlobalTable1. Then, you can use the "Write to a Global Table" option in the Custom Code activity in Process Flow. That option will write to a Global Table if that table is a Tree table (the non bundle type of table) or a bundle table, it makes no difference.

If it's the second option, then you just need to treat cell (1,1) as a table itself, but there isn't really a dropdown option that does this for you. So you will need to do something like this in the Code Editor, or by choosing the Code Snippet dropdown option, either way in the Custom Code activity:

Table(Table("GlobalTable1").cell(1, 1))[1][1] = Model.time;

Or you can also do something like this:

addbundleentry(Table("GlobalTable1").cell(1, 1), Model.time);

Doing it this way, you'll probably want to add a bundle field to the cell first. You can do this by double clicking on the cell to open the bundle in a Table view, then you can add columns for every field that you want in the bundle. If it's just the one value (Model.time) that you want to add to the bundle, then one field will be sufficient.

If you're trying to do something different with bundles, and these two options do not answer your question, please give us some more information about what you want to accomplish using bundles.

· 3
5 |100000

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

SudheerReddy avatar image SudheerReddy commented ·

@Logan Gold Thanks for your answer.


Table(Table("GlobalTable1").cell(1, 1))[1][1] = Model.time;

For above code when I tried following is the error I got

BundleData.fsm

addbundleentry(Table("GlobalTable1").cell(1, 1), Model.time);

For the above code the following error I am getting

BundleData_1.fsm

And When I tried with entire Global table as bundle data following error I am getting

BundleData_2.fsm

0 Likes 0 ·
bundledata.fsm (30.6 KiB)
bundlecode1.png (69.8 KiB)
bundledata-1.fsm (30.9 KiB)
bundlecode2.png (55.1 KiB)
bundledata-2.fsm (30.8 KiB)
bundlecode3.png (40.6 KiB)
Joerg Vogel avatar image Joerg Vogel SudheerReddy commented ·
  • New bundle:

addbundlefield(..) prepare a new column

  • New row

addbundleentry(..) prepare and set initial values

or

setbundlevalue(obj node, num row base 0, list of values)

  • New values

like in a table which is not a global table

      Table myTable = [treenode reference]
      myTable[1][1] = [value of datatype in column]
0 Likes 0 ·
Logan Gold avatar image Logan Gold ♦♦ SudheerReddy commented ·

@Sudheer Reddy

Sorry, but I forgot to mention that if you use the method using this code (as in bundleData.fsm):

Table(Table("GlobalTable1").cell(1, 1))[1][1] = Model.time;

You will have first needed to add enough entries to the bundle. So you need at least one entry/row already added if you are trying to change row 1 of the bundle. If you were to continue trying to change [2][1], [3][1], etc., then you'll need to make sure there are enough entries already added to the bundle before changing the data in those entries. Think of it like a Global Table, where you need enough rows and columns in the table before you can change the values of the table cells.

For simplicity, you could just use the other option using addbundleentry() (like with bundledata-1.fsm). This will automatically add the entry for you, then automatically set the data in that entry according to the second parameter. And just like Jorg mentioned, you will need to add a field to your bundle before adding entries in either case. Just doubleclick on the cell in GlobalTable1 to open the bundle in a Table view, then use the Quick Properties of that bundle table to add columns. The columns in the table view are the same as bundle fields, where the field name will be the text in the column headers. If you only want Model.time in each row/entry, then one column/field is sufficient. More data per entry will require adding more fields.

If you change the entire Global Table to a bundle (like with bundledata-2.fsm), don't use the Table().cell() command. Just add your data like any other Global Table. You can either use the "Write to a Global Table" dropdown option or something like:

Table("GlobalTable1")[1][1] = Model.time;

Here again, make sure there are enough rows already added to the table before trying to change the values in a specific row.

0 Likes 0 ·