Commit f9d61b3d authored by Maxime Perrotin's avatar Maxime Perrotin

Make progress bar more alive

parent 3a914e10
......@@ -60,12 +60,12 @@ fi
# Check if models are from V2 and convert to V1_3 accordingly
V2=0
grep "version => \"2" InterfaceView.aadl >/dev/null && {
echo '20 Analyse Interface View' > $myfifo
echo '0-40 Analyse Interface View' > $myfifo
echo -e "${INFO} Converting interface view from V2 to V1.3"
TASTE --load-interface-view InterfaceView.aadl --export-interface-view-to-1_3 __iv_1_3.aadl
INTERFACEVIEW=__iv_1_3.aadl
echo -e "${INFO} Converting deployment view from V2 to V1.3"
echo '40 Analyse Deployment View' > $myfifo
echo '40-60 Analyse Deployment View' > $myfifo
TASTE --load-deployment-view "$DEPLOYMENTVIEW" --export-deployment-view-to-1_3 __dv_1_3.aadl
DEPLOYMENTVIEW=__dv_1_3.aadl
V2=1
......@@ -85,13 +85,13 @@ AADL_PROPERTIES+="$(taste-config --prefix)/share/config_ellidiss/TASTE_DV_Proper
OCARINA_COMPONENTS="$(taste-config --prefix)/share/ocarina/AADLv2/ocarina_components.aadl"
# Tempdir will not be deleted - OS shall make the cleanup (likely at reboot)
echo '60 Parse Data View' > $myfifo
echo '60-80 Parse Data View' > $myfifo
tempdir=$(mktemp -d)
mono $(which taste-extract-asn-from-design.exe) -i "$INTERFACEVIEW" -j "$tempdir"/dataview-uniq.asn
asn2aadlPlus "$tempdir"/dataview-uniq.asn "$tempdir"/dataview-uniq.aadl -aadlv2
mono $(which taste-extract-asn-from-design.exe) -i "$INTERFACEVIEW" -k "$tempdir"/dataview-uniq.asn
DATAVIEW="$tempdir"/dataview-uniq.aadl
echo '80 Generate Concurrency View' > $myfifo
echo '80-100 Generate Concurrency View' > $myfifo
CMD="buildsupport -i ${INTERFACEVIEW}
-c ${DEPLOYMENTVIEW}
-d ${DATAVIEW}
......
......@@ -85,21 +85,21 @@ md5sum "$INTERFACEVIEW" > InterfaceView.md5
# Detect models from Ellidiss tools v2, and convert them to 1.3
grep "version => \"2" "$INTERFACEVIEW" >/dev/null && {
echo -e "${INFO} Converting interface view from V2 to V1.3"
echo '20 Analysing Interface View' > $myfifo
echo '0-40 Analysing Interface View' > $myfifo
cp -f "$INTERFACEVIEW" "$output_dir"/__interfaceview-v2.aadl
TASTE --load-interface-view "$output_dir"/__interfaceview-v2.aadl --export-interface-view-to-1_3 "$INTERFACEVIEW"
};
mkdir -p "$output_dir" 2>/dev/null && shift || output_dir=.
echo -e "${INFO} Collecting ASN.1 files"
echo '40 Collecting ASN.1 models' > $myfifo
echo '40-80 Collecting ASN.1 models' > $myfifo
mono $(which taste-extract-asn-from-design.exe) -i "$INTERFACEVIEW" -j "$output_dir"/dataview-uniq.asn
echo -e "${INFO} Generating AADL data view"
asn2aadlPlus "$output_dir"/dataview-uniq.asn "$output_dir"/dataview-uniq.aadl -aadlv2
asn2aadlPlus "$output_dir"/dataview-uniq.asn "$output_dir"/dataview-uniq-v1.aadl
mono $(which taste-extract-asn-from-design.exe) -i "$INTERFACEVIEW" -k "$output_dir"/dataview-uniq.asn
echo -e "${INFO} Parsing AADL and generating skeletons with buildsupport"
echo '80 Generate code skeletons' > $myfifo
echo '80-100 Generate code skeletons' > $myfifo
buildsupport -i "$INTERFACEVIEW" -d "$output_dir"/dataview-uniq.aadl --gw --aadlv2 -o "$output_dir" --keep-case "$AADL_PROPERTIES" "$@"
if [ $? -eq 0 ]
then
......
......@@ -9,7 +9,7 @@ from collections import deque
import PySide
from PySide import QtGui
from PySide.QtCore import QThread, Signal, QObject, Qt, Slot
from PySide.QtCore import QThread, Signal, QObject, Qt, Slot, QTimer
from PySide.QtGui import (QApplication,
QMessageBox,
......@@ -20,51 +20,63 @@ from PySide.QtGui import (QApplication,
log = deque()
class MyThread(QThread, QObject):
''' Thread waiting for data on stdin and sending signals to the prgress
bar in case something came in.
Text can be formatted:
* if the line starts with a number, it will use the value (range 0..100)
to update the progress bar, and it will display the text above the bar.
* if the line starts with @ERROR@ the process will stop and all the
history will be dispayed in a log dialog.
* in all other cases, the line is appended to the log
To update the bar, the line shall start with either a range or a numer.
e.g.
0-50 Doing something # The bar will progress from 0 to 49%
70 Something else # The bar will remain at 70%
Without a number/range, the text is only appended to the log
If the line starts with @ERROR@ the thread will stop
'''
text = Signal(str)
progress = Signal(int)
progress = Signal(int, int)
end = Signal()
error = Signal()
force_quit = False
def update_bar(self, from_value, to_value, text):
''' Request an update of the progress bar (value/range and text) '''
if 100 < from_value < 0 or 100 < to_value < 0:
return
self.progress.emit(from_value, to_value)
self.text.emit(text)
if from_value == 100:
self.end.emit()
self.force_quit = True
def run(self):
value = 10
while True:
# read from stdin without any buffering
if self.force_quit:
return
line = sys.stdin.readline()
if len(line) == 0:
print("Bye")
self.end.emit()
return
else:
split = line.split()
split = line.split(' ', 1)
try:
# check for format "NUMBER text"
possible_val = split[0]
value = int(possible_val)
if 100 < value < 0:
# check for a range format (e.g. 10-20)
left, right = split[0].split('-')
from_v, to_v = int(left), int(right)
if from_v > to_v:
raise ValueError
text = ' '.join(split[1:])
self.progress.emit(value)
self.text.emit(text)
if value == 100:
self.end.emit()
return
if 100 < from_v < 0 or 100 < to_v < 0:
raise ValueError
text = split[1]
self.update_bar(from_v, to_v, text)
except (ValueError, IndexError):
text = line
try:
# check for format "NUMBER text"
possible_val = split[0]
value = int(possible_val)
text = split[1]
self.update_bar(value, value, text)
except (ValueError, IndexError):
text = line
log.append(text)
try:
if split[0] == '@ERROR@':
......@@ -73,6 +85,7 @@ class MyThread(QThread, QObject):
except IndexError:
pass
class MyDialog(QDialog):
def __init__(self):
super(MyDialog, self).__init__()
......@@ -111,6 +124,21 @@ class MyDialog(QDialog):
def complete_or_cancel(self):
self.done = True
def periodic_update(self):
self.current_value += 5
if self.current_value >= self.target_value:
self.current_value = self.target_value - 1
else:
QTimer.singleShot(200, self.periodic_update)
self.bar.setValue(self.current_value)
@Slot(int, int)
def reach_target(self, from_value, to_value):
self.current_value = from_value
self.target_value = to_value
self.bar.setValue(self.current_value)
QTimer.singleShot(100, self.periodic_update)
def closeEvent(self, e):
if not self.done:
e.ignore()
......@@ -129,11 +157,11 @@ def run_gui():
progress.setValue(0)
thread.text.connect (dialog.label.setText)
thread.end.connect (dialog.complete_or_cancel)
thread.end.connect (dialog.close)
thread.progress.connect (progress.setValue)
thread.error.connect (handle_error)
thread.text.connect (dialog.label.setText)
thread.end.connect (dialog.complete_or_cancel)
thread.end.connect (dialog.close)
thread.progress.connect (dialog.reach_target)
thread.error.connect (handle_error)
thread.start()
dialog.exec_()
......
......@@ -91,7 +91,7 @@ DATAVIEW+=" $(taste-config --prefix)/share/taste-types/taste-types.asn"
# can asn2aadlPlus with a call to uniq to filter out duplicate outputs
# due to multiple calls to the ASN.1 compiler
#asn2aadlPlus $DATAVIEW "$AADL" -aadlv2 2>&1 | uniq >&2
echo '50 Updating data view' > $myfifo
echo '0-100 Updating data view' > $myfifo
asn2aadlPlus $DATAVIEW "$AADL" -aadlv2 2>&1 > >(uniq >&2)
echo '100 Completed' > $myfifo
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment