@abi-software/simulationvuer 0.7.0-vue-3-alpha.4 → 1.0.0

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.
@@ -1,522 +1,522 @@
1
- import { Validator } from "jsonschema";
2
- import { OPENCOR_SOLVER_NAME } from "./common.js";
3
-
4
- export function validJson(json) {
5
- // Check the JSON against our schema.
6
-
7
- let validator = new Validator();
8
- let schema = {
9
- additionalProperties: false,
10
- properties: {
11
- input: {
12
- items: {
13
- oneOf: [
14
- {
15
- additionalProperties: false,
16
- properties: {
17
- defaultValue: {
18
- required: true,
19
- type: "number",
20
- },
21
- id: {
22
- type: "string",
23
- },
24
- name: {
25
- required: true,
26
- type: "string",
27
- },
28
- possibleValues: {
29
- items: {
30
- additionalProperties: false,
31
- properties: {
32
- name: {
33
- required: true,
34
- type: "string",
35
- },
36
- value: {
37
- required: true,
38
- type: "number",
39
- },
40
- },
41
- type: "object",
42
- },
43
- minItems: 1,
44
- required: true,
45
- type: "array",
46
- },
47
- visible: {
48
- type: "string",
49
- },
50
- },
51
- },
52
- {
53
- additionalProperties: false,
54
- properties: {
55
- defaultValue: {
56
- required: true,
57
- type: "number",
58
- },
59
- id: {
60
- type: "string",
61
- },
62
- maximumValue: {
63
- required: true,
64
- type: "number",
65
- },
66
- minimumValue: {
67
- required: true,
68
- type: "number",
69
- },
70
- name: {
71
- required: true,
72
- type: "string",
73
- },
74
- stepValue: {
75
- type: "number",
76
- },
77
- visible: {
78
- type: "string",
79
- },
80
- },
81
- },
82
- ],
83
- type: "object",
84
- },
85
- minItems: 1,
86
- required: true,
87
- type: "array",
88
- },
89
- output: {
90
- additionalProperties: false,
91
- minItems: 1,
92
- properties: {
93
- data: {
94
- items: {
95
- additionalProperties: false,
96
- properties: {
97
- id: {
98
- required: true,
99
- type: "string",
100
- },
101
- name: {
102
- required: true,
103
- type: "string",
104
- },
105
- },
106
- type: "object",
107
- },
108
- minItems: 1,
109
- required: true,
110
- type: "array",
111
- },
112
- plots: {
113
- items: {
114
- additionalProperties: false,
115
- properties: {
116
- xAxisTitle: {
117
- required: true,
118
- type: "string",
119
- },
120
- xValue: {
121
- required: true,
122
- type: "string",
123
- },
124
- yAxisTitle: {
125
- required: true,
126
- type: "string",
127
- },
128
- yValue: {
129
- required: true,
130
- type: "string",
131
- },
132
- },
133
- type: "object",
134
- },
135
- maxItems: 9,
136
- minItems: 1,
137
- required: true,
138
- type: "array",
139
- },
140
- },
141
- required: true,
142
- type: "object",
143
- },
144
- parameters: {
145
- items: {
146
- additionalProperties: false,
147
- properties: {
148
- name: {
149
- required: true,
150
- type: "string",
151
- },
152
- value: {
153
- required: true,
154
- type: "string",
155
- },
156
- },
157
- type: "object",
158
- },
159
- type: "array",
160
- },
161
- simulation: {
162
- additionalProperties: false,
163
- properties: {
164
- opencor: {
165
- additionalProperties: false,
166
- properties: {
167
- endingPoint: {
168
- type: "number",
169
- },
170
- pointInterval: {
171
- type: "number",
172
- },
173
- resource: {
174
- required: true,
175
- type: "string",
176
- },
177
- },
178
- type: "object",
179
- },
180
- solvers: {
181
- items: {
182
- additionalProperties: false,
183
- properties: {
184
- if: {
185
- type: "string",
186
- },
187
- input: {
188
- additionalProperties: false,
189
- properties: {
190
- name: {
191
- required: true,
192
- type: "string",
193
- },
194
- value: {
195
- required: true,
196
- type: "string",
197
- },
198
- },
199
- type: "object",
200
- },
201
- name: {
202
- required: true,
203
- type: "string",
204
- },
205
- version: {
206
- required: true,
207
- type: "string",
208
- },
209
- },
210
- type: "object",
211
- },
212
- minItems: 1,
213
- required: true,
214
- type: "array",
215
- },
216
- },
217
- required: true,
218
- type: "object",
219
- },
220
- },
221
- type: "object",
222
- };
223
-
224
- let result = validator.validate(json, schema, { nestedErrors: true });
225
-
226
- if (!result.valid) {
227
- console.warn(result.toString());
228
-
229
- return false;
230
- }
231
-
232
- // Make sure that the input information makes sense.
233
-
234
- let inputIdUsed = [];
235
- let inputValid = json.input.every((input) => {
236
- if (input.id !== undefined) {
237
- if (input.id === "") {
238
- console.warn("JSON: the input id must not be empty.");
239
-
240
- return false;
241
- }
242
-
243
- if (inputIdUsed[input.id]) {
244
- console.warn("JSON: the input id must be unique (" + input.id + " is used more than once).");
245
-
246
- return false;
247
- }
248
-
249
- inputIdUsed[input.id] = true;
250
- }
251
-
252
- if (input.name === "") {
253
- console.warn("JSON: the input name must not be empty.");
254
-
255
- return false;
256
- }
257
-
258
- if (input.possibleValues !== undefined) {
259
- if (!input.possibleValues.every((possibleValue) => {
260
- if (possibleValue.name === "") {
261
- console.warn("JSON: an input possible value must not be empty.");
262
-
263
- return false;
264
- }
265
-
266
- return true;
267
- })) {
268
- return false;
269
- }
270
-
271
- let values = input.possibleValues.map((value) => {
272
- return value.value;
273
- });
274
- let valueUsed = [];
275
-
276
- if (!values.every((value) => {
277
- if (valueUsed[value]) {
278
- console.warn("JSON: an input possible value must have a unique value (" + value + " is used more than once).");
279
-
280
- return false;
281
- }
282
-
283
- valueUsed[value] = true;
284
-
285
- return true;
286
- })) {
287
- return false;
288
- }
289
-
290
- if (!values.includes(input.defaultValue)) {
291
- console.warn("JSON: the input default value (" + input.defaultValue + ") must be one of the possible values (" + values.join(", ") + ").");
292
-
293
- return false;
294
- }
295
- }
296
-
297
- if ((input.minimumValue !== undefined) && (input.maximumValue !== undefined)) {
298
- if (input.minimumValue >= input.maximumValue) {
299
- console.warn("JSON: the input minimum value (" + input.minimumValue + ") must be lower than the maximum value (" + input.maximumValue + ").");
300
-
301
- return false;
302
- }
303
-
304
- if ((input.defaultValue < input.minimumValue) || (input.defaultValue > input.maximumValue)) {
305
- console.warn("JSON: the input default value (" + input.defaultValue + ") must be greater or equal than the minimum value (" + input.minimumValue + ") and lower or equal than the maximum value (" + input.maximumValue + ").");
306
-
307
- return false;
308
- }
309
-
310
- let range = input.maximumValue - input.minimumValue;
311
-
312
- if (input.stepValue !== undefined) {
313
- if ((input.stepValue <= 0) || (input.stepValue > range)) {
314
- console.warn("JSON: the input step value (" + input.stepValue + ") must be greater than zero and lower or equal than the range value (" + range + ").");
315
-
316
- return false;
317
- }
318
-
319
- if (!Number.isInteger(range / input.stepValue)) {
320
- console.warn("JSON: the input step value (" + input.stepValue + ") must be a factor of the range value (" + range + ").");
321
-
322
- return false;
323
- }
324
- } else {
325
- if (!Number.isInteger(range)) {
326
- console.warn("JSON: the (default) input step value (1) must be a factor of the range value (" + range + ").");
327
-
328
- return false;
329
- }
330
- }
331
- }
332
-
333
- if (input.visible !== undefined) {
334
- if (input.visible === "") {
335
- console.warn("JSON: the input visible must not be empty.");
336
-
337
- return false;
338
- }
339
- }
340
-
341
- return true;
342
- });
343
-
344
- if (!inputValid) {
345
- return false;
346
- }
347
-
348
- // Make sure that the output information makes sense.
349
-
350
- let outputIdUsed = [];
351
- let outputDataValid = json.output.data.every((outputData) => {
352
- if (outputData.id !== undefined) {
353
- if (outputData.id === "") {
354
- console.warn("JSON: the output data id must not be empty.");
355
-
356
- return false;
357
- }
358
-
359
- if (outputIdUsed[outputData.id]) {
360
- console.warn("JSON: the output data id must be unique (" + outputData.id + " is used more than once).");
361
-
362
- return false;
363
- }
364
-
365
- outputIdUsed[outputData.id] = true;
366
- }
367
-
368
- if (outputData.name === "") {
369
- console.warn("JSON: the output data name must not be empty.");
370
-
371
- return false;
372
- }
373
-
374
- return true;
375
- });
376
-
377
- if (!outputDataValid) {
378
- return false;
379
- }
380
-
381
- let outputPlotsValid = json.output.plots.every((outputPlot) => {
382
- if (outputPlot.xAxisTitle === "") {
383
- console.warn("JSON: the output plot X axis title must not be empty.");
384
-
385
- return false;
386
- }
387
-
388
- if (outputPlot.xValue === "") {
389
- console.warn("JSON: the output plot X value must not be empty.");
390
-
391
- return false;
392
- }
393
-
394
- if (outputPlot.yAxisTitle === "") {
395
- console.warn("JSON: the output plot Y axis title must not be empty.");
396
-
397
- return false;
398
- }
399
-
400
- if (outputPlot.yValue === "") {
401
- console.warn("JSON: the output plot Y value must not be empty.");
402
-
403
- return false;
404
- }
405
-
406
- return true;
407
- });
408
-
409
- if (!outputPlotsValid) {
410
- return false;
411
- }
412
-
413
- // Make sure that the parameters information makes sense.
414
-
415
- if (json.parameters !== undefined) {
416
- let parametersValid = json.parameters.every((parameter) => {
417
- if (parameter.name === "") {
418
- console.warn("JSON: the parameter name must not be empty.");
419
-
420
- return false;
421
- }
422
-
423
- if (parameter.value === "") {
424
- console.warn("JSON: the parameter value must not be empty.");
425
-
426
- return false;
427
- }
428
-
429
- return true;
430
- });
431
-
432
- if (!parametersValid) {
433
- return false;
434
- }
435
- }
436
-
437
- // Make sure that the simulation information makes sense.
438
-
439
- let needOpencorSettings = false;
440
-
441
- if (!json.simulation.solvers.every((solver) => {
442
- if (solver.if !== undefined) {
443
- if (solver.if === "") {
444
- console.warn("JSON: a simulation solver if must not be empty.");
445
-
446
- return false;
447
- }
448
- }
449
-
450
- if (solver.input !== undefined) {
451
- if (solver.input.name === "") {
452
- console.warn("JSON: a simulation solver input name must not be empty.");
453
-
454
- return false;
455
- }
456
-
457
- if (solver.input.value === "") {
458
- console.warn("JSON: a simulation solver input value must not be empty.");
459
-
460
- return false;
461
- }
462
- }
463
-
464
- if (solver.name === "") {
465
- console.warn("JSON: a simulation solver name must not be empty.");
466
-
467
- return false;
468
- }
469
-
470
- needOpencorSettings = needOpencorSettings || (solver.name === OPENCOR_SOLVER_NAME);
471
-
472
- if (solver.version === "") {
473
- console.warn("JSON: a simulation solver version must not be empty.");
474
-
475
- return false;
476
- }
477
-
478
- return true;
479
- })) {
480
- return false;
481
- }
482
-
483
- if (needOpencorSettings && (json.simulation.opencor === undefined)) {
484
- console.warn("JSON: the simulation solver for OpenCOR is specified so simulation OpenCOR settings must also be specified.");
485
-
486
- return false;
487
- }
488
-
489
- if (json.simulation.opencor !== undefined) {
490
- if (json.simulation.opencor.resource === "") {
491
- console.warn("JSON: the simulation OpenCOR resource must not be empty.");
492
-
493
- return false;
494
- }
495
-
496
- if (json.simulation.opencor.endingPoint !== undefined) {
497
- if (json.simulation.opencor.pointInterval !== undefined) {
498
- if (json.simulation.opencor.endingPoint <= 0.0) {
499
- console.warn("JSON: the simulation OpenCOR ending point (" + json.simulation.opencor.endingPoint + ") must be greater than zero.");
500
-
501
- return false;
502
- }
503
-
504
- if (json.simulation.opencor.pointInterval <= 0.0) {
505
- console.warn("JSON: the simulation OpenCOR point interval (" + json.simulation.opencor.pointInterval + ") must be greater than zero.");
506
-
507
- return false;
508
- }
509
- } else {
510
- console.warn("JSON: a simulation OpenCOR ending point is specified so a simulation OpenCOR point interval must also be specified.");
511
-
512
- return false;
513
- }
514
- } else if (json.simulation.opencor.pointInterval !== undefined) {
515
- console.warn("JSON: a simulation OpenCOR point interval is specified so a simulation OpenCOR ending point must also be specified.");
516
-
517
- return false;
518
- }
519
- }
520
-
521
- return true;
522
- }
1
+ import { Validator } from "jsonschema";
2
+ import { OPENCOR_SOLVER_NAME } from "./common.js";
3
+
4
+ export function validJson(json) {
5
+ // Check the JSON against our schema.
6
+
7
+ let validator = new Validator();
8
+ let schema = {
9
+ additionalProperties: false,
10
+ properties: {
11
+ input: {
12
+ items: {
13
+ oneOf: [
14
+ {
15
+ additionalProperties: false,
16
+ properties: {
17
+ defaultValue: {
18
+ required: true,
19
+ type: "number",
20
+ },
21
+ id: {
22
+ type: "string",
23
+ },
24
+ name: {
25
+ required: true,
26
+ type: "string",
27
+ },
28
+ possibleValues: {
29
+ items: {
30
+ additionalProperties: false,
31
+ properties: {
32
+ name: {
33
+ required: true,
34
+ type: "string",
35
+ },
36
+ value: {
37
+ required: true,
38
+ type: "number",
39
+ },
40
+ },
41
+ type: "object",
42
+ },
43
+ minItems: 1,
44
+ required: true,
45
+ type: "array",
46
+ },
47
+ visible: {
48
+ type: "string",
49
+ },
50
+ },
51
+ },
52
+ {
53
+ additionalProperties: false,
54
+ properties: {
55
+ defaultValue: {
56
+ required: true,
57
+ type: "number",
58
+ },
59
+ id: {
60
+ type: "string",
61
+ },
62
+ maximumValue: {
63
+ required: true,
64
+ type: "number",
65
+ },
66
+ minimumValue: {
67
+ required: true,
68
+ type: "number",
69
+ },
70
+ name: {
71
+ required: true,
72
+ type: "string",
73
+ },
74
+ stepValue: {
75
+ type: "number",
76
+ },
77
+ visible: {
78
+ type: "string",
79
+ },
80
+ },
81
+ },
82
+ ],
83
+ type: "object",
84
+ },
85
+ minItems: 1,
86
+ required: true,
87
+ type: "array",
88
+ },
89
+ output: {
90
+ additionalProperties: false,
91
+ minItems: 1,
92
+ properties: {
93
+ data: {
94
+ items: {
95
+ additionalProperties: false,
96
+ properties: {
97
+ id: {
98
+ required: true,
99
+ type: "string",
100
+ },
101
+ name: {
102
+ required: true,
103
+ type: "string",
104
+ },
105
+ },
106
+ type: "object",
107
+ },
108
+ minItems: 1,
109
+ required: true,
110
+ type: "array",
111
+ },
112
+ plots: {
113
+ items: {
114
+ additionalProperties: false,
115
+ properties: {
116
+ xAxisTitle: {
117
+ required: true,
118
+ type: "string",
119
+ },
120
+ xValue: {
121
+ required: true,
122
+ type: "string",
123
+ },
124
+ yAxisTitle: {
125
+ required: true,
126
+ type: "string",
127
+ },
128
+ yValue: {
129
+ required: true,
130
+ type: "string",
131
+ },
132
+ },
133
+ type: "object",
134
+ },
135
+ maxItems: 9,
136
+ minItems: 1,
137
+ required: true,
138
+ type: "array",
139
+ },
140
+ },
141
+ required: true,
142
+ type: "object",
143
+ },
144
+ parameters: {
145
+ items: {
146
+ additionalProperties: false,
147
+ properties: {
148
+ name: {
149
+ required: true,
150
+ type: "string",
151
+ },
152
+ value: {
153
+ required: true,
154
+ type: "string",
155
+ },
156
+ },
157
+ type: "object",
158
+ },
159
+ type: "array",
160
+ },
161
+ simulation: {
162
+ additionalProperties: false,
163
+ properties: {
164
+ opencor: {
165
+ additionalProperties: false,
166
+ properties: {
167
+ endingPoint: {
168
+ type: "number",
169
+ },
170
+ pointInterval: {
171
+ type: "number",
172
+ },
173
+ resource: {
174
+ required: true,
175
+ type: "string",
176
+ },
177
+ },
178
+ type: "object",
179
+ },
180
+ solvers: {
181
+ items: {
182
+ additionalProperties: false,
183
+ properties: {
184
+ if: {
185
+ type: "string",
186
+ },
187
+ input: {
188
+ additionalProperties: false,
189
+ properties: {
190
+ name: {
191
+ required: true,
192
+ type: "string",
193
+ },
194
+ value: {
195
+ required: true,
196
+ type: "string",
197
+ },
198
+ },
199
+ type: "object",
200
+ },
201
+ name: {
202
+ required: true,
203
+ type: "string",
204
+ },
205
+ version: {
206
+ required: true,
207
+ type: "string",
208
+ },
209
+ },
210
+ type: "object",
211
+ },
212
+ minItems: 1,
213
+ required: true,
214
+ type: "array",
215
+ },
216
+ },
217
+ required: true,
218
+ type: "object",
219
+ },
220
+ },
221
+ type: "object",
222
+ };
223
+
224
+ let result = validator.validate(json, schema, { nestedErrors: true });
225
+
226
+ if (!result.valid) {
227
+ console.warn(result.toString());
228
+
229
+ return false;
230
+ }
231
+
232
+ // Make sure that the input information makes sense.
233
+
234
+ let inputIdUsed = [];
235
+ let inputValid = json.input.every((input) => {
236
+ if (input.id !== undefined) {
237
+ if (input.id === "") {
238
+ console.warn("JSON: the input id must not be empty.");
239
+
240
+ return false;
241
+ }
242
+
243
+ if (inputIdUsed[input.id]) {
244
+ console.warn("JSON: the input id must be unique (" + input.id + " is used more than once).");
245
+
246
+ return false;
247
+ }
248
+
249
+ inputIdUsed[input.id] = true;
250
+ }
251
+
252
+ if (input.name === "") {
253
+ console.warn("JSON: the input name must not be empty.");
254
+
255
+ return false;
256
+ }
257
+
258
+ if (input.possibleValues !== undefined) {
259
+ if (!input.possibleValues.every((possibleValue) => {
260
+ if (possibleValue.name === "") {
261
+ console.warn("JSON: an input possible value must not be empty.");
262
+
263
+ return false;
264
+ }
265
+
266
+ return true;
267
+ })) {
268
+ return false;
269
+ }
270
+
271
+ let values = input.possibleValues.map((value) => {
272
+ return value.value;
273
+ });
274
+ let valueUsed = [];
275
+
276
+ if (!values.every((value) => {
277
+ if (valueUsed[value]) {
278
+ console.warn("JSON: an input possible value must have a unique value (" + value + " is used more than once).");
279
+
280
+ return false;
281
+ }
282
+
283
+ valueUsed[value] = true;
284
+
285
+ return true;
286
+ })) {
287
+ return false;
288
+ }
289
+
290
+ if (!values.includes(input.defaultValue)) {
291
+ console.warn("JSON: the input default value (" + input.defaultValue + ") must be one of the possible values (" + values.join(", ") + ").");
292
+
293
+ return false;
294
+ }
295
+ }
296
+
297
+ if ((input.minimumValue !== undefined) && (input.maximumValue !== undefined)) {
298
+ if (input.minimumValue >= input.maximumValue) {
299
+ console.warn("JSON: the input minimum value (" + input.minimumValue + ") must be lower than the maximum value (" + input.maximumValue + ").");
300
+
301
+ return false;
302
+ }
303
+
304
+ if ((input.defaultValue < input.minimumValue) || (input.defaultValue > input.maximumValue)) {
305
+ console.warn("JSON: the input default value (" + input.defaultValue + ") must be greater or equal than the minimum value (" + input.minimumValue + ") and lower or equal than the maximum value (" + input.maximumValue + ").");
306
+
307
+ return false;
308
+ }
309
+
310
+ let range = input.maximumValue - input.minimumValue;
311
+
312
+ if (input.stepValue !== undefined) {
313
+ if ((input.stepValue <= 0) || (input.stepValue > range)) {
314
+ console.warn("JSON: the input step value (" + input.stepValue + ") must be greater than zero and lower or equal than the range value (" + range + ").");
315
+
316
+ return false;
317
+ }
318
+
319
+ if (!Number.isInteger(range / input.stepValue)) {
320
+ console.warn("JSON: the input step value (" + input.stepValue + ") must be a factor of the range value (" + range + ").");
321
+
322
+ return false;
323
+ }
324
+ } else {
325
+ if (!Number.isInteger(range)) {
326
+ console.warn("JSON: the (default) input step value (1) must be a factor of the range value (" + range + ").");
327
+
328
+ return false;
329
+ }
330
+ }
331
+ }
332
+
333
+ if (input.visible !== undefined) {
334
+ if (input.visible === "") {
335
+ console.warn("JSON: the input visible must not be empty.");
336
+
337
+ return false;
338
+ }
339
+ }
340
+
341
+ return true;
342
+ });
343
+
344
+ if (!inputValid) {
345
+ return false;
346
+ }
347
+
348
+ // Make sure that the output information makes sense.
349
+
350
+ let outputIdUsed = [];
351
+ let outputDataValid = json.output.data.every((outputData) => {
352
+ if (outputData.id !== undefined) {
353
+ if (outputData.id === "") {
354
+ console.warn("JSON: the output data id must not be empty.");
355
+
356
+ return false;
357
+ }
358
+
359
+ if (outputIdUsed[outputData.id]) {
360
+ console.warn("JSON: the output data id must be unique (" + outputData.id + " is used more than once).");
361
+
362
+ return false;
363
+ }
364
+
365
+ outputIdUsed[outputData.id] = true;
366
+ }
367
+
368
+ if (outputData.name === "") {
369
+ console.warn("JSON: the output data name must not be empty.");
370
+
371
+ return false;
372
+ }
373
+
374
+ return true;
375
+ });
376
+
377
+ if (!outputDataValid) {
378
+ return false;
379
+ }
380
+
381
+ let outputPlotsValid = json.output.plots.every((outputPlot) => {
382
+ if (outputPlot.xAxisTitle === "") {
383
+ console.warn("JSON: the output plot X axis title must not be empty.");
384
+
385
+ return false;
386
+ }
387
+
388
+ if (outputPlot.xValue === "") {
389
+ console.warn("JSON: the output plot X value must not be empty.");
390
+
391
+ return false;
392
+ }
393
+
394
+ if (outputPlot.yAxisTitle === "") {
395
+ console.warn("JSON: the output plot Y axis title must not be empty.");
396
+
397
+ return false;
398
+ }
399
+
400
+ if (outputPlot.yValue === "") {
401
+ console.warn("JSON: the output plot Y value must not be empty.");
402
+
403
+ return false;
404
+ }
405
+
406
+ return true;
407
+ });
408
+
409
+ if (!outputPlotsValid) {
410
+ return false;
411
+ }
412
+
413
+ // Make sure that the parameters information makes sense.
414
+
415
+ if (json.parameters !== undefined) {
416
+ let parametersValid = json.parameters.every((parameter) => {
417
+ if (parameter.name === "") {
418
+ console.warn("JSON: the parameter name must not be empty.");
419
+
420
+ return false;
421
+ }
422
+
423
+ if (parameter.value === "") {
424
+ console.warn("JSON: the parameter value must not be empty.");
425
+
426
+ return false;
427
+ }
428
+
429
+ return true;
430
+ });
431
+
432
+ if (!parametersValid) {
433
+ return false;
434
+ }
435
+ }
436
+
437
+ // Make sure that the simulation information makes sense.
438
+
439
+ let needOpencorSettings = false;
440
+
441
+ if (!json.simulation.solvers.every((solver) => {
442
+ if (solver.if !== undefined) {
443
+ if (solver.if === "") {
444
+ console.warn("JSON: a simulation solver if must not be empty.");
445
+
446
+ return false;
447
+ }
448
+ }
449
+
450
+ if (solver.input !== undefined) {
451
+ if (solver.input.name === "") {
452
+ console.warn("JSON: a simulation solver input name must not be empty.");
453
+
454
+ return false;
455
+ }
456
+
457
+ if (solver.input.value === "") {
458
+ console.warn("JSON: a simulation solver input value must not be empty.");
459
+
460
+ return false;
461
+ }
462
+ }
463
+
464
+ if (solver.name === "") {
465
+ console.warn("JSON: a simulation solver name must not be empty.");
466
+
467
+ return false;
468
+ }
469
+
470
+ needOpencorSettings = needOpencorSettings || (solver.name === OPENCOR_SOLVER_NAME);
471
+
472
+ if (solver.version === "") {
473
+ console.warn("JSON: a simulation solver version must not be empty.");
474
+
475
+ return false;
476
+ }
477
+
478
+ return true;
479
+ })) {
480
+ return false;
481
+ }
482
+
483
+ if (needOpencorSettings && (json.simulation.opencor === undefined)) {
484
+ console.warn("JSON: the simulation solver for OpenCOR is specified so simulation OpenCOR settings must also be specified.");
485
+
486
+ return false;
487
+ }
488
+
489
+ if (json.simulation.opencor !== undefined) {
490
+ if (json.simulation.opencor.resource === "") {
491
+ console.warn("JSON: the simulation OpenCOR resource must not be empty.");
492
+
493
+ return false;
494
+ }
495
+
496
+ if (json.simulation.opencor.endingPoint !== undefined) {
497
+ if (json.simulation.opencor.pointInterval !== undefined) {
498
+ if (json.simulation.opencor.endingPoint <= 0.0) {
499
+ console.warn("JSON: the simulation OpenCOR ending point (" + json.simulation.opencor.endingPoint + ") must be greater than zero.");
500
+
501
+ return false;
502
+ }
503
+
504
+ if (json.simulation.opencor.pointInterval <= 0.0) {
505
+ console.warn("JSON: the simulation OpenCOR point interval (" + json.simulation.opencor.pointInterval + ") must be greater than zero.");
506
+
507
+ return false;
508
+ }
509
+ } else {
510
+ console.warn("JSON: a simulation OpenCOR ending point is specified so a simulation OpenCOR point interval must also be specified.");
511
+
512
+ return false;
513
+ }
514
+ } else if (json.simulation.opencor.pointInterval !== undefined) {
515
+ console.warn("JSON: a simulation OpenCOR point interval is specified so a simulation OpenCOR ending point must also be specified.");
516
+
517
+ return false;
518
+ }
519
+ }
520
+
521
+ return true;
522
+ }