taste-edit-concurrency-view 4.63 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 10 11 12 13 14
# Initialise the progress bar
myfifo=/tmp/$$$RANDOM
mkfifo $myfifo
tail -f $myfifo | taste-progress-dialog.py &

function quit {
    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
}
15

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

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
38
        echo -e "${INFO} Using InterfaceView.aadl, DeploymentView.aadl, DataView.aadl (defaults)"
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
39 40 41 42 43
	INTERFACEVIEW=InterfaceView.aadl
        DEPLOYMENTVIEW=DeploymentView.aadl
        DATAVIEW=DataView.aadl
    else
        error=1
Maxime Perrotin's avatar
Maxime Perrotin committed
44
        echo -e "${ERROR} Missing files (need InterfaceView.aadl, DeploymentView.aadl, DataView.aadl)"
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
45 46 47 48 49
    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
50
        echo -e "${INFO} Loading interface, deployment and data views: $1 $2 $3"
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
51 52 53 54 55
        INTERFACEVIEW="$1"
        DEPLOYMENTVIEW="$2"
        DATAVIEW="$3"
    else
        error=1
Maxime Perrotin's avatar
Maxime Perrotin committed
56
        echo -e "${ERROR} Specified files missing or wrong number of parameters"
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
57 58 59
    fi
fi

Maxime Perrotin's avatar
Maxime Perrotin committed
60 61 62
# 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
63
    echo '20 Analyse Interface View' > $myfifo
Maxime Perrotin's avatar
Maxime Perrotin committed
64 65 66 67
    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
68
    echo '40 Analyse Deployment View' > $myfifo
Maxime Perrotin's avatar
Maxime Perrotin committed
69 70 71 72 73 74
    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
75 76
if [ $error -eq 1 ]
then
Maxime Perrotin's avatar
Maxime Perrotin committed
77 78
    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
79 80
    echo '100 Error' > $myfifo
    quit 1
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
81 82 83 84 85 86 87
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
88
echo '60 Parse Data View' > $myfifo
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
89
tempdir=$(mktemp -d)
90
mono $(which taste-extract-asn-from-design.exe) -i "$INTERFACEVIEW" -j "$tempdir"/dataview-uniq.asn
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
91
asn2aadlPlus "$tempdir"/dataview-uniq.asn "$tempdir"/dataview-uniq.aadl -aadlv2
92
mono $(which taste-extract-asn-from-design.exe) -i "$INTERFACEVIEW" -k "$tempdir"/dataview-uniq.asn
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
93
DATAVIEW="$tempdir"/dataview-uniq.aadl
Maxime Perrotin's avatar
Maxime Perrotin committed
94
echo '80 Generate Concurrency View' > $myfifo
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
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
118
    echo -e "${ERROR} The following command failed:
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
119 120
${CMD}
"
Maxime Perrotin's avatar
Maxime Perrotin committed
121
    echo -e "${ERROR} Buildsupport reported errors - Fix your models before you can edit the Concurrency View"
Maxime Perrotin's avatar
Maxime Perrotin committed
122 123
    echo '100 Error' > $myfifo
    quit 2
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
124 125 126 127 128 129 130 131 132 133 134
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
135 136 137 138

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

Maxime Perrotin's avatar
Maxime Perrotin committed
144
echo '100 Done' >  $myfifo
145

Maxime Perrotin's avatar
Maxime Perrotin committed
146
quit 0