How to get the different recipes output from mixer.

How to get the different recipes output from mixer.

Rambabu
Not applicable
52 Views
5 Replies
Message 1 of 6

How to get the different recipes output from mixer.

Rambabu
Not applicable

[ FlexSim 23.1.3 ]

Hi flexsimers,

I have a query on mixing the ingredient in different proportions to make different recipes using mixer. In my model I am using mixer to mix four ingredients and make four different recipes. The ratio of ingredients to be mixed are taken in the global table. Is there any solution?

I am attaching the model here: mixing ingredients.fsm

Thankyou.


0 Likes
Accepted solutions (1)
53 Views
5 Replies
Replies (5)
Message 2 of 6

jason_lightfootVL7B4
Autodesk
Autodesk
Accepted solution

Just write to the table which is found at:

Table recipetable = getvarnode(current,"recipetable");

Then read the values from the global table with your format you'll need something like:

Table recipeTable=getvarnode(Model.find("FluidMixer1"),"recipetable");
Table globRecipes=Table("RecipesTable");
string newRecipe="Recipe2";
for (int n=globRecipes.numCols;n>0;n--){
    string ingredient=globRecipes.getColHeader(n);
    int row=recipeTable.getRowByKey(ingredient,1);
    recipeTable[row]["Amount"]=globRecipes[newRecipe];
}

But you need to change the ingredient names to match those of the mixer. Example attached.

Note you can also choose the option to update from a global table on the triggers, but that relies on your table format matching what the trigger expects.

mixing-ingredients_jl.fsm


0 Likes
Message 3 of 6

Rambabu
Not applicable

@Jason Lightfoot The above code indicates only for recipe2. Can you Explain that How to do for remaining recipes by order. I am using global table data only.

Thankyou

0 Likes
Message 4 of 6

jason_lightfootVL7B4
Autodesk
Autodesk

Create a user command that accepts two parameters: the mixer and the recipe name.

1696680501972.png

In the code place this version of the above script:

Object mixer=param(1);
string newRecipe=param(2);

Table recipeTable=getvarnode(mixer,"recipetable");
Table globRecipes=Table("RecipesTable");
for (int n=globRecipes.numCols;n>0;n--){
    string ingredient=globRecipes.getColHeader(n);
    int row=recipeTable.getRowByKey(ingredient,1);
    recipeTable[row]["Amount"]=globRecipes[newRecipe];
}

then call the command using

changeMixerRecipe(<mixerObject>,<recipename>)

where you replace the chevron parameters with a mixer object and a string name of a recipe. eg:

Object mymixer=Model.find("FluidMixer1");
string recipe=getRecipeForOrder(orderNum);   // another user command
changeMixerRecipe(mymixer,recipe);

I can't tell you how you map the order to the recipe - that will be based on the data you know and have.

0 Likes
Message 5 of 6

Rambabu
Not applicable

@Jason Lightfoot Thankyou for your answer, But I applied that code to my model that shows error. When I debugging the code. It is showing the error in the last line. Could You tell me why it was going wrong.

  1. Table recipeTable=getvarnode(Model.find("FluidMixer1"),"recipetable");
  2. Table globRecipes=Table("RecipesTable");
  3. string newRecipe="Recipe2";
  4. for (int n=globRecipes.numCols;n>0;n--){
  5. string ingredient=globRecipes.getColHeader(n);
  6. int row=recipeTable.getRowByKey(ingredient,1);
  7. recipeTable[row]["Amount"]=globRecipes[newRecipe][n];
  8. }


image-2023-10-09-13-10-53.png

Thankyou

0 Likes
Message 6 of 6

jason_lightfootVL7B4
Autodesk
Autodesk

I don't think the error screen matches the code - nowhere do you mention Recipe3 - we'd need to see the model to determine what is wrong. Your row headers should look something like this:

1696861383493.png

0 Likes