franca / franca

A framework for defining and transforming interfaces
Eclipse Public License 1.0
226 stars 72 forks source link

Usage of IDL enumerations and literals in deployment #214

Open moltob opened 7 years ago

moltob commented 7 years ago

Franca IDL allows defining enumerations like this:

typeCollection MyTypes {
    enumeration Status {
        STILL = 12
        UNKNOWN = 13
        INVALID = 15
    }
}

It would be great to allow using such enumerations (from the IDL) also in deployment specifications:

specification MySpec {
    for attributes {
        ReplacementValue: MyTypes.Status (default: MyTypes.Status.INVALID)
    }
}

Note that this is different from today's capabilities, where we have to define inline enumations as part of the deployment specification.

In many cases we will have one specifications like this, but for various types. In such a scenario it would be great to allow specifying "any enum literal" as new meta type, just like it's currently possible with meta types Interface and Instance (see grammar rule FdPredefinedTypeId). Then the above would become something like this:

specification MySpec {
    for attributes {
        ReplacementValue: EnumerationLiteral
    }
}

A generic default is obviously difficult here. Once could allow using an Integer value...

Then, the deployment definition would look like this:

define MySpec for interface SomeInterface {
    attribute myAttrib {
        ReplacementValue = MyTypes.Status.UNKNOWN
    }
}

Note that the deployment definition is not referencing an enumeration type, but one of its literals. That's why I suggested EnumerationLiteralas new meta type name and not Enumeration.

For our domains (AUTOSAR, classic automotive), enumerations are used widely and are usually defined as part of an interface. It would be very helpful to easily reuse those definitions and the corresponding literals in deployment models.

bhennlich commented 7 years ago

In Franca+ (https://github.com/GENIVI/franca_plus) is proposal included which accesses in the deployment Franca IDL defined consts and enumerations. See there the examples in https://github.com/GENIVI/franca_plus/tree/master/examples/org.franca.examples.components/defaults.