taste-edit-concurrency-view 4.77 KB
Newer Older
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 Completed' > $myfifo
Maxime Perrotin's avatar
Maxime Perrotin committed
11
    rm $myfifo
12 13 14 15 16 17 18
    tailps=$(pstree -p $$ | grep tail | python -c "try:
    import sys, re; print re.search(r'tail\((.*)\)', [x for x in sys.stdin][0]).group(1)
except: pass")
    if [ ! -z $tailps ]
    then
        kill $tailps || xterm -e "echo Internal Error in taste-update-data-view"
    fi
Maxime Perrotin's avatar
Maxime Perrotin committed
19 20
    exit $1
}
21

22 23 24
# Install a trap handler to make sure Ctrl-C leads to calling the quit function (trap 2 = SINGINT)
trap 2 quit 1

Maxime Perrotin's avatar
Maxime Perrotin committed
25 26 27
# Logging with colors (only in a terminal)
if [ -t 1 ] ; then
    COLORON="\e[1m\e[32m"
Maxime Perrotin's avatar
Maxime Perrotin committed
28
    REDCOLORON="\e[1m\e[31m"
Maxime Perrotin's avatar
Maxime Perrotin committed
29 30 31
    COLOROFF="\e[0m"
else
    COLORON=""
Maxime Perrotin's avatar
Maxime Perrotin committed
32
    REDCOLORON=""
Maxime Perrotin's avatar
Maxime Perrotin committed
33 34 35
    COLOROFF=""
fi
INFO="${COLORON}[INFO]${COLOROFF}"
Maxime Perrotin's avatar
Maxime Perrotin committed
36
ERROR="${REDCOLORON}[ERROR]${COLOROFF}"
37 38 39 40 41 42 43 44 45 46

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
47
        echo -e "${INFO} Using InterfaceView.aadl, DeploymentView.aadl, DataView.aadl (defaults)"
48
        INTERFACEVIEW=InterfaceView.aadl
49 50 51 52
        DEPLOYMENTVIEW=DeploymentView.aadl
        DATAVIEW=DataView.aadl
    else
        error=1
Maxime Perrotin's avatar
Maxime Perrotin committed
53
        echo -e "${ERROR} Missing files (need InterfaceView.aadl, DeploymentView.aadl, DataView.aadl)"
54 55 56 57 58
    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
59
        echo -e "${INFO} Loading interface, deployment and data views: $1 $2 $3"
60 61 62 63 64
        INTERFACEVIEW="$1"
        DEPLOYMENTVIEW="$2"
        DATAVIEW="$3"
    else
        error=1
Maxime Perrotin's avatar
Maxime Perrotin committed
65
        echo -e "${ERROR} Specified files missing or wrong number of parameters"
66 67 68
    fi
fi

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


84 85
if [ $error -eq 1 ]
then
Maxime Perrotin's avatar
Maxime Perrotin committed
86 87
    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
88 89
    echo '100 Error' > $myfifo
    quit 1
90 91 92 93 94 95 96
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)
97
echo '60-80 Parse Data View' > $myfifo
98
tempdir=$(mktemp -d)
99
mono $(which taste-extract-asn-from-design.exe) -i "$INTERFACEVIEW" -j "$tempdir"/dataview-uniq.asn
100
asn2aadlPlus "$tempdir"/dataview-uniq.asn "$tempdir"/dataview-uniq.aadl -aadlv2
101
mono $(which taste-extract-asn-from-design.exe) -i "$INTERFACEVIEW" -k "$tempdir"/dataview-uniq.asn
102
DATAVIEW="$tempdir"/dataview-uniq.aadl
103
echo '80-100 Generate Concurrency View' > $myfifo
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126
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
127
    echo -e "${ERROR} The following command failed:
128 129
${CMD}
"
Maxime Perrotin's avatar
Maxime Perrotin committed
130
    echo -e "${ERROR} Buildsupport reported errors - Fix your models before you can edit the Concurrency View"
Maxime Perrotin's avatar
Maxime Perrotin committed
131 132
    echo '100 Error' > $myfifo
    quit 2
133 134 135 136 137 138 139 140 141 142 143
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
144 145 146 147

if [ $V2 -eq 0 ]
then
    TASTE-CV  --edit-aadl $PROCESS --update-properties $PROPERTIES 
148 149 150
else
    rm -rf ConcurrencyView
    mv "$tempdir"/ConcurrencyView .
Maxime Perrotin's avatar
Maxime Perrotin committed
151 152
fi

Maxime Perrotin's avatar
Maxime Perrotin committed
153
quit 0