matlab dymola connection fails after a while

若如初见. 提交于 2019-12-01 13:57:44
Marcus

OK, this problem is four years old, but I just spent the last two weeks usings unsatifactory workarounds before finally getting to this solution.

I solved the problem with the following tactic:

I overloaded the function dymolaM.m with my own modified version. I commented out the command:

DymolaChannel = ddeinit('dymola', ' ');

and replaced it with:

% DymolaChannel = ddeinit('dymola', ' ');
DymolaChannel = get_dymola_channel();

I defined the function get_dymola_channel(); as follows:

function DymolaChannel = get_dymola_channel()
    persistent dymola_channel_persistent
    if isempty(dymola_channel_persistent)
        dymola_channel_persistent = ddeinit('dymola', ' ');
    end
    DymolaChannel = dymola_channel_persistent;
end

This means the function ddeinit (which can only create a limited number of channels) is only called once.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!