| 74 | |
| 75 | |
| 76 | fmi2Component fmi2Instantiate(fmi2String instanceName, |
| 77 | fmi2Type fmuType, |
| 78 | fmi2String fmuGUID, |
| 79 | fmi2String fmuResourceLocation, |
| 80 | const fmi2CallbackFunctions* functions, |
| 81 | fmi2Boolean visible, |
| 82 | fmi2Boolean loggingOn) |
| 83 | { |
| 84 | |
| 85 | // Convert URI %20 to space |
| 86 | auto resources = std::regex_replace(std::string(fmuResourceLocation), std::regex("%20"), " "); |
| 87 | const auto find = resources.find("file://"); |
| 88 | |
| 89 | if (find != std::string::npos) { |
| 90 | #ifdef _MSC_VER |
| 91 | resources.replace(find, 8, ""); |
| 92 | #else |
| 93 | resources.replace(find, 7, ""); |
| 94 | #endif |
| 95 | } |
| 96 | |
| 97 | auto logger = std::make_unique<Fmi2Logger>(instanceName, functions); |
| 98 | logger->setDebugLogging(loggingOn); |
| 99 | |
| 100 | try { |
| 101 | |
| 102 | auto instance = pythonfmu::createInstance( |
| 103 | {logger.get(), |
| 104 | visible == fmi2True, |
| 105 | instanceName, |
| 106 | resources, |
| 107 | nullptr}); |
| 108 | |
| 109 | auto component = std::make_unique<Fmi2Component>(std::move(instance), std::move(logger)); |
| 110 | return component.release(); |
| 111 | } catch (const std::exception& e) { |
| 112 | logger->log(fmi2Fatal, e.what()); |
| 113 | return nullptr; |
| 114 | } |
| 115 | } |
| 116 | |
| 117 | |
| 118 | void fmi2FreeInstance(fmi2Component c) |
nothing calls this directly
no test coverage detected