diff options
author | Sunil Shetye | 2025-05-19 09:28:23 +0530 |
---|---|---|
committer | Sunil Shetye | 2025-05-19 10:54:05 +0530 |
commit | 849833fe2f93dcb90cca640883935c13aa3b1df7 (patch) | |
tree | ae27e52979eab69c894132e9f9da66c18f42a0f3 | |
parent | b7433a00d8d0886510e1e8675a5392e0003146cb (diff) | |
download | Common-Interface-Project-849833fe2f93dcb90cca640883935c13aa3b1df7.tar.gz Common-Interface-Project-849833fe2f93dcb90cca640883935c13aa3b1df7.tar.bz2 Common-Interface-Project-849833fe2f93dcb90cca640883935c13aa3b1df7.zip |
add setSimulating in simulation slice
use isSimulating instead of isStatusDone()
-rw-r--r-- | blocks/eda-frontend/src/components/SchematicEditor/SimulationScreen.js | 13 | ||||
-rw-r--r-- | blocks/eda-frontend/src/redux/simulationSlice.js | 6 |
2 files changed, 14 insertions, 5 deletions
diff --git a/blocks/eda-frontend/src/components/SchematicEditor/SimulationScreen.js b/blocks/eda-frontend/src/components/SchematicEditor/SimulationScreen.js index aff1ded7..08512da7 100644 --- a/blocks/eda-frontend/src/components/SchematicEditor/SimulationScreen.js +++ b/blocks/eda-frontend/src/components/SchematicEditor/SimulationScreen.js @@ -6,8 +6,8 @@ import { makeStyles } from '@material-ui/core/styles' import CloseIcon from '@material-ui/icons/Close' import { useSelector, useDispatch } from 'react-redux' -import Graph, { setStatusDone, setStatusClosed, isStatusDone } from '../Shared/Graph' -import { setResultGraph } from '../../redux/simulationSlice' +import Graph, { setStatusDone, setStatusClosed } from '../Shared/Graph' +import { setResultGraph, setSimulating } from '../../redux/simulationSlice' import api from '../../utils/Api' let sse = null @@ -112,6 +112,7 @@ export function setGraphStatusClosed () { export default function SimulationScreen ({ open, close }) { const classes = useStyles() const dispatch = useDispatch() + const isSimulating = useSelector(state => state.simulation.isSimulating) const isGraph = useSelector(state => state.simulation.isGraph) const rtitle = useSelector(state => state.simulation.title) const stitle = useSelector(state => state.saveSchematic.title) @@ -151,7 +152,7 @@ export default function SimulationScreen ({ open, close }) { if (graphsRef.current[refId] !== undefined) { graphsRef.current[refId].addPointToQueue(id, point) } else { - console.log('cannot add point', id, point, chartIdList) + console.log('cannot add point', id, point, chartIdList.current) } } @@ -546,6 +547,7 @@ export default function SimulationScreen ({ open, close }) { createAffichDisplaytext(p, blockId) } + dispatch(setSimulating(true)) sse = new EventSource('/api/' + streamingUrl, { withCredentials: true }) sse.addEventListener('log', e => { ++loglines @@ -590,6 +592,7 @@ export default function SimulationScreen ({ open, close }) { sse.close() sse = null setGraphStatusDone() + dispatch(setSimulating(false)) }, false) sse.addEventListener('ERROR', e => { printloglines() @@ -683,14 +686,14 @@ export default function SimulationScreen ({ open, close }) { close(taskId) } - if (!isStatusDone()) { + if (isSimulating) { window.addEventListener('beforeunload', handleTabClose) } return () => { window.removeEventListener('beforeunload', handleTabClose) } - }, [taskId, isStatusDone()]) + }, [taskId, isSimulating]) /* * Function to display values of all affich blocks diff --git a/blocks/eda-frontend/src/redux/simulationSlice.js b/blocks/eda-frontend/src/redux/simulationSlice.js index c4618de5..6d46c9a6 100644 --- a/blocks/eda-frontend/src/redux/simulationSlice.js +++ b/blocks/eda-frontend/src/redux/simulationSlice.js @@ -1,6 +1,7 @@ import { createSlice } from '@reduxjs/toolkit' const initialState = { + isSimulating: false, title: '', isGraph: false, text: [], @@ -15,6 +16,7 @@ const simulationSlice = createSlice({ initialState, reducers: { resetResult: (state) => { + state.isSimulating = false state.title = '' state.isGraph = false state.text = [] @@ -22,6 +24,9 @@ const simulationSlice = createSlice({ state.isSimRes = false state.taskId = '' }, + setSimulating: (state, action) => { + state.isSimulating = action.payload + }, setResultTitle: (state, action) => { state.title = action.payload }, @@ -46,6 +51,7 @@ const simulationSlice = createSlice({ export const { resetResult, + setSimulating, setResultTitle, setResultGraph, setResultText, |