英文:
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()<3){
node.setFillColor(red);
}else{
node.setFillColor(green);
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论