【问题标题】:Insert an ID into the loop trough my dbase通过我的数据库将 ID 插入到循环中
【发布时间】:2020-11-11 15:28:28
【问题描述】:

我想将循环通过我的 dbase 和 MAIN 中的 create_mydynamic 事件用于不同的流程。我必须插入一个函数,它只会选择具有指定 ID 的托盘。因此,我使用源块插入到我的流程中的不同托盘类型 (ID) 应该具有相同的 ID,就像我将根据我的数据库选择的托盘一样。所以类似的东西:

agent.typeID= tor77_kunde1.id

如果可以的话,你能帮帮我吗?

List< Tuple > amounts =selectFrom( tor77_kunde1 ).list();
for( Tuple tup : amounts ) {
    Date today=date();
    Date future=tup.get(tor77_kunde1.picktime);
    long diff = future.getTime() - today.getTime();
    int n =tup.get(tor77_kunde1.n);
    process.create_MyDynamicEvent(diff, MILLISECOND, n);
    process1.create_MyDynamicEvent(diff, MILLISECOND, n);
}

【问题讨论】:

    标签: anylogic


    【解决方案1】:

    目前,您正在释放“等待”对象中的最后一个代理。您需要释放 DE 中包含 typeID == n 的那个。

    所以把你的循环改成这样:

    for (MyAgentTypeWaitingInWait currentAgent : wait.getAgent()) {
        if (currentAgent.typeID == n) {
            wait.free(currentAgent);
            break;
        }
    }
    

    MyCurrentAgentType 是在“等待”中等待的代理类型。 (大写!)。阅读“enhanced for-loop”以更好地理解

    【讨论】:

    • Error the method getAgent() is undefined for the type Wait for (Pallet p : wait.getAgent()) { if (p.typeID == n) { wait.free(p );休息; } }
    • 我是否也应该更改 Main 中 createmyDE 中的某些内容?或者你知道我的错误在哪里吗?
    • 检查“等待”对象有哪些方法可以返回其中的所有代理。可能叫法不同。因此,我说“类似这样的东西”并建议(在其他地方)让您开始使用代码完成 :)
    猜你喜欢
    • 1970-01-01
    • 2018-10-16
    • 2014-06-13
    • 2019-05-27
    • 1970-01-01
    • 2015-07-08
    • 1970-01-01
    • 1970-01-01
    • 2013-04-23
    相关资源
    最近更新 更多