如何根据节点中的代理数量更改矩形节点的颜色在AnyLogic中?

huangapple go评论58阅读模式
英文:

How to change the color of rectangular node based on number of agents in the node in Anylogic?

问题

有没有办法根据资源池中的资源空闲/繁忙数量来更改我的矩形节点(表示为资源池)的颜色。例如,如果我有10个可用的资源池,那么主节点将是绿色,如果我有10个资源中有5个可用,那么主节点将是黄色,如果少于3个资源可用,那么主节点将是红色。

英文:

Is there a way to change the color of my rectangular nodes (represented as resource pool) based on number of resources idle/busy. For example, if I have 10 resource pool available, then the home node will be green, if I have 5 available resource out of 10 then the home node will be yellow, and if it is less than 3 then the home node will be red.

答案1

得分: 1

你可以使用每秒触发的事件,或者每10秒触发的事件,或者每当资源被占用或释放时触发的事件(检查资源池块上的占用和释放操作)。

if (resurcePool.idle() < 3) {
    node.setFillColor(red);
} else {
    node.setFillColor(green);
}
英文:

you can use an event that is triggered every second, or every 10 seconds, or every time a resource is seized or released (check the actions on seize and release on the resourcepool block)

if(resurcePool.idle()&lt;3){
   node.setFillColor(red);
}else{
   node.setFillColor(green);
}

huangapple
  • 本文由 发表于 2023年7月31日 21:34:44
  • 转载请务必保留本文链接:https://go.coder-hub.com/76804173.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定