33 <p v-if =" !hasValidSimulationUiInfo && !showUserMessage" class =" default error" ><span class =" error" >Error:</span > an unknown or invalid model was provided.</p >
44 <div class =" main" v-if =" hasValidSimulationUiInfo" >
55 <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 >
88 <p class =" default input-parameters" >Input parameters</p >
99 <div class =" input scrollbar" >
1010 <SimulationVuerInput v-for =" (input, index) in simulationUiInfo.input"
1919 />
2020 </div >
2121 <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 >
2323 </div >
2424 <div class =" secondary-button" v-if =" uuid" >
2525 <el-button size =" small" @click =" runOnOsparc()" >Run on oSPARC</el-button >
2626 </div >
2727 <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 >
2929 </div >
3030 <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 >
3232 </div >
3333 <p class =" default note" v-if =" uuid" >Additional parameters are available on oSPARC</p >
3434 </div >
@@ -57,7 +57,7 @@ import { ElButton, ElDivider, ElLoading } from "element-plus";
5757import { evaluateValue , finaliseUi , OPENCOR_SOLVER_NAME } from " ./common.js" ;
5858import { validJson } from " ./json.js" ;
5959import libOpenCOR from " ./libopencor.js" ;
60- import { toRaw } from " vue" ;
60+ import { markRaw } from " vue" ;
6161import { create , all } from " mathjs" ;
6262
6363const LIBOPENCOR_SOLVER = " libOpenCOR" ;
@@ -126,6 +126,7 @@ export default {
126126 isSimulationValid: true ,
127127 layout: [],
128128 libopencor: undefined ,
129+ libopencorSet: false ,
129130 name: null ,
130131 opencorBasedSimulation: true ,
131132 output: undefined ,
@@ -188,7 +189,7 @@ export default {
188189 * @arg `fileContents`
189190 */
190191 manageFile (url , fileContents ) {
191- let file = toRaw ( this .fileManager ) .file (url);
192+ let file = this .fileManager .file (url);
192193
193194 if (file === null ) {
194195 file = new this.libopencor.File (url);
@@ -213,29 +214,27 @@ export default {
213214 if (this .instance === undefined ) {
214215 // Retrieve an instance of the model.
215216
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 ));
217218
218- this .instance = document .instantiate ();
219+ this .instance = markRaw ( document .instantiate () );
219220
220221 document .delete ();
221222 }
222223
223224 // Run the simulation after passing some initial conditions to it, if any.
224225
225- const instance = toRaw (this .instance );
226-
227- instance .removeAllInitialConditions ();
226+ this .instance .removeAllInitialConditions ();
228227
229228 for (const [parameter , value ] of Object .entries (this .parametersData ())) {
230- instance .addInitialCondition (parameter, value);
229+ this . instance .addInitialCondition (parameter, value);
231230 }
232231
233- instance .run ();
232+ this . instance .run ();
234233
235234 // Retrieve the simulation results.
236235
237236 const res = {};
238- const instanceTask = instance .tasks ().get (0 );
237+ const instanceTask = this . instance .tasks ().get (0 );
239238
240239 for (const output of this .outputData ()) {
241240 if (output === instanceTask .voiName ()) {
@@ -663,8 +662,9 @@ export default {
663662 if (xmlhttp .readyState === 4 ) {
664663 if (xmlhttp .status === 200 ) {
665664 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 ());
668668
669669 const fileContents = Uint8Array .from (atob (xmlhttp .response ), (c ) => c .charCodeAt (0 ));
670670 const file = this .manageFile (PMR_URL + this .id , fileContents);
0 commit comments