diff --git a/Data/Agent/borealis-agent.py b/Data/Agent/borealis-agent.py index acaaa5d..676509b 100644 --- a/Data/Agent/borealis-agent.py +++ b/Data/Agent/borealis-agent.py @@ -11,8 +11,8 @@ from PyQt5 import QtCore, QtGui, QtWidgets from PIL import ImageGrab # ---------------- Configuration ---------------- -#SERVER_URL = "http://localhost:5000" # WebSocket-enabled Internal URL -SERVER_URL = "https://borealis.bunny-lab.io" # WebSocket-enabled Public URL" +SERVER_URL = "http://localhost:5000" # WebSocket-enabled Internal URL +#SERVER_URL = "https://borealis.bunny-lab.io" # WebSocket-enabled Public URL" HOSTNAME = socket.gethostname().lower() RANDOM_SUFFIX = uuid.uuid4().hex[:8] diff --git a/Data/WebUI/src/nodes/Data Manipulation/Node_Array_Index_Extractor.jsx b/Data/WebUI/src/nodes/Data Manipulation/Node_Array_Index_Extractor.jsx new file mode 100644 index 0000000..d5b3928 --- /dev/null +++ b/Data/WebUI/src/nodes/Data Manipulation/Node_Array_Index_Extractor.jsx @@ -0,0 +1,141 @@ +import React, { useEffect, useRef, useState } from "react"; +import { Handle, Position, useReactFlow, useStore } from "reactflow"; + +if (!window.BorealisValueBus) window.BorealisValueBus = {}; +if (!window.BorealisUpdateRate) window.BorealisUpdateRate = 100; + +const ArrayIndexExtractorNode = ({ id, data }) => { + const edges = useStore((state) => state.edges); + const { setNodes } = useReactFlow(); + + const [lineNumber, setLineNumber] = useState(data?.lineNumber || 1); + const [result, setResult] = useState("Line Does Not Exist"); + + const valueRef = useRef(result); + + const handleLineNumberChange = (e) => { + const num = parseInt(e.target.value, 10); + const clamped = isNaN(num) ? 1 : Math.max(1, num); + setLineNumber(clamped); + + setNodes((nds) => + nds.map((n) => + n.id === id ? { ...n, data: { ...n.data, lineNumber: clamped } } : n + ) + ); + }; + + useEffect(() => { + let intervalId = null; + let currentRate = window.BorealisUpdateRate; + + const runNodeLogic = () => { + const inputEdge = edges.find((e) => e.target === id); + if (!inputEdge) { + valueRef.current = "Line Does Not Exist"; + setResult("Line Does Not Exist"); + window.BorealisValueBus[id] = "Line Does Not Exist"; + return; + } + + const upstreamValue = window.BorealisValueBus[inputEdge.source]; + if (!Array.isArray(upstreamValue)) { + valueRef.current = "Line Does Not Exist"; + setResult("Line Does Not Exist"); + window.BorealisValueBus[id] = "Line Does Not Exist"; + return; + } + + const index = Math.max(0, lineNumber - 1); // Convert 1-based input to 0-based + const selected = upstreamValue[index] ?? "Line Does Not Exist"; + + if (selected !== valueRef.current) { + valueRef.current = selected; + setResult(selected); + window.BorealisValueBus[id] = selected; + } + }; + + intervalId = setInterval(runNodeLogic, currentRate); + + const monitor = setInterval(() => { + const newRate = window.BorealisUpdateRate; + if (newRate !== currentRate) { + clearInterval(intervalId); + currentRate = newRate; + intervalId = setInterval(runNodeLogic, currentRate); + } + }, 300); + + return () => { + clearInterval(intervalId); + clearInterval(monitor); + }; + }, [id, edges, lineNumber]); + + return ( +