question

michela-08 avatar image
0 Likes"
michela-08 asked Jacob W2 edited

Update Target Quantity

In my model, I am using 5 combiners and 5 Queues. I am using the Join mode. In the combiner tab of each combiner, I want to update target quantity of each combiner using global table which is imported from excel sheet. There is an option in "combiner" tab where I am able to update the target quantity based on that specific combiner.

But in my case I want to update combiner target quantity for all the respective combiners using global table for that specific combiner's name from a single global table.

How to achieve this?

target_quantity_update.fsm

FlexSim 22.2.3
combinertarget quantity
· 1
5 |100000

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

Jeanette F avatar image Jeanette F ♦♦ commented ·

Hi @michela-08, was Jacob W2's answer helpful? If so, please click the "Accept" button at the bottom of their answer. Or if you still have questions, add a comment and we'll continue the conversation.

If we haven't heard back from you within 3 business days we'll auto-accept an answer, but you can always unaccept and comment back to reopen your question.

0 Likes 0 ·
Jacob W2 avatar image
0 Likes"
Jacob W2 answered Jacob W2 edited

Hi @michela_08,

In my attached model I have set up an "on reset" trigger on combiner 5. This trigger runs the following code block

treenode thelist = getvarnode(current,"componentlist");
treenode thesum = getvarnode(current,"targetcomponentsum");
setnodenum(thesum,Table("Combiner_Quantity")[current.name][1]);  
setnodenum(cellrowcolumn(thelist,1,1),Table("Combiner_Quantity")[current.name][1]);

This code finds the nodes for the combiners' target quantity, and then sets the value in the nodes to be whatever value that combiner should have according to the table value.

The following link also explains more about this code.

https://answers.flexsim.com/questions/70097/update-combiner-target-quantity-by-code-when-the-l.html

target-quantity-update_JW.fsm


· 9
5 |100000

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

michela-08 avatar image michela-08 commented ·
Thank you @Jacob W2, I have few doubts regarding the model.

In the model, the "Combiner 2" 's target quantity is not changing and is 0 even after running the model. For all other combiner's its updating.

What does the code in the script represent? is it only for specific combiner's? Can you please tell me what the code in the script is useful for target quantity?

0 Likes 0 ·
Felix Möhlmann avatar image Felix Möhlmann michela-08 commented ·

None of the combiners in the attached model seem to actually have the reset code set. So none of the should be updating when you change the table values.

A combiner has two nodes in its attribute tree that govern how many items are received through each port (starting at rank 2, port 1 always only receives the container item) before the process starts.

Those are the "componentlist" and the "targetcomponentsum" (marked yellow in the screenshot below).

1669808798498.png

The componentlist represents the list you see in the combiner's properties. The value is stored in the "Target Quantity" node (pink)

1669808828026.png

As such it posesses a subnode structure that can be accessed as a table. The level below the main node represents the rows ("From Input Port 2") and the subnodes of those are the respective cell values (Target Quantity, Current Quantity (not shown in the properties)).

The "targetcomponentsum" is the total sum of items received through all ports. Since there is only one port (port 2) that will receive items, the value of the this node and the "Target Quantity" in the component list are the same.

The code first gets references to the these two nodes. It then assigns the value from the global table to "targetcomponentsum" and "Target Quantity", depending on the name of the object that is executing the code (the combiner).

The code to assign the values comes from older versions of FlexSim. The same can be done with the following using the newer dot-syntax.

// Read the target quantity from the global table
int qty = Table("Combiner_Quantity")[current.name][1];
// Get reference to the "componentlist" node as a table class variable
Table thelist = getvarnode(current,"componentlist");
// Get reference to the "targetcomponentsum" node
treenode thesum = getvarnode(current,"targetcomponentsum");
// Set the "Target Quantity" through port 2 (first row, first column) to be equal to the table value
thelist[1][1] = qty;
// Set the value of "targetcomponentsum" to be equal to the table value
thesum.value = qty;
0 Likes 0 ·
1669808798498.png (8.8 KiB)
1669808828026.png (4.0 KiB)
michela-08 avatar image michela-08 Felix Möhlmann commented ·
Hi @Felix Möhlmann

A model with the code you stated would be really helpful. It is being difficult for me to understand where to add the code so as to achieve the combiner target quantity.

Can you please attach a sample model so as to understand clearly?

0 Likes 0 ·
Show more comments
Joerg Vogel avatar image
0 Likes"
Joerg Vogel answered

There is a standard procedure to update components lists in combiners. It is a template, which copies columns of a global table to nodes in the tree of a combiner to replace a component list, which you can also edit manually from properties panels.

You can adjust this code to update the involved tree nodes like it is suggested at many places here at this forum by label values -

OR you can update the global table cell values in an assign structure and let handle updating a component list by the standard procedure.

If you want to get the standard procedure work successfully you only have to update the involved global table cell values before an item is entering a combiner through input port number one.

5 |100000

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