[英]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.我有一个只有 1 个资源单元的资源池,我想让节点“myArea”根据资源单元是空闲还是忙碌来改变它的颜色。 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").我在函数“updateColor”主体中键入了以下代码,我在资源池操作“on seize”和“on release”(以及主代理“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?有什么建议?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.