Trait hierarchy
A trait is a interface of labels that a vertex or edge must honor.
Exemplifying with the current “standard” ForSyDe IO trait hierarchy,
a trait AbstractDigitalComponent dictates that the node must possess an
integer property “nominal frequency in HZ”; Whereas a trait of SYComb dictates that the node
must be connected to another node in a port “combinator”.
The traits form a hierarchy (a tree) from least to most specific. For the sake of understanding, you can consider this trait hierarchy equal to class hierarchies from Object Oriented programming. The next figure showcases an example trait hierarchy which contains the examples mentioned in the previous paragraph.
As classes impose static structures to objects in Object-oriented programming, traits impose the minimum expected structures. A big difference is that a vertex can have multiple unrelated traits, giving it possible different aspects.
For example, suppose a trait hierarchy with two unrelated traits, Instrumented and Task.
A vertex that conforms to Instrumented must have an integer property called “global WCET”;
And a vertex that conforms to Task must have an integer property called “period”.
Assume now a system graph with a vertex Element1 that declares the traits Instrumented and Task.
Using the trait hierarchy just described, a consistent model (system graph + trait hierarchy),
requires Element1 to have at least the two properties listed. One such valid case would be the following
properties:
- period: an int of 20
- name: a string of “me”
- global WCET: an int of 10
Viewers
Viewers build upon trait hierarchies to transform a generic system graph into a typed object graph. In other words, “viewing” a vertex enables one to access its properties and ports just like it was a class in standard object oriented programming.
Take the same example previously given with Element1, Instrumented and Task.
Both Instrumented and Task traits have their viewers which temporarily transforms Element1
into an object of traits Instrumented and Task. The next image showcases with color coding
how the viewers enable one to know ahead-of-time the names of the properties and access them
in a type-safe manner.
The viewers layer is a key abstraction for two reasons:
- It enables cross-cutting modelling in the same model,
- It enables simple typed consumption of the generic system graph in statically typed languages.