Beispiel #1
0
boost::weak_ptr<IMixedSystem> SimController::LoadModelicaSystem(PATH modelica_path,string modelKey)
{
    if(_use_modelica_compiler)
    {
        // if the modell is already loaded
        std::map<string,boost::shared_ptr<IMixedSystem> >::iterator iter = _systems.find(modelKey);
        if(iter != _systems.end())
        {
            // destroy simdata
            std::map<string,boost::shared_ptr<ISimData> >::iterator iter2 = _sim_data.find(modelKey);
            if(iter2 != _sim_data.end())
            {
                _sim_data.erase(iter2);
            }
            // destroy system
            _systems.erase(iter);
        }
        boost::shared_ptr<ISimData> simData = getSimData(modelKey).lock();
        boost::shared_ptr<ISimVars> simVars = getSimVars(modelKey).lock();
        boost::shared_ptr<IMixedSystem> system = createModelicaSystem(modelica_path, modelKey, _config->getGlobalSettings(), _algloopsolverfactory, simData, simVars);
        _systems[modelKey] = system;
        return system;
    }
    else
        throw ModelicaSimulationError(SIMMANAGER,"No Modelica Compiler configured");
}
shared_ptr<IMixedSystem> VxWorksFactory::LoadSystem(IGlobalSettings* globalSettings,shared_ptr<ISimObjects> simObjects)
{
    IMixedSystem* system = createModelicaSystem(globalSettings, simObjects);
    return shared_ptr<IMixedSystem>(system);
}