使用引擎条件暂停或停止模型导致错误

Pause or Stop model using engine condition cause error

我正在尝试使用以下代码在达到目标数量后停止引擎:

if (self.count() >= Total_Input) {
    
    engine.pause();
    
   
}

但是我有以下错误:

engine cannot be resolved 

我查看了 Anylogic 文档,关于停止或暂停模型似乎很简单。

任何人都可以向我解释错误以及我该如何解决它。

以防万一有人遇到 engine cannot be resolved 错误,您需要使用 getEngine(). stop() 代码。

  if (self.count() >= Total_Input) {
        
        getEngine().stop();
        
       
    }

替代方法:有 2 个函数可以从任何地方调用而无需引用引擎:pauseSimulation() 这类似于在模拟中按 暂停 按钮控件和 finishSimulation() 相当于点击 stop.