diff --git a/package-lock.json b/package-lock.json index 0847f8c..62a1e22 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@abi-software/simulationvuer", - "version": "2.0.0", + "version": "2.0.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@abi-software/simulationvuer", - "version": "2.0.0", + "version": "2.0.1", "license": "Apache-2.0", "dependencies": { "@abi-software/plotvuer": "^1.0.0", diff --git a/package.json b/package.json index 63aafca..68dd0cb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@abi-software/simulationvuer", - "version": "2.0.0", + "version": "2.0.1", "private": false, "scripts": { "serve": "vite serve --host", diff --git a/src/App.vue b/src/App.vue index 7c00cc9..eb402e9 100644 --- a/src/App.vue +++ b/src/App.vue @@ -13,10 +13,10 @@ Dataset {{ dataset.id }}: {{ dataset.description }} - ISAN: {{ dataset.description }} {{ typeof dataset.id }} + ISAN: {{ dataset.description }}
- +
@@ -38,16 +38,16 @@ export default { return { apiLocation: import.meta.env.VITE_API_LOCATION, datasets: [ - { id: 0, label: "0", description: "Non-simulation dataset", preferredSolver: SimulationVuer.OSPARC_SOLVER }, - { id: 135, label: "135", description: "Computational analysis of the human sinus node action potential - Model development and effects of mutations", preferredSolver: SimulationVuer.OSPARC_SOLVER }, - { id: 157, label: "157", description: "Fabbri-based composite SAN model", preferredSolver: SimulationVuer.OSPARC_SOLVER }, - { id: 308, label: "308", description: "Kember Cardiac Nerve Model", preferredSolver: SimulationVuer.OSPARC_SOLVER }, - { id: 318, label: "318", description: "Multi-scale rabbit cardiac electrophysiology models", preferredSolver: SimulationVuer.OSPARC_SOLVER }, - { id: 320, label: "320", description: "Multi-scale human cardiac electrophysiology models", preferredSolver: SimulationVuer.OSPARC_SOLVER }, - { id: "workspace/b7c/rawfile/00e2d3c7774bb66400b5c925e43181d775695417/135.omex", label: "ISAN-135", description: "Example of a COMBINE archive with a simulation UI file", preferredSolver: SimulationVuer.LIBOPENCOR_SOLVER }, - { id: "workspace/b7c/rawfile/00e2d3c7774bb66400b5c925e43181d775695417/157.omex", label: "ISAN-157", description: "Example of a COMBINE archive with a simulation UI file", preferredSolver: SimulationVuer.LIBOPENCOR_SOLVER }, - { id: "workspace/b7c/rawfile/00e2d3c7774bb66400b5c925e43181d775695417/lorenz.omex", label: "ISAN-Lorenz", description: "Example of a COMBINE archive with a simulation UI file", preferredSolver: SimulationVuer.LIBOPENCOR_SOLVER }, - { id: "workspace/b7c/rawfile/00e2d3c7774bb66400b5c925e43181d775695417/tt04.omex", label: "ISAN-TT04", description: "Example of a COMBINE archive with a simulation UI file", preferredSolver: SimulationVuer.LIBOPENCOR_SOLVER }, + { id: 0, label: "0", description: "Non-simulation dataset" }, + { id: 135, label: "135", description: "Computational analysis of the human sinus node action potential - Model development and effects of mutations" }, + { id: 157, label: "157", description: "Fabbri-based composite SAN model" }, + { id: 308, label: "308", description: "Kember Cardiac Nerve Model" }, + { id: 318, label: "318", description: "Multi-scale rabbit cardiac electrophysiology models" }, + { id: 320, label: "320", description: "Multi-scale human cardiac electrophysiology models" }, + { id: "workspace/b7c/rawfile/00e2d3c7774bb66400b5c925e43181d775695417/135.omex", label: "ISAN-135", description: "COMBINE archive from PMR" }, + { id: "workspace/b7c/rawfile/00e2d3c7774bb66400b5c925e43181d775695417/157.omex", label: "ISAN-157", description: "COMBINE archive from PMR" }, + { id: "workspace/b7c/rawfile/00e2d3c7774bb66400b5c925e43181d775695417/lorenz.omex", label: "ISAN-Lorenz", description: "COMBINE archive from PMR" }, + { id: "workspace/b7c/rawfile/00e2d3c7774bb66400b5c925e43181d775695417/tt04.omex", label: "ISAN-TT04", description: "COMBINE archive from PMR" }, ], id: 0, ready: [], diff --git a/src/components/SimulationVuer.vue b/src/components/SimulationVuer.vue index dec4616..4c72e50 100644 --- a/src/components/SimulationVuer.vue +++ b/src/components/SimulationVuer.vue @@ -3,8 +3,8 @@

Error: an unknown or invalid model was provided.

-

{{name}}

- +

{{name}}

+

Input parameters

- Run Simulation + Run Simulation
Run on oSPARC
- View Dataset + View Dataset
- View Workspace + View Workspace

Additional parameters are available on oSPARC

@@ -89,20 +89,12 @@ export default { type: String, }, /** - * The ID of the simulation-based dataset. + * The ID of the simulation-based dataset, if it is a number, or the path + * to a PMR file, if it is a string. */ id: { required: true, }, - /** - * The preferred solver to use for OpenCOR-based simulations. This property - * is optional and defaults to "oSPARC". The only value that is currently - * supported is "libOpenCOR". Any other value will default to "oSPARC". - */ - preferredSolver: { - type: String, - default: OSPARC_SOLVER, - }, }, data: function() { // Retrieve some information about the dataset. @@ -140,7 +132,6 @@ export default { perfectScollbarOptions: { suppressScrollX: true, }, - pmrBasedCombineArchive: false, showUserMessage: false, simulationResults: {}, simulationResultsId: {}, @@ -216,27 +207,14 @@ export default { }, /** * @vuese - * Run the simulation using libOpenCOR. + * Run a PMR-based COMBINE archive using libOpenCOR. */ runSimulation() { if (this.instance === undefined) { - const fileNameOrUrl = this.pmrBasedCombineArchive ? PMR_URL + this.id : this.simulationUiInfo.simulation.opencor.resource; - const document = new this.libopencor.SedDocument(toRaw(this.fileManager).file(fileNameOrUrl)); - - // Customise the ending point and point interval of the simulation, if - // needed. - - if ( !this.pmrBasedCombineArchive - && (this.simulationUiInfo.simulation.opencor.endingPoint !== undefined) - && (this.simulationUiInfo.simulation.opencor.pointInterval !== undefined)) { - const simulation = document.simulations().get(0); - - simulation.setOutputEndTime(this.simulationUiInfo.simulation.opencor.endingPoint); - simulation.setNumberOfSteps(this.simulationUiInfo.simulation.opencor.endingPoint / this.simulationUiInfo.simulation.opencor.pointInterval); - } - // Retrieve an instance of the model. + const document = new this.libopencor.SedDocument(toRaw(this.fileManager).file(PMR_URL + this.id)); + this.instance = document.instantiate(); document.delete(); @@ -301,7 +279,7 @@ export default { // Make sure that the simulation UI information is valid. - this.hasValidSimulationUiInfo = validJson(this.simulationUiInfo, !this.pmrBasedCombineArchive); + this.hasValidSimulationUiInfo = validJson(this.simulationUiInfo, this.libopencor === undefined); if (!this.hasValidSimulationUiInfo) { return; @@ -310,7 +288,7 @@ export default { // Retrieve and keep track of the solver to be used for the simulation, if // needed. - if (!this.pmrBasedCombineArchive) { + if (this.libopencor === undefined) { this.simulationUiInfo.simulation.solvers.forEach((solver) => { if ((solver.if === undefined) || evaluateValue(this, solver.if)) { this.solver = solver; @@ -330,14 +308,14 @@ export default { // load libOpenCOR if we are dealing with an OpenCOR-based simulation and // we want to use libOpenCOR. - if (this.pmrBasedCombineArchive) { + if (this.libopencor !== undefined) { this.userMessage = "Running the model..."; this.showUserMessage = true; this.$nextTick(() => { this.runSimulation(); }); - } else if (this.opencorBasedSimulation && (this.preferredSolver === LIBOPENCOR_SOLVER)) { + } else if (this.opencorBasedSimulation && (this.libopencor !== undefined)) { this.userMessage = "Retrieving and running the model..."; this.showUserMessage = true; @@ -583,6 +561,16 @@ export default { ]; }); }, + /** + * @vuese + * Show an HTTP issue using the given `xmlhttp`. + * @arg `xmlhttp` + */ + showHttpIssue(xmlhttp) { + this.isSimulationValid = false; + this.showUserMessage = false; + this.errorMessage = xmlhttp.statusText.toLowerCase() + " (" + xmlhttp.status + ")"; + }, /** * @vuese * Check the progress of the simulation using the given `data`, a JSON object that contains the simulation job ID, @@ -623,12 +611,10 @@ export default { } } else { this.showUserMessage = false; - this.errorMessage = response.description; + this.errorMessage = response.description + "QWEQWEQWE"; } } else { - this.isSimulationValid = false; - this.showUserMessage = false; - this.errorMessage = xmlhttp.statusText.toLowerCase() + " (" + xmlhttp.status + ")"; + this.showHttpIssue(xmlhttp); } } }; @@ -664,12 +650,10 @@ export default { this.checkSimulation(response.data); } else { this.showUserMessage = false; - this.errorMessage = response.description; + this.errorMessage = response.description + "ASDASDASD"; } } else { - this.isSimulationValid = false; - this.showUserMessage = false; - this.errorMessage = xmlhttp.statusText.toLowerCase() + " (" + xmlhttp.status + ")"; + this.showHttpIssue(xmlhttp); } } }; @@ -704,7 +688,7 @@ export default { xmlhttp.send(); }); } else if (this.id !== 0) { - this.userMessage = "Retrieving OMEX file..."; + this.userMessage = "Retrieving COMBINE archive from PMR..."; this.showUserMessage = true; // Retrieve the OMEX file, extract the simulation UI JSON file from it and @@ -716,24 +700,27 @@ export default { xmlhttp.open("POST", this.apiLocation + "/pmr_file"); xmlhttp.setRequestHeader("Content-type", "application/json"); xmlhttp.onreadystatechange = () => { - if ((xmlhttp.readyState === 4) && (xmlhttp.status === 200)) { - libOpenCOR().then((libopencor) => { - this.pmrBasedCombineArchive = true; - this.libopencor = libopencor; - this.fileManager = this.libopencor.FileManager.instance(); + if (xmlhttp.readyState === 4) { + if (xmlhttp.status === 200) { + libOpenCOR().then((libopencor) => { + this.libopencor = libopencor; + this.fileManager = this.libopencor.FileManager.instance(); - const fileContents = Uint8Array.from(atob(xmlhttp.response), (c) => c.charCodeAt(0)); - const file = this.manageFile(PMR_URL + this.id, fileContents); + const fileContents = Uint8Array.from(atob(xmlhttp.response), (c) => c.charCodeAt(0)); + const file = this.manageFile(PMR_URL + this.id, fileContents); - const decoder = new TextDecoder(); - const simulationUiInfo = JSON.parse(decoder.decode(file.childFile("simulation.json").contents())); + const decoder = new TextDecoder(); + const simulationUiInfo = JSON.parse(decoder.decode(file.childFile("simulation.json").contents())); - this.showUserMessage = false; + this.showUserMessage = false; - this.$nextTick(() => { - this.buildSimulationUi(simulationUiInfo); + this.$nextTick(() => { + this.buildSimulationUi(simulationUiInfo); + }); }); - }); + } else { + this.showUserMessage = false; + } } }; xmlhttp.send(JSON.stringify({path: this.id}));