question

ANIL KUMAR N avatar image
1 Like"
ANIL KUMAR N asked Ben Wilson edited

How to set an available label "temperature" to the source

We are having the temperature column as shown in figure. Now we need to show the color variance when temperature is less than 50 then green color else red color. For that we have written script at source like this:

/**Custom Code*/
treenode item = parnode(1);
treenode current = ownerobject(c);
int port = parval(2);
double newtype =1;
if(getoutput(current)>100)
{
	 newtype=2;
	 setitemtype(item,newtype);
}
int value=getitemtype(item);
colorarray(item, value);

We have a confusion how to set for temperature values. We are new to this FlexSim. Any help would be appreciated.

Choose One
flexsim commandsflexsim users manualflexscript
capture1.png (122.4 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

·
David Seo avatar image
2 Likes"
David Seo answered

@ANIL KUMAR N

if (item.Temperature < 50) item.color = Color.green;

else if (item.Temperature >= 50) item.color = Color.red;

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

ANIL KUMAR N avatar image ANIL KUMAR N commented ·

Thanks for your answer. It worked out. Now I want the processor to send the items based on colors to different queues. How it can be achieved? It's been passing the products to a single queue

0 Likes 0 ·
David Seo avatar image David Seo ANIL KUMAR N commented ·

@ANIL KUMAR N

int port = 0;

if (item.Temperature < 50) {

item.color = Color.green; port = 1; }

else if (item.Temperature >= 50) {

item.color = Color.red; port = 2; }

return port;

This custom code should be used in 'Send To Port'.

I want to know which trigger you set your custome code in.

You need to use the value of the itemType generally to set the item color and the port number to be sent.

0 Likes 0 ·
ANIL KUMAR N avatar image ANIL KUMAR N David Seo commented ·

Thank you once again. Code is working fine.

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.