Skip to content

Commit

Permalink
refactor: moved simulation screen to shared
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaustuv942 committed Jun 3, 2021
1 parent 00759dd commit 4c29097
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 501 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { makeStyles } from '@material-ui/core/styles'
import { useSelector, useDispatch } from 'react-redux'
import { setControlLine, setControlBlock, setResultTitle, setResultGraph, setResultText } from '../../redux/actions/index'
import { GenerateNetList, GenerateNodeList, GenerateCompList } from './Helper/ToolbarTools'
import SimulationScreen from './SimulationScreen'
import SimulationScreen from '../Shared/SimulationScreen'
import { Multiselect } from 'multiselect-react-dropdown'

import api from '../../utils/Api'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, {useEffect} from 'react'
import React, { useEffect } from 'react'
import PropTypes from 'prop-types'
import {
Slide,
Expand All @@ -18,13 +18,12 @@ import {
TableContainer,
TableHead,
TableRow

} from '@material-ui/core'
import { makeStyles } from '@material-ui/core/styles'
import CloseIcon from '@material-ui/icons/Close'
import { useSelector } from 'react-redux'

import Graph from '../Shared/Graph'
import Graph from './Graph'

var FileSaver = require('file-saver')

Expand All @@ -51,9 +50,8 @@ const useStyles = makeStyles((theme) => ({
color: '#fff'
}
}))

// Screen to display simulation result in graph or text format
export default function SimulationScreen({ open, close, isResult, task_id }) {
// {details:{},title:''} simResults
export default function SimulationScreen ({ open, close, isResult, taskId }) {
const classes = useStyles()
const result = useSelector((state) => state.simulationReducer)
const stitle = useSelector((state) => state.netlistReducer.title)
Expand All @@ -71,16 +69,6 @@ export default function SimulationScreen({ open, close, isResult, task_id }) {
n: 0.000000001,
p: 0.000000000001
}
const handleXScale = (evt) => {
setXScale(evt.target.value)
}

const handleYScale = (evt) => {
setYScale(evt.target.value)
}
const handlePrecision = (evt) => {
setPrecision(evt.target.value)
}
const toFixed = (x) => {
var e = 0
if (Math.abs(x) < 1.0) {
Expand Down Expand Up @@ -113,7 +101,7 @@ export default function SimulationScreen({ open, close, isResult, task_id }) {
}
useEffect(() => {
if (isResult === true) {
if (result.graph !== {} && result.isGraph !== "false") {
if (result.graph !== {} && result.isGraph !== "false") {
setScales()
}
}
Expand Down Expand Up @@ -165,6 +153,16 @@ export default function SimulationScreen({ open, close, isResult, task_id }) {
}
}
}
const handleXScale = (evt) => {
setXScale(evt.target.value)
}

const handleYScale = (evt) => {
setYScale(evt.target.value)
}
const handlePrecision = (evt) => {
setPrecision(evt.target.value)
}
const generateCSV = () => {
var headings = ''
result.graph.labels.forEach(label => {
Expand Down Expand Up @@ -236,13 +234,14 @@ export default function SimulationScreen({ open, close, isResult, task_id }) {
{/* Display graph result */}
{isResult === true ? <>
{

(result.graph !== {} && result.isGraph === 'true')
? <Grid item xs={12} sm={12}>
<Paper className={classes.paper}>
<Typography variant="h4" align="center" gutterBottom>
GRAPH OUTPUT
</Typography>
<div style={{ padding: '15px 10px 10px 10px', margin: '20px 0px', backgroundColor: 'white', borderRadius: '5px' }} >
<div style={{ padding: '15px 10px 10px 10px', margin: '20px 0px', backgroundColor: 'white', borderRadius: '5px' }}>
<TextField
style={{ width: '20%' }}
id="xscale"
Expand Down Expand Up @@ -348,7 +347,7 @@ export default function SimulationScreen({ open, close, isResult, task_id }) {
}

</TextField>
{result.isGraph === 'true' && <Button variant="contained" style={{ marginLeft: "1%" }} color="primary" size="medium" onClick={handleCsvDownload}>
{result.isGraph === 'true' && <Button variant="contained" style={{ marginLeft: '1%' }} color="primary" size="medium" onClick={handleCsvDownload}>
Download Graph Output
</Button>}
</div>
Expand All @@ -365,7 +364,6 @@ export default function SimulationScreen({ open, close, isResult, task_id }) {
: (result.isGraph === 'true') ? <span>SOMETHING WENT WRONG PLEASE CHECK THE SIMULATION PARAMETERS.</span> : <span></span>
}

{/* Display text result */}
{
(result.isGraph === 'false')
? <Grid item xs={12} sm={12}>
Expand Down Expand Up @@ -467,11 +465,11 @@ export default function SimulationScreen({ open, close, isResult, task_id }) {
</Paper>
</Grid>
: <span></span>
} </>
}</>
: <Grid item xs={12} sm={12}>
<Paper className={classes.paper}>
<Typography variant="h6" align="center" gutterBottom>
SOMETHING WENT WRONG PLEASE CHECK THE SIMULATION PARAMETERS AND SCHEMATIC DIAGRAM. {/* Error handeling message in case of null result */}
SOMETHING WENT WRONG PLEASE CHECK THE NETLIST.
</Typography>
</Paper>
</Grid>
Expand All @@ -486,5 +484,7 @@ export default function SimulationScreen({ open, close, isResult, task_id }) {
SimulationScreen.propTypes = {
open: PropTypes.bool,
close: PropTypes.func,
isResult: PropTypes.bool
isResult: PropTypes.bool,
taskId: PropTypes.string
// simResults: PropTypes.object
}
Loading

0 comments on commit 4c29097

Please sign in to comment.