question

Trex avatar image
0 Likes"
Trex asked Joshua S commented

How to update number of steps of mixer through code

How to update the number of steps & click on update menu through code

I have tried an option with command setsize of current table but its not reflecting in the number of steps column.

I need to insert the number of steps at first and then it should update the table as per that

Kindly do help me, if anyone has worked on changing mixer steps & mixer recipe through codes

FlexSim 19.0.2
updatemixer recipemixermixer steps
5 |100000

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

Mischa Spelt avatar image
0 Likes"
Mischa Spelt answered

Hi Joshua, please note that Trex is using the FlexSim Fluid Library instead of FloWorks. I don't know much about the former, but the latter can handle changing recipes. If you want to do that, I recommend unchecking "Continuously produce recipe", then you can change the recipe in the On Empty trigger and call FlowMixer.startRecipe() whenever you are ready for it. Or use the "Mixers with recipe table" process flow if you want to run a predefined schedule, of course.

I reworked the model into a FloWorks version - based on the original scripting so it's far from optimal, but it shows the concept: 17904-mini-11-fw.fsm


5 |100000

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

Joshua S avatar image
1 Like"
Joshua S answered Joshua S converted comment to answer

This code should do that for you

int Steps=5;
int recipies=6;
Object Mixer=Model.find("FlowMixer1");
treenode Node=getvarnode(Mixer, "steptable");
Node.subnodes.clear();
Node=getvarnode(Mixer, "recipetable");
Node.subnodes.clear();
for (int i=1;i<=Steps;i++)
{
	treenode Node=getvarnode(Mixer, "steptable");
	treenode Step= Node.subnodes.add();
	Step.name="Step "+numtostring(Node.subnodes.length); 
	treenode Description= Step.subnodes.add();
	Description.name="Description";
	Description.value="just added a new step";
	treenode Delay=Step.subnodes.add();
	Delay.value=0.00;
}

for (int i=1;i<=recipies;i++)
{
	treenode Node=getvarnode(Mixer, "recipetable");
	treenode Recipe= Node.subnodes.add();
	
	treenode Ingredient= Recipe.subnodes.add();
	Ingredient.name="Ingredient";
	Ingredient.value=1;
	
	treenode Port= Recipe.subnodes.add();
	Port.name="Port";
	Port.value=1;
	
	treenode Amount= Recipe.subnodes.add();
	Amount.name="Amount";
	Amount.value=1;
	
	treenode Step= Recipe.subnodes.add();
	Step.name="Step";
	Step.value=1;
}

This updates the step and recipe tables and allows you to change all the values through code.

· 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.

Trex avatar image Trex commented ·

mini-11.fsm

@Joshua S

Thank you for support.

Enclosed is the model attached for more clarity.

Problem: I have 3 schedules to be followed in the mixer using table RUN_Schedule. Mixer gets triggered for new schedule at empty state & send a message to mixer to bring new recipe along with steps. Though it changes the mixer recipe & steps but the content to be pulled from fluid generator remains similar to the last recipe and the model gets stuck.

Further details:

  • When schedule changes it refers to different global table
  • All recipe & steps data has been fetched from All_sequence global table

I am looking ahead, model should be capable of running any schedule

0 Likes 0 ·
mini-11.fsm (49.3 KiB)
Joshua S avatar image Joshua S Trex commented ·

@Mischa Spelt

Does changing the recipe and steps cause issues with a mixer during runtime normally?

0 Likes 0 ·
Trex avatar image Trex Joshua S commented ·

Yes, it does. If you have a static recipe & steps, it works fine during runtime.
But when we keep changing it during the runtime, it keeps on taking the value of last recipe.
Note: Visually the table changes but it takes the previous recipe value from the memory

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

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