Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/fmi/sumo2fmi_bridge.h
169666 views
1
/****************************************************************************/
2
// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3
// Copyright (C) 2020-2025 German Aerospace Center (DLR) and others.
4
// This program and the accompanying materials are made available under the
5
// terms of the Eclipse Public License 2.0 which is available at
6
// https://www.eclipse.org/legal/epl-2.0/
7
// This Source Code may also be made available under the following Secondary
8
// Licenses when the conditions for such availability set forth in the Eclipse
9
// Public License 2.0 are satisfied: GNU General Public License, version 2
10
// or later which is available at
11
// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13
/****************************************************************************/
14
/// @file sumo2fmi_bridge.h
15
/// @author Robert Hilbrich
16
/// @author Matthias Schwamborn
17
/// @date Mon, 24 Aug 2020
18
///
19
// Declarations for the logic and data strcutures for the SUMO to FMI bridge
20
/****************************************************************************/
21
22
#ifndef SUMO2FMI_BRIDGE_H
23
#define SUMO2FMI_BRIDGE_H
24
25
#include <stdio.h>
26
#include <stdbool.h>
27
#include <stdarg.h>
28
#include <foreign/fmi/fmi2FunctionTypes.h>
29
#include <foreign/fmi/fmi2TypesPlatform.h>
30
31
/* Type definitions for callback functions */
32
typedef void* (*allocateMemoryType)(size_t nobj, size_t size);
33
typedef void (*loggerType)(void* componentEnvironment, const char* instanceName, int status, const char* category, const char* message, ...);
34
typedef void (*freeMemoryType)(void* obj);
35
36
/* Several declarations for the model component (housekeeping stuff) */
37
typedef struct {
38
void* componentEnvironment;
39
const char* instanceName;
40
const char* resourceLocation;
41
42
loggerType logger;
43
allocateMemoryType allocateMemory;
44
freeMemoryType freeMemory;
45
46
double startTime;
47
double stopTime;
48
49
char* libsumoCallOptions;
50
51
/**
52
* @brief Parameters stored for the next (libsumo) getter call.
53
* Workaround for FMIv2 not allowing input values for an output
54
* model variable (see modelDescription.xml).
55
*/
56
char* getterParameters;
57
58
/* Buffer for string value array used in fmi2GetString(). */
59
fmi2String* bufferArray;
60
int bufferArrayLength;
61
62
bool logEvents;
63
bool logErrors;
64
} ModelInstance;
65
66
/* Declarations of utility functions */
67
void sumo2fmi_logEvent(ModelInstance* comp, const char* message, ...);
68
void sumo2fmi_logError(ModelInstance* comp, const char* message, ...);
69
void sumo2fmi_logMessage(ModelInstance* comp, int status, const char* category, const char* message, va_list args);
70
71
/* Getter/Setter Functions */
72
fmi2Status sumo2fmi_getInteger(ModelInstance* comp, const fmi2ValueReference vr, int* value);
73
fmi2Status sumo2fmi_getString(ModelInstance* comp, const fmi2ValueReference vr, fmi2String* value);
74
fmi2Status sumo2fmi_setString(ModelInstance* comp, fmi2ValueReference vr, fmi2String value);
75
76
/* Stepping Functions */
77
fmi2Status sumo2fmi_step(ModelInstance* comp, double tNext);
78
79
/* Setting the start values for all parameters */
80
void sumo2fmi_set_startValues(ModelInstance* comp);
81
82
#endif /* SUMO2FMI_BRIDGE_H */
83
84