13
13
)
14
14
from typing import Optional
15
15
16
- from . import CosimConstants , CosimEnums , CosimLibrary , CosimManipulator , CosimObserver , CosimSlave
17
- from ._internal import wrap_function
16
+ from . import CosimConstants , CosimEnums , CosimManipulator , CosimObserver , CosimSlave
17
+ from ._internal import wrap_function , libcosimc
18
18
from .CosimAlgorithm import CosimAlgorithm
19
19
20
20
if typing .TYPE_CHECKING :
@@ -57,55 +57,55 @@ def __init__(self, create_key: object = None, execution_ptr: Optional[CosimExecu
57
57
self .__execution_status_ptr = pointer (self .execution_status )
58
58
59
59
self .__multiple_steps = wrap_function (
60
- lib = CosimLibrary . lib ,
60
+ lib = libcosimc () ,
61
61
funcname = "cosim_execution_step" ,
62
62
argtypes = [POINTER (CosimExecution ), c_int64 ],
63
63
restype = None ,
64
64
)
65
65
self .__add_local_slave = wrap_function (
66
- lib = CosimLibrary . lib ,
66
+ lib = libcosimc () ,
67
67
funcname = "cosim_execution_add_slave" ,
68
68
argtypes = [POINTER (CosimExecution ), POINTER (CosimSlave .CosimLocalSlave )],
69
69
restype = c_int ,
70
70
)
71
71
self .__simulate_until = wrap_function (
72
- lib = CosimLibrary . lib ,
72
+ lib = libcosimc () ,
73
73
funcname = "cosim_execution_simulate_until" ,
74
74
argtypes = [POINTER (CosimExecution ), c_int64 ],
75
75
restype = c_int ,
76
76
)
77
77
self .__stop = wrap_function (
78
- lib = CosimLibrary . lib ,
78
+ lib = libcosimc () ,
79
79
funcname = "cosim_execution_stop" ,
80
80
argtypes = [POINTER (CosimExecution )],
81
81
restype = c_int ,
82
82
)
83
83
self .__enable_real_time_simulation = wrap_function (
84
- lib = CosimLibrary . lib ,
84
+ lib = libcosimc () ,
85
85
funcname = "cosim_execution_enable_real_time_simulation" ,
86
86
argtypes = [POINTER (CosimExecution )],
87
87
restype = c_int ,
88
88
)
89
89
self .__disable_real_time_simulation = wrap_function (
90
- lib = CosimLibrary . lib ,
90
+ lib = libcosimc () ,
91
91
funcname = "cosim_execution_disable_real_time_simulation" ,
92
92
argtypes = [POINTER (CosimExecution )],
93
93
restype = c_int ,
94
94
)
95
95
self .__real_time_factor_target = wrap_function (
96
- lib = CosimLibrary . lib ,
96
+ lib = libcosimc () ,
97
97
funcname = "cosim_execution_set_real_time_factor_target" ,
98
98
argtypes = [POINTER (CosimExecution ), c_double ],
99
99
restype = c_int ,
100
100
)
101
101
self .__steps_to_monitor = wrap_function (
102
- lib = CosimLibrary . lib ,
102
+ lib = libcosimc () ,
103
103
funcname = "cosim_execution_set_steps_to_monitor" ,
104
104
argtypes = [POINTER (CosimExecution ), c_int ],
105
105
restype = c_int ,
106
106
)
107
107
self .__add_manipulator = wrap_function (
108
- lib = CosimLibrary . lib ,
108
+ lib = libcosimc () ,
109
109
funcname = "cosim_execution_add_manipulator" ,
110
110
argtypes = [
111
111
POINTER (CosimExecution ),
@@ -114,31 +114,31 @@ def __init__(self, create_key: object = None, execution_ptr: Optional[CosimExecu
114
114
restype = c_int ,
115
115
)
116
116
self .__add_observer = wrap_function (
117
- lib = CosimLibrary . lib ,
117
+ lib = libcosimc () ,
118
118
funcname = "cosim_execution_add_observer" ,
119
119
argtypes = [POINTER (CosimExecution ), POINTER (CosimObserver .CosimObserver )],
120
120
restype = c_int ,
121
121
)
122
122
self .__status = wrap_function (
123
- lib = CosimLibrary . lib ,
123
+ lib = libcosimc () ,
124
124
funcname = "cosim_execution_get_status" ,
125
125
argtypes = [POINTER (CosimExecution ), POINTER (CosimExecutionStatus )],
126
126
restype = c_int ,
127
127
)
128
128
self .__slave_num_variables = wrap_function (
129
- lib = CosimLibrary . lib ,
129
+ lib = libcosimc () ,
130
130
funcname = "cosim_slave_get_num_variables" ,
131
131
argtypes = [POINTER (CosimExecution ), c_int ],
132
132
restype = c_int ,
133
133
)
134
134
self .__num_modified_variables = wrap_function (
135
- lib = CosimLibrary . lib ,
135
+ lib = libcosimc () ,
136
136
funcname = "cosim_get_num_modified_variables" ,
137
137
argtypes = [POINTER (CosimExecution )],
138
138
restype = c_int ,
139
139
)
140
140
self .__load_scenario = wrap_function (
141
- lib = CosimLibrary . lib ,
141
+ lib = libcosimc () ,
142
142
funcname = "cosim_execution_load_scenario" ,
143
143
argtypes = [
144
144
POINTER (CosimExecution ),
@@ -148,55 +148,55 @@ def __init__(self, create_key: object = None, execution_ptr: Optional[CosimExecu
148
148
restype = c_int ,
149
149
)
150
150
self .__real_initial = wrap_function (
151
- lib = CosimLibrary . lib ,
151
+ lib = libcosimc () ,
152
152
funcname = "cosim_execution_set_real_initial_value" ,
153
153
argtypes = [POINTER (CosimExecution ), c_int , c_uint32 , c_double ],
154
154
restype = c_int ,
155
155
)
156
156
self .__integer_initial = wrap_function (
157
- lib = CosimLibrary . lib ,
157
+ lib = libcosimc () ,
158
158
funcname = "cosim_execution_set_integer_initial_value" ,
159
159
argtypes = [POINTER (CosimExecution ), c_int , c_uint32 , c_int ],
160
160
restype = c_int ,
161
161
)
162
162
163
163
self .__boolean_initial = wrap_function (
164
- lib = CosimLibrary . lib ,
164
+ lib = libcosimc () ,
165
165
funcname = "cosim_execution_set_boolean_initial_value" ,
166
166
argtypes = [POINTER (CosimExecution ), c_int , c_uint32 , c_bool ],
167
167
restype = c_int ,
168
168
)
169
169
170
170
self .__string_initial = wrap_function (
171
- lib = CosimLibrary . lib ,
171
+ lib = libcosimc () ,
172
172
funcname = "cosim_execution_set_string_initial_value" ,
173
173
argtypes = [POINTER (CosimExecution ), c_int , c_uint32 , c_char_p ],
174
174
restype = c_int ,
175
175
)
176
176
177
177
self .__connect_real_variables = wrap_function (
178
- lib = CosimLibrary . lib ,
178
+ lib = libcosimc () ,
179
179
funcname = "cosim_execution_connect_real_variables" ,
180
180
argtypes = [POINTER (CosimExecution ), c_int , c_uint32 , c_int , c_uint32 ],
181
181
restype = c_int ,
182
182
)
183
183
184
184
self .__connect_int_variables = wrap_function (
185
- lib = CosimLibrary . lib ,
185
+ lib = libcosimc () ,
186
186
funcname = "cosim_execution_connect_integer_variables" ,
187
187
argtypes = [POINTER (CosimExecution ), c_int , c_uint32 , c_int , c_uint32 ],
188
188
restype = c_int ,
189
189
)
190
190
191
191
self .__connect_string_variables = wrap_function (
192
- lib = CosimLibrary . lib ,
192
+ lib = libcosimc () ,
193
193
funcname = "cosim_execution_connect_string_variables" ,
194
194
argtypes = [POINTER (CosimExecution ), c_int , c_uint32 , c_int , c_uint32 ],
195
195
restype = c_int ,
196
196
)
197
197
198
198
self .__connect_boolean_variables = wrap_function (
199
- lib = CosimLibrary . lib ,
199
+ lib = libcosimc () ,
200
200
funcname = "cosim_execution_connect_boolean_variables" ,
201
201
argtypes = [POINTER (CosimExecution ), c_int , c_uint32 , c_int , c_uint32 ],
202
202
restype = c_int ,
@@ -210,7 +210,7 @@ def from_algorithm(cls, algorithm: CosimAlgorithm):
210
210
:return: CosimExecution object
211
211
"""
212
212
execution_create = wrap_function (
213
- lib = CosimLibrary . lib ,
213
+ lib = libcosimc () ,
214
214
funcname = "cosim_execution_create_with_algorithm" ,
215
215
argtypes = [c_int64 , POINTER (CosimAlgorithm )],
216
216
restype = POINTER (CosimExecution ),
@@ -243,7 +243,7 @@ def from_step_size(cls, step_size: int | float):
243
243
assert step_size > 0 , "Step size must be a positive and non-zero integer"
244
244
245
245
execution_create = wrap_function (
246
- lib = CosimLibrary . lib ,
246
+ lib = libcosimc () ,
247
247
funcname = "cosim_execution_create" ,
248
248
argtypes = [c_int64 , c_int64 ],
249
249
restype = POINTER (CosimExecution ),
@@ -260,7 +260,7 @@ def from_osp_config_file(cls, osp_path: str):
260
260
:return: CosimExecution object
261
261
"""
262
262
osp_execution_create = wrap_function (
263
- lib = CosimLibrary . lib ,
263
+ lib = libcosimc () ,
264
264
funcname = "cosim_osp_config_execution_create" ,
265
265
argtypes = [c_char_p , c_bool , c_int64 ],
266
266
restype = POINTER (CosimExecution ),
@@ -288,7 +288,7 @@ def from_ssp_file(cls, ssp_path: str, step_size: Optional[int | float] = None):
288
288
if step_size is None :
289
289
# Create simulation without defined step size
290
290
ssp_execution_create = wrap_function (
291
- lib = CosimLibrary . lib ,
291
+ lib = libcosimc () ,
292
292
funcname = "cosim_ssp_execution_create" ,
293
293
argtypes = [c_char_p , c_bool , c_int64 ],
294
294
restype = POINTER (CosimExecution ),
@@ -309,7 +309,7 @@ def from_ssp_file(cls, ssp_path: str, step_size: Optional[int | float] = None):
309
309
310
310
# Create simulation with defined step size
311
311
ssp_fixed_step_execution_create = wrap_function (
312
- lib = CosimLibrary . lib ,
312
+ lib = libcosimc () ,
313
313
funcname = "cosim_ssp_fixed_step_execution_create" ,
314
314
argtypes = [c_char_p , c_bool , c_int64 , c_int64 ],
315
315
restype = POINTER (CosimExecution ),
@@ -327,7 +327,7 @@ def num_slaves(self):
327
327
:return: int Number of currently connected slaves
328
328
"""
329
329
execution_get_num_slaves = wrap_function (
330
- lib = CosimLibrary . lib ,
330
+ lib = libcosimc () ,
331
331
funcname = "cosim_execution_get_num_slaves" ,
332
332
argtypes = [POINTER (CosimExecution )],
333
333
restype = c_int ,
@@ -341,7 +341,7 @@ def start(self):
341
341
:return: bool Successful start of execution
342
342
"""
343
343
execution_start = wrap_function (
344
- lib = CosimLibrary . lib ,
344
+ lib = libcosimc () ,
345
345
funcname = "cosim_execution_start" ,
346
346
argtypes = [POINTER (CosimExecution )],
347
347
restype = c_int ,
@@ -468,7 +468,7 @@ def slave_infos(self):
468
468
slave_count = self .num_slaves ()
469
469
slave_infos_list = (CosimSlave .CosimSlaveInfo * slave_count )()
470
470
slave_infos = wrap_function (
471
- lib = CosimLibrary . lib ,
471
+ lib = libcosimc () ,
472
472
funcname = "cosim_execution_get_slave_infos" ,
473
473
argtypes = [
474
474
POINTER (CosimExecution ),
@@ -521,7 +521,7 @@ def slave_variables(self, slave_index: int):
521
521
slave_variables_count = self .num_slave_variables (slave_index )
522
522
slave_variables_list = (CosimSlave .CosimSlaveVariableDescription * slave_variables_count )()
523
523
slave_variables = wrap_function (
524
- lib = CosimLibrary . lib ,
524
+ lib = libcosimc () ,
525
525
funcname = "cosim_slave_get_variables" ,
526
526
argtypes = [
527
527
POINTER (CosimExecution ),
@@ -675,7 +675,7 @@ def __del__(self):
675
675
# Release object in C when object is removed (if pointer exists)
676
676
if self .__ptr is not None :
677
677
execution_destroy = wrap_function (
678
- lib = CosimLibrary . lib ,
678
+ lib = libcosimc () ,
679
679
funcname = "cosim_execution_destroy" ,
680
680
argtypes = [POINTER (CosimExecution )],
681
681
restype = c_int ,
0 commit comments