无法从自定义函数调用 StopDelay() 代码

问题描述 投票:0回答:1

该模拟涉及从五台挤出机挤出自行车车架,将它们存放在仓库中,然后将它们聚集在一处进行焊接和组装。 逻辑 整个逻辑 五个流程是相同的。

Store1到store5是延迟块。 商店1到商店5

传输的代理是一个“ContainerBox”,由布尔变量“isStored”和表示帧编号的双精度变量“num”组成。 代理 - ContainerBox

我将其设置为当代理存储在机架中时,变量会像这样存储。另外,我设置了agent.isStored = false;当代理处于“RackPick”中时。 货架存储块

我想当ContainerBox代理为“sink”时,调用store1到store5的stopDelay()函数。(工厂逻辑-sink6~sink15)

对于 selectOutput 块,我将其设置为只有第一个代理转到“true”,所有后续代理都转到“false”。

我编写了以下代码来调用store1到store5的stopDelay()函数 功能:请求

ContainerBox box = randomWhere( containerBoxes, bx -> bx.isStored );
if (box != null  && box.num == 1 ){
    store1.stopDelay( box );
}
else if (box != null  && box.num == 2 ){
    store2.stopDelay( box );
}
else if (box != null  && box.num == 3 ){
    store3.stopDelay( box );
}
else if (box != null  && box.num == 4 ){
    store4.stopDelay( box );
}
else if (box != null  && box.num == 5 ){
    store5.stopDelay( box );
}

而在sink6到sink15中,我写了request(); 水槽6到水槽15

但是,当我运行模拟时,没有错误,但没有调用 stopDelay(),并且代理不断在 store1 到 store5 中累积。您能帮我找出我的代码或逻辑的任何问题吗?

如果您需要任何其他信息,请询问我! 谢谢你。

simulation anylogic
1个回答
0
投票

始终首先构建一个微小的示例模型来尝试复制您的核心问题。

如果你这样做,你会发现

stopDelay(box)
工作得很好。

但是,您还将了解到,如果

box
根本不在 Delay 块中,则该函数执行时不会出现任何错误。因此,在致电之前,您需要确保它确实在那里
stopDelay()

© www.soinside.com 2019 - 2024. All rights reserved.