@cognipilot/rumoca 0.9.4 → 0.9.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/modelica_language.js +88 -0
- package/package.json +7 -1
- package/parse_worker.js +1 -2
- package/rumoca_bind_wasm.d.ts +188 -12
- package/rumoca_bind_wasm.js +825 -94
- package/rumoca_bind_wasm_bg.wasm +0 -0
- package/rumoca_bind_wasm_diffsol_bg.wasm +0 -0
- package/rumoca_diffsol.js +2 -2
- package/rumoca_gpu.js +139 -79
- package/rumoca_interactive.js +1098 -0
- package/rumoca_package_meta.json +1 -1
- package/rumoca_runtime.js +164 -0
- package/rumoca_worker.js +307 -87
package/rumoca_bind_wasm.js
CHANGED
|
@@ -1,5 +1,146 @@
|
|
|
1
1
|
/* @ts-self-types="./rumoca_bind_wasm.d.ts" */
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Opaque handle to a real-time simulation stepper running in WASM.
|
|
5
|
+
*
|
|
6
|
+
* Compiles a Modelica model and creates an interactive stepper that can be
|
|
7
|
+
* driven from JavaScript via `requestAnimationFrame`.
|
|
8
|
+
*/
|
|
9
|
+
export class WasmStepper {
|
|
10
|
+
__destroy_into_raw() {
|
|
11
|
+
const ptr = this.__wbg_ptr;
|
|
12
|
+
this.__wbg_ptr = 0;
|
|
13
|
+
WasmStepperFinalization.unregister(this);
|
|
14
|
+
return ptr;
|
|
15
|
+
}
|
|
16
|
+
free() {
|
|
17
|
+
const ptr = this.__destroy_into_raw();
|
|
18
|
+
wasm.__wbg_wasmstepper_free(ptr, 0);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Read a single variable value by name.
|
|
22
|
+
* @param {string} name
|
|
23
|
+
* @returns {number | undefined}
|
|
24
|
+
*/
|
|
25
|
+
get(name) {
|
|
26
|
+
const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
27
|
+
const len0 = WASM_VECTOR_LEN;
|
|
28
|
+
const ret = wasm.wasmstepper_get(this.__wbg_ptr, ptr0, len0);
|
|
29
|
+
return ret[0] === 0 ? undefined : ret[1];
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Get available input names as a JSON array string.
|
|
33
|
+
* @returns {string}
|
|
34
|
+
*/
|
|
35
|
+
input_names() {
|
|
36
|
+
let deferred1_0;
|
|
37
|
+
let deferred1_1;
|
|
38
|
+
try {
|
|
39
|
+
const ret = wasm.wasmstepper_input_names(this.__wbg_ptr);
|
|
40
|
+
deferred1_0 = ret[0];
|
|
41
|
+
deferred1_1 = ret[1];
|
|
42
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
43
|
+
} finally {
|
|
44
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Compile a Modelica model and create a stepper ready for interactive stepping.
|
|
49
|
+
*
|
|
50
|
+
* `source` is the full Modelica source text and `model_name` is the class
|
|
51
|
+
* to simulate. The stepper backend is chosen by the compiled package and
|
|
52
|
+
* model experiment metadata, not by the batch simulation solver selector.
|
|
53
|
+
* @param {string} source
|
|
54
|
+
* @param {string} model_name
|
|
55
|
+
*/
|
|
56
|
+
constructor(source, model_name) {
|
|
57
|
+
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
58
|
+
const len0 = WASM_VECTOR_LEN;
|
|
59
|
+
const ptr1 = passStringToWasm0(model_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
60
|
+
const len1 = WASM_VECTOR_LEN;
|
|
61
|
+
const ret = wasm.wasmstepper_new(ptr0, len0, ptr1, len1);
|
|
62
|
+
if (ret[2]) {
|
|
63
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
64
|
+
}
|
|
65
|
+
this.__wbg_ptr = ret[0] >>> 0;
|
|
66
|
+
WasmStepperFinalization.register(this, this.__wbg_ptr, this);
|
|
67
|
+
return this;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Reset the simulation to initial conditions.
|
|
71
|
+
*/
|
|
72
|
+
reset() {
|
|
73
|
+
const ret = wasm.wasmstepper_reset(this.__wbg_ptr);
|
|
74
|
+
if (ret[1]) {
|
|
75
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Set an input value by name. Takes effect on the next `step()` call.
|
|
80
|
+
* @param {string} name
|
|
81
|
+
* @param {number} value
|
|
82
|
+
*/
|
|
83
|
+
set_input(name, value) {
|
|
84
|
+
const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
85
|
+
const len0 = WASM_VECTOR_LEN;
|
|
86
|
+
const ret = wasm.wasmstepper_set_input(this.__wbg_ptr, ptr0, len0, value);
|
|
87
|
+
if (ret[1]) {
|
|
88
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Get all current variable values as a JSON string `{"time": t, "values": {...}}`.
|
|
93
|
+
* @returns {string}
|
|
94
|
+
*/
|
|
95
|
+
state_json() {
|
|
96
|
+
let deferred1_0;
|
|
97
|
+
let deferred1_1;
|
|
98
|
+
try {
|
|
99
|
+
const ret = wasm.wasmstepper_state_json(this.__wbg_ptr);
|
|
100
|
+
deferred1_0 = ret[0];
|
|
101
|
+
deferred1_1 = ret[1];
|
|
102
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
103
|
+
} finally {
|
|
104
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Step the simulation forward by `dt` seconds.
|
|
109
|
+
* @param {number} dt
|
|
110
|
+
*/
|
|
111
|
+
step(dt) {
|
|
112
|
+
const ret = wasm.wasmstepper_step(this.__wbg_ptr, dt);
|
|
113
|
+
if (ret[1]) {
|
|
114
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Get the current simulation time.
|
|
119
|
+
* @returns {number}
|
|
120
|
+
*/
|
|
121
|
+
time() {
|
|
122
|
+
const ret = wasm.wasmstepper_time(this.__wbg_ptr);
|
|
123
|
+
return ret;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Get all solver variable names as a JSON array string.
|
|
127
|
+
* @returns {string}
|
|
128
|
+
*/
|
|
129
|
+
variable_names() {
|
|
130
|
+
let deferred1_0;
|
|
131
|
+
let deferred1_1;
|
|
132
|
+
try {
|
|
133
|
+
const ret = wasm.wasmstepper_variable_names(this.__wbg_ptr);
|
|
134
|
+
deferred1_0 = ret[0];
|
|
135
|
+
deferred1_1 = ret[1];
|
|
136
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
137
|
+
} finally {
|
|
138
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
if (Symbol.dispose) WasmStepper.prototype[Symbol.dispose] = WasmStepper.prototype.free;
|
|
143
|
+
|
|
3
144
|
/**
|
|
4
145
|
* Check Modelica source code and return all diagnostics.
|
|
5
146
|
* @param {string} source
|
|
@@ -143,37 +284,6 @@ export function compile_to_json(source, model_name) {
|
|
|
143
284
|
}
|
|
144
285
|
}
|
|
145
286
|
|
|
146
|
-
/**
|
|
147
|
-
* @param {string} source
|
|
148
|
-
* @param {string} model_name
|
|
149
|
-
* @param {string} project_sources_json
|
|
150
|
-
* @returns {string}
|
|
151
|
-
*/
|
|
152
|
-
export function compile_with_project_sources(source, model_name, project_sources_json) {
|
|
153
|
-
let deferred5_0;
|
|
154
|
-
let deferred5_1;
|
|
155
|
-
try {
|
|
156
|
-
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
157
|
-
const len0 = WASM_VECTOR_LEN;
|
|
158
|
-
const ptr1 = passStringToWasm0(model_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
159
|
-
const len1 = WASM_VECTOR_LEN;
|
|
160
|
-
const ptr2 = passStringToWasm0(project_sources_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
161
|
-
const len2 = WASM_VECTOR_LEN;
|
|
162
|
-
const ret = wasm.compile_with_project_sources(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
163
|
-
var ptr4 = ret[0];
|
|
164
|
-
var len4 = ret[1];
|
|
165
|
-
if (ret[3]) {
|
|
166
|
-
ptr4 = 0; len4 = 0;
|
|
167
|
-
throw takeFromExternrefTable0(ret[2]);
|
|
168
|
-
}
|
|
169
|
-
deferred5_0 = ptr4;
|
|
170
|
-
deferred5_1 = len4;
|
|
171
|
-
return getStringFromWasm0(ptr4, len4);
|
|
172
|
-
} finally {
|
|
173
|
-
wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
|
|
177
287
|
/**
|
|
178
288
|
* @param {string} source
|
|
179
289
|
* @param {string} model_name
|
|
@@ -245,6 +355,37 @@ export function compile_with_source_roots_with_options(source, model_name, sourc
|
|
|
245
355
|
}
|
|
246
356
|
}
|
|
247
357
|
|
|
358
|
+
/**
|
|
359
|
+
* @param {string} source
|
|
360
|
+
* @param {string} model_name
|
|
361
|
+
* @param {string} workspace_sources_json
|
|
362
|
+
* @returns {string}
|
|
363
|
+
*/
|
|
364
|
+
export function compile_with_workspace_sources(source, model_name, workspace_sources_json) {
|
|
365
|
+
let deferred5_0;
|
|
366
|
+
let deferred5_1;
|
|
367
|
+
try {
|
|
368
|
+
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
369
|
+
const len0 = WASM_VECTOR_LEN;
|
|
370
|
+
const ptr1 = passStringToWasm0(model_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
371
|
+
const len1 = WASM_VECTOR_LEN;
|
|
372
|
+
const ptr2 = passStringToWasm0(workspace_sources_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
373
|
+
const len2 = WASM_VECTOR_LEN;
|
|
374
|
+
const ret = wasm.compile_with_workspace_sources(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
375
|
+
var ptr4 = ret[0];
|
|
376
|
+
var len4 = ret[1];
|
|
377
|
+
if (ret[3]) {
|
|
378
|
+
ptr4 = 0; len4 = 0;
|
|
379
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
380
|
+
}
|
|
381
|
+
deferred5_0 = ptr4;
|
|
382
|
+
deferred5_1 = len4;
|
|
383
|
+
return getStringFromWasm0(ptr4, len4);
|
|
384
|
+
} finally {
|
|
385
|
+
wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
|
|
248
389
|
/**
|
|
249
390
|
* @param {string} uris_json
|
|
250
391
|
* @returns {Uint8Array}
|
|
@@ -511,28 +652,31 @@ export function load_source_roots(source_roots_json) {
|
|
|
511
652
|
* @param {string} model_name
|
|
512
653
|
* @param {number} t_end
|
|
513
654
|
* @param {number} dt
|
|
655
|
+
* @param {string} parameter_overrides_json
|
|
514
656
|
* @returns {string}
|
|
515
657
|
*/
|
|
516
|
-
export function lower_model_to_solve_json(source, model_name, t_end, dt) {
|
|
517
|
-
let
|
|
518
|
-
let
|
|
658
|
+
export function lower_model_to_solve_json(source, model_name, t_end, dt, parameter_overrides_json) {
|
|
659
|
+
let deferred5_0;
|
|
660
|
+
let deferred5_1;
|
|
519
661
|
try {
|
|
520
662
|
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
521
663
|
const len0 = WASM_VECTOR_LEN;
|
|
522
664
|
const ptr1 = passStringToWasm0(model_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
523
665
|
const len1 = WASM_VECTOR_LEN;
|
|
524
|
-
const
|
|
525
|
-
|
|
526
|
-
|
|
666
|
+
const ptr2 = passStringToWasm0(parameter_overrides_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
667
|
+
const len2 = WASM_VECTOR_LEN;
|
|
668
|
+
const ret = wasm.lower_model_to_solve_json(ptr0, len0, ptr1, len1, t_end, dt, ptr2, len2);
|
|
669
|
+
var ptr4 = ret[0];
|
|
670
|
+
var len4 = ret[1];
|
|
527
671
|
if (ret[3]) {
|
|
528
|
-
|
|
672
|
+
ptr4 = 0; len4 = 0;
|
|
529
673
|
throw takeFromExternrefTable0(ret[2]);
|
|
530
674
|
}
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
return getStringFromWasm0(
|
|
675
|
+
deferred5_0 = ptr4;
|
|
676
|
+
deferred5_1 = len4;
|
|
677
|
+
return getStringFromWasm0(ptr4, len4);
|
|
534
678
|
} finally {
|
|
535
|
-
wasm.__wbindgen_free(
|
|
679
|
+
wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
|
|
536
680
|
}
|
|
537
681
|
}
|
|
538
682
|
|
|
@@ -810,6 +954,99 @@ export function merge_parsed_source_roots_binary(bytes) {
|
|
|
810
954
|
return ret[0] >>> 0;
|
|
811
955
|
}
|
|
812
956
|
|
|
957
|
+
/**
|
|
958
|
+
* Compile a model and return tunable scalar parameter metadata as JSON.
|
|
959
|
+
* @param {string} source
|
|
960
|
+
* @param {string} model_name
|
|
961
|
+
* @returns {string}
|
|
962
|
+
*/
|
|
963
|
+
export function model_parameter_metadata(source, model_name) {
|
|
964
|
+
let deferred4_0;
|
|
965
|
+
let deferred4_1;
|
|
966
|
+
try {
|
|
967
|
+
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
968
|
+
const len0 = WASM_VECTOR_LEN;
|
|
969
|
+
const ptr1 = passStringToWasm0(model_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
970
|
+
const len1 = WASM_VECTOR_LEN;
|
|
971
|
+
const ret = wasm.model_parameter_metadata(ptr0, len0, ptr1, len1);
|
|
972
|
+
var ptr3 = ret[0];
|
|
973
|
+
var len3 = ret[1];
|
|
974
|
+
if (ret[3]) {
|
|
975
|
+
ptr3 = 0; len3 = 0;
|
|
976
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
977
|
+
}
|
|
978
|
+
deferred4_0 = ptr3;
|
|
979
|
+
deferred4_1 = len3;
|
|
980
|
+
return getStringFromWasm0(ptr3, len3);
|
|
981
|
+
} finally {
|
|
982
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
983
|
+
}
|
|
984
|
+
}
|
|
985
|
+
|
|
986
|
+
/**
|
|
987
|
+
* Compile with additional source-root libraries and return parameter metadata.
|
|
988
|
+
* @param {string} source
|
|
989
|
+
* @param {string} model_name
|
|
990
|
+
* @param {string} source_roots_json
|
|
991
|
+
* @returns {string}
|
|
992
|
+
*/
|
|
993
|
+
export function model_parameter_metadata_with_source_roots(source, model_name, source_roots_json) {
|
|
994
|
+
let deferred5_0;
|
|
995
|
+
let deferred5_1;
|
|
996
|
+
try {
|
|
997
|
+
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
998
|
+
const len0 = WASM_VECTOR_LEN;
|
|
999
|
+
const ptr1 = passStringToWasm0(model_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1000
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1001
|
+
const ptr2 = passStringToWasm0(source_roots_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1002
|
+
const len2 = WASM_VECTOR_LEN;
|
|
1003
|
+
const ret = wasm.model_parameter_metadata_with_source_roots(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
1004
|
+
var ptr4 = ret[0];
|
|
1005
|
+
var len4 = ret[1];
|
|
1006
|
+
if (ret[3]) {
|
|
1007
|
+
ptr4 = 0; len4 = 0;
|
|
1008
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1009
|
+
}
|
|
1010
|
+
deferred5_0 = ptr4;
|
|
1011
|
+
deferred5_1 = len4;
|
|
1012
|
+
return getStringFromWasm0(ptr4, len4);
|
|
1013
|
+
} finally {
|
|
1014
|
+
wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
|
|
1015
|
+
}
|
|
1016
|
+
}
|
|
1017
|
+
|
|
1018
|
+
/**
|
|
1019
|
+
* Compile with additional workspace-local sources and return parameter metadata.
|
|
1020
|
+
* @param {string} source
|
|
1021
|
+
* @param {string} model_name
|
|
1022
|
+
* @param {string} workspace_sources_json
|
|
1023
|
+
* @returns {string}
|
|
1024
|
+
*/
|
|
1025
|
+
export function model_parameter_metadata_with_workspace_sources(source, model_name, workspace_sources_json) {
|
|
1026
|
+
let deferred5_0;
|
|
1027
|
+
let deferred5_1;
|
|
1028
|
+
try {
|
|
1029
|
+
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1030
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1031
|
+
const ptr1 = passStringToWasm0(model_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1032
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1033
|
+
const ptr2 = passStringToWasm0(workspace_sources_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1034
|
+
const len2 = WASM_VECTOR_LEN;
|
|
1035
|
+
const ret = wasm.model_parameter_metadata_with_workspace_sources(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
1036
|
+
var ptr4 = ret[0];
|
|
1037
|
+
var len4 = ret[1];
|
|
1038
|
+
if (ret[3]) {
|
|
1039
|
+
ptr4 = 0; len4 = 0;
|
|
1040
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1041
|
+
}
|
|
1042
|
+
deferred5_0 = ptr4;
|
|
1043
|
+
deferred5_1 = len4;
|
|
1044
|
+
return getStringFromWasm0(ptr4, len4);
|
|
1045
|
+
} finally {
|
|
1046
|
+
wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
|
|
1047
|
+
}
|
|
1048
|
+
}
|
|
1049
|
+
|
|
813
1050
|
/**
|
|
814
1051
|
* Parse Modelica source code and return whether it's valid.
|
|
815
1052
|
* @param {string} source
|
|
@@ -898,6 +1135,17 @@ export function prepare_gpu_simulation(source, model_name) {
|
|
|
898
1135
|
}
|
|
899
1136
|
}
|
|
900
1137
|
|
|
1138
|
+
/**
|
|
1139
|
+
* @returns {number}
|
|
1140
|
+
*/
|
|
1141
|
+
export function prime_source_root_completion_cache() {
|
|
1142
|
+
const ret = wasm.prime_source_root_completion_cache();
|
|
1143
|
+
if (ret[2]) {
|
|
1144
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1145
|
+
}
|
|
1146
|
+
return ret[0] >>> 0;
|
|
1147
|
+
}
|
|
1148
|
+
|
|
901
1149
|
/**
|
|
902
1150
|
* @param {string} dae_json
|
|
903
1151
|
* @param {string} model_name
|
|
@@ -925,25 +1173,24 @@ export function render_target(dae_json, model_name, target, manifest_source, tem
|
|
|
925
1173
|
}
|
|
926
1174
|
|
|
927
1175
|
/**
|
|
928
|
-
*
|
|
929
|
-
*
|
|
930
|
-
* @param {string}
|
|
931
|
-
* @param {
|
|
932
|
-
* @param {
|
|
933
|
-
* @param {string} solver
|
|
1176
|
+
* Default colocated `rumoca-scenario.<model>.toml` (`{ ok, path, content }`)
|
|
1177
|
+
* for a create-config action on a Modelica model.
|
|
1178
|
+
* @param {string} workspace_sources_json
|
|
1179
|
+
* @param {string} model
|
|
1180
|
+
* @param {string} task
|
|
934
1181
|
* @returns {string}
|
|
935
1182
|
*/
|
|
936
|
-
export function
|
|
1183
|
+
export function scenario_default_scenario_config(workspace_sources_json, model, task) {
|
|
937
1184
|
let deferred5_0;
|
|
938
1185
|
let deferred5_1;
|
|
939
1186
|
try {
|
|
940
|
-
const ptr0 = passStringToWasm0(
|
|
1187
|
+
const ptr0 = passStringToWasm0(workspace_sources_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
941
1188
|
const len0 = WASM_VECTOR_LEN;
|
|
942
|
-
const ptr1 = passStringToWasm0(
|
|
1189
|
+
const ptr1 = passStringToWasm0(model, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
943
1190
|
const len1 = WASM_VECTOR_LEN;
|
|
944
|
-
const ptr2 = passStringToWasm0(
|
|
1191
|
+
const ptr2 = passStringToWasm0(task, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
945
1192
|
const len2 = WASM_VECTOR_LEN;
|
|
946
|
-
const ret = wasm.
|
|
1193
|
+
const ret = wasm.scenario_default_scenario_config(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
947
1194
|
var ptr4 = ret[0];
|
|
948
1195
|
var len4 = ret[1];
|
|
949
1196
|
if (ret[3]) {
|
|
@@ -959,71 +1206,523 @@ export function simulate_model(source, model_name, t_end, dt, solver) {
|
|
|
959
1206
|
}
|
|
960
1207
|
|
|
961
1208
|
/**
|
|
962
|
-
*
|
|
963
|
-
* @param {string}
|
|
964
|
-
* @param {string}
|
|
965
|
-
* @param {string} project_sources_json
|
|
966
|
-
* @param {number} t_end
|
|
967
|
-
* @param {number} dt
|
|
968
|
-
* @param {string} solver
|
|
1209
|
+
* Configured `[codegen]` target settings for a model (`{ target, outputDir }`).
|
|
1210
|
+
* @param {string} workspace_sources_json
|
|
1211
|
+
* @param {string} model
|
|
969
1212
|
* @returns {string}
|
|
970
1213
|
*/
|
|
971
|
-
export function
|
|
972
|
-
let
|
|
973
|
-
let
|
|
1214
|
+
export function scenario_get_codegen_config(workspace_sources_json, model) {
|
|
1215
|
+
let deferred4_0;
|
|
1216
|
+
let deferred4_1;
|
|
974
1217
|
try {
|
|
975
|
-
const ptr0 = passStringToWasm0(
|
|
1218
|
+
const ptr0 = passStringToWasm0(workspace_sources_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
976
1219
|
const len0 = WASM_VECTOR_LEN;
|
|
977
|
-
const ptr1 = passStringToWasm0(
|
|
1220
|
+
const ptr1 = passStringToWasm0(model, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
978
1221
|
const len1 = WASM_VECTOR_LEN;
|
|
979
|
-
const
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
const len3 = WASM_VECTOR_LEN;
|
|
983
|
-
const ret = wasm.simulate_model_with_project_sources(ptr0, len0, ptr1, len1, ptr2, len2, t_end, dt, ptr3, len3);
|
|
984
|
-
var ptr5 = ret[0];
|
|
985
|
-
var len5 = ret[1];
|
|
1222
|
+
const ret = wasm.scenario_get_codegen_config(ptr0, len0, ptr1, len1);
|
|
1223
|
+
var ptr3 = ret[0];
|
|
1224
|
+
var len3 = ret[1];
|
|
986
1225
|
if (ret[3]) {
|
|
987
|
-
|
|
1226
|
+
ptr3 = 0; len3 = 0;
|
|
988
1227
|
throw takeFromExternrefTable0(ret[2]);
|
|
989
1228
|
}
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
return getStringFromWasm0(
|
|
1229
|
+
deferred4_0 = ptr3;
|
|
1230
|
+
deferred4_1 = len3;
|
|
1231
|
+
return getStringFromWasm0(ptr3, len3);
|
|
993
1232
|
} finally {
|
|
994
|
-
wasm.__wbindgen_free(
|
|
1233
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
995
1234
|
}
|
|
996
1235
|
}
|
|
997
1236
|
|
|
998
1237
|
/**
|
|
999
|
-
*
|
|
1238
|
+
* Parse a single `rumoca-scenario.toml` scenario file (by workspace path) into the editor's
|
|
1239
|
+
* scenario descriptor (`task`, `model`, `viewerMode`, interactive ports, ...).
|
|
1240
|
+
* @param {string} workspace_sources_json
|
|
1241
|
+
* @param {string} path
|
|
1000
1242
|
* @returns {string}
|
|
1001
1243
|
*/
|
|
1002
|
-
export function
|
|
1003
|
-
let
|
|
1004
|
-
let
|
|
1244
|
+
export function scenario_get_scenario_config(workspace_sources_json, path) {
|
|
1245
|
+
let deferred4_0;
|
|
1246
|
+
let deferred4_1;
|
|
1005
1247
|
try {
|
|
1006
|
-
const ptr0 = passStringToWasm0(
|
|
1248
|
+
const ptr0 = passStringToWasm0(workspace_sources_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1007
1249
|
const len0 = WASM_VECTOR_LEN;
|
|
1008
|
-
const
|
|
1009
|
-
|
|
1010
|
-
|
|
1250
|
+
const ptr1 = passStringToWasm0(path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1251
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1252
|
+
const ret = wasm.scenario_get_scenario_config(ptr0, len0, ptr1, len1);
|
|
1253
|
+
var ptr3 = ret[0];
|
|
1254
|
+
var len3 = ret[1];
|
|
1011
1255
|
if (ret[3]) {
|
|
1012
|
-
|
|
1256
|
+
ptr3 = 0; len3 = 0;
|
|
1013
1257
|
throw takeFromExternrefTable0(ret[2]);
|
|
1014
1258
|
}
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
return getStringFromWasm0(
|
|
1259
|
+
deferred4_0 = ptr3;
|
|
1260
|
+
deferred4_1 = len3;
|
|
1261
|
+
return getStringFromWasm0(ptr3, len3);
|
|
1018
1262
|
} finally {
|
|
1019
|
-
wasm.__wbindgen_free(
|
|
1263
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
1020
1264
|
}
|
|
1021
1265
|
}
|
|
1022
1266
|
|
|
1023
1267
|
/**
|
|
1024
|
-
*
|
|
1025
|
-
*
|
|
1026
|
-
*
|
|
1268
|
+
* Full `rumoca-scenario.toml` scenario as a JSON tree for the config GUI:
|
|
1269
|
+
* `{ ok, config: <toml-as-json>, descriptor }`. The `config` tree round-trips
|
|
1270
|
+
* every section (including nested interactive-IO) losslessly.
|
|
1271
|
+
* @param {string} workspace_sources_json
|
|
1272
|
+
* @param {string} path
|
|
1273
|
+
* @returns {string}
|
|
1274
|
+
*/
|
|
1275
|
+
export function scenario_get_scenario_config_full(workspace_sources_json, path) {
|
|
1276
|
+
let deferred4_0;
|
|
1277
|
+
let deferred4_1;
|
|
1278
|
+
try {
|
|
1279
|
+
const ptr0 = passStringToWasm0(workspace_sources_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1280
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1281
|
+
const ptr1 = passStringToWasm0(path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1282
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1283
|
+
const ret = wasm.scenario_get_scenario_config_full(ptr0, len0, ptr1, len1);
|
|
1284
|
+
var ptr3 = ret[0];
|
|
1285
|
+
var len3 = ret[1];
|
|
1286
|
+
if (ret[3]) {
|
|
1287
|
+
ptr3 = 0; len3 = 0;
|
|
1288
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1289
|
+
}
|
|
1290
|
+
deferred4_0 = ptr3;
|
|
1291
|
+
deferred4_1 = len3;
|
|
1292
|
+
return getStringFromWasm0(ptr3, len3);
|
|
1293
|
+
} finally {
|
|
1294
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
1295
|
+
}
|
|
1296
|
+
}
|
|
1297
|
+
|
|
1298
|
+
/**
|
|
1299
|
+
* Effective + preset + default simulation settings for a model, given the
|
|
1300
|
+
* workspace's `rumoca-scenario.toml` files and an optional editor `fallback` settings JSON.
|
|
1301
|
+
* @param {string} workspace_sources_json
|
|
1302
|
+
* @param {string} model
|
|
1303
|
+
* @param {string} fallback_json
|
|
1304
|
+
* @returns {string}
|
|
1305
|
+
*/
|
|
1306
|
+
export function scenario_get_simulation_config(workspace_sources_json, model, fallback_json) {
|
|
1307
|
+
let deferred5_0;
|
|
1308
|
+
let deferred5_1;
|
|
1309
|
+
try {
|
|
1310
|
+
const ptr0 = passStringToWasm0(workspace_sources_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1311
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1312
|
+
const ptr1 = passStringToWasm0(model, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1313
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1314
|
+
const ptr2 = passStringToWasm0(fallback_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1315
|
+
const len2 = WASM_VECTOR_LEN;
|
|
1316
|
+
const ret = wasm.scenario_get_simulation_config(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
1317
|
+
var ptr4 = ret[0];
|
|
1318
|
+
var len4 = ret[1];
|
|
1319
|
+
if (ret[3]) {
|
|
1320
|
+
ptr4 = 0; len4 = 0;
|
|
1321
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1322
|
+
}
|
|
1323
|
+
deferred5_0 = ptr4;
|
|
1324
|
+
deferred5_1 = len4;
|
|
1325
|
+
return getStringFromWasm0(ptr4, len4);
|
|
1326
|
+
} finally {
|
|
1327
|
+
wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
|
|
1328
|
+
}
|
|
1329
|
+
}
|
|
1330
|
+
|
|
1331
|
+
/**
|
|
1332
|
+
* Scenario-local source roots configured for a model (`{ sourceRootPaths }`).
|
|
1333
|
+
* @param {string} workspace_sources_json
|
|
1334
|
+
* @param {string} model
|
|
1335
|
+
* @param {string} task
|
|
1336
|
+
* @returns {string}
|
|
1337
|
+
*/
|
|
1338
|
+
export function scenario_get_source_roots(workspace_sources_json, model, task) {
|
|
1339
|
+
let deferred5_0;
|
|
1340
|
+
let deferred5_1;
|
|
1341
|
+
try {
|
|
1342
|
+
const ptr0 = passStringToWasm0(workspace_sources_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1343
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1344
|
+
const ptr1 = passStringToWasm0(model, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1345
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1346
|
+
const ptr2 = passStringToWasm0(task, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1347
|
+
const len2 = WASM_VECTOR_LEN;
|
|
1348
|
+
const ret = wasm.scenario_get_source_roots(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
1349
|
+
var ptr4 = ret[0];
|
|
1350
|
+
var len4 = ret[1];
|
|
1351
|
+
if (ret[3]) {
|
|
1352
|
+
ptr4 = 0; len4 = 0;
|
|
1353
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1354
|
+
}
|
|
1355
|
+
deferred5_0 = ptr4;
|
|
1356
|
+
deferred5_1 = len4;
|
|
1357
|
+
return getStringFromWasm0(ptr4, len4);
|
|
1358
|
+
} finally {
|
|
1359
|
+
wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
|
|
1360
|
+
}
|
|
1361
|
+
}
|
|
1362
|
+
|
|
1363
|
+
/**
|
|
1364
|
+
* Configured plot/visualization views for a model (`{ views: [...] }`).
|
|
1365
|
+
* @param {string} workspace_sources_json
|
|
1366
|
+
* @param {string} model
|
|
1367
|
+
* @returns {string}
|
|
1368
|
+
*/
|
|
1369
|
+
export function scenario_get_visualization_config(workspace_sources_json, model) {
|
|
1370
|
+
let deferred4_0;
|
|
1371
|
+
let deferred4_1;
|
|
1372
|
+
try {
|
|
1373
|
+
const ptr0 = passStringToWasm0(workspace_sources_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1374
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1375
|
+
const ptr1 = passStringToWasm0(model, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1376
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1377
|
+
const ret = wasm.scenario_get_visualization_config(ptr0, len0, ptr1, len1);
|
|
1378
|
+
var ptr3 = ret[0];
|
|
1379
|
+
var len3 = ret[1];
|
|
1380
|
+
if (ret[3]) {
|
|
1381
|
+
ptr3 = 0; len3 = 0;
|
|
1382
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1383
|
+
}
|
|
1384
|
+
deferred4_0 = ptr3;
|
|
1385
|
+
deferred4_1 = len3;
|
|
1386
|
+
return getStringFromWasm0(ptr3, len3);
|
|
1387
|
+
} finally {
|
|
1388
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
1389
|
+
}
|
|
1390
|
+
}
|
|
1391
|
+
|
|
1392
|
+
/**
|
|
1393
|
+
* Clear a model's simulation preset. Returns `{ writes, result }`.
|
|
1394
|
+
* @param {string} workspace_sources_json
|
|
1395
|
+
* @param {string} model
|
|
1396
|
+
* @returns {string}
|
|
1397
|
+
*/
|
|
1398
|
+
export function scenario_reset_simulation_preset(workspace_sources_json, model) {
|
|
1399
|
+
let deferred4_0;
|
|
1400
|
+
let deferred4_1;
|
|
1401
|
+
try {
|
|
1402
|
+
const ptr0 = passStringToWasm0(workspace_sources_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1403
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1404
|
+
const ptr1 = passStringToWasm0(model, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1405
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1406
|
+
const ret = wasm.scenario_reset_simulation_preset(ptr0, len0, ptr1, len1);
|
|
1407
|
+
var ptr3 = ret[0];
|
|
1408
|
+
var len3 = ret[1];
|
|
1409
|
+
if (ret[3]) {
|
|
1410
|
+
ptr3 = 0; len3 = 0;
|
|
1411
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1412
|
+
}
|
|
1413
|
+
deferred4_0 = ptr3;
|
|
1414
|
+
deferred4_1 = len3;
|
|
1415
|
+
return getStringFromWasm0(ptr3, len3);
|
|
1416
|
+
} finally {
|
|
1417
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
1418
|
+
}
|
|
1419
|
+
}
|
|
1420
|
+
|
|
1421
|
+
/**
|
|
1422
|
+
* Write a model's `[codegen]` target settings. Returns `{ writes, result }`.
|
|
1423
|
+
* @param {string} workspace_sources_json
|
|
1424
|
+
* @param {string} model
|
|
1425
|
+
* @param {string} codegen_json
|
|
1426
|
+
* @returns {string}
|
|
1427
|
+
*/
|
|
1428
|
+
export function scenario_set_codegen_config(workspace_sources_json, model, codegen_json) {
|
|
1429
|
+
let deferred5_0;
|
|
1430
|
+
let deferred5_1;
|
|
1431
|
+
try {
|
|
1432
|
+
const ptr0 = passStringToWasm0(workspace_sources_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1433
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1434
|
+
const ptr1 = passStringToWasm0(model, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1435
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1436
|
+
const ptr2 = passStringToWasm0(codegen_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1437
|
+
const len2 = WASM_VECTOR_LEN;
|
|
1438
|
+
const ret = wasm.scenario_set_codegen_config(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
1439
|
+
var ptr4 = ret[0];
|
|
1440
|
+
var len4 = ret[1];
|
|
1441
|
+
if (ret[3]) {
|
|
1442
|
+
ptr4 = 0; len4 = 0;
|
|
1443
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1444
|
+
}
|
|
1445
|
+
deferred5_0 = ptr4;
|
|
1446
|
+
deferred5_1 = len4;
|
|
1447
|
+
return getStringFromWasm0(ptr4, len4);
|
|
1448
|
+
} finally {
|
|
1449
|
+
wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
|
|
1450
|
+
}
|
|
1451
|
+
}
|
|
1452
|
+
|
|
1453
|
+
/**
|
|
1454
|
+
* Render a `rumoca-scenario.toml` from the config GUI's JSON tree. Returns
|
|
1455
|
+
* `{ writes: [{path, content}], result }` for the editor to apply.
|
|
1456
|
+
* @param {string} path
|
|
1457
|
+
* @param {string} config_json
|
|
1458
|
+
* @returns {string}
|
|
1459
|
+
*/
|
|
1460
|
+
export function scenario_set_scenario_config(path, config_json) {
|
|
1461
|
+
let deferred4_0;
|
|
1462
|
+
let deferred4_1;
|
|
1463
|
+
try {
|
|
1464
|
+
const ptr0 = passStringToWasm0(path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1465
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1466
|
+
const ptr1 = passStringToWasm0(config_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1467
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1468
|
+
const ret = wasm.scenario_set_scenario_config(ptr0, len0, ptr1, len1);
|
|
1469
|
+
var ptr3 = ret[0];
|
|
1470
|
+
var len3 = ret[1];
|
|
1471
|
+
if (ret[3]) {
|
|
1472
|
+
ptr3 = 0; len3 = 0;
|
|
1473
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1474
|
+
}
|
|
1475
|
+
deferred4_0 = ptr3;
|
|
1476
|
+
deferred4_1 = len3;
|
|
1477
|
+
return getStringFromWasm0(ptr3, len3);
|
|
1478
|
+
} finally {
|
|
1479
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
1480
|
+
}
|
|
1481
|
+
}
|
|
1482
|
+
|
|
1483
|
+
/**
|
|
1484
|
+
* Write a model's simulation preset into its colocated `rum.<model>.toml`.
|
|
1485
|
+
* Returns `{ writes, result }` for the editor to apply to its workspace store.
|
|
1486
|
+
* @param {string} workspace_sources_json
|
|
1487
|
+
* @param {string} model
|
|
1488
|
+
* @param {string} preset_json
|
|
1489
|
+
* @returns {string}
|
|
1490
|
+
*/
|
|
1491
|
+
export function scenario_set_simulation_preset(workspace_sources_json, model, preset_json) {
|
|
1492
|
+
let deferred5_0;
|
|
1493
|
+
let deferred5_1;
|
|
1494
|
+
try {
|
|
1495
|
+
const ptr0 = passStringToWasm0(workspace_sources_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1496
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1497
|
+
const ptr1 = passStringToWasm0(model, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1498
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1499
|
+
const ptr2 = passStringToWasm0(preset_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1500
|
+
const len2 = WASM_VECTOR_LEN;
|
|
1501
|
+
const ret = wasm.scenario_set_simulation_preset(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
1502
|
+
var ptr4 = ret[0];
|
|
1503
|
+
var len4 = ret[1];
|
|
1504
|
+
if (ret[3]) {
|
|
1505
|
+
ptr4 = 0; len4 = 0;
|
|
1506
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1507
|
+
}
|
|
1508
|
+
deferred5_0 = ptr4;
|
|
1509
|
+
deferred5_1 = len4;
|
|
1510
|
+
return getStringFromWasm0(ptr4, len4);
|
|
1511
|
+
} finally {
|
|
1512
|
+
wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
|
|
1513
|
+
}
|
|
1514
|
+
}
|
|
1515
|
+
|
|
1516
|
+
/**
|
|
1517
|
+
* Write a model's scenario-local source roots. Returns `{ writes, result }`.
|
|
1518
|
+
* @param {string} workspace_sources_json
|
|
1519
|
+
* @param {string} model
|
|
1520
|
+
* @param {string} source_roots_json
|
|
1521
|
+
* @returns {string}
|
|
1522
|
+
*/
|
|
1523
|
+
export function scenario_set_source_roots(workspace_sources_json, model, source_roots_json) {
|
|
1524
|
+
let deferred5_0;
|
|
1525
|
+
let deferred5_1;
|
|
1526
|
+
try {
|
|
1527
|
+
const ptr0 = passStringToWasm0(workspace_sources_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1528
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1529
|
+
const ptr1 = passStringToWasm0(model, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1530
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1531
|
+
const ptr2 = passStringToWasm0(source_roots_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1532
|
+
const len2 = WASM_VECTOR_LEN;
|
|
1533
|
+
const ret = wasm.scenario_set_source_roots(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
1534
|
+
var ptr4 = ret[0];
|
|
1535
|
+
var len4 = ret[1];
|
|
1536
|
+
if (ret[3]) {
|
|
1537
|
+
ptr4 = 0; len4 = 0;
|
|
1538
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1539
|
+
}
|
|
1540
|
+
deferred5_0 = ptr4;
|
|
1541
|
+
deferred5_1 = len4;
|
|
1542
|
+
return getStringFromWasm0(ptr4, len4);
|
|
1543
|
+
} finally {
|
|
1544
|
+
wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
|
|
1545
|
+
}
|
|
1546
|
+
}
|
|
1547
|
+
|
|
1548
|
+
/**
|
|
1549
|
+
* Write a model's plot/visualization views. Returns `{ writes, result }`.
|
|
1550
|
+
* @param {string} workspace_sources_json
|
|
1551
|
+
* @param {string} model
|
|
1552
|
+
* @param {string} views_json
|
|
1553
|
+
* @returns {string}
|
|
1554
|
+
*/
|
|
1555
|
+
export function scenario_set_visualization_config(workspace_sources_json, model, views_json) {
|
|
1556
|
+
let deferred5_0;
|
|
1557
|
+
let deferred5_1;
|
|
1558
|
+
try {
|
|
1559
|
+
const ptr0 = passStringToWasm0(workspace_sources_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1560
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1561
|
+
const ptr1 = passStringToWasm0(model, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1562
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1563
|
+
const ptr2 = passStringToWasm0(views_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1564
|
+
const len2 = WASM_VECTOR_LEN;
|
|
1565
|
+
const ret = wasm.scenario_set_visualization_config(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
1566
|
+
var ptr4 = ret[0];
|
|
1567
|
+
var len4 = ret[1];
|
|
1568
|
+
if (ret[3]) {
|
|
1569
|
+
ptr4 = 0; len4 = 0;
|
|
1570
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1571
|
+
}
|
|
1572
|
+
deferred5_0 = ptr4;
|
|
1573
|
+
deferred5_1 = len4;
|
|
1574
|
+
return getStringFromWasm0(ptr4, len4);
|
|
1575
|
+
} finally {
|
|
1576
|
+
wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
|
|
1577
|
+
}
|
|
1578
|
+
}
|
|
1579
|
+
|
|
1580
|
+
/**
|
|
1581
|
+
* Compile and simulate a Modelica model.
|
|
1582
|
+
* @param {string} source
|
|
1583
|
+
* @param {string} model_name
|
|
1584
|
+
* @param {number} t_end
|
|
1585
|
+
* @param {number} dt
|
|
1586
|
+
* @param {string} solver
|
|
1587
|
+
* @param {string} parameter_overrides_json
|
|
1588
|
+
* @returns {string}
|
|
1589
|
+
*/
|
|
1590
|
+
export function simulate_model(source, model_name, t_end, dt, solver, parameter_overrides_json) {
|
|
1591
|
+
let deferred6_0;
|
|
1592
|
+
let deferred6_1;
|
|
1593
|
+
try {
|
|
1594
|
+
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1595
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1596
|
+
const ptr1 = passStringToWasm0(model_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1597
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1598
|
+
const ptr2 = passStringToWasm0(solver, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1599
|
+
const len2 = WASM_VECTOR_LEN;
|
|
1600
|
+
const ptr3 = passStringToWasm0(parameter_overrides_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1601
|
+
const len3 = WASM_VECTOR_LEN;
|
|
1602
|
+
const ret = wasm.simulate_model(ptr0, len0, ptr1, len1, t_end, dt, ptr2, len2, ptr3, len3);
|
|
1603
|
+
var ptr5 = ret[0];
|
|
1604
|
+
var len5 = ret[1];
|
|
1605
|
+
if (ret[3]) {
|
|
1606
|
+
ptr5 = 0; len5 = 0;
|
|
1607
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1608
|
+
}
|
|
1609
|
+
deferred6_0 = ptr5;
|
|
1610
|
+
deferred6_1 = len5;
|
|
1611
|
+
return getStringFromWasm0(ptr5, len5);
|
|
1612
|
+
} finally {
|
|
1613
|
+
wasm.__wbindgen_free(deferred6_0, deferred6_1, 1);
|
|
1614
|
+
}
|
|
1615
|
+
}
|
|
1616
|
+
|
|
1617
|
+
/**
|
|
1618
|
+
* Compile with additional source-root libraries and simulate a Modelica model.
|
|
1619
|
+
* @param {string} source
|
|
1620
|
+
* @param {string} model_name
|
|
1621
|
+
* @param {string} source_roots_json
|
|
1622
|
+
* @param {number} t_end
|
|
1623
|
+
* @param {number} dt
|
|
1624
|
+
* @param {string} solver
|
|
1625
|
+
* @param {string} parameter_overrides_json
|
|
1626
|
+
* @returns {string}
|
|
1627
|
+
*/
|
|
1628
|
+
export function simulate_model_with_source_roots(source, model_name, source_roots_json, t_end, dt, solver, parameter_overrides_json) {
|
|
1629
|
+
let deferred7_0;
|
|
1630
|
+
let deferred7_1;
|
|
1631
|
+
try {
|
|
1632
|
+
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1633
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1634
|
+
const ptr1 = passStringToWasm0(model_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1635
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1636
|
+
const ptr2 = passStringToWasm0(source_roots_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1637
|
+
const len2 = WASM_VECTOR_LEN;
|
|
1638
|
+
const ptr3 = passStringToWasm0(solver, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1639
|
+
const len3 = WASM_VECTOR_LEN;
|
|
1640
|
+
const ptr4 = passStringToWasm0(parameter_overrides_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1641
|
+
const len4 = WASM_VECTOR_LEN;
|
|
1642
|
+
const ret = wasm.simulate_model_with_source_roots(ptr0, len0, ptr1, len1, ptr2, len2, t_end, dt, ptr3, len3, ptr4, len4);
|
|
1643
|
+
var ptr6 = ret[0];
|
|
1644
|
+
var len6 = ret[1];
|
|
1645
|
+
if (ret[3]) {
|
|
1646
|
+
ptr6 = 0; len6 = 0;
|
|
1647
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1648
|
+
}
|
|
1649
|
+
deferred7_0 = ptr6;
|
|
1650
|
+
deferred7_1 = len6;
|
|
1651
|
+
return getStringFromWasm0(ptr6, len6);
|
|
1652
|
+
} finally {
|
|
1653
|
+
wasm.__wbindgen_free(deferred7_0, deferred7_1, 1);
|
|
1654
|
+
}
|
|
1655
|
+
}
|
|
1656
|
+
|
|
1657
|
+
/**
|
|
1658
|
+
* Compile with additional workspace-local sources and simulate a Modelica model.
|
|
1659
|
+
* @param {string} source
|
|
1660
|
+
* @param {string} model_name
|
|
1661
|
+
* @param {string} workspace_sources_json
|
|
1662
|
+
* @param {number} t_end
|
|
1663
|
+
* @param {number} dt
|
|
1664
|
+
* @param {string} solver
|
|
1665
|
+
* @param {string} parameter_overrides_json
|
|
1666
|
+
* @returns {string}
|
|
1667
|
+
*/
|
|
1668
|
+
export function simulate_model_with_workspace_sources(source, model_name, workspace_sources_json, t_end, dt, solver, parameter_overrides_json) {
|
|
1669
|
+
let deferred7_0;
|
|
1670
|
+
let deferred7_1;
|
|
1671
|
+
try {
|
|
1672
|
+
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1673
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1674
|
+
const ptr1 = passStringToWasm0(model_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1675
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1676
|
+
const ptr2 = passStringToWasm0(workspace_sources_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1677
|
+
const len2 = WASM_VECTOR_LEN;
|
|
1678
|
+
const ptr3 = passStringToWasm0(solver, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1679
|
+
const len3 = WASM_VECTOR_LEN;
|
|
1680
|
+
const ptr4 = passStringToWasm0(parameter_overrides_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1681
|
+
const len4 = WASM_VECTOR_LEN;
|
|
1682
|
+
const ret = wasm.simulate_model_with_workspace_sources(ptr0, len0, ptr1, len1, ptr2, len2, t_end, dt, ptr3, len3, ptr4, len4);
|
|
1683
|
+
var ptr6 = ret[0];
|
|
1684
|
+
var len6 = ret[1];
|
|
1685
|
+
if (ret[3]) {
|
|
1686
|
+
ptr6 = 0; len6 = 0;
|
|
1687
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1688
|
+
}
|
|
1689
|
+
deferred7_0 = ptr6;
|
|
1690
|
+
deferred7_1 = len6;
|
|
1691
|
+
return getStringFromWasm0(ptr6, len6);
|
|
1692
|
+
} finally {
|
|
1693
|
+
wasm.__wbindgen_free(deferred7_0, deferred7_1, 1);
|
|
1694
|
+
}
|
|
1695
|
+
}
|
|
1696
|
+
|
|
1697
|
+
/**
|
|
1698
|
+
* @param {string} workspace_sources_json
|
|
1699
|
+
* @returns {string}
|
|
1700
|
+
*/
|
|
1701
|
+
export function sync_workspace_sources(workspace_sources_json) {
|
|
1702
|
+
let deferred3_0;
|
|
1703
|
+
let deferred3_1;
|
|
1704
|
+
try {
|
|
1705
|
+
const ptr0 = passStringToWasm0(workspace_sources_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1706
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1707
|
+
const ret = wasm.sync_workspace_sources(ptr0, len0);
|
|
1708
|
+
var ptr2 = ret[0];
|
|
1709
|
+
var len2 = ret[1];
|
|
1710
|
+
if (ret[3]) {
|
|
1711
|
+
ptr2 = 0; len2 = 0;
|
|
1712
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1713
|
+
}
|
|
1714
|
+
deferred3_0 = ptr2;
|
|
1715
|
+
deferred3_1 = len2;
|
|
1716
|
+
return getStringFromWasm0(ptr2, len2);
|
|
1717
|
+
} finally {
|
|
1718
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
1719
|
+
}
|
|
1720
|
+
}
|
|
1721
|
+
|
|
1722
|
+
/**
|
|
1723
|
+
* Re-settle the prepared vectors of the last `prepare_gpu_simulation` for
|
|
1724
|
+
* new parameter values, without re-lowering the model. `overrides_json`
|
|
1725
|
+
* is a `{ "name": value }` object naming scalar parameters. Returns
|
|
1027
1726
|
* `{ "y0": [...], "p0": [...] }`.
|
|
1028
1727
|
* @param {string} source
|
|
1029
1728
|
* @param {string} model_name
|
|
@@ -1065,6 +1764,34 @@ export function wasm_init(_num_threads) {
|
|
|
1065
1764
|
return ret !== 0;
|
|
1066
1765
|
}
|
|
1067
1766
|
|
|
1767
|
+
/**
|
|
1768
|
+
* @param {string} workspace_sources_json
|
|
1769
|
+
* @param {string} focus_path
|
|
1770
|
+
* @returns {string}
|
|
1771
|
+
*/
|
|
1772
|
+
export function workspace_effective_source_roots(workspace_sources_json, focus_path) {
|
|
1773
|
+
let deferred4_0;
|
|
1774
|
+
let deferred4_1;
|
|
1775
|
+
try {
|
|
1776
|
+
const ptr0 = passStringToWasm0(workspace_sources_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1777
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1778
|
+
const ptr1 = passStringToWasm0(focus_path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1779
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1780
|
+
const ret = wasm.workspace_effective_source_roots(ptr0, len0, ptr1, len1);
|
|
1781
|
+
var ptr3 = ret[0];
|
|
1782
|
+
var len3 = ret[1];
|
|
1783
|
+
if (ret[3]) {
|
|
1784
|
+
ptr3 = 0; len3 = 0;
|
|
1785
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1786
|
+
}
|
|
1787
|
+
deferred4_0 = ptr3;
|
|
1788
|
+
deferred4_1 = len3;
|
|
1789
|
+
return getStringFromWasm0(ptr3, len3);
|
|
1790
|
+
} finally {
|
|
1791
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
1792
|
+
}
|
|
1793
|
+
}
|
|
1794
|
+
|
|
1068
1795
|
function __wbg_get_imports() {
|
|
1069
1796
|
const import0 = {
|
|
1070
1797
|
__proto__: null,
|
|
@@ -1108,7 +1835,7 @@ function __wbg_get_imports() {
|
|
|
1108
1835
|
const ret = Reflect.get(arg0, arg1);
|
|
1109
1836
|
return ret;
|
|
1110
1837
|
}, arguments); },
|
|
1111
|
-
|
|
1838
|
+
__wbg_log_eb5eb4b225300419: function(arg0, arg1) {
|
|
1112
1839
|
console.log(getStringFromWasm0(arg0, arg1));
|
|
1113
1840
|
},
|
|
1114
1841
|
__wbg_new_361308b2356cecd0: function() {
|
|
@@ -1190,6 +1917,10 @@ function __wbg_get_imports() {
|
|
|
1190
1917
|
};
|
|
1191
1918
|
}
|
|
1192
1919
|
|
|
1920
|
+
const WasmStepperFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
1921
|
+
? { register: () => {}, unregister: () => {} }
|
|
1922
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_wasmstepper_free(ptr >>> 0, 1));
|
|
1923
|
+
|
|
1193
1924
|
function addToExternrefTable0(obj) {
|
|
1194
1925
|
const idx = wasm.__externref_table_alloc();
|
|
1195
1926
|
wasm.__wbindgen_externrefs.set(idx, obj);
|