OMSimulatorLib
The OMSimulator project is a FMI-based co-simulation environment.
Loading...
Searching...
No Matches
ResultWriter.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_RESULTWRITER_H_
37#define _OMS_RESULTWRITER_H_
38
39#include "ComRef.h"
40#include <string>
41#include <vector>
42
43namespace oms
44{
51
53 {
54 double realValue;
57 };
58
59 struct Signal
60 {
62 std::string description;
64 };
65
71
73 {
74 public:
75 ResultWriter(unsigned int bufferSize);
76 virtual ~ResultWriter();
77
78 unsigned int addSignal(const ComRef& name, const std::string& description, SignalType_t type);
79 void addParameter(const ComRef& name, const std::string& description, SignalType_t type, SignalValue_t value);
80
81 bool create(const std::string& filename, double startTime, double stopTime);
82 void close();
83
84 void updateSignal(unsigned int id, SignalValue_t value);
85 void emit(double time);
86
87 private:
88 // Stop the compiler generating methods for copying the object
89 ResultWriter(ResultWriter const& copy); // Not Implemented
90 ResultWriter& operator=(ResultWriter const& copy); // Not Implemented
91
92 protected:
93 virtual bool createFile(const std::string& filename, double startTime, double stopTime) = 0;
94 virtual void closeFile() = 0;
95 virtual void writeFile() = 0;
96
97 std::vector<Signal> signals;
98 std::vector<Parameter> parameters;
99
100 double* data_2;
101 unsigned int bufferSize;
102 unsigned int nEmits;
103 };
104
106 public ResultWriter
107 {
108 public:
111
112 protected:
113 bool createFile(const std::string& filename, double startTime, double stopTime) {return true;}
114 void closeFile() {}
115 void writeFile() {}
116 };
117}
118
119#endif
ComRef - component reference.
Definition ComRef.h:51
Definition ResultWriter.h:73
virtual void writeFile()=0
void emit(double time)
Definition ResultWriter.cpp:143
virtual void closeFile()=0
void updateSignal(unsigned int id, SignalValue_t value)
Definition ResultWriter.cpp:124
double * data_2
Definition ResultWriter.h:100
void addParameter(const ComRef &name, const std::string &description, SignalType_t type, SignalValue_t value)
Definition ResultWriter.cpp:77
virtual ~ResultWriter()
Definition ResultWriter.cpp:48
std::vector< Parameter > parameters
Definition ResultWriter.h:98
ResultWriter(ResultWriter const &copy)
void close()
Definition ResultWriter.cpp:110
unsigned int addSignal(const ComRef &name, const std::string &description, SignalType_t type)
Definition ResultWriter.cpp:54
ResultWriter & operator=(ResultWriter const &copy)
bool create(const std::string &filename, double startTime, double stopTime)
Definition ResultWriter.cpp:100
unsigned int nEmits
Definition ResultWriter.h:102
virtual bool createFile(const std::string &filename, double startTime, double stopTime)=0
std::vector< Signal > signals
Definition ResultWriter.h:97
unsigned int bufferSize
Definition ResultWriter.h:101
Definition ResultWriter.h:107
bool createFile(const std::string &filename, double startTime, double stopTime)
Definition ResultWriter.h:113
VoidWriter(unsigned int bufferSize)
Definition ResultWriter.h:109
void writeFile()
Definition ResultWriter.h:115
~VoidWriter()
Definition ResultWriter.h:110
void closeFile()
Definition ResultWriter.h:114
Definition AlgLoop.h:49
SignalType_t
Definition ResultWriter.h:46
@ SignalType_REAL
Definition ResultWriter.h:47
@ SignalType_BOOL
Definition ResultWriter.h:49
@ SignalType_INT
Definition ResultWriter.h:48
Definition ResultWriter.h:67
Signal signal
Definition ResultWriter.h:68
SignalValue_t value
Definition ResultWriter.h:69
Definition ResultWriter.h:60
std::string description
Definition ResultWriter.h:62
ComRef name
Definition ResultWriter.h:61
SignalType_t type
Definition ResultWriter.h:63
Definition ResultWriter.h:53
bool boolValue
Definition ResultWriter.h:56
double realValue
Definition ResultWriter.h:54
int intValue
Definition ResultWriter.h:55