OMCompiler/SimulationRuntime/cpp/Core/DataExchange/SimData.cpp
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /* | ||
| 2 | * This file belongs to the OpenModelica Run-Time System | ||
| 3 | * | ||
| 4 | * Copyright (c) 1998-2026, Open Source Modelica Consortium (OSMC), c/o Linköpings | ||
| 5 | * universitet, Department of Computer and Information Science, SE-58183 Linköping, Sweden. All rights | ||
| 6 | * reserved. | ||
| 7 | * | ||
| 8 | * THIS PROGRAM IS PROVIDED UNDER THE TERMS OF THE BSD NEW LICENSE OR THE | ||
| 9 | * AGPL VERSION 3 LICENSE OR THE OSMC PUBLIC LICENSE (OSMC-PL) VERSION 1.8. ANY | ||
| 10 | * USE, REPRODUCTION OR DISTRIBUTION OF THIS PROGRAM CONSTITUTES RECIPIENT'S | ||
| 11 | * ACCEPTANCE OF THE BSD NEW LICENSE OR THE OSMC PUBLIC LICENSE OR THE AGPL | ||
| 12 | * VERSION 3, ACCORDING TO RECIPIENTS CHOICE. | ||
| 13 | * | ||
| 14 | * The OpenModelica software and the OSMC (Open Source Modelica Consortium) Public License | ||
| 15 | * (OSMC-PL) are obtained from OSMC, either from the above address, from the URLs: | ||
| 16 | * http://www.openmodelica.org or https://github.com/OpenModelica/ or | ||
| 17 | * http://www.ida.liu.se/projects/OpenModelica, and in the OpenModelica distribution. GNU | ||
| 18 | * AGPL version 3 is obtained from: https://www.gnu.org/licenses/licenses.html#GPL. The BSD NEW | ||
| 19 | * License is obtained from: http://www.opensource.org/licenses/BSD-3-Clause. | ||
| 20 | * | ||
| 21 | * This program is distributed WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, EXCEPT AS EXPRESSLY | ||
| 23 | * SET FORTH IN THE BY RECIPIENT SELECTED SUBSIDIARY LICENSE CONDITIONS OF | ||
| 24 | * OSMC-PL. | ||
| 25 | * | ||
| 26 | */ | ||
| 27 | |||
| 28 | /** @addtogroup dataexchange | ||
| 29 | * | ||
| 30 | * @{ | ||
| 31 | */ | ||
| 32 | |||
| 33 | #include <Core/ModelicaDefine.h> | ||
| 34 | #include <Core/Modelica.h> | ||
| 35 | #include <Core/DataExchange/SimData.h> | ||
| 36 | |||
| 37 | 40 | SimData::SimData(void) | |
| 38 | { | ||
| 39 | 40 | } | |
| 40 | |||
| 41 | ✗ | SimData::SimData(SimData &instance) | |
| 42 | { | ||
| 43 | ✗ | } | |
| 44 | |||
| 45 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 40 times.
|
80 | SimData::~SimData(void) |
| 46 | { | ||
| 47 | 80 | } | |
| 48 | |||
| 49 | ✗ | ISimData* SimData::clone() | |
| 50 | { | ||
| 51 | ✗ | return new SimData(*this); | |
| 52 | } | ||
| 53 | |||
| 54 | ✗ | void SimData::Add(string key, shared_ptr<ISimVar> var) | |
| 55 | { | ||
| 56 | ✗ | std::pair<string,shared_ptr<ISimVar> > elem(key,var); | |
| 57 | std::pair<Objects_type::iterator,bool> p = _sim_vars.insert(elem); | ||
| 58 | ✗ | } | |
| 59 | |||
| 60 | ✗ | ISimVar* SimData::Get(string key) | |
| 61 | { | ||
| 62 | Objects_type::const_iterator iter =_sim_vars.find(key); | ||
| 63 | |||
| 64 | //Prüfen ob das Simobjekt in Liste ist. | ||
| 65 | ✗ | if(iter!=_sim_vars.end()) | |
| 66 | { | ||
| 67 | shared_ptr<ISimVar> obj = iter->second; | ||
| 68 | ✗ | return obj.get(); | |
| 69 | } | ||
| 70 | else | ||
| 71 | ✗ | throw ModelicaSimulationError(DATASTORAGE,"There is no such sim variable " + key); | |
| 72 | } | ||
| 73 | |||
| 74 | ✗ | void SimData::addOutputResults(string name,ublas::vector<double> v) | |
| 75 | { | ||
| 76 | ✗ | std::pair<string,ublas::vector<double> > elem(name,v); | |
| 77 | std::pair<OutputResults_type::iterator,bool> p = _result_vars.insert(elem); | ||
| 78 | ✗ | } | |
| 79 | |||
| 80 | ✗ | void SimData::getTimeEntries(vector<double>& time_entries) | |
| 81 | { | ||
| 82 | ✗ | time_entries = omcpp::ref(_time_entries); | |
| 83 | ✗ | } | |
| 84 | |||
| 85 | ✗ | void SimData::addTimeEntries(vector<double> time_entries) | |
| 86 | { | ||
| 87 | ✗ | _time_entries = time_entries; | |
| 88 | ✗ | } | |
| 89 | |||
| 90 | ✗ | void SimData::destroy() | |
| 91 | { | ||
| 92 | ✗ | delete this; | |
| 93 | ✗ | } | |
| 94 | |||
| 95 | ✗ | void SimData::clearResults() | |
| 96 | { | ||
| 97 | _result_vars.clear(); | ||
| 98 | _time_entries.clear(); | ||
| 99 | ✗ | } | |
| 100 | |||
| 101 | ✗ | void SimData::clearVars() | |
| 102 | { | ||
| 103 | _sim_vars.clear(); | ||
| 104 | ✗ | } | |
| 105 | |||
| 106 | ✗ | void SimData::getOutputResults(string name,ublas::vector<double>& v) | |
| 107 | { | ||
| 108 | OutputResults_type::const_iterator iter =_result_vars.find(name); | ||
| 109 | |||
| 110 | //Prüfen ob die Ergebnisse in Liste ist. | ||
| 111 | ✗ | if(iter!=_result_vars.end()) | |
| 112 | { | ||
| 113 | |||
| 114 | ✗ | v = omcpp::ref(iter->second); | |
| 115 | } | ||
| 116 | else | ||
| 117 | ✗ | throw ModelicaSimulationError(DATASTORAGE,"There is no such output variable " + name); | |
| 118 | ✗ | } | |
| 119 | |||
| 120 | ✗ | extern "C" ISimData* createSimDataAnalyzation() | |
| 121 | { | ||
| 122 | ✗ | return new SimData(); | |
| 123 | } | ||
| 124 | /** @} */ // end of dataexchange | ||
| 125 |