【发布时间】:2023-05-19 12:42:01
【问题描述】:
我正在使用 anylogic 来构建随机移动汽车的模型。 在该模型中,我想使用变量和事件块收集有关代理(汽车)的一些信息。
在模型上,我希望 事件 将变量 carsLane 设置为当前在路上的汽车的车道,并且每 2 秒执行一次。
问题是,每次假设发生事件时,我都会收到“NullpointerException”错误,并且在我尝试使用的 Car 的每种方法上都会发生这种情况使用事件。
事件在主选项卡上,我在操作框上使用的代码:
carsLane=Car.getLaneIndex();
On the image you can see the formation of the blocks and the code on the event's action box
我使用的 事件 是错误的还是其他原因?
感谢您的任何帮助。
【问题讨论】: