3
3
<p v-if =" !hasValidSimulationUiInfo && !showUserMessage" class =" default error" ><span class =" error" >Error:</span > an unknown or invalid model was provided.</p >
4
4
<div class =" main" v-if =" hasValidSimulationUiInfo" >
5
5
<div class =" main-left" >
6
- <p class =" default name" v-if =" libopencor === undefined " >{{name}}</p >
7
- <el-divider v-if =" libopencor === undefined " ></el-divider >
6
+ <p class =" default name" v-if =" !libopencorSet " >{{name}}</p >
7
+ <el-divider v-if =" !libopencorSet " ></el-divider >
8
8
<p class =" default input-parameters" >Input parameters</p >
9
9
<div class =" input scrollbar" >
10
10
<SimulationVuerInput v-for =" (input, index) in simulationUiInfo.input"
19
19
/>
20
20
</div >
21
21
<div class =" primary-button" >
22
- <el-button type =" primary" size =" small" @click =" startSimulation()" v-if =" libopencor === undefined " >Run Simulation</el-button >
22
+ <el-button type =" primary" size =" small" @click =" startSimulation()" v-if =" !libopencorSet " >Run Simulation</el-button >
23
23
</div >
24
24
<div class =" secondary-button" v-if =" uuid" >
25
25
<el-button size =" small" @click =" runOnOsparc()" >Run on oSPARC</el-button >
26
26
</div >
27
27
<div class =" secondary-button" >
28
- <el-button size =" small" @click =" viewDataset()" v-if =" libopencor === undefined " >View Dataset</el-button >
28
+ <el-button size =" small" @click =" viewDataset()" v-if =" !libopencorSet " >View Dataset</el-button >
29
29
</div >
30
30
<div class =" secondary-button" >
31
- <el-button size =" small" @click =" viewWorkspace()" v-if =" libopencor !== undefined " >View Workspace</el-button >
31
+ <el-button size =" small" @click =" viewWorkspace()" v-if =" libopencorSet " >View Workspace</el-button >
32
32
</div >
33
33
<p class =" default note" v-if =" uuid" >Additional parameters are available on oSPARC</p >
34
34
</div >
@@ -57,7 +57,7 @@ import { ElButton, ElDivider, ElLoading } from "element-plus";
57
57
import { evaluateValue , finaliseUi , OPENCOR_SOLVER_NAME } from " ./common.js" ;
58
58
import { validJson } from " ./json.js" ;
59
59
import libOpenCOR from " ./libopencor.js" ;
60
- import { toRaw } from " vue" ;
60
+ import { markRaw } from " vue" ;
61
61
import { create , all } from " mathjs" ;
62
62
63
63
const LIBOPENCOR_SOLVER = " libOpenCOR" ;
@@ -126,6 +126,7 @@ export default {
126
126
isSimulationValid: true ,
127
127
layout: [],
128
128
libopencor: undefined ,
129
+ libopencorSet: false ,
129
130
name: null ,
130
131
opencorBasedSimulation: true ,
131
132
output: undefined ,
@@ -188,7 +189,7 @@ export default {
188
189
* @arg `fileContents`
189
190
*/
190
191
manageFile (url , fileContents ) {
191
- let file = toRaw ( this .fileManager ) .file (url);
192
+ let file = this .fileManager .file (url);
192
193
193
194
if (file === null ) {
194
195
file = new this.libopencor.File (url);
@@ -213,29 +214,27 @@ export default {
213
214
if (this .instance === undefined ) {
214
215
// Retrieve an instance of the model.
215
216
216
- const document = new this.libopencor.SedDocument (toRaw ( this .fileManager ) .file (PMR_URL + this .id ));
217
+ const document = new this.libopencor.SedDocument (this .fileManager .file (PMR_URL + this .id ));
217
218
218
- this .instance = document .instantiate ();
219
+ this .instance = markRaw ( document .instantiate () );
219
220
220
221
document .delete ();
221
222
}
222
223
223
224
// Run the simulation after passing some initial conditions to it, if any.
224
225
225
- const instance = toRaw (this .instance );
226
-
227
- instance .removeAllInitialConditions ();
226
+ this .instance .removeAllInitialConditions ();
228
227
229
228
for (const [parameter , value ] of Object .entries (this .parametersData ())) {
230
- instance .addInitialCondition (parameter, value);
229
+ this . instance .addInitialCondition (parameter, value);
231
230
}
232
231
233
- instance .run ();
232
+ this . instance .run ();
234
233
235
234
// Retrieve the simulation results.
236
235
237
236
const res = {};
238
- const instanceTask = instance .tasks ().get (0 );
237
+ const instanceTask = this . instance .tasks ().get (0 );
239
238
240
239
for (const output of this .outputData ()) {
241
240
if (output === instanceTask .voiName ()) {
@@ -663,8 +662,9 @@ export default {
663
662
if (xmlhttp .readyState === 4 ) {
664
663
if (xmlhttp .status === 200 ) {
665
664
libOpenCOR ().then ((libopencor ) => {
666
- this .libopencor = libopencor;
667
- this .fileManager = this .libopencor .FileManager .instance ();
665
+ this .libopencor = markRaw (libopencor);
666
+ this .libopencorSet = true ;
667
+ this .fileManager = markRaw (this .libopencor .FileManager .instance ());
668
668
669
669
const fileContents = Uint8Array .from (atob (xmlhttp .response ), (c ) => c .charCodeAt (0 ));
670
670
const file = this .manageFile (PMR_URL + this .id , fileContents);
0 commit comments