taste-edit-concurrency-view 4.65 KB
Newer Older
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
1
#!/bin/bash
Maxime Perrotin's avatar
Maxime Perrotin committed
2
3
# TASTE Concurrency View Creator

Maxime Perrotin's avatar
Maxime Perrotin committed
4
5
6
7
8
9
# Initialise the progress bar
myfifo=/tmp/$$$RANDOM
mkfifo $myfifo
tail -f $myfifo | taste-progress-dialog.py &

function quit {
10
    echo '100 Done' > $myfifo
Maxime Perrotin's avatar
Maxime Perrotin committed
11
12
13
14
15
    rm $myfifo
    tailps=$(pstree -p $$ | grep tail | python -c "import sys, re; print re.search(r'tail\((.*)\)', [x for x in sys.stdin][0]).group(1)")
    kill $tailps || xterm -e "echo Internal Error, unable to kill subprocess. Open a terminal and type 'pkill tail' to (hopefully) recover"
    exit $1
}
16

Maxime Perrotin's avatar
Maxime Perrotin committed
17
18
19
# Logging with colors (only in a terminal)
if [ -t 1 ] ; then
    COLORON="\e[1m\e[32m"
Maxime Perrotin's avatar
Maxime Perrotin committed
20
    REDCOLORON="\e[1m\e[31m"
Maxime Perrotin's avatar
Maxime Perrotin committed
21
22
23
    COLOROFF="\e[0m"
else
    COLORON=""
Maxime Perrotin's avatar
Maxime Perrotin committed
24
    REDCOLORON=""
Maxime Perrotin's avatar
Maxime Perrotin committed
25
26
27
    COLOROFF=""
fi
INFO="${COLORON}[INFO]${COLOROFF}"
Maxime Perrotin's avatar
Maxime Perrotin committed
28
ERROR="${REDCOLORON}[ERROR]${COLOROFF}"
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
29
30
31
32
33
34
35
36
37
38

error=0
NB_ARGS=3
AUTO=0

# If there are no parameters, take default names for Interface, Deployment and Data view
if [ $# -eq $AUTO ]
then
    if [[ -f InterfaceView.aadl && -f DeploymentView.aadl && -f DataView.aadl ]]
    then
Maxime Perrotin's avatar
Maxime Perrotin committed
39
        echo -e "${INFO} Using InterfaceView.aadl, DeploymentView.aadl, DataView.aadl (defaults)"
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
40
41
42
43
44
	INTERFACEVIEW=InterfaceView.aadl
        DEPLOYMENTVIEW=DeploymentView.aadl
        DATAVIEW=DataView.aadl
    else
        error=1
Maxime Perrotin's avatar
Maxime Perrotin committed
45
        echo -e "${ERROR} Missing files (need InterfaceView.aadl, DeploymentView.aadl, DataView.aadl)"
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
46
47
48
49
50
    fi
else
    # Check if there are 3 parameters and that the files are all present
    if [[ $# -eq $NB_ARGS && -f "$1" && -f "$2" && -f "$3" ]]
    then
Maxime Perrotin's avatar
Maxime Perrotin committed
51
        echo -e "${INFO} Loading interface, deployment and data views: $1 $2 $3"
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
52
53
54
55
56
        INTERFACEVIEW="$1"
        DEPLOYMENTVIEW="$2"
        DATAVIEW="$3"
    else
        error=1
Maxime Perrotin's avatar
Maxime Perrotin committed
57
        echo -e "${ERROR} Specified files missing or wrong number of parameters"
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
58
59
60
    fi
fi

Maxime Perrotin's avatar
Maxime Perrotin committed
61
62
63
# Check if models are from V2 and convert to V1_3 accordingly
V2=0
grep "version => \"2" InterfaceView.aadl >/dev/null && {
Maxime Perrotin's avatar
Maxime Perrotin committed
64
    echo '0-40 Analyse Interface View' > $myfifo
Maxime Perrotin's avatar
Maxime Perrotin committed
65
66
67
68
    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"
Maxime Perrotin's avatar
Maxime Perrotin committed
69
    echo '40-60 Analyse Deployment View' > $myfifo
Maxime Perrotin's avatar
Maxime Perrotin committed
70
71
72
73
74
75
    TASTE --load-deployment-view "$DEPLOYMENTVIEW" --export-deployment-view-to-1_3 __dv_1_3.aadl
    DEPLOYMENTVIEW=__dv_1_3.aadl
    V2=1
};


Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
76
77
if [ $error -eq 1 ]
then
Maxime Perrotin's avatar
Maxime Perrotin committed
78
79
    echo -e "${ERROR} If you are using custom names for interface, deployment and data views, please specify them in order:
Usage: taste-edit-concurrency-view InterfaceView.aadl DeploymentView.aadl DataView.aadl"
Maxime Perrotin's avatar
Maxime Perrotin committed
80
81
    echo '100 Error' > $myfifo
    quit 1
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
82
83
84
85
86
87
88
fi

AADL_PROPERTIES="$(taste-config --prefix)/share/config_ellidiss/TASTE_IV_Properties.aadl "
AADL_PROPERTIES+="$(taste-config --prefix)/share/config_ellidiss/TASTE_DV_Properties.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)
Maxime Perrotin's avatar
Maxime Perrotin committed
89
echo '60-80 Parse Data View' > $myfifo
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
90
tempdir=$(mktemp -d)
91
mono $(which taste-extract-asn-from-design.exe) -i "$INTERFACEVIEW" -j "$tempdir"/dataview-uniq.asn
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
92
asn2aadlPlus "$tempdir"/dataview-uniq.asn "$tempdir"/dataview-uniq.aadl -aadlv2
93
mono $(which taste-extract-asn-from-design.exe) -i "$INTERFACEVIEW" -k "$tempdir"/dataview-uniq.asn
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
94
DATAVIEW="$tempdir"/dataview-uniq.aadl
Maxime Perrotin's avatar
Maxime Perrotin committed
95
echo '80-100 Generate Concurrency View' > $myfifo
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
CMD="buildsupport -i ${INTERFACEVIEW}
                  -c ${DEPLOYMENTVIEW}
                  -d ${DATAVIEW}
                  ${AADL_PROPERTIES}
                  ${OCARINA_COMPONENTS}
                  -glue
                  -gw
                  -o ${tempdir}"

[ ! -z $DEBUG ] && echo "${CMD}"

# Execute buildsupport:
$CMD

if [ $? -eq 0 ]
then
    PROCESS="$tempdir"/ConcurrencyView/process.aadl
    for file in "$tempdir"/ConcurrencyView/*_Thread.aadl
    do
        PROCESS+=,$file
    done
    PROCESS+=,$OCARINA_COMPONENTS
else
Maxime Perrotin's avatar
Maxime Perrotin committed
119
    echo -e "${ERROR} The following command failed:
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
120
121
${CMD}
"
Maxime Perrotin's avatar
Maxime Perrotin committed
122
    echo -e "${ERROR} Buildsupport reported errors - Fix your models before you can edit the Concurrency View"
Maxime Perrotin's avatar
Maxime Perrotin committed
123
124
    echo '100 Error' > $myfifo
    quit 2
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
125
126
127
128
129
130
131
132
133
134
135
fi

echo 'Running the Concurrency View editor from TASTE
From this tool you may:

- Verify the schedulability of your system with CHEDDAR
- Simulate the real-time architecture with MARZHIN
- Edit the thread priorities, stack size and offset/phase'

PROPERTIES=ConcurrencyView.pro
[ ! -z $DEBUG ] && echo TASTE-CV --edit-aadl $PROCESS --update-properties $PROPERTIES
Maxime Perrotin's avatar
Maxime Perrotin committed
136
137
138
139

if [ $V2 -eq 0 ]
then
    TASTE-CV  --edit-aadl $PROCESS --update-properties $PROPERTIES 
140
141
142
else
    rm -rf ConcurrencyView
    mv "$tempdir"/ConcurrencyView .
Maxime Perrotin's avatar
Maxime Perrotin committed
143
144
fi

Maxime Perrotin's avatar
Maxime Perrotin committed
145
quit 0