Change conveyor color based on the number of items on that

Change conveyor color based on the number of items on that

amir_a
Not applicable
11 Views
3 Replies
Message 1 of 4

Change conveyor color based on the number of items on that

amir_a
Not applicable

[ FlexSim 17.0.13 ]

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

12719-111111.png

0 Likes
Accepted solutions (1)
12 Views
3 Replies
Replies (3)
Message 2 of 4

jing_chen
Not applicable
Accepted solution

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

Message 3 of 4

amir_a
Not applicable

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
Message 4 of 4

jing_chen
Not applicable

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)

12771-nodes.png

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.