Anylogic:从图形界面生成的代码抛出类型转换异常
Anylogic: Code generated from graphical interface throws type casting exceptions
按照 问题的答案中给出的建议,我最终得到了一个模型:
main
中的代理人数量为空
所述代理类型中引用 main 的状态图(通过前一点实现)
离散事件流程图,引用代理的状态
但是在构建模型之后,出现了 3 个类型和转换错误,它们在自动生成的代码中。我不明白上述代码提供了什么功能。
对于上下文,我的模型称为 "Trenes",我的代理类型是 "Train"。所有错误都发生在 Train
java 文件中。
异常发生在以下片段中:
第一个:
// User API -----------------------------------------------------
public Main get_Main() {
{
Agent owner = getOwner();
if ( owner instanceof Main ) return (Main) owner;
}
return null;
}
这个原因 Cannot cast from Agent to Main
,多亏了铸造 (Main) owner
。它还会导致 Incompatible conditional operand types Agent and Main.
因为 owner instanceof Main
.
第二个:
@AnyLogicInternalCodegenAPI
private void setupReferences_xjal() {
main = get_Main();
}
这个从第一个片段调用方法并在 main = get_Main();
行中导致 Type mismatch: cannot convert from org.eclipse.jdt.internal.compiler.batch.Main to trenes.Main.
如果有人能指导我了解什么样的图形界面配置会导致这些错误,以及我如何在不撤消我对引用 main 的状态图的工作的情况下更正它,我将不胜感激。
编辑以添加我的模型结构和相关逻辑的捕获:
代理类型
- The train agent
- Logic of the crewed state
- Logic of the uncrewed state
- Logic of the 'hogging' transition
- Logic of the 'crew arrival' transition
离散事件流程图
- The full flowchart
- Logic of the wait block
- Logic of the delay block
您可能弄乱了一些内部编码,这种情况在极少数情况下会发生。
试试这个:
- 创建一个全新的class
TrainNew
- 将其作为代理群体嵌入 Main 中
- 一点一点 "move over" 您的功能(状态图、函数、变量)从
Train
到 TrainNew
- 完全删除
Train
并解决任何最终冲突(通过指向 TrainNew
按照
main
中的代理人数量为空
所述代理类型中引用 main 的状态图(通过前一点实现)
离散事件流程图,引用代理的状态
但是在构建模型之后,出现了 3 个类型和转换错误,它们在自动生成的代码中。我不明白上述代码提供了什么功能。
对于上下文,我的模型称为 "Trenes",我的代理类型是 "Train"。所有错误都发生在 Train
java 文件中。
异常发生在以下片段中:
第一个:
// User API -----------------------------------------------------
public Main get_Main() {
{
Agent owner = getOwner();
if ( owner instanceof Main ) return (Main) owner;
}
return null;
}
这个原因 Cannot cast from Agent to Main
,多亏了铸造 (Main) owner
。它还会导致 Incompatible conditional operand types Agent and Main.
因为 owner instanceof Main
.
第二个:
@AnyLogicInternalCodegenAPI
private void setupReferences_xjal() {
main = get_Main();
}
这个从第一个片段调用方法并在 main = get_Main();
Type mismatch: cannot convert from org.eclipse.jdt.internal.compiler.batch.Main to trenes.Main.
如果有人能指导我了解什么样的图形界面配置会导致这些错误,以及我如何在不撤消我对引用 main 的状态图的工作的情况下更正它,我将不胜感激。
编辑以添加我的模型结构和相关逻辑的捕获:
代理类型
- The train agent
- Logic of the crewed state
- Logic of the uncrewed state
- Logic of the 'hogging' transition
- Logic of the 'crew arrival' transition
离散事件流程图
- The full flowchart
- Logic of the wait block
- Logic of the delay block
您可能弄乱了一些内部编码,这种情况在极少数情况下会发生。
试试这个:
- 创建一个全新的class
TrainNew
- 将其作为代理群体嵌入 Main 中
- 一点一点 "move over" 您的功能(状态图、函数、变量)从
Train
到TrainNew
- 完全删除
Train
并解决任何最终冲突(通过指向TrainNew