From ce6ec7a08ea8f521391e55fdc25db4409c215e2e Mon Sep 17 00:00:00 2001 From: Kiryl Koniukh <49252228+Kasmadei@users.noreply.github.com> Date: Wed, 17 Jul 2024 15:52:46 +0200 Subject: [PATCH 1/2] [#485]-Required failure rate for ext referenced node --- src/components/editor/faultTree/shapes/RenderTree.tsx | 5 +++++ src/components/editor/faultTree/shapes/shapesDefinitions.tsx | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/src/components/editor/faultTree/shapes/RenderTree.tsx b/src/components/editor/faultTree/shapes/RenderTree.tsx index d350409c..96b877ac 100644 --- a/src/components/editor/faultTree/shapes/RenderTree.tsx +++ b/src/components/editor/faultTree/shapes/RenderTree.tsx @@ -82,6 +82,11 @@ const renderTree = async (container, node, parentShape = null, pathsToHighlight, } } + if (isReferencedNode(node) && node.supertypes?.hasFailureRate?.requirement?.upperBound) { + const probReqValue = node.supertypes.hasFailureRate.requirement.upperBound.toExponential(2); + nodeShape.attr(["probabilityRequirementLabel", "text"], probReqValue); + } + if (has(node, "probabilityRequirement")) { nodeShape.attr(["probabilityRequirementLabel", "text"], node.probabilityRequirement.toExponential(2)); } diff --git a/src/components/editor/faultTree/shapes/shapesDefinitions.tsx b/src/components/editor/faultTree/shapes/shapesDefinitions.tsx index c8d2efc8..13daaeb5 100644 --- a/src/components/editor/faultTree/shapes/shapesDefinitions.tsx +++ b/src/components/editor/faultTree/shapes/shapesDefinitions.tsx @@ -183,6 +183,10 @@ export const ExternalEvent = Event.define( }, refY2: -20, }, + probabilityRequirementLabel: { + fontSize: 16, + refX: "120%", + }, gate: { d: "M -15 -16 L 0 -30 L 15 -16 L 15 0 L -15 0 Z M 0 -30 L 0 -59", stroke: STROKE_COLOR, From 1485faff508d19863aede0aae8e324bd3db1fe9d Mon Sep 17 00:00:00 2001 From: Kiryl Koniukh <49252228+Kasmadei@users.noreply.github.com> Date: Wed, 17 Jul 2024 18:39:07 +0200 Subject: [PATCH 2/2] logic simplifying --- src/components/editor/faultTree/shapes/RenderTree.tsx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/components/editor/faultTree/shapes/RenderTree.tsx b/src/components/editor/faultTree/shapes/RenderTree.tsx index 96b877ac..469b0c6a 100644 --- a/src/components/editor/faultTree/shapes/RenderTree.tsx +++ b/src/components/editor/faultTree/shapes/RenderTree.tsx @@ -82,14 +82,14 @@ const renderTree = async (container, node, parentShape = null, pathsToHighlight, } } - if (isReferencedNode(node) && node.supertypes?.hasFailureRate?.requirement?.upperBound) { - const probReqValue = node.supertypes.hasFailureRate.requirement.upperBound.toExponential(2); + const probReqValue = + (isReferencedNode(node) && node.supertypes?.hasFailureRate?.requirement?.upperBound?.toExponential(2)) || + (has(node, "probabilityRequirement") && node.probabilityRequirement.toExponential(2)); + + if (probReqValue) { nodeShape.attr(["probabilityRequirementLabel", "text"], probReqValue); } - if (has(node, "probabilityRequirement")) { - nodeShape.attr(["probabilityRequirementLabel", "text"], node.probabilityRequirement.toExponential(2)); - } if (shouldHighlight) { nodeShape.attr("body/stroke", ERROR_PATH_COLOR); nodeShape.attr("body/fill", ERROR_PATH_COLOR);