taste-create-data-view 2.01 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

Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
15 16 17 18 19 20 21 22 23 24 25 26 27


# 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
28 29 30 31 32 33
if [ -f "DataView.asn" ]
then
    if [ -z $NONINTERACTIVE ]
    then
        echo -e "${INFO} Opening existing DataView.asn"
    fi
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
34
else
Maxime Perrotin's avatar
Maxime Perrotin committed
35 36 37 38
    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
39 40 41 42
    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
43 44 45
-- 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
46

Maxime Perrotin's avatar
Maxime Perrotin committed
47
-- Simple types:
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
48

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

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

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
81
    echo -e "${INFO} Converting the data view to AADL..."
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
82 83 84 85 86 87 88 89
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
90 91 92 93
    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
94
fi