@abi-software/simulationvuer 2.0.0 → 2.0.2
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/dist/simulationvuer.js +3278 -3280
- package/dist/simulationvuer.umd.cjs +29 -29
- package/dist/style.css +1 -1
- package/package.json +1 -1
- package/src/App.vue +12 -12
- package/src/components/SimulationVuer.vue +44 -57
|
@@ -3,8 +3,8 @@
|
|
|
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">{{name}}</p>
|
|
7
|
-
<el-divider></el-divider>
|
|
6
|
+
<p class="default name" v-if="libopencor === undefined">{{name}}</p>
|
|
7
|
+
<el-divider v-if="libopencor === undefined"></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,16 +19,16 @@
|
|
|
19
19
|
/>
|
|
20
20
|
</div>
|
|
21
21
|
<div class="primary-button">
|
|
22
|
-
<el-button type="primary" size="small" @click="startSimulation()" v-if="
|
|
22
|
+
<el-button type="primary" size="small" @click="startSimulation()" v-if="libopencor === undefined">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="
|
|
28
|
+
<el-button size="small" @click="viewDataset()" v-if="libopencor === undefined">View Dataset</el-button>
|
|
29
29
|
</div>
|
|
30
30
|
<div class="secondary-button">
|
|
31
|
-
<el-button size="small" @click="viewWorkspace()" v-if="
|
|
31
|
+
<el-button size="small" @click="viewWorkspace()" v-if="libopencor !== undefined">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>
|
|
@@ -89,20 +89,12 @@ export default {
|
|
|
89
89
|
type: String,
|
|
90
90
|
},
|
|
91
91
|
/**
|
|
92
|
-
* The ID of the simulation-based dataset
|
|
92
|
+
* The ID of the simulation-based dataset, if it is a number, or the path
|
|
93
|
+
* to a PMR file, if it is a string.
|
|
93
94
|
*/
|
|
94
95
|
id: {
|
|
95
96
|
required: true,
|
|
96
97
|
},
|
|
97
|
-
/**
|
|
98
|
-
* The preferred solver to use for OpenCOR-based simulations. This property
|
|
99
|
-
* is optional and defaults to "oSPARC". The only value that is currently
|
|
100
|
-
* supported is "libOpenCOR". Any other value will default to "oSPARC".
|
|
101
|
-
*/
|
|
102
|
-
preferredSolver: {
|
|
103
|
-
type: String,
|
|
104
|
-
default: OSPARC_SOLVER,
|
|
105
|
-
},
|
|
106
98
|
},
|
|
107
99
|
data: function() {
|
|
108
100
|
// Retrieve some information about the dataset.
|
|
@@ -140,7 +132,6 @@ export default {
|
|
|
140
132
|
perfectScollbarOptions: {
|
|
141
133
|
suppressScrollX: true,
|
|
142
134
|
},
|
|
143
|
-
pmrBasedCombineArchive: false,
|
|
144
135
|
showUserMessage: false,
|
|
145
136
|
simulationResults: {},
|
|
146
137
|
simulationResultsId: {},
|
|
@@ -216,27 +207,14 @@ export default {
|
|
|
216
207
|
},
|
|
217
208
|
/**
|
|
218
209
|
* @vuese
|
|
219
|
-
* Run
|
|
210
|
+
* Run a PMR-based COMBINE archive using libOpenCOR.
|
|
220
211
|
*/
|
|
221
212
|
runSimulation() {
|
|
222
213
|
if (this.instance === undefined) {
|
|
223
|
-
const fileNameOrUrl = this.pmrBasedCombineArchive ? PMR_URL + this.id : this.simulationUiInfo.simulation.opencor.resource;
|
|
224
|
-
const document = new this.libopencor.SedDocument(toRaw(this.fileManager).file(fileNameOrUrl));
|
|
225
|
-
|
|
226
|
-
// Customise the ending point and point interval of the simulation, if
|
|
227
|
-
// needed.
|
|
228
|
-
|
|
229
|
-
if ( !this.pmrBasedCombineArchive
|
|
230
|
-
&& (this.simulationUiInfo.simulation.opencor.endingPoint !== undefined)
|
|
231
|
-
&& (this.simulationUiInfo.simulation.opencor.pointInterval !== undefined)) {
|
|
232
|
-
const simulation = document.simulations().get(0);
|
|
233
|
-
|
|
234
|
-
simulation.setOutputEndTime(this.simulationUiInfo.simulation.opencor.endingPoint);
|
|
235
|
-
simulation.setNumberOfSteps(this.simulationUiInfo.simulation.opencor.endingPoint / this.simulationUiInfo.simulation.opencor.pointInterval);
|
|
236
|
-
}
|
|
237
|
-
|
|
238
214
|
// Retrieve an instance of the model.
|
|
239
215
|
|
|
216
|
+
const document = new this.libopencor.SedDocument(toRaw(this.fileManager).file(PMR_URL + this.id));
|
|
217
|
+
|
|
240
218
|
this.instance = document.instantiate();
|
|
241
219
|
|
|
242
220
|
document.delete();
|
|
@@ -301,7 +279,7 @@ export default {
|
|
|
301
279
|
|
|
302
280
|
// Make sure that the simulation UI information is valid.
|
|
303
281
|
|
|
304
|
-
this.hasValidSimulationUiInfo = validJson(this.simulationUiInfo,
|
|
282
|
+
this.hasValidSimulationUiInfo = validJson(this.simulationUiInfo, this.libopencor === undefined);
|
|
305
283
|
|
|
306
284
|
if (!this.hasValidSimulationUiInfo) {
|
|
307
285
|
return;
|
|
@@ -310,7 +288,7 @@ export default {
|
|
|
310
288
|
// Retrieve and keep track of the solver to be used for the simulation, if
|
|
311
289
|
// needed.
|
|
312
290
|
|
|
313
|
-
if (
|
|
291
|
+
if (this.libopencor === undefined) {
|
|
314
292
|
this.simulationUiInfo.simulation.solvers.forEach((solver) => {
|
|
315
293
|
if ((solver.if === undefined) || evaluateValue(this, solver.if)) {
|
|
316
294
|
this.solver = solver;
|
|
@@ -330,14 +308,14 @@ export default {
|
|
|
330
308
|
// load libOpenCOR if we are dealing with an OpenCOR-based simulation and
|
|
331
309
|
// we want to use libOpenCOR.
|
|
332
310
|
|
|
333
|
-
if (this.
|
|
311
|
+
if (this.libopencor !== undefined) {
|
|
334
312
|
this.userMessage = "Running the model...";
|
|
335
313
|
this.showUserMessage = true;
|
|
336
314
|
|
|
337
315
|
this.$nextTick(() => {
|
|
338
316
|
this.runSimulation();
|
|
339
317
|
});
|
|
340
|
-
} else if (this.opencorBasedSimulation && (this.
|
|
318
|
+
} else if (this.opencorBasedSimulation && (this.libopencor !== undefined)) {
|
|
341
319
|
this.userMessage = "Retrieving and running the model...";
|
|
342
320
|
this.showUserMessage = true;
|
|
343
321
|
|
|
@@ -583,6 +561,16 @@ export default {
|
|
|
583
561
|
];
|
|
584
562
|
});
|
|
585
563
|
},
|
|
564
|
+
/**
|
|
565
|
+
* @vuese
|
|
566
|
+
* Show an HTTP issue using the given `xmlhttp`.
|
|
567
|
+
* @arg `xmlhttp`
|
|
568
|
+
*/
|
|
569
|
+
showHttpIssue(xmlhttp) {
|
|
570
|
+
this.isSimulationValid = false;
|
|
571
|
+
this.showUserMessage = false;
|
|
572
|
+
this.errorMessage = xmlhttp.statusText.toLowerCase() + " (<a href='https://httpstatuses.com/" + xmlhttp.status + "/' target='_blank'>" + xmlhttp.status + "</a>)";
|
|
573
|
+
},
|
|
586
574
|
/**
|
|
587
575
|
* @vuese
|
|
588
576
|
* Check the progress of the simulation using the given `data`, a JSON object that contains the simulation job ID,
|
|
@@ -626,9 +614,7 @@ export default {
|
|
|
626
614
|
this.errorMessage = response.description;
|
|
627
615
|
}
|
|
628
616
|
} else {
|
|
629
|
-
this.
|
|
630
|
-
this.showUserMessage = false;
|
|
631
|
-
this.errorMessage = xmlhttp.statusText.toLowerCase() + " (<a href='https://httpstatuses.com/" + xmlhttp.status + "/' target='_blank'>" + xmlhttp.status + "</a>)";
|
|
617
|
+
this.showHttpIssue(xmlhttp);
|
|
632
618
|
}
|
|
633
619
|
}
|
|
634
620
|
};
|
|
@@ -664,12 +650,10 @@ export default {
|
|
|
664
650
|
this.checkSimulation(response.data);
|
|
665
651
|
} else {
|
|
666
652
|
this.showUserMessage = false;
|
|
667
|
-
this.errorMessage = response.description;
|
|
653
|
+
this.errorMessage = response.description + "ASDASDASD";
|
|
668
654
|
}
|
|
669
655
|
} else {
|
|
670
|
-
this.
|
|
671
|
-
this.showUserMessage = false;
|
|
672
|
-
this.errorMessage = xmlhttp.statusText.toLowerCase() + " (<a href='https://httpstatuses.com/" + xmlhttp.status + "/' target='_blank'>" + xmlhttp.status + "</a>)";
|
|
656
|
+
this.showHttpIssue(xmlhttp);
|
|
673
657
|
}
|
|
674
658
|
}
|
|
675
659
|
};
|
|
@@ -704,7 +688,7 @@ export default {
|
|
|
704
688
|
xmlhttp.send();
|
|
705
689
|
});
|
|
706
690
|
} else if (this.id !== 0) {
|
|
707
|
-
this.userMessage = "Retrieving
|
|
691
|
+
this.userMessage = "Retrieving COMBINE archive from PMR...";
|
|
708
692
|
this.showUserMessage = true;
|
|
709
693
|
|
|
710
694
|
// Retrieve the OMEX file, extract the simulation UI JSON file from it and
|
|
@@ -716,24 +700,27 @@ export default {
|
|
|
716
700
|
xmlhttp.open("POST", this.apiLocation + "/pmr_file");
|
|
717
701
|
xmlhttp.setRequestHeader("Content-type", "application/json");
|
|
718
702
|
xmlhttp.onreadystatechange = () => {
|
|
719
|
-
if (
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
703
|
+
if (xmlhttp.readyState === 4) {
|
|
704
|
+
if (xmlhttp.status === 200) {
|
|
705
|
+
libOpenCOR().then((libopencor) => {
|
|
706
|
+
this.libopencor = libopencor;
|
|
707
|
+
this.fileManager = this.libopencor.FileManager.instance();
|
|
724
708
|
|
|
725
|
-
|
|
726
|
-
|
|
709
|
+
const fileContents = Uint8Array.from(atob(xmlhttp.response), (c) => c.charCodeAt(0));
|
|
710
|
+
const file = this.manageFile(PMR_URL + this.id, fileContents);
|
|
727
711
|
|
|
728
|
-
|
|
729
|
-
|
|
712
|
+
const decoder = new TextDecoder();
|
|
713
|
+
const simulationUiInfo = JSON.parse(decoder.decode(file.childFile("simulation.json").contents()));
|
|
730
714
|
|
|
731
|
-
|
|
715
|
+
this.showUserMessage = false;
|
|
732
716
|
|
|
733
|
-
|
|
734
|
-
|
|
717
|
+
this.$nextTick(() => {
|
|
718
|
+
this.buildSimulationUi(simulationUiInfo);
|
|
719
|
+
});
|
|
735
720
|
});
|
|
736
|
-
}
|
|
721
|
+
} else {
|
|
722
|
+
this.showUserMessage = false;
|
|
723
|
+
}
|
|
737
724
|
}
|
|
738
725
|
};
|
|
739
726
|
xmlhttp.send(JSON.stringify({path: this.id}));
|