OMSimulatorLib
The OMSimulator project is a FMI-based co-simulation environment.
Loading...
Searching...
No Matches
ComponentDCP.h
Go to the documentation of this file.
1/*
2 * This file is part of OpenModelica.
3 *
4 * Copyright (c) 1998-2026, Open Source Modelica Consortium (OSMC),
5 * c/o Linköpings universitet, Department of Computer and Information Science,
6 * SE-58183 Linköping, Sweden.
7 *
8 * All rights reserved.
9 *
10 * THIS PROGRAM IS PROVIDED UNDER THE TERMS OF AGPL VERSION 3 LICENSE OR
11 * THIS OSMC PUBLIC LICENSE (OSMC-PL) VERSION 1.8.
12 * ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS PROGRAM CONSTITUTES
13 * RECIPIENT'S ACCEPTANCE OF THE OSMC PUBLIC LICENSE OR THE GNU AGPL
14 * VERSION 3, ACCORDING TO RECIPIENTS CHOICE.
15 *
16 * The OpenModelica software and the OSMC (Open Source Modelica Consortium)
17 * Public License (OSMC-PL) are obtained from OSMC, either from the above
18 * address, from the URLs:
19 * http://www.openmodelica.org or
20 * https://github.com/OpenModelica/ or
21 * http://www.ida.liu.se/projects/OpenModelica,
22 * and in the OpenModelica distribution.
23 *
24 * GNU AGPL version 3 is obtained from:
25 * https://www.gnu.org/licenses/licenses.html#GPL
26 *
27 * This program is distributed WITHOUT ANY WARRANTY; without
28 * even the implied warranty of MERCHANTABILITY or FITNESS
29 * FOR A PARTICULAR PURPOSE, EXCEPT AS EXPRESSLY SET FORTH
30 * IN THE BY RECIPIENT SELECTED SUBSIDIARY LICENSE CONDITIONS OF OSMC-PL.
31 *
32 * See the full OSMC Public License conditions for more details.
33 *
34 */
35
36#ifndef _OMS_COMPONENT_DCP_H_
37#define _OMS_COMPONENT_DCP_H_
38
39
40
41#include "Component.h"
42#include "ComRef.h"
43#include "DCPInfo.h"
44#include "ResultWriter.h"
45#include "Snapshot.h"
46#include "Values.h"
47#include "Variable.h"
48
49#include <fmi4c.h>
50#include <map>
51#include <pugixml.hpp>
52#include <string>
53#include <unordered_map>
54#include <vector>
55#include <cmath>
56#include <dcp/driver/ethernet/udp/UdpDriver.hpp> //Must be included first because of include conflict with Asio and windows.h
57#include <dcp/logic/DcpManagerMaster.hpp>
58
59class SlaveDescription_t;
60
61namespace oms
62{
63class System;
64
65class ComponentDCP : public Component
66{
67public:
69
70 static Component* NewComponent(const ComRef& cref, System* parentSystem, const std::string& dcpPath, std::string replaceComponent = "");
71 static Component* NewComponent(const pugi::xml_node& node, System* parentSystem, const std::string& sspVersion, const Snapshot& snapshot, std::string variantName);
72 const DCPInfo* getDCPInfo() const {return &(this->dcpInfo);}
73
74
75 oms_status_enu_t addSignalsToResults(const char* regex);
76 oms_status_enu_t exportToSSD(pugi::xml_node& node, Snapshot& snapshot, std::string variantName) const;
77 oms_status_enu_t initialize();
78 oms_status_enu_t instantiate();
79 oms_status_enu_t stepUntil(double stopTime) { return oms_status_ok; }
80 oms_status_enu_t registerSignalsForResultFile(ResultWriter& resultFile);
81 oms_status_enu_t removeSignalsFromResults(const char* regex);
82 oms_status_enu_t reset();
83 oms_status_enu_t terminate();
84 oms_status_enu_t updateSignals(ResultWriter& resultWriter);
86 void getFilteredSignals(std::vector<Connector>& filteredSignals) const;
87 oms_status_enu_t initializeDependencyGraph_outputs();
88
89protected:
90 ComponentDCP(const ComRef& cref, System* parentSystem, const std::string& fmuPath);
91
92 // stop the compiler generating methods copying the object
95
96private:
98 std::shared_ptr<SlaveDescription_t> dcpSlaveDescription;
99 std::vector<Variable> allVariables;
100 std::vector<unsigned int> calculatedParameters;
101 std::vector<unsigned int> derivatives;
102 std::vector<unsigned int> inputs;
103 std::vector<unsigned int> outputs;
104 std::vector<unsigned int> parameters;
105 std::vector<bool> exportVariables;
107
108 double time;
109
111};
112}
113
114#endif
ComRef - component reference.
Definition ComRef.h:51
Definition ComponentDCP.h:66
std::vector< Variable > allVariables
Definition ComponentDCP.h:99
oms_status_enu_t stepUntil(double stopTime)
Definition ComponentDCP.h:79
Values values
start values defined before instantiating the FMU and external inputs defined after initialization
Definition ComponentDCP.h:106
std::vector< unsigned int > derivatives
Definition ComponentDCP.h:101
oms_status_enu_t registerSignalsForResultFile(ResultWriter &resultFile)
Definition ComponentDCP.cpp:316
oms::ComRef getValidCref(ComRef cref)
double time
Definition ComponentDCP.h:108
ComponentDCP & operator=(ComponentDCP const &copy)
not implemented
oms_status_enu_t updateSignals(ResultWriter &resultWriter)
Definition ComponentDCP.cpp:338
ComponentDCP(ComponentDCP const &copy)
not implemented
oms_status_enu_t reset()
Definition ComponentDCP.cpp:328
oms_status_enu_t initialize()
Definition ComponentDCP.cpp:305
std::shared_ptr< SlaveDescription_t > dcpSlaveDescription
Definition ComponentDCP.h:98
std::vector< unsigned int > outputs
Definition ComponentDCP.h:103
void getFilteredSignals(std::vector< Connector > &filteredSignals) const
Definition ComponentDCP.cpp:344
oms_status_enu_t instantiate()
Definition ComponentDCP.cpp:311
DCPInfo dcpInfo
Definition ComponentDCP.h:97
oms_status_enu_t initializeDependencyGraph_outputs()
Definition ComponentDCP.cpp:355
std::vector< bool > exportVariables
Definition ComponentDCP.h:105
~ComponentDCP()
Definition ComponentDCP.cpp:62
static Component * NewComponent(const ComRef &cref, System *parentSystem, const std::string &dcpPath, std::string replaceComponent="")
Definition ComponentDCP.cpp:66
std::vector< unsigned int > inputs
Definition ComponentDCP.h:102
oms_status_enu_t addSignalsToResults(const char *regex)
Definition ComponentDCP.cpp:267
std::vector< unsigned int > parameters
Definition ComponentDCP.h:104
std::vector< unsigned int > calculatedParameters
Definition ComponentDCP.h:100
const DCPInfo * getDCPInfo() const
Definition ComponentDCP.h:72
oms_status_enu_t removeSignalsFromResults(const char *regex)
Definition ComponentDCP.cpp:322
Variable * getVariable(const ComRef &cref)
Definition ComponentDCP.cpp:349
oms_status_enu_t exportToSSD(pugi::xml_node &node, Snapshot &snapshot, std::string variantName) const
Definition ComponentDCP.cpp:286
oms_status_enu_t terminate()
Definition ComponentDCP.cpp:333
Definition Component.h:65
ComRef cref
Definition Component.h:190
System * parentSystem
Definition Component.h:189
DCP info.
Definition DCPInfo.h:53
Definition ResultWriter.h:73
Definition Snapshot.h:51
Definition System.h:72
Definition Values.h:50
Definition Variable.h:58
Definition AlgLoop.h:52