Skip to content

Commit 07c3cf6

Browse files
committed
JSON schema: add a name property for traces.
1 parent 15023b1 commit 07c3cf6

File tree

4 files changed

+27
-5
lines changed

4 files changed

+27
-5
lines changed

src/renderer/src/components/views/SimulationExperimentView.vue

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,8 @@ const standardConsoleContents = vue.ref<string>(`<b>${props.file.path()}</b>`);
193193
194194
populateParameters(standardParameters, standardInstanceTask);
195195
196-
function traceName(xValue: string, yValue: string): string {
197-
return `${yValue} <i>vs.</i> ${xValue}`;
196+
function traceName(name: string | undefined, xValue: string, yValue: string): string {
197+
return name !== undefined ? name : `${yValue} <i>vs.</i> ${xValue}`;
198198
}
199199
200200
function onRun(): void {
@@ -220,7 +220,7 @@ const yInfo = vue.computed(() => locCommon.simulationDataInfo(standardInstanceTa
220220
221221
function updatePlot() {
222222
standardData.value = {
223-
name: traceName(standardXParameter.value, standardYParameter.value),
223+
name: traceName(undefined, standardXParameter.value, standardYParameter.value),
224224
xValues: locCommon.simulationData(standardInstanceTask, xInfo.value),
225225
yValues: locCommon.simulationData(standardInstanceTask, yInfo.value)
226226
};
@@ -359,14 +359,14 @@ function updateInteractiveSimulation(): void {
359359
360360
plot.additionalTraces?.forEach((additionalTrace: locApi.IUiJsonOutputPlotAdditionalTrace) => {
361361
additionalTraces.push({
362-
name: traceName(additionalTrace.xValue, additionalTrace.yValue),
362+
name: traceName(additionalTrace.name, additionalTrace.xValue, additionalTrace.yValue),
363363
xValues: parser.evaluate(additionalTrace.xValue),
364364
yValues: parser.evaluate(additionalTrace.yValue)
365365
});
366366
});
367367
368368
return {
369-
name: traceName(plot.xValue, plot.yValue),
369+
name: traceName(plot.name, plot.xValue, plot.yValue),
370370
xAxisTitle: plot.xAxisTitle,
371371
xValues: parser.evaluate(plot.xValue),
372372
yAxisTitle: plot.yAxisTitle,

src/renderer/src/libopencor/locUiJsonApi.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,15 @@ export interface IUiJsonOutputData {
4848
export interface IUiJsonOutputPlotAdditionalTrace {
4949
xValue: string;
5050
yValue: string;
51+
name?: string;
5152
}
5253

5354
export interface IUiJsonOutputPlot {
5455
xAxisTitle?: string;
5556
xValue: string;
5657
yAxisTitle?: string;
5758
yValue: string;
59+
name?: string;
5860
additionalTraces?: IUiJsonOutputPlotAdditionalTrace[];
5961
}
6062

@@ -208,6 +210,9 @@ export function uiJsonIssues(uiJson: IUiJson | undefined): IIssue[] {
208210
required: true,
209211
type: 'string'
210212
},
213+
name: {
214+
type: 'string'
215+
},
211216
additionalTraces: {
212217
items: {
213218
additionalProperties: false,
@@ -219,6 +224,9 @@ export function uiJsonIssues(uiJson: IUiJson | undefined): IIssue[] {
219224
yValue: {
220225
required: true,
221226
type: 'string'
227+
},
228+
name: {
229+
type: 'string'
222230
}
223231
},
224232
type: 'object'
@@ -481,6 +489,13 @@ export function uiJsonIssues(uiJson: IUiJson | undefined): IIssue[] {
481489
});
482490
}
483491

492+
if (outputPlot.name === '') {
493+
res.push({
494+
type: EIssueType.WARNING,
495+
description: 'UI JSON: an output plot name must not be empty.'
496+
});
497+
}
498+
484499
if (outputPlot.additionalTraces !== undefined) {
485500
for (const additionalTrace of outputPlot.additionalTraces) {
486501
if (additionalTrace.xValue === '') {
@@ -496,6 +511,13 @@ export function uiJsonIssues(uiJson: IUiJson | undefined): IIssue[] {
496511
description: 'UI JSON: an output plot additional trace Y value must not be empty.'
497512
});
498513
}
514+
515+
if (additionalTrace.name === '') {
516+
res.push({
517+
type: EIssueType.WARNING,
518+
description: 'UI JSON: an output plot additional trace name must not be empty.'
519+
});
520+
}
499521
}
500522
}
501523
}
17.2 KB
Binary file not shown.

0 commit comments

Comments
 (0)