summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSunil Shetye2022-11-15 23:07:41 +0530
committerSunil Shetye2022-11-16 16:23:40 +0530
commit373f6381ee86b05d6a9aae23fe4698da8ea71dca (patch)
treefd8aafc60ccadc9633bbb3347e6d8c6f96dc48e7
parent03a4f5aa34349a4867192504f7a65f3aded6f0a5 (diff)
downloadCommon-Interface-Project-373f6381ee86b05d6a9aae23fe4698da8ea71dca.tar.gz
Common-Interface-Project-373f6381ee86b05d6a9aae23fe4698da8ea71dca.tar.bz2
Common-Interface-Project-373f6381ee86b05d6a9aae23fe4698da8ea71dca.zip
add statusClosed
-rw-r--r--blocks/eda-frontend/src/components/SchematicEditor/SimulationProperties.js3
-rw-r--r--blocks/eda-frontend/src/components/SchematicEditor/SimulationScreen.js60
-rw-r--r--blocks/eda-frontend/src/components/Shared/Graph.js17
3 files changed, 47 insertions, 33 deletions
diff --git a/blocks/eda-frontend/src/components/SchematicEditor/SimulationProperties.js b/blocks/eda-frontend/src/components/SchematicEditor/SimulationProperties.js
index 71822587..a59ebab7 100644
--- a/blocks/eda-frontend/src/components/SchematicEditor/SimulationProperties.js
+++ b/blocks/eda-frontend/src/components/SchematicEditor/SimulationProperties.js
@@ -17,7 +17,7 @@ import { useSelector, useDispatch } from 'react-redux'
import { setResultTitle, setResultTaskId } from '../../redux/actions/index'
import { saveXml } from './Helper/ToolbarTools'
-import SimulationScreen from './SimulationScreen'
+import SimulationScreen, { setGraphStatusClosed } from './SimulationScreen'
import api from '../../utils/Api'
const useStyles = makeStyles((theme) => ({
@@ -73,6 +73,7 @@ export default function SimulationProperties () {
}
const handleSimulateClose = () => {
+ setGraphStatusClosed()
setSimulateOpen(false)
}
diff --git a/blocks/eda-frontend/src/components/SchematicEditor/SimulationScreen.js b/blocks/eda-frontend/src/components/SchematicEditor/SimulationScreen.js
index 59e1ba91..be57a737 100644
--- a/blocks/eda-frontend/src/components/SchematicEditor/SimulationScreen.js
+++ b/blocks/eda-frontend/src/components/SchematicEditor/SimulationScreen.js
@@ -6,10 +6,12 @@ import { makeStyles } from '@material-ui/core/styles'
import CloseIcon from '@material-ui/icons/Close'
import { useSelector, useDispatch } from 'react-redux'
-import Graph, { setStatusDone } from '../Shared/Graph'
+import Graph, { setStatusDone, setStatusClosed } from '../Shared/Graph'
import { setResultGraph } from '../../redux/actions/index'
import api from '../../utils/Api'
+let sse = null
+
const Transition = React.forwardRef(function Transition (props, ref) {
return <Slide direction='up' ref={ref} {...props} />
})
@@ -38,6 +40,14 @@ export function setGraphStatusDone () {
setStatusDone()
}
+export function setGraphStatusClosed () {
+ if (sse !== null) {
+ sse.close()
+ sse = null
+ }
+ setStatusClosed()
+}
+
// Screen to display simulation result in graph or text format
export default function SimulationScreen ({ open, close }) {
const classes = useStyles()
@@ -229,7 +239,7 @@ export default function SimulationScreen ({ open, close }) {
return colorAxisArray
}
- const sse = new EventSource('/api/' + streamingUrl, { withCredentials: true })
+ sse = new EventSource('/api/' + streamingUrl, { withCredentials: true })
sse.addEventListener('log', e => {
++loglines
@@ -239,7 +249,7 @@ export default function SimulationScreen ({ open, close }) {
const block = parseInt(data[0])
const figureId = (block === 2) ? data[4] : data[2] // For CMSCOPE
let noOfGraph
- if (block === 5 || block === 10) { // For 3D-SCOPE blocks
+ if (block === 5 || block === 10) { // For CANIMXY3D or CSCOPXY3D
noOfGraph = data[11]
} else if (block === 11) { // For BARXY
noOfGraph = data[12]
@@ -257,7 +267,7 @@ export default function SimulationScreen ({ open, close }) {
xmax = data[12]
ymin = data[13]
ymax = data[14]
- } else if (block === 5 || block === 10) { // For 3D-SCOPE blocks
+ } else if (block === 5 || block === 10) { // For CSCOPXY3D or CANIMXY3D
xmin = data[12]
xmax = data[13]
ymin = data[14]
@@ -274,12 +284,12 @@ export default function SimulationScreen ({ open, close }) {
xmax = data[8]
ymin = 0
ymax = data[10]
- } else if (block === 23) { // For CEVENTSCOPE
+ } else if (block === 23) { // For CEVSCPE
xmin = 0
xmax = data[11]
ymin = 0
ymax = 1
- } else {
+ } else { // For CSCOPE or CMSCOPE
xmin = 0
xmax = data[13]
ymin = data[11]
@@ -287,7 +297,7 @@ export default function SimulationScreen ({ open, close }) {
}
let alpha = null
let theta = null
- if (block === 5 || block === 10) { // For 3D-SCOPE blocks
+ if (block === 5 || block === 10) { // For CSCOPXY3D or CANIMXY3D
alpha = data[18]
theta = data[19]
}
@@ -301,7 +311,7 @@ export default function SimulationScreen ({ open, close }) {
typeChart = 'scatter'
} else if (block === 12) { // For CMATVIEW
typeChart = 'heatmap'
- } else if (block === 23) { // For CEVENTSCOPE
+ } else if (block === 23) { // For CEVSCPE
typeChart = 'column'
} else {
typeChart = 'line'
@@ -309,17 +319,17 @@ export default function SimulationScreen ({ open, close }) {
let titleText
if (block === 4) { // For CSCOPXY
titleText = data[15] + '-' + data[2]
- } else if (block === 5) { // For 3D-SCOPE block
+ } else if (block === 5) { // For CSCOPXY3D
titleText = data[20] + '-' + data[2]
} else if (block === 9) { // For CANIMXY
titleText = data[16] + '-' + data[2]
- } else if (block === 10) { // For 3D-SCOPE block
+ } else if (block === 10) { // For CANIMXY3D
titleText = data[21] + '-' + data[2]
} else if (block === 11) { // For BARXY
titleText = data[13] + '-' + figureId
} else if (block === 12) { // For CMATVIEW
titleText = data[data.length - 1] + '-' + figureId
- } else if (block === 23) { // For CEVENTSCOPE
+ } else if (block === 23) { // For CEVSCPE
titleText = data[12] + '-' + data[2]
} else {
titleText = data[14] + '-' + data[2]
@@ -336,8 +346,7 @@ export default function SimulationScreen ({ open, close }) {
}
}
- // For BARXY
- if (block === 11) {
+ if (block === 11) { // For BARXY
const x1 = parseFloat(data[4])
const y1 = parseFloat(data[5])
const x2 = parseFloat(data[6])
@@ -390,44 +399,40 @@ export default function SimulationScreen ({ open, close }) {
} else if (block < 5 || block === 9 || block === 23 || block === 12) {
// added new condition for ceventscope
// process data for 2D-SCOPE blocks
- const lineId = parseInt(data[6])
const x = parseFloat(data[8])
const y = parseFloat(data[9])
// store 2d-data
if (block !== 12) {
- addPointToGraph(figureId, [lineId, x, y])
+ addPointToGraph(figureId, [x, y])
} else {
const values = getPointsForData(data, data[8], data[10])
cmatviewCounter++ // to count lines from log
if (cmatviewCounter === 1) {
// Only add points of line 1, so that no delay in chart appearance)
- addPointToGraph(figureId, [lineId, values])
+ addPointToGraph(figureId, [values])
} else if (cmatviewCounter < 16) {
// Only add points of line which are multiple of 5, till 15 like 5 10 15 (this is to reduce load on browser)
const count = cmatviewCounter % 5
if (count === 0) {
- addPointToGraph(figureId, [lineId, values])
+ addPointToGraph(figureId, [values])
}
} else {
// Only add points of line which are multiple of 10 but after 16 like 20 30 ... (this is to reduce load on browser)
const count = cmatviewCounter % 10
if (count === 0) {
- addPointToGraph(figureId, [lineId, values])
+ addPointToGraph(figureId, [values])
}
}
}
// store block number for chart creation
- } else if (block === 5 || block === 10) {
- // process data for 3D-SCOPE blocks
- const lineId = parseInt(data[6])
+ } else if (block === 5 || block === 10) { // For CSCOPXY3D or CANIMXY3D
const x = parseFloat(data[8])
const y = parseFloat(data[9])
const z = parseFloat(data[10])
// store 3d-data
- addPointToGraph(figureId, [lineId, x, y, z])
+ addPointToGraph(figureId, [x, y, z])
// store block number for chart creation
- } else if (block === 13) {
- // process data for CMAT3D blocks
+ } else if (block === 13) { // For CMAT3D
// const blockUid = data[2]
// const m = data[8]
// const n = data[10]
@@ -440,9 +445,7 @@ export default function SimulationScreen ({ open, close }) {
// const alpha = data[24]
// const theta = data[26]
// Chart function need to be written
- } else if (block === 20) {
- // Process data for Affich_m block
-
+ } else if (block === 20) { // For AFFICH_m
// store length of data for each line
const lengthOfData = data.length
const blockId = data[2] // to store block id of affichm block
@@ -478,6 +481,7 @@ export default function SimulationScreen ({ open, close }) {
printloglines()
console.log('DONE')
sse.close()
+ sse = null
setGraphStatusDone()
}, false)
sse.addEventListener('ERROR', e => {
@@ -485,11 +489,13 @@ export default function SimulationScreen ({ open, close }) {
console.log('ERROR', e)
setError('Error in simulation: ' + e.data)
sse.close()
+ sse = null
}, false)
sse.addEventListener('MESSAGE', e => {
printloglines()
console.log('MESSAGE', e)
sse.close()
+ sse = null
}, false)
}, [taskId, chartIdList])
diff --git a/blocks/eda-frontend/src/components/Shared/Graph.js b/blocks/eda-frontend/src/components/Shared/Graph.js
index ac7278c1..27d20d1a 100644
--- a/blocks/eda-frontend/src/components/Shared/Graph.js
+++ b/blocks/eda-frontend/src/components/Shared/Graph.js
@@ -5,11 +5,16 @@ import HighchartsReact from 'highcharts-react-official'
import { Queue } from '../../utils/Queue'
let statusDone = false
+let statusClosed = false
export function setStatusDone () {
statusDone = true
}
+export function setStatusClosed () {
+ statusClosed = true
+}
+
class Graph extends React.Component {
pointList = new Queue()
@@ -34,29 +39,31 @@ class Graph extends React.Component {
function addPoints () {
while (!pointList.isEmpty()) {
+ if (statusClosed) {
+ clearInterval(myInterval)
+ return
+ }
const xmax = chart.xAxis[0].max
const xmin = chart.xAxis[0].min
const xshift = (xmax - xmin) * 0.2
const point = pointList.peek()
- const x = parseFloat(point[1])
+ const x = parseFloat(point[0])
if (x > xmax) {
chart.xAxis[0].update({
max: xmax + xshift,
min: xmin + xshift
})
- chart.redraw()
}
const timediff = starttime + x * 1000 - Date.now()
if (timediff > 0) {
chart.redraw()
return
}
- const y = parseFloat(point[2])
- series.addPoint([x, y])
+ series.addPoint(point)
pointList.dequeue()
}
chart.redraw()
- if (pointList.isEmpty() && statusDone) {
+ if ((pointList.isEmpty() && statusDone) || statusClosed) {
clearInterval(myInterval)
}
}