From fe77fcf767030e73e0290ab255cfabe94c085b5d Mon Sep 17 00:00:00 2001 From: RemDelaporteMathurin Date: Tue, 12 Aug 2025 21:40:25 -0400 Subject: [PATCH 1/9] added Swtich and Interface --- src/components/nodes/SwitchNode.jsx | 54 +++++++++++++++++++++++++++++ src/nodeConfig.js | 11 ++++-- src/python/pathsim_utils.py | 2 ++ 3 files changed, 65 insertions(+), 2 deletions(-) create mode 100644 src/components/nodes/SwitchNode.jsx diff --git a/src/components/nodes/SwitchNode.jsx b/src/components/nodes/SwitchNode.jsx new file mode 100644 index 0000000..d31faca --- /dev/null +++ b/src/components/nodes/SwitchNode.jsx @@ -0,0 +1,54 @@ +import React from 'react'; +import { Handle } from '@xyflow/react'; + +export default function SwitchNode({ data }) { + return ( +
+
{data.label}
+ + +
+ 0 +
+ + +
+ 1 +
+ +
+ ); +} diff --git a/src/nodeConfig.js b/src/nodeConfig.js index 01de910..01ea35b 100644 --- a/src/nodeConfig.js +++ b/src/nodeConfig.js @@ -14,6 +14,7 @@ import { Splitter2Node, Splitter3Node } from './components/nodes/Splitters'; import BubblerNode from './components/nodes/BubblerNode'; import WallNode from './components/nodes/WallNode'; import { DynamicHandleNode } from './components/nodes/DynamicHandleNode'; +import SwitchNode from './components/nodes/SwitchNode'; // Node types mapping export const nodeTypes = { @@ -59,6 +60,8 @@ export const nodeTypes = { butterworthbandstop: DefaultNode, fir: DefaultNode, ode: DynamicHandleNode, + interface: DynamicHandleNode, + switch: SwitchNode, }; export const nodeMathTypes = { @@ -87,7 +90,7 @@ Object.keys(nodeMathTypes).forEach(type => { } }); -export const nodeDynamicHandles = ['ode', 'function']; +export const nodeDynamicHandles = ['ode', 'function', 'interface']; // Node categories for better organization export const nodeCategories = { @@ -116,7 +119,7 @@ export const nodeCategories = { description: 'Fuel cycle specific nodes' }, 'Others': { - nodes: ['samplehold', 'comparator'], + nodes: ['samplehold', 'comparator', 'switch', 'interface'], description: 'Miscellaneous nodes' }, 'Output': { @@ -184,6 +187,10 @@ export const getNodeDisplayName = (nodeType) => { 'butterworthbandpass': 'Butterworth Band-Pass Filter', 'butterworthbandstop': 'Butterworth Band-Stop Filter', 'fir': 'FIR Filter', + 'switch': 'Switch', + 'samplehold': 'Sample Hold', + 'comparator': 'Comparator', + 'interface': 'Interface', }; return displayNames[nodeType] || nodeType.charAt(0).toUpperCase() + nodeType.slice(1); diff --git a/src/python/pathsim_utils.py b/src/python/pathsim_utils.py index 57f4b05..5d6c2e8 100644 --- a/src/python/pathsim_utils.py +++ b/src/python/pathsim_utils.py @@ -132,6 +132,8 @@ "butterworthbandpass": pathsim.blocks.ButterworthBandpassFilter, "butterworthbandstop": pathsim.blocks.ButterworthBandstopFilter, "fir": pathsim.blocks.FIR, + "interface": pathsim.subsystem.Interface, + "switch": pathsim.blocks.Switch, } math_blocks = { From 7024691fae074665c830270ff79ddfd2edb8c817 Mon Sep 17 00:00:00 2001 From: RemDelaporteMathurin Date: Wed, 13 Aug 2025 08:42:05 -0400 Subject: [PATCH 2/9] ruff --- src/components/EventsTab.jsx | 44 ++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/src/components/EventsTab.jsx b/src/components/EventsTab.jsx index 6405461..fb1cb1a 100644 --- a/src/components/EventsTab.jsx +++ b/src/components/EventsTab.jsx @@ -46,7 +46,7 @@ const EventsTab = ({ events, setEvents }) => { ...eventDefaults[initialEventType] }; }); - + // State to track if we're editing an existing event const [editingEventId, setEditingEventId] = useState(null); @@ -79,13 +79,13 @@ const EventsTab = ({ events, setEvents }) => { const addEvent = () => { if (currentEvent.name) { // Validate required fields based on event type - + // For Schedule, func_act is required if (['Schedule', 'ScheduleList'].includes(currentEvent.type) && !currentEvent.func_act) { alert('func_act is required for Schedule events'); return; } - + // For other event types, both func_evt and func_act are typically required if (!['Schedule', 'ScheduleList'].includes(currentEvent.type) && (!currentEvent.func_evt || !currentEvent.func_act)) { alert('Both func_evt and func_act are required for this event type'); @@ -93,7 +93,7 @@ const EventsTab = ({ events, setEvents }) => { } setEvents(prev => [...prev, { ...currentEvent, id: Date.now() }]); - + // Reset to defaults for current type const resetDefaults = eventDefaults[currentEvent.type] || {}; setCurrentEvent({ @@ -111,23 +111,23 @@ const EventsTab = ({ events, setEvents }) => { const saveEditedEvent = () => { if (currentEvent.name) { - + // For Schedule, func_act is required if (currentEvent.type === 'Schedule' && !currentEvent.func_act) { alert('func_act is required for Schedule events'); return; } - + // For other event types, both func_evt and func_act are typically required if (currentEvent.type !== 'Schedule' && (!currentEvent.func_evt || !currentEvent.func_act)) { alert('Both func_evt and func_act are required for this event type'); return; } - setEvents(prev => prev.map(event => + setEvents(prev => prev.map(event => event.id === editingEventId ? { ...currentEvent } : event )); - + // Reset form and exit edit mode cancelEdit(); } @@ -179,7 +179,7 @@ const EventsTab = ({ events, setEvents }) => {

{editingEventId ? 'Edit Event' : 'Add New Event'}

- +
-