taste-create-data-view 2.08 KB
Newer Older
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
1 2
#!/bin/bash -e

Maxime Perrotin's avatar
Maxime Perrotin committed
3 4 5 6 7 8 9 10 11 12 13 14
# TASTE Dataview Editor

if [ -t 0 ] ; then
    COLORON="\e[1m\e[32m"
    REDCOLORON="\e[1m\e[31m"
    COLOROFF="\e[0m"
else
    COLORON=""
    REDCOLORON=""
    COLOROFF=""
fi

15 16
INFO="${COLORON}[INFO]${COLOROFF}"
ERROR="${REDCOLORON}[ERROR]${COLOROFF}"
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
17 18 19 20 21 22 23 24 25 26 27 28 29


# Find a suitable text editor, in order of priority: kate, gvim, vi
if [ ! -z $(which kate) ]
then
    EDITOR="kate -n"
elif [ ! -z $(which gvim) ]
then
    EDITOR="gvim -f"
else
    EDITOR=vi
fi

Maxime Perrotin's avatar
Maxime Perrotin committed
30 31 32 33 34 35
if [ -f "DataView.asn" ]
then
    if [ -z $NONINTERACTIVE ]
    then
        echo -e "${INFO} Opening existing DataView.asn"
    fi
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
36
else
Maxime Perrotin's avatar
Maxime Perrotin committed
37 38 39 40
    if [ -z $NONINTERACTIVE ]
    then
        echo -e "${INFO} Creating a dummy ASN.1 file with a few type examples - feel free to add, edit, delete..."
    fi
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
41 42 43 44
    echo 'TASTE-Dataview DEFINITIONS ::=
BEGIN
IMPORTS T-Int32, T-UInt32, T-Int8, T-UInt8, T-Boolean FROM TASTE-BasicTypes;

Maxime Perrotin's avatar
Maxime Perrotin committed
45 46 47
-- ASN.1 Type definitions must start with an uppercase
-- Field names in records (SEQUENCE) must start with a lowercase
-- Underscores are not allowed: use dash (hyphen) 
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
48

Maxime Perrotin's avatar
Maxime Perrotin committed
49
-- Simple types:
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
50

Maxime Perrotin's avatar
Maxime Perrotin committed
51 52
MyInteger   ::= INTEGER (0..255)
MyReal      ::= REAL (0.0 .. 1000.0)
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
53
MyBool      ::= BOOLEAN
Maxime Perrotin's avatar
Maxime Perrotin committed
54
MyEnum      ::= ENUMERATED { hello, world, how-are-you }
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
55

Maxime Perrotin's avatar
Maxime Perrotin committed
56
-- Complex types:
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82

MySeq       ::= SEQUENCE {
    input-data  MyInteger,
    output-data MyInteger,
    validity    ENUMERATED { valid, invalid }
}

MyChoice    ::= CHOICE {
    a BOOLEAN,
    b MySeq
}

MySeqOf     ::= SEQUENCE (SIZE (2)) OF MyEnum

MyOctStr    ::= OCTET STRING (SIZE (3))

-- You can also declare constants
myVar       MySeqOf     ::= { hello, world }

END
' > DataView.asn
fi

if [ -z $NONINTERACTIVE ]
then
    $EDITOR DataView.asn
Maxime Perrotin's avatar
Maxime Perrotin committed
83
    echo -e "${INFO} Converting the data view to AADL..."
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
84 85 86 87 88 89 90 91
fi

cp $(taste-config --prefix)/share/taste-types/taste-types.asn .

taste-update-data-view

if [ -z $NONINTERACTIVE ]
then
Maxime Perrotin's avatar
Maxime Perrotin committed
92 93 94 95
    echo -e "${INFO} Data View created"
    echo -e "${INFO} Run taste-edit-data-view to edit"
    echo -e "${INFO}     taste-create-acn-model to specify binary encodings with ACN"
    echo -e "${INFO}     taste-create-project to create a new TASTE project"
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
96
fi