From 443073f134d2825989137a80a2638fc3fb7c0ce0 Mon Sep 17 00:00:00 2001 From: Shawn Yama Date: Wed, 17 Apr 2024 10:03:25 -0400 Subject: [PATCH] fix: parameter unit assignment when adding a template card (#3358) --- .../src/components/model/petrinet/tera-parameter-table.vue | 6 +++--- packages/client/hmi-client/src/services/model-templating.ts | 6 +++--- packages/client/hmi-client/src/types/Types.ts | 2 +- .../models/dataservice/modelparts/ModelParameter.java | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/client/hmi-client/src/components/model/petrinet/tera-parameter-table.vue b/packages/client/hmi-client/src/components/model/petrinet/tera-parameter-table.vue index f0c1448b1f..8a82742960 100644 --- a/packages/client/hmi-client/src/components/model/petrinet/tera-parameter-table.vue +++ b/packages/client/hmi-client/src/components/model/petrinet/tera-parameter-table.vue @@ -516,7 +516,7 @@ const buildParameterTable = () => { type: paramType, description: param?.description ?? '', concept: param?.grounding ?? { identifiers: {} }, - unit: param?.unit?.expression ?? '', + units: param?.units?.expression ?? '', value: param, source: sourceValue, visibility: false, @@ -550,7 +550,7 @@ const buildParameterTable = () => { type: paramType, description: param.description ?? '', concept: param.grounding ?? { identifiers: {} }, - unit: param.unit?.expression, + unit: param.units?.expression, value: param, source: sourceValue, visibility: false, @@ -571,7 +571,7 @@ const buildParameterTable = () => { type: paramType, description: aux.description, concept: aux.grounding, - unit: aux.unit?.expression, + unit: aux.units?.expression, value: aux, source: sourceValue, visibility: false, diff --git a/packages/client/hmi-client/src/services/model-templating.ts b/packages/client/hmi-client/src/services/model-templating.ts index d3be6316aa..cc17841373 100644 --- a/packages/client/hmi-client/src/services/model-templating.ts +++ b/packages/client/hmi-client/src/services/model-templating.ts @@ -10,7 +10,7 @@ import type { } from '@/types/model-templating'; import { DecomposedModelTemplateTypes } from '@/types/model-templating'; import { KernelSessionManager } from '@/services/jupyter'; -import { Model, Initial, ModelUnit } from '@/types/Types'; +import { Model, Initial } from '@/types/Types'; import { logger } from '@/utils/logger'; import naturalConversionTemplate from './model-templates/natural-conversion.json'; import naturalProductionTemplate from './model-templates/natural-production.json'; @@ -29,7 +29,7 @@ interface AddTemplateArguments { controller_initial_value?: string; parameter_name?: string; parameter_value?: number; - parameter_units?: ModelUnit; + parameter_units?: string; parameter_description?: string; template_expression?: string; template_name?: string; @@ -252,7 +252,7 @@ export function addDecomposedTemplateInKernel( if (parameters) { addTemplateArguments.parameter_name = parameters[0].id; addTemplateArguments.parameter_value = parameters[0].value; - addTemplateArguments.parameter_units = parameters[0].unit ?? undefined; + addTemplateArguments.parameter_units = parameters[0]?.units?.expression; addTemplateArguments.parameter_description = parameters[0].description; } diff --git a/packages/client/hmi-client/src/types/Types.ts b/packages/client/hmi-client/src/types/Types.ts index c8fa6d6a92..31afa99e13 100644 --- a/packages/client/hmi-client/src/types/Types.ts +++ b/packages/client/hmi-client/src/types/Types.ts @@ -1106,7 +1106,7 @@ export interface ModelParameter { value?: number; grounding?: ModelGrounding; distribution?: ModelDistribution; - unit?: ModelUnit; + units?: ModelUnit; } export interface Observable { diff --git a/packages/server/src/main/java/software/uncharted/terarium/hmiserver/models/dataservice/modelparts/ModelParameter.java b/packages/server/src/main/java/software/uncharted/terarium/hmiserver/models/dataservice/modelparts/ModelParameter.java index 47c0c4e1fc..526fd9887c 100644 --- a/packages/server/src/main/java/software/uncharted/terarium/hmiserver/models/dataservice/modelparts/ModelParameter.java +++ b/packages/server/src/main/java/software/uncharted/terarium/hmiserver/models/dataservice/modelparts/ModelParameter.java @@ -35,5 +35,5 @@ public class ModelParameter extends SupportAdditionalProperties implements Seria private ModelDistribution distribution; @TSOptional - private ModelUnit unit; + private ModelUnit units; }