summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSunil Shetye2025-02-03 12:48:10 +0530
committerSunil Shetye2025-02-03 12:48:10 +0530
commit4817d4505ac67a6d6ee7c698fc6ddbdbb86eb490 (patch)
treef4190bccc5db1c6409d2a8295844a5c7e059415c
parent80689be5b146b46bfa4a2d5e0d68f97c0b7fe755 (diff)
downloadCommon-Interface-Project-4817d4505ac67a6d6ee7c698fc6ddbdbb86eb490.tar.gz
Common-Interface-Project-4817d4505ac67a6d6ee7c698fc6ddbdbb86eb490.tar.bz2
Common-Interface-Project-4817d4505ac67a6d6ee7c698fc6ddbdbb86eb490.zip
add figure_id as key to lastlogtimes
-rw-r--r--blocks/.dockerignore3
-rw-r--r--blocks/simulationAPI/views.py17
2 files changed, 13 insertions, 7 deletions
diff --git a/blocks/.dockerignore b/blocks/.dockerignore
index 39bccca2..c4d35a5a 100644
--- a/blocks/.dockerignore
+++ b/blocks/.dockerignore
@@ -24,3 +24,6 @@ Xcos/xcosblocks.py
blocks/xcosblocks/xcosblocks.py
**/__pycache__
**/__snapshots__
+file_storage/*
+!file_storage/uploads
+file_storage/uploads/*
diff --git a/blocks/simulationAPI/views.py b/blocks/simulationAPI/views.py
index 74603a0e..44f19a77 100644
--- a/blocks/simulationAPI/views.py
+++ b/blocks/simulationAPI/views.py
@@ -161,7 +161,8 @@ def parse_line(line, lineno):
return (None, NOLINE)
-def get_line_and_state(file, figure_list, lineno, incomplete_line):
+def get_line_and_state(file, figure_list, lastlogtimes,
+ lineno, incomplete_line):
'''
Function to get a new line from file
This also parses the line and appends new figures to figure List
@@ -180,6 +181,7 @@ def get_line_and_state(file, figure_list, lineno, incomplete_line):
# New figure created
# Add figure ID to list
figure_list.append(figure_id) # figure id of block is added to list
+ lastlogtimes[figure_id] = -1
line = None
elif state == ENDING:
# End of figure
@@ -187,10 +189,11 @@ def get_line_and_state(file, figure_list, lineno, incomplete_line):
# Once ending of log file/data is encountered for that block, figure id
# will be removed
figure_list.remove(figure_id)
+ del lastlogtimes[figure_id]
line = None
elif state == NOLINE:
line = None
- return (line, state)
+ return (line, figure_id, state)
class StreamView(APIView):
@@ -252,17 +255,17 @@ class StreamView(APIView):
self.duplicatelineno = 0
self.duplicatelines = 0
lastline = ''
- lastlogtime = -1
lineno = 0
line = None
starttime = time.time()
endtime = starttime + SCILAB_INSTANCE_TIMEOUT_INTERVAL
log_size = 0
figure_list = []
+ lastlogtimes = {}
while time.time() <= endtime and log_size <= MAX_LOG_SIZE:
- (line, state) = get_line_and_state(log_file, figure_list,
- lineno, line)
+ (line, figure_id, state) = get_line_and_state(log_file, figure_list, lastlogtimes,
+ lineno, line)
# if incomplete line, wait for the complete line
if state == NOLINE:
time.sleep(LOOK_DELAY)
@@ -282,10 +285,10 @@ class StreamView(APIView):
if len(words) == 15 and words[-1] == 'CSCOPE':
logtime = float(words[8])
totallogtime = float(words[-2])
- if logtime < lastlogtime + 0.001 * totallogtime:
+ if logtime < lastlogtimes[figure_id] + 0.001 * totallogtime:
line = None
continue
- lastlogtime = logtime
+ lastlogtimes[figure_id] = logtime
interval = starttime + logtime - time.time() - 0.1
if interval > 0:
time.sleep(interval)