简体   繁体   中英

Idle units in resource pool

I have a resource pool with only 1 resource unit, I'd like to have a node "myArea" changes its color depending on if the resource unit is idle or busy. I typed the following code in a function "updateColor" body which I call in the resource pool actions "on seize" and "on release" (and in the Main agent "on startup").

int idleUnits = speedyBag.idle();
if (idleUnits == 1){
myArea.setFillColor(Color.GREEN);
} else if (idleUnits == 0) {
myArea.setFillColor(Color.RED);
}

However this code doesn't work as I expected, the simulation starts with a green area but when the resource unit is seized it turns red and stays red forever. I guess with

speedyBag.idle()

I'm not pointing at what i think (the number of idle units in the pool, indicated in the picture). Any suggestions?

image

No need for your approach, you can just use the dynamic color property of your node. Code below ensures the node fills green if you have 1 or more idle units. If all are busy, it shows red: 在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM