question

ShabDz avatar image
0 Likes"
ShabDz asked jing.c commented

Change conveyor color based on the number of items on that

How can I change the color of a conveyor based on the number of items on that? For instance, in the attached model, I want the conveyor color changed to red when it's carrying more than 4 items. I would appreciate any help.

conveyor-color.fsm

FlexSim 17.0.13
conveyor properties
111111.png (29.0 KiB)
conveyor-color.fsm (18.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

·
jing.c avatar image
4 Likes"
jing.c answered jing.c commented

hi @Amir About

You can change the node control the color of conveyor, and the path is MODEL:/Conveyor1>variables/localType/drawColor

I attached the modified model.

If the conveyor type is not "custom", you should find the node in MODEL:/ConveyorSystem>variables/conveyorTypes/ConveyorType1

conveyor-colorbychjv17.fsm


· 2
5 |100000

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

ShabDz avatar image ShabDz commented ·

Thanks @jing.chen.

The modified model does exactly what I need. Can you please explain three custom codes in the derision points. Some parts aren't clear to me:

DP1 (On Arrival):

Object current = param(1);
Object item = param(2);
Object conveyor = param(3);

if(conveyor.subnodes.length >= 4)
{
	treenode colornode = getvarnode(conveyor, "localType").subnodes[38];
	setnodenum(first(colornode),0);
}

DP11 (On Arrival):

Object current = param(1);
Object item = param(2);
Object conveyor = param(3);

if(conveyor.subnodes.length == 4)
{
	treenode colornode = getvarnode(conveyor, "localType").subnodes[38];
	setnodenum(first(colornode),1);
	repaintall();
}

DP11 (On Reset):

Object current = param(1);
Object conveyor = param(2);

treenode colornode = getvarnode(conveyor, "localType").subnodes[38];
setnodenum(first(colornode),1);
0 Likes 0 ·
jing.c avatar image jing.c ShabDz commented ·

What color of an object shown in FlexSim is based on 3 subnodes (value is 0 to 1,{1,1,1} will show white color) under the "colornode".(You can see in the pic attached)

In OnArrival of DP1 is to check the content of conveyor had come to 4 or more, if so it will set the value of any subnode of "drawColor" to 0(any value different from the original value is OK).

While in OnArrival of DP11 is to check the content of conveyor less than 4, and make it back to white color.

1 Like 1 ·
nodes.png (22.1 KiB)

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.