Commit f9d61b3d authored by Maxime Perrotin's avatar Maxime Perrotin

Make progress bar more alive

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