summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSuchita Lad2025-06-19 11:03:14 +0530
committerSuchita Lad2025-06-19 11:03:14 +0530
commitc0d1fbc0a6ab97424ab6067f17046bbf3e6007a7 (patch)
tree113fc0977680b6c24e2057da1b17e8c64677b673
parent60446b465deafeba535fab465bb0fdee9aaca02c (diff)
downloadCommon-Interface-Project-c0d1fbc0a6ab97424ab6067f17046bbf3e6007a7.tar.gz
Common-Interface-Project-c0d1fbc0a6ab97424ab6067f17046bbf3e6007a7.tar.bz2
Common-Interface-Project-c0d1fbc0a6ab97424ab6067f17046bbf3e6007a7.zip
Changes done for close button to close simulation
-rw-r--r--blocks/eda-frontend/src/components/SchematicEditor/SimulationScreen.js55
-rw-r--r--blocks/simulationAPI/helpers/ngspice_helper.py28
-rw-r--r--blocks/simulationAPI/tasks.py6
-rw-r--r--blocks/simulationAPI/views.py2
4 files changed, 46 insertions, 45 deletions
diff --git a/blocks/eda-frontend/src/components/SchematicEditor/SimulationScreen.js b/blocks/eda-frontend/src/components/SchematicEditor/SimulationScreen.js
index e233b0e7..5b15ad1f 100644
--- a/blocks/eda-frontend/src/components/SchematicEditor/SimulationScreen.js
+++ b/blocks/eda-frontend/src/components/SchematicEditor/SimulationScreen.js
@@ -615,33 +615,34 @@ export default function SimulationScreen ({ open, close }) {
.get(url)
.then((res) => {
switch (res.data.state) {
- case 'PENDING':
- case 'STARTED':
- case 'RETRY':
- setIsResult(false)
- timeoutRef.current = setTimeout(() => simulationResult(url, streamingUrl, 10000), timeout)
- break
-
- case 'STREAMING':
- case 'SUCCESS':
- streamSimulationResult(streamingUrl)
- setIsResult(true)
- dispatch(setResultGraph({}))
- if (timeoutRef.current !== null) {
- clearTimeout(timeoutRef.current)
- timeoutRef.current = null
- }
- break
-
- case 'FAILURE':
- case 'CANCELED':
- setIsResult(true)
- dispatch(setErrorMessage(res.data.details))
- if (timeoutRef.current !== null) {
- clearTimeout(timeoutRef.current)
- timeoutRef.current = null
- }
- break
+ case 'PENDING':
+ case 'STARTED':
+ case 'RETRY':
+ setIsResult(false)
+ timeoutRef.current = setTimeout(() => simulationResult(url, streamingUrl, 10000), timeout)
+ break
+
+ case 'STREAMING':
+ case 'SUCCESS':
+ streamSimulationResult(streamingUrl)
+ setIsResult(true)
+ dispatch(setResultGraph({}))
+ if (timeoutRef.current !== null) {
+ clearTimeout(timeoutRef.current)
+ timeoutRef.current = null
+ }
+ break
+
+ case 'FAILURE':
+ case 'CANCELED':
+ setIsResult(true)
+ dispatch(setErrorMessage(res.data.details))
+ setGraphStatusDone()
+ if (timeoutRef.current !== null) {
+ clearTimeout(timeoutRef.current)
+ timeoutRef.current = null
+ }
+ break
default:
console.log('unhandled case', res)
diff --git a/blocks/simulationAPI/helpers/ngspice_helper.py b/blocks/simulationAPI/helpers/ngspice_helper.py
index 52cb356b..b41b13a9 100644
--- a/blocks/simulationAPI/helpers/ngspice_helper.py
+++ b/blocks/simulationAPI/helpers/ngspice_helper.py
@@ -50,27 +50,27 @@ class CannotRunParser(Exception):
""" Base class for exceptions in this module. """
-def update_task_status(task_id, status, meta=None):
- logger.info(f"status: {status} {task_id}")
+def update_task_status(task, task_id, status, meta=None):
# Update Celery backend state
- if current_task is not None:
+ if task is not None:
try:
- current_task.update_state(state=status, meta=meta or {})
+ task.update_state(state=status, meta=meta or {})
except Exception as e:
logger.error(f"Error updating Celery task state: {e}")
# Update Django database
- Task.objects.filter(task_id=task_id).update(
- status=status,
- start_time=Case(
- When(status__in=START_STATES, then=Value(now())),
- default=F("start_time")
- ),
- end_time=Case(
- When(status__in=END_STATES, then=Value(now())),
- default=F("end_time")
+ if task_id is not None:
+ Task.objects.filter(task_id=task_id).update(
+ status=status,
+ start_time=Case(
+ When(status__in=START_STATES, then=Value(now())),
+ default=F("start_time")
+ ),
+ end_time=Case(
+ When(status__in=END_STATES, then=Value(now())),
+ default=F("end_time")
+ )
)
- )
def CreateXml(file_path, parameters, task_id, workspace_file):
diff --git a/blocks/simulationAPI/tasks.py b/blocks/simulationAPI/tasks.py
index 8155b076..c76f5e91 100644
--- a/blocks/simulationAPI/tasks.py
+++ b/blocks/simulationAPI/tasks.py
@@ -37,13 +37,13 @@ def process_task(self, task_id):
state = 'STARTED'
status = 'Started Processing File'
- update_task_status(task_id, state, meta={'status': status})
+ update_task_status(self, task_id, state, meta={'status': status})
if task_type == 'SCRIPT':
output = uploadscript(task.session, task)
output = getscriptoutput(task.session, task)
state = 'SUCCESS'
- update_task_status(task_id, state, meta=output)
+ update_task_status(self, task_id, state, meta=output)
else:
output = ExecXml(task, self.name, task.workspace_file)
if output == "Streaming":
@@ -56,7 +56,7 @@ def process_task(self, task_id):
logger.error('%s', output)
raise CannotRunParser(output)
- update_task_status(task_id, state, meta={'status': status})
+ update_task_status(self, task_id, state, meta={'status': status})
return output
diff --git a/blocks/simulationAPI/views.py b/blocks/simulationAPI/views.py
index 63f819a2..8b44f3e2 100644
--- a/blocks/simulationAPI/views.py
+++ b/blocks/simulationAPI/views.py
@@ -388,7 +388,7 @@ class StreamView(APIView):
else:
logger.info('lines = %s, log size = %s', lineno, log_size)
- update_task_status(task_id, 'SUCCESS')
+ update_task_status(None, task_id, 'SUCCESS')
# Notify Client
yield "event: DONE\ndata: None\n\n"