From 14f1e9e1be94d9da6dfca8efb48ea0adc1b32616 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joan=20F=C3=ADsica?= Date: Fri, 30 May 2025 17:10:50 +0200 Subject: [PATCH] Show name on protection packets --- .../ProtectionMessageView.tsx | 2 +- .../ProtectionView/ProtectionView.tsx | 34 +++++++++---------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/ethernet-view/src/components/MessagesContainer/Messages/MessageView/ProtectionMessageView/ProtectionMessageView.tsx b/ethernet-view/src/components/MessagesContainer/Messages/MessageView/ProtectionMessageView/ProtectionMessageView.tsx index 0e615b9a6..79368b0cc 100644 --- a/ethernet-view/src/components/MessagesContainer/Messages/MessageView/ProtectionMessageView/ProtectionMessageView.tsx +++ b/ethernet-view/src/components/MessagesContainer/Messages/MessageView/ProtectionMessageView/ProtectionMessageView.tsx @@ -21,7 +21,7 @@ export const ProtectionMessageView = ({ message, className }: Props) => { name={message.name} /> - + ); }; diff --git a/ethernet-view/src/components/MessagesContainer/Messages/MessageView/ProtectionMessageView/ProtectionView/ProtectionView.tsx b/ethernet-view/src/components/MessagesContainer/Messages/MessageView/ProtectionMessageView/ProtectionView/ProtectionView.tsx index 9d7a2dad7..af0d6e345 100644 --- a/ethernet-view/src/components/MessagesContainer/Messages/MessageView/ProtectionMessageView/ProtectionView/ProtectionView.tsx +++ b/ethernet-view/src/components/MessagesContainer/Messages/MessageView/ProtectionMessageView/ProtectionView/ProtectionView.tsx @@ -1,8 +1,8 @@ import styles from './ProtectionView.module.scss'; -import { Protection } from 'common'; +import { ProtectionMessage } from 'common'; type Props = { - protection: Protection; + protection: ProtectionMessage; }; const DECIMALS = 2; @@ -13,43 +13,43 @@ export const ProtectionView = ({ protection }: Props) => { return
{ProtectionText}
; }; -function getProtectionText(protection: Protection) { - switch (protection.kind) { +function getProtectionText(protection: ProtectionMessage) { + switch (protection.payload.kind) { case 'OUT_OF_BOUNDS': return ( <> {' '} - Want: [{protection.data.bounds[0].toFixed( + Want: [{protection.payload.data.bounds[0].toFixed( DECIMALS - )}, {protection.data.bounds[1].toFixed(DECIMALS)}] + )}, {protection.payload.data.bounds[1].toFixed(DECIMALS)}] {' '} - Got: {protection.data.value.toFixed(DECIMALS)} + Got: {protection.payload.data.value.toFixed(DECIMALS)} ); case 'UPPER_BOUND': return ( <> - Want: x {'<'} {protection.data.bound.toFixed(DECIMALS)} + Want: [{protection.name}] {'<'} {protection.payload.data.bound.toFixed(DECIMALS)} {' '} - Got: {protection.data.value.toFixed(DECIMALS)} + Got: {protection.payload.data.value.toFixed(DECIMALS)} ); case 'LOWER_BOUND': return ( <> - Want: x {'>'} {protection.data.bound.toFixed(DECIMALS)} + Want: [{protection.name}] {'>'} {protection.payload.data.bound.toFixed(DECIMALS)} {' '} - Got: {protection.data.value.toFixed(DECIMALS)} + Got: {protection.payload.data.value.toFixed(DECIMALS)} ); case 'EQUALS': return ( <> - Mustn't be {protection.data.value.toFixed(DECIMALS)} + Mustn't be {protection.payload.data.value.toFixed(DECIMALS)} ); @@ -57,20 +57,20 @@ function getProtectionText(protection: Protection) { return ( <> - Must be {protection.data.want.toFixed(DECIMALS)} but is{' '} - {protection.data.value.toFixed(DECIMALS)} + Must be {protection.payload.data.want.toFixed(DECIMALS)} but is{' '} + {protection.payload.data.value.toFixed(DECIMALS)} ); case 'TIME_ACCUMULATION': return ( - Value was {protection.data.value.toFixed(DECIMALS)} for{' '} - {protection.data.timelimit.toFixed(DECIMALS)} seconds + Value was {protection.payload.data.value.toFixed(DECIMALS)} for{' '} + {protection.payload.data.timelimit.toFixed(DECIMALS)} seconds ); case 'ERROR_HANDLER': case 'WARNING': - return {protection.data}; + return {protection.payload.data}; } }