Fixing the index numbering
[AGL/documentation.git] / docs / 6_Component_Documentation / 4_rba.md
1 ---
2 title: Rule Based Arbitrator (RBA)
3 ---
4
5 # RBA
6
7 Rule Based Arbitrator decides which of the content to display when a large number of contents to be displayed on the cockpit display device (CID, meter, HUD, etc.) occur simultaneously under a certain rule (arbitration).
8
9 ### 1. Overview
10
11 #### 1.1 Purpose of this document
12
13 This document describes the syntax of the Rule-based Arbitration Model.
14
15 #### 1.2 Basic syntax
16
17 The basic syntax of the Rule-based Arbitration Model is as follows.
18
19 ![Basic syntax](images/rba/Basic_syntax.png)
20
21 Define the properties of the model element in {} after declaration of Model element keyword, Model element ID. Each property depends on the element. The properties of the model element may also define other model elements.
22
23 #### 1.3 Relationship between files and Model definitions
24
25 The Rule-based Arbitration Model can be defined in multiple files. (The extension of the file will be ".rba") Firstly, define the Package model element in the file.
26
27 Areas.rba
28 ```shell
29 Package AreasPackage {
30
31 }
32 ```
33 Content.rba
34 ```shell
35 Package ContentsPackage {
36
37 }
38 ```
39
40 #### 1.4 Structure of Rule-based Arbitration Model
41
42 The elements of the Rule-based Arbitration Model are as follows. Each inheritance relationship between elements is defined and expresses elements that can be described in PackagableElement.
43
44 ![model](images/rba/model.png)
45
46 #### 1.5 Notation of Syntax Definition
47
48 For Model element
49
50 syntax:
51 ```shell
52 Package [ID] {
53   description: [String]
54   [PackagableElement]
55 }
56 ```
57
58 Description:
59
60 | Syntax element            | Description  |
61 | :---                      |    :----     |
62 | description:  0..1        | Description  |
63 | [PackagableElement]   *   | Child element Package,Display,Size,Constraint,PostConstraint,Scene,Event,Rule,Area,AreaSet,ViewContent,ViewContentSet|
64
65 The multiplicity is expressed as follows:
66
67 | Expression of multiplicity    | Description |
68 | :---                          | :---        |
69 | *                             | 0 or more   |
70 | 1..*                          | 1 or more   |
71 | 1                             | 1           |
72 | 0..1                          | 0 or 1      |
73
74 Description of [] notation is as follows:
75
76 | Syntax element            | Description  |
77 | :---                      |    :----     |
78 | [ID]                      | ID. A character string in which the first character is not a number. Only _ can be used for symbols, Space cannot be used.
79 | [String]                  | An arbitrary character string. specify it by enclosing with "". |
80 | [Number]                  | An integer that is greater than equal 0. |
81 | [expression]              | An expression whose return value is a property type. |
82 | [<Model element keyword\>] | Definition of other Model elements. Sometimes an abstract class is specified. |
83 | [ID of A]                 | Reference to other Model elements. A represents an element. |
84 | [X\|Y]                    | Indicates that you can describe X or Y. |
85
86 ### 2. Common
87
88 #### 2.1 Package
89
90 The Package element is the root element in the file. It has PackagableElement as a Child element and groups PackagableElements in arbitrary units.
91
92 syntax:
93 ```shell
94 Package [ID] {
95   description: [String]
96   [PackagableElement]
97 }
98 ```
99
100 | Syntax element            | Description  |
101 | :---                      |    :----     |
102 | description:  0..1        | Description  |
103 | [PackagableElement]   *   | Child element Package,Display,Size,Constraint,PostConstraint,Scene,Event,Rule,Area,AreaSet,ViewContent,ViewContentSet|
104
105 Description example:
106 ```shell
107 Package SamplePackage {
108         description: "This is a sample Packege"
109         Area SampleArea {
110                 arbitrationPolicy: DEFAULT
111                 sizeReference: SampleSize1
112                 visibility: NONE_VALUE
113                 zorder: 3
114         }
115         ViewContent SampleContent {
116                 allocatable: [SampleArea1]
117                 State NORMAL {
118                         priority: STANDARD_VALUE
119                 }
120         }
121 }
122 ```
123
124 #### 2.2 Size
125
126 Size is the size of Area and ViewContent.
127
128 Syntax:
129
130 ```shell
131 Size [ID] {
132   description: [String]
133   width: [Number]
134   height: [Number]
135 }
136 ```
137
138 | Syntax element            | Description  |
139 | :---                      |    :----     |
140 | description:  0..1        | Description of Size element |
141 | width: 1                  | width  |
142 | height:       1           | height |
143
144 Description example:
145 ```shell
146 Size ScreenSize {
147         description: " Screen size"
148         width: 200
149         height: 200
150 }
151 ```
152
153 #### 2.3 Project
154
155 The Project element is an element that can be defined only once in one project.
156 Like The Package element, it can be defined directly under the file.
157
158 Syntax:
159 ```shell
160 Project {
161   version: [String]
162 }
163 ```
164
165 | Syntax element            | Description  |
166 | :---                      |    :----     |
167 |version:       1|      Version of the Project|
168
169 Description example:
170 ```shell
171 Project {
172         version: "version 1.0"
173 }
174 ```
175
176
177 ### 3. Area
178
179 Area is a frame to display the ViewContent on the screen. Only one ViewContent is allocated to one Area at most. Since Arbitration is executed for each Area, the Arbitration Policy is defined.
180
181 Syntax:
182
183 ```shell
184 Area [ID] {
185   description: [String]
186   arbitrationPolicy: [DEFAULT | FIRST_COME_FIRST | LAST_COME_FIRST | PRIORITY_FIRST_COME_FIRST | PRIORITY_LAST_COME_FIRST]
187   [[Size]| sizeReference:[ID of Size]]
188   [visibility|priority]:[Number|Expression]
189   zorder:[Number|Expression]
190 }
191 ```
192
193 | Syntax element |      Description |
194 | :---                      |    :----     |
195 | description:  0..1 | Description |
196 | arbitrationPolicy: 0..1 | Arbitration Policy for Area. Refer to "Types of Arbitration Policy" for the policies which can be specified. If not specified, consider it as "DEFAULT".
197 | [Size\|sizeReference:]        1..* | Size: Size definition.|
198 || sizeReference: Reference to Size definition.|
199 || ※One or more definitions of either Size or sizeReference are needed. Multiple definitions should be defined consecutively.|
200 | [visibility\|priority]:       1       | Value of Area. Describe the relative value for other Areas as an expression or set a numerical value.|
201 || The following predefined value can be set as a String. NONE_VALUE, STANDARD_VALUE, MIN_VALUE, MAX_VALUE See " Value / Z order definition" for details. |
202 | zorder:       1 | Z order of Area. Describe the relative Z order for other Areas as an expression or set a numerical value. The following predefined value can be set as a String. |
203 ||NONE_VALUE, STANDARD_VALUE, MIN_VALUE, MAX_VALUE See " Value / Z order definition" for details. |
204
205
206
207 Types of Arbitration Policy
208
209 | Arbitration Policy           | Description  |
210 | :---                      |    :----     |
211 | DEFAULT | Same as Priority and First Come First Arbitration. If the Arbitration Policy is not specified, it will be this type.|
212 | FIRST_COME_FIRST | First Come First Arbitration. Give priority to the request which occurred first. |
213 | LAST_COME_FIRST | Last Come First Arbitration. Give priority to the request which occurred later. |
214 | PRIORITY_FIRST_COME_FIRST | Priority and First Come First Arbitration. It follows the priority set to the Content. If the priority is the same, give priority to the request which occurred first. |
215 | PRIORITY_LAST_COME_FIRST | Priority and Last Come First Arbitration. It follows the priority set to the Content. If the priority is the same, give priority to the request which occurred later.|
216
217 Description example:
218 ```shell
219 Area SampleArea {
220         description: "This is a sample Area."
221         arbitrationPolicy: DEFAULT
222         Size Default {
223                 width: 200
224                 height: 150
225         }
226         sizeReference: SampleSize1
227         visibility: NONE_VALUE
228         zorder: 3
229 }
230 ```
231
232 ### 4. Value / Z order definition
233
234 Values (visibility or priority) of area is the order of arbitrating of the area. The higher is arbitrated first. You can describe only one of the visibility or priority.
235 For the Z order (zorder), the higher one will be on the front of the screen. You can define values absolutely by number or define relatively to other areas by expressions. You can use comparison operators (> and <), equality operator (=) and That-of operator for the expressions.
236
237 - Description example of value :
238 Visibility of SampleArea2 is 10, zorder is 5.
239 ```shell
240 Area SampleArea2 {
241         visibility: 10
242         zorder: 5
243 }
244 ```
245 - Description example of comparison operator:
246 Priority of SampleArea1 is greater than SampleArea2. Zorder of SampleArea1 is less than SampleArea3.
247 ```shell
248 Area SampleArea1 {
249         priority: > That-of SampleArea1
250         zorder: < That-of SampleArea3
251 }
252 ```
253 - Description example of range:
254 Visibility of SampleArea1 is greater than 1 and less than SampleArea2. Zorder of SampleArea1 is greater than SampleArea3 and less than SampleArea4.
255 ```shell
256 Area SampleArea1 {
257         visibility: (> 1 AND < That-of SampleArea2)
258         zorder: (> That-of SampleArea3 AND < That-of SampleArea4)
259 }
260 ```
261
262 - Description example of equality operator:
263 ```shell
264 Area SampleArea1 {
265         visibility: = That-of SampleArea2
266         zorder: = That-of SampleArea3 + That-of SampleArea2
267 }
268 ```
269
270 - Equality operator can be omitted.
271 ```shell
272 Area SampleArea1 {
273         visibility: That-of SampleArea2
274         zorder: That-of SampleArea3 + That-of SampleArea2
275 }
276 ```
277
278 ### 5. ViewContent definition
279
280 #### 5.1 ViewContent
281
282 ViewContent is an object to be displayed in the Area. ViewContent has multiple states. When ViewContent is allocated to an Area, active state of theViewContent is displayed. Define the Area which can display ViewContent to the ViewContent. You can define several Areas.
283
284 Syntax:
285 ```shell
286 ViewContent [ID] {
287   description: [String]
288   allocatable: [ [ID of Area] | [ID of Set] ]
289   [ViewContentState]
290   [[Size]|sizeReference: [ID of Size]]
291   loserType: [GOOD_LOSER | DO_NOT_GIVEUP_UNTIL_WIN | NEVER_GIVEUP]
292 }
293 ```
294
295 |Syntax element |       Description|
296 | :---              |    :----     |
297 |description:   0..1 | Description|
298 |allocatable:   0..* |  Displayable Area. Specify the ID of displayable Areas or Sets with comma-separated.If don’t specify allocatable, should specify allocatable in the ViewContentSet that includes this ViewContent. |
299 | [ViewContentState]    1..* |Define the State of ViewContent.|
300 |[Size\|sizeReference:] 1..*|Size: Size definition|
301 ||sizeReference: Reference to Size definition.|
302 ||※One or more definitions of either Size or sizeReference are needed. Multiple definitions should be defined consecutively.|
303 |loserType:     0..1| Action on lost. Specify whether to cancel a request, if ViewContent is not displayed after arbitration. See "Types of Action on lost" for details. If not defined, consider it as "NEVER_GIVEUP".|
304
305 Types of Action on lost
306
307 |loserType |    Description|
308 | :---              |    :----     |
309 |GOOD_LOSER     |When losing arbitration, cancel a request.|
310 |DO_NOT_GIVEUP_UNTIL_WIN |When the state is changed visible to invisible , cancel a request.|
311 |NEVER_GIVEUP|Keep a request.|
312
313 Description example:
314 ```shell
315 ViewContent Power {
316 description: " Warning from power management"
317   allocatable: [
318     MessageArea, HUDMessageArea
319   ]
320   State Warning {
321     priority: > That-of Power.Attention
322   }
323   State Attention {
324     priority: > That-of TEL.Incoming
325   }
326 Size Default {
327 description: "Default size"
328 width: 200
329 height: 200
330 }
331   sizeReference: InterruptMessageSize
332   loserType: GOOD_LOSER
333 }
334 ```
335 #### 5.2 State(ViewContent)
336
337 State is the state of the ViewContent.
338
339 Syntax:
340 ```shell
341 State [ID] {
342   description: [String]
343   [priority|value]: [Number|Expression]
344 }
345 ```
346
347 |Syntax element |       Description|
348 | :---              |    :----     |
349 |description:   0..1 |  Description
350 |[priority\|value]:     1 |     Priority of ViewContent. |
351 ||Describe the relative value for other State under ViewContent as an expression, or set a numerical value. |
352 ||The following predefined value can be set as a String.NONE_VALUE, STANDARD_VALUE, MIN_VALUE, MAX_VALUE See "Priority definition"for details. |
353
354 Description example:
355 ```shell
356 State Warning {
357   description: "Display warning message"
358 priority: > That-of Attention
359 }
360 State Attention {
361   description: " Display attention message "
362 priority: > That-of TEL.Incoming
363 }
364 ```
365 ### 6. Priority definition
366
367 Define the priority of Content to the State under ViewContent or SoundContent (hereinafter, Content). The priority is used when the area / zone arbitration policy is "Priority and First Come First Arbitration" or "Priority and Last Come First Arbitration", the higher one is allocated first. Values can be defined absolutely by number or relative to other areas by expressions. You can describe only one of the visibility or priority. You can use comparison operators (> and <), equality operator (=) and That-of operator for the expressions.
368
369 - Description example of value:
370 Priority of Warning is 10.
371 ```shell
372 State Warning {
373   description: " Display warning message "
374 priority: 10
375 }
376 ```
377 - Description example of comparison operator:
378 Value of Warning is greater than Attention.
379 <br>Value of Attention is greater than State Incoming of TEL of other Content.
380 <br>Value of Notice is less than Attention.
381 <br>※When referring to the State of another Content, refer to the Content ID and State ID by connecting with “.”.
382 ```shell
383 State Warning {
384   value: > That-of Attention
385 }
386
387 State Attention {
388   value: > That-of TEL.Incoming
389 }
390
391 State Notice {
392   value: < That-of Attention
393 }
394 ```
395
396 - Description example of range: Priority of Attention is greater than Incoming of TEL and less than Warning.
397 <br>※When referring to the State of another Content, refer to the Content ID and State ID by connecting with “.”.
398 ```shell
399 State Attention {
400   priority: (> That-of TEL.Incoming AND < That-of Warning)
401 }
402 ```
403
404 - Description example of equality operator:Value of Attention is equal to State Incoming of TEL of other Content.
405 ```shell
406 State Attention {
407   priority: = That-of TEL.Incoming
408 }
409 ```
410 - Equality operator can be omitted.
411 ```shell
412 State Attention {
413   priority: That-of TEL.Incoming
414 }
415 ```
416
417 ### 7. Screen layout definition
418
419 #### 7.1. Display
420
421 Display represents one screen. When defined more than one, it will be Multi-screen layout.
422 The Display defines the set of Areas to be allocated on the screen.
423
424 Syntax:
425 ```shell
426 Display [ID] {
427   description: [String]
428   [CompositeArea]
429   [[Size]|sizeReference:[ID of Size]]
430 }
431 ```
432
433 |Syntax element |       Description|
434 | :---              |    :----     |
435 | description:  0..1 |  Description|
436 |[CompositeArea]        1 |     Component of the screen|
437 |[Size\|sizeReference:] 1 |     Size: Size definition|
438 || sizeReference: Reference to Size definition|
439 || ※One or more definitions of either Size or sizeReference are needed. |
440
441 Description example:
442 ```shell
443 Display METER {
444         description:"Meter display definition"
445         Size FULLSCREEN {
446                 width: 500
447                 height: 400
448         }
449         CompositeArea METER_Root {
450                 layout: FixedPositionLayout {
451                         PositionContainer {
452                                 x: 100
453                                 y: 100
454                                 basePoint: LEFT_TOP
455                                 areaReference: SpeedMeterArea
456                         }
457                 }
458         }
459 }
460 ```
461
462 #### 7.2. CompositeArea
463
464 CompositeArea specifies an Area that becomes a component of Display.
465
466 Syntax:
467 ```shell
468 CompositeArea [ID] {
469   description: [String]
470   layout: [FixedPositionLayout]
471 }
472 ```
473
474 |Syntax element |       Description|
475 | :---              |    :----     |
476 |description:   0..1 |  Description |
477 |layout: [FixedPositionLayout]  1|      Layout type of Area|
478
479 Description example:
480 ```shell
481 CompositeArea METER_Root {
482         description:" Definition of Area’s layout method"
483         layout: FixedPositionLayout {
484                 PositionContainer {
485                         x: 100
486                         y: 100
487                         basePoint: LEFT_TOP
488                         areaReference: SpeedMeterArea
489                 }
490         }
491 }
492 ```
493
494 #### 7.3. FixedPositionLayout
495
496 FixedPositionLayout declares that areas are laid out with fixed values. The specific position define by PositionContainer.
497
498 Syntax:
499 ```shell
500 FixedPositionLayout {
501   [PositionContainer]
502 }
503 ```
504
505 |Syntax element |       Description|
506 | :---              |    :----     |
507 |[PositionContainer]    1..*|   Position information.|
508
509 ```shell
510 FixedPositionLayout {
511         PositionContainer {
512                 x: 100
513                 y: 100
514                 basePoint: LEFT_TOP
515                 areaReference: SpeedMeterArea
516         }
517 }
518 ```
519 #### 7.4. PositionContainer
520
521 PositionContainer specifies the display position of the Area.
522
523 syntax:
524 ```shell
525 PositionContainer {
526   x: [Number]
527   y: [Number]
528   basePoint: [Value]
529   areaReference: [ID of Area]
530   [Offset]
531 }
532 ```
533
534 |Syntax element |       Description|
535 | :---              |    :----     |
536 |x:     1       |x position|
537 |y:     1       |y position|
538 |basePoint:     1 |     Defined x, y position. The following predefined value can be set.|
539 || CENTER_BOTTOM (Define x, y as the lower center position)|
540 || CENTER_MIDDLE(Define x, y as center position)|
541 || CENTER_TOP (Define x, y as the upper center position)|
542 ||LEFT_BOTTOM (Define x, y as the lower left position)|
543 ||LEFT_MIDDLE (Define x, y as the left center position)|
544 ||LEFT_TOP (Define x, y as the upper left position)|
545 ||RIGHT_BOTTOM (Define x, y as the lower right position)|
546 ||RIGHT_MIDDLE (Define x, y as right center position)|
547 ||RIGHT_TOP (Define x, y as the upper right position)|
548 |areaReference: 1|      Area to be placed in Display. Specify ID of the Area.|
549 |[Offset]       0..*|   Display position offset of AreaSpecify the position of the Area for each size.|
550
551
552 Description example:
553 ```shell
554 FixedPositionLayout {
555         PositionContainer {
556                 x: 100
557                 y: 100
558                 basePoint: LEFT_TOP
559                 areaReference: SpeedMeterArea
560                 Offset { x:-50 y:20 sizeReference: SpeedMeterArea }
561         }
562 }
563 ```
564 #### 7.5. Offset
565
566 Offset is the offset position for each size.
567
568 Syntax:
569 ```shell
570 Offset {
571   description: [String]
572   x: [Number]
573   y: [Number]
574   sizeReference: [ID of Size]
575 }
576 ```
577
578 |Syntax element      |  Description|
579 | :---             |    :----     |
580 |description:   0..1|   Description|
581 |x:     1|      Offset from x position of PositionContainer.|
582 |y:     1|      Offset from y position of PositionContainer.|
583 |sizeReference: 1|      Size to apply the offset. Specify ID of Size.|
584 ||※ This Size must be specified in Area.|
585
586 Description example:
587 ```shell
588 Offset {
589 description:"Offset"
590         x: 100
591         y: -50
592         sizeReference: SpeedMeterSize
593 }
594 ```
595
596 ### 8. Constraint defination
597
598 Constraints can be defined according to the state of the Area/Zone and the state of the ViewContent/SoundContent. The syntax can be used for Constraints is shown below.
599
600 - State reference of Area:
601
602 |Name   | Notation      |Meaning|
603 | :---              |    :----     |    :----     |
604 |IsDisplayed | <Area\>.isDisplayed()|   The Area is displayed. (At this time, the ViewContent is necessarily allocated to the Area) True if the Area is displayed.|
605 |DisplayingContent|     <Area\>.displayingContent()|    ViewContent which is displayed in the Area. When the Area is hidden or ViewContent is not allocated, it is not evaluated.
606 |AllocatedContent|      <Area\>.allocatedContent()|     ViewContent which is allocated to the Area. Even if the Area is hidden after allocation, it is possible to refer to the allocated ViewContent.|
607 |IsHidden|      <Area\>.isHidden()      |The Area is hidden. Regardless of whether the ViewContent is allocated to the Area or not,true if the Area is hidden.|
608 |ContentValue|  <Area\>.contentValue()| The value of the ViewContentState allocated to the Area. If ViewContent is not allocated to the Area, it is not evaluated.|
609 |ContentsList|  <Area\>.contentsList()| A set of ViewContent which is allocatable to the Area.|
610 |activeContents|        <Area\>.activeContents()        |The set of active content amang the ViewContent which is allocatable to the Area|
611
612 - State reference of ViewContent:
613
614 |Name   | Notation      |Meaning|
615 | :---              |    :----     |    :----     |
616 |IsActive|      <ViewContent\>.isActive()|      True if there is a Content request of ViewContent.|
617 |IsVisible|     <ViewContent\>.isVisible()|     The ViewContent is displayed. True if the ViewContent is allocated to any Area.|
618 |StateValue     |<ViewContent\>.stateValue()    |Priority/value that is defined in active state of the ViewContent. When the ViewContent has no active state, it does not evaluate.|
619 |HasComeEarlierThan|    <ViewContentA\>.hasComeEarlierThan(<ViewContentB\>)|    True if the ViewContentA’s request has come earlier than the ViewContentB’s. When the either ViewContent has been not requested, it does not evaluate.|
620 |HasComeLaterThan|      <ViewContentA\>.hasComeLaterThan(<ViewContentB\>)       |True if the ViewContentA’s request has come later than the ViewContentB’s. When the either ViewContent has been not requested, it does not evaluate.|
621 |Allocatables|  <ViewContent\>.allocatables()|  A set of Areas where the ViewContent can be displayed.|
622
623 - Scene reference:
624
625 |Name   | Notation      |Meaning|
626 | :---              |    :----     |    :----     |
627 |IsOn|  <Scene\>.isOn()|        True if the Scene is valid.|
628 |Get|   <Scene\>.<Property\>.get()|     Get scene property value.|
629
630 - Stereotyope:
631
632 |Name   | Notation      |Meaning|
633 | :---              |    :----     |    :----     |
634 |isTypeOf|      <Model\>.isTypeOf(“<ID of Stereotype\>”)|   Whether or not “<ID of Stereotype\>” is used in the <Model\> |
635 |||It can be applied to the following models Area,ViewContent|
636
637 - Operator:
638
639 |Name   | Notation      |Meaning|
640 | :---              |    :----     |    :----     |
641 |AND|   <Bool expression\> AND <Bool expression\>|      True if all Bool expressions are true.|
642 |OR|    <Bool expression\> OR <Bool expression\>        |True if any Bool expression is true.|
643 |Negation|      ! <Bool expression\>|   True if Bool expression is false.|
644 |Implication|   <Bool expression\> -> <Bool expression\>        | A -> B is equivalent to ((A AND B) OR !A).|
645 |Equal sign (Comparison of values)|     <Expression\> = <Expression\>|  True if the values shown on the left-hand side and the right-hand side are identical.The type of left-hand side and the right-hand side expressions must match.|
646 |Equal sign (Comparison of objects)     |<Expression\> == <Expression\>|        True if the values shown on the left-hand side and the right-hand side are identical.The type of left-hand side and the right-hand side expressions must match.|
647 |Comparison (greater than)      |<Number\> \> <Number\>|True if the Number on the left-hand side is greater than the Number on the right-hand side.|
648 |Comparison (greater than)|     <Number\> \>= <Number\>|True if the Number on the left-hand side is greater than equal to the Number on the right-hand side.|
649 |Comparison (less than)|        <Number\> < <Number\>|  True if the Number on the left-hand side is less than the Number on the right-hand side.|
650 |Comparison (less than)|        <Number\> <= <Number\>| True if the Number on the left-hand side is less than the equal to Number on the right-hand side.|
651
652 - Quantization symbol:
653
654 |Name   | Notation      |Meaning|
655 | :---              |    :----     |    :----     |
656 |∀(For All)   |For-All<Set\>{ <x\> \| <Expression\> } |<Set\> contains the ViewContentSet or the SoundContentSet, the AreaSet, the ZoneSet, and the One-time Set. True if <Expression\> is true for all set element <x\>.|
657 |∃(Exists)|   Exists< Set\>{ <x\> \| <Expression\> }  |<Set\> contains the ViewContentSet or the SoundContentSet, the AreaSet, the ZoneSet, and the One-time Set. True if < Set\> has one or more elements that satisfy <Expression\>.|
658
659 - Built-in defined Expression:
660
661 |Name   | Notation      |Meaning|
662 | :---              |    :----     |    :----     |
663 |All Area|      ALL_AREAS|      A set of all the Areas defined in the Model.|
664 |All ViewContent|       ALL_VIEWCONTENTS|       A set of all the ViewContents defined in the Model.|
665 |IF-THEN-ELSE Syntax|   IF (<Bool expression\>)THEN <Expression\>ELSE <Expression\>|    The type of the expression must be identical, for the THEN clause, if the Bool expression is true, for THEN and ELSE clause ,if the Bool expression is false.|
666 |Let Expression|      let <Variable name\> = <Object expression\>|    Evaluate <Object expression\> as variable <variabl name>, which can then be referenced in subsequent expressions|
667 |||Can only be used inside the expression. For-All, Exists, Max, Min, Select|
668 |Pre-arbitration value specifier|       (pre)<Area \| ViewContent \| Scene\| Scene.Property\> | Refere to the state before arbitration of Area, ViewContent, Property.|
669
670 **The syntax precedence and associativity are shown below:**
671
672 |Priority|      Name|   Notation|       Connectivity|
673 | :---              |    :----     |    :----     | :----     |
674 |1      |Parentheses|   (<Expression\>) |-|
675 |2|     ∃(Exists)|    Exists<Set\>{ <x\> \| <Expression\> }|-|
676 ||      ∀(For All)|   For-All<Set\>{ <x\> \| <Expression\> }| -|
677 ||      IF-THEN-ELSE Syntax|    IF (<Bool expressinon\>) THEN <Expressinon\> ELSE <Expressinon\>|       -|
678 ||SetOf operator|       { <Expression\>, <Expression\> }|       -|
679 ||      Pre-arbitration value specifier|        (pre)<Area\| ViewContent\| Scene\| Scene.Property\>|    -|
680 |3|Predicate connector  |<Object\>.<Predicate expression\>|     Left|
681 |4      |Negation|      ! <Bool expression\>|   Right|
682 |5|     Comparison (less than)| <Number\> < <Number\>|  Left|
683 ||      Comparison (greater than)|<Number\> \> <Number\>|Left|
684 ||      Comparison (less than)| <Number\> <= <Number\>| Left|
685 ||      Comparison (greater than)|      <Number\> \>= <Number\>|        Left|
686 |6|     Equal sign (Comparison of values)|      <Expressinon\> = <Expressinon\>|        Left|
687 ||      Equal sign (Comparison of objects)|     <Expressinon\> == <Expressinon\>|       Left|
688 |7|     AND|    <BoolExpressinon\> AND <BoolExpressinon\>       |Left|
689 |8      |OR|    <BoolExpressinon\> OR <BoolExpressinon\>|       Left|
690 |9      |Implication|   <BoolExpressinon\> -\> <BoolExpressinon\>|      Left|
691
692
693 #### 8.1 Constraint
694
695 Constraint describes constraint expressions. There are two types of constraint expressions Runtime constraints and Offline constraints. A Runtime constraint is a constraint expression that should be be true at the time of arbitration and controls the behavior of arbitration. An Offline constraint is a constraint expression that should be satisfied after arbitration and tests the arbitration result.
696
697 Syntax:
698 ```shell
699 Constraint [ID] {
700   description: [String]
701   runtime: [true|false]
702   [expression]
703 }
704 ```
705
706 |Syntax element         |Description|
707 | :---              |    :----     |
708 |description:   0..1|   Description|
709 |runtime:       1       |true: Runtime constraint|
710 ||Arbitrate each Area / Zone to be true this constraint.|
711 ||false: Offline constraint|
712 ||Verify that this constraint is true after all Area arbitration.|
713 |[expression]   1|      Constraint expression|
714
715 Description example
716
717 - AND/ OR/ Negation
718 <br>In the constraint expression, it is possible to express logical AND, logical OR, negation, which is a general logical operator, with AND, OR, and !. By using () you can also use in combination.
719
720 Example: Content1 is displayed or Content2 and Content3 are not displayed at the same time.
721 ```shell
722 Constraint SampleConstraint1 {
723 runtime: true
724 Content1.isVisible() OR !(Content2.isVisible() AND Content3.isVisible())
725 }
726 ```
727 Example: SampleContent1 is displayed or SampleContent2 is not displayed.
728 ```shell
729 Constraint SampleConstraint1 {
730         description: "Sample Constraint Expression"
731         runtime: true
732         SampleContent1.isVisible() OR !SampleContent2.isVisible()
733 }
734 ```
735
736 - Implication
737
738 Implications are false only if the left-hand side is true and the right-hand side is false, otherwise it is true.
739
740 Example: SampleContent4 is displayed if there is a request of SampleContent4.
741 ```shell
742 Constraint SampleConstraint3 {
743         runtime: true
744         SampleContent4.isActive() -> SampleContent4.isVisible()
745 }
746 ```
747
748 Example: If SampleArea1 displays SampleContent3, SampleArea2 does not display SampleContent3.
749 ```shell
750 Constraint SampleConstraint2 {
751         runtime: true
752         (SampleArea1.displayingContent() == SampleContent3)
753 -> !(SampleArea2.displayingContent() == SampleContent3)
754 }
755 ```
756
757 Example: If the value of the content displayed on SampleArea1 is higher than the value of the content displayed in SampleArea2, hide SampleArea2.
758 ```shell
759 Constraint SampleConstraint2 {
760         runtime: true
761         (SampleArea1.contentValue() > SampleArea2.contentValue())
762 -> SampleArea2.isHidden())
763 }
764 ```
765
766 Example: If the value of property1 of the information received from other RBAModel (Project) is 1, Content10 is not displayed.
767 ```shell
768 Constraint SampleConstraint {
769   (SampleScene1.isOn() AND SampleScene1.property1.get() = 1)
770     -> ! Content10.isVisible()
771 }
772 ```
773
774 - For-All
775
776 For-All targets a set, and it is true if all element of the set satisfies a lambda expression ({element name declaration | element condition}).
777 For the set, you can specify a defined set or an One-time set. (Refer to “Group definition” for more informations.)
778 <br>Example: If SampleContent1 is displayed, all Areas of AreaGroup1 is not displayed.
779 <br> It is assumed that "AreaGroup1" is defined as AreaSet.
780
781 ```shell
782 Constraint SampleConstraint {
783         runtime: true
784         SampleContent1.isVisible() ->
785 For-All AreaGroup1 { x | x.isHidden() }
786 }
787 ```
788
789 - Exists
790
791 Exists targets a set, and it is true if even one element of the set satisfies a Lambda expression ({element name declaration | element condition}).
792 <br>For the set, you can specify a defined set or an One-time set. (Refer to “Group definition” for more informations.)
793 <br>Example: If any Content of ContentGroup1 is displayed, all Areas of AreaGroup1 is not displayed.
794 <br> It is assumed that "ContentGroup1" is defined as ContentSet.
795 <br> It is assumed that "AreaGroup1" is defined as AreaSet.
796 ```shell
797 Constraint SampleConstraint {
798         runtime: true
799         Exists ContentGroup1{ x | x.isVisible() } ->
800 For-All AreaGroup1 { x | x.isHidden() }
801 }
802 ```
803
804 - IF-THEN-ELSE
805 Example: If the scene is SampleScene1, SampleContent4 is displayed, otherwise SampleContent4 is not displayed.
806
807 ```shell
808 Constraint SampleConstraint4 {
809         runtime: true
810         IF(SampleScene1.isOn())
811         THEN
812                 SampleContent4.isVisible()
813         ELSE
814                 !SampleContent4.isVisible()
815 }
816 ```
817
818 - (pre)
819 Example: If SampleContent 1 is displayed (before arbitration), SampleContent 2 is not displayed.
820 ```shell
821 Constraint SampleConstraint {
822         runtime: true
823 (pre)SampleContent1.isVisible() -> !SampleContent2.isVisible()
824 }
825 ```
826
827 - HasComeEarlierThan/HasComeLaterThan
828 Example: If request SampleContent 1 has come earlier then SampleContent 2, SampleContent 2 does not displayed.
829 ```shell
830 Constraint SampleConstraint {
831         runtime: true
832 SampleContent1.hasComeEarlierThan(SampleContent2) -> !SampleContent2.isVisible()
833 }
834 ```
835 Below constraint behave as same as above.
836 ```shell
837 Constraint SampleConstraint {
838         runtime: true
839 SampleContent2.hasComeLaterThan(SampleContent1) -> !SampleContent2.isVisible()
840 }
841 ```
842
843 #### 8.2 Syntax sugar
844
845 This syntax sugar simplifies the constraint expressions and improves their readability. You can use them like the existing constraint expressions.
846 Below are the syntax sugars that can be used.
847
848 - Inequality(!=)
849 <br>It means that the left side value and the right side value are not equal. You can use this to compare objects.
850 True if the left side value and the right side value are not equal.
851 The types of expressions on the left and the right sides must match.
852
853 |Type|  Operator|
854 | :---              |    :----     |
855 |Notation|      <Expression1\> != <Expression2\>|
856 |ECE*|  !(<Expression1\> == <Expression2\>)|
857
858 *ECE: Equivalent constraint expression
859
860 Description example: The ViewContent allocated to AreaA is not Content1.
861
862 |||
863 | :---              |    :----     |
864 |Notation|      AreaA.allocatedContent() != Content1|
865 |ECE|   !( AreaA.allocatedContent() == Content1)|
866
867 - Allocation of Area/Zone
868 <br>It indicates that ViewContent/SoundContent is allocated to the Area/Zone.
869 True if theViewConten/SoundContentt is allocated to the Area/Zone.
870
871 |Type|  State reference of ViewContent|
872 | :---              |    :----     |
873 |Notation|      <ViewContent\>.isAllocatedTo(<Area\>)|
874 |ECE|   <Area\>.allocatedContent() == <ViewContent\>|
875
876 Description example: The Content1 is allocated to the AreaA.
877
878 |||
879 | :---              |    :----     |
880 |Notation|      Content1.isAllocatedTo(AreaA)|
881 |ECE|   AreaA.allocatedContent() == Content1|
882
883 - Allocation changing of Area/Zone
884 <br>It indicates a changing of the ViewContent’s/SoundContent’s allocated to the Area/Zone.
885 True if the changing happens.
886
887 |Type   |State reference of Area|
888 | :---              |    :----     |
889 |Notation|      <Area\>.isChanged()|
890 |ECE|   !((pre)<Area\>.allocatedContent() == <Area\>.allocatedContent())|
891
892 Description example: The ViewContent allocated to AreaA has changed.
893
894 |||
895 | :---              |    :----     |
896 |Notation|      AreaA.isChanged()|
897 |ECE|   !((pre)AreaA.allocatedContent() == AreaA.allocatedContent())|
898
899 - Changing of a content allocated to Area/Zone
900 <br>It indicates whether a ViewContent/SoundContent allocated to the Area/Zone has changed to the specified ViewContent/SoundContent.True if the changing happens
901
902 |Type   |State reference of Area|
903 | :---              |    :----     |
904 |Notation|      <Area\>.isTranslatedTo(<ViewContent\>)|
905 |ECE|   !((pre)<Area\>.allocatedContent() == <ViewContent\>) AND (<Area\>.allocatedContent() == <ViewContent\>)|
906
907 Description example: A ViewContent allocated to the AreaA has changed to Content1.
908
909 |||
910 | :---              |    :----     |
911 |Notation|      AreaA.isTranslatedTo(Content1)|
912 |ECE    |!((pre)AreaA.allocatedContent() == Content1) AND (AreaA.allocatedContent() == Content1)|
913
914 - Displaying in the Area
915 <br>It indicates whether the ViewContent displayed or not in the Area.
916 True if the ViewContent is displayed in the Area.
917
918 |Type|  State reference of ViewContent|
919 | :---              |    :----     |
920 |Notation|      <ViewContent\>.isDisplayedOn(<Area\>)|
921 |ECE|   <Area\>.isDisplayed() AND (<Area\>.displayingContent() == <ViewContent\>)|
922
923 Description example: The Content1 is displayed in the AreaA.
924
925 |||
926 | :---              |    :----     |
927 |Notation|      Content1.isDisplayedOn(AreaA)|
928 |ECE|   AreaA.isDisplayed() AND (AreaA.displayingContent() == Content1)|
929
930 - Display changing of the Area
931 <br>It indicates whether the display of the Area changes or not.
932 True if the change happens.
933
934 |Type   |State reference of Area|
935 | :---              |    :----     |
936 |Notation|      <Area\>.isChangedDisplay()|
937 |ECE    |!((pre)<Area\>.displayingContent() == <Area\>.displayingContent()) OR ((pre)<Area\>.isDisplayed() AND !<Area\>.isDisplayed()) OR (!(pre)<Area\>.isDisplayed() AND <Area\>.isDisplayed())|
938
939 Description example: The display of the AreaA has changed.
940
941 |||
942 | :---              |    :----     |
943 |Notation       |AreaA.isChangedDisplay()|
944 |ECE    |!((pre)AreaA.displayingContent() == AreaA.displayingContent()) OR((pre)AreaA.isDisplayed() AND !AreaA.isDisplayed()) OR(!(pre)AreaA.isDisplayed() AND AreaA.isDisplayed())|
945
946 - Changing of the displayed ViewContent to the specified ViewContent
947 <br>It indicates whether the ViewContent displayed in the Area has changed to anther specified ViewContent.
948 True if the change happens.
949
950 |Type   |State reference of Area|
951 | :---              |    :----     |
952 |Notation|      <Area\>.isTranslatedViewTo(<ViewContent\>)|
953 |ECE    |(<Area\>.isDisplayed()) AND (<Area\>.displayingContent() == <ViewContent\>) AND (!((pre)<Area\>.displayingContent() == <ViewContent\>) OR !(pre) <Area\>.isDisplayed())|
954
955 Description example: A ViewContent displayed in the AreaA has changed to another Content1.
956
957 |||
958 | :---              |    :----     |
959 |Notation|      AreaA.isTranslatedViewTo(Content1)|
960 |ECE|   (AreaA.isDisplayed()) AND (AreaA.displayingContent() == Content1) AND (!((pre)AreaA.displayingContent() == Content1) OR !(pre)AreaA.isDisplayed())|
961
962 - Hide a lower priority Area
963 <br>Compare the two Areas and hide the Area displaying a ViewContent with lower priority.
964
965 |Type|  State reference of Area|
966 | :---              |    :----     |
967 |Notation|      HideLowerPriority(<Area1\>, <Area2\>)|
968 |ECE|   ((<Area1\>.contentValue() < <Area2\>.contentValue() -\> <Area1\>.isHidden()) AND (<Area1\>.contentValue() \> <Area2\>.contentValue() -\> <Area2\>.isHidden()))|
969
970 Description example: AreaA and AreaB are compared to hide the Area which displays a ViewContent with lower priority.
971
972 |||
973 | :---              |    :----     |
974 |Notation|      HideLowerPriority(AreaA, AreaB)|
975 |ECE|   ((AreaA.contentValue() < AreaB.contentValue() -\> AreaA.isHidden()) AND (AreaA.contentValue() \> AreaB.contentValue() -\> AreaB.isHidden()))|
976
977 ### 9. Group definition
978
979 #### 9.1 AreaSet
980
981 When dealing with multiple Areas in the Constraint expression, in order to describe it simply, you can define multiple Areas together in one group.
982
983 Syntax:
984 ```shell
985 AreaSet [ID] {
986   description: [String]
987   target: [ [ID of Area] ]
988 }
989 ```
990
991 |Syntax element |       Description|
992 | :---             |    :----     |
993 |description: | 0..1    Description|
994 |target:        0..*    | Areas or AreaSets which compose the group. Specify the ID of the Area or the AreaSet with comma-separated.|
995
996 Description example:
997 ```shell
998 AreaSet MainScreen {
999         description: "Area constituting the main screen"
1000         target: [SampleArea, SampleArea1, OtherAreaSet]
1001 }
1002 ```
1003 #### 9.2 ViewContentSet
1004
1005 When dealing with multiple ViewContents in the Constraint expression, in order to describe it simply, you can define multiple ViewContents together in one group.
1006
1007 Syntax:
1008 ```shell
1009 ViewContentSet [ID] {
1010   description: [String]
1011   allocatable: [ [ID of Area] ]
1012   target: [ [ID of ViewContent] ]
1013 }
1014 ```
1015
1016 |Syntax element |       Description|
1017 | :---             |    :----     |
1018 |description: | 0..1    Description|
1019 |allocatable:   0..*|   Displayable Areas or AreaSets.Specify the ID of the Areas or the AreaSets with comma-separated.|
1020 |target:        0..*|   ViewContents or ViewContentSets which compose the group. Specify the ID of the ViewContents or ViewContentSets with comma-separated.|
1021
1022 Description example:
1023 ```shell
1024 ViewContentSet InterruptContent{
1025   allocatable: [
1026     MessageArea, HUDMessageArea, InterruptAreaGroup
1027   ]
1028   target: [
1029     TEL,Power, ViewContentGroup
1030   ]
1031 }
1032 ```
1033
1034 #### 9.3 One-time Set
1035
1036 Specify an set in the For-All or the Exists constraint, you can define the One-time set.
1037
1038 Syntax:
1039 ```shell
1040 { [ID] }
1041 ```
1042
1043 |Syntax element |       Description|
1044 | :---             |    :----     |
1045 |[ID]   1..*    |Element of the set. Specify the IDs of elements with comma-separated.
1046 ||The type of elements should be same.|
1047 ||At this time, Area and AreaSet regard it as the same type.( ViewContent and ViewContentSet are treat similarly.)
1048
1049 - Description example: Define the One-time set as AreaSet.
1050 ```shell
1051 Constraint SampleConstraint {
1052         runtime: true
1053         SampleContent1.isVisible() ->
1054 For-All {Area1, Area2, Area3} { x | x.isHidden() }
1055 }
1056 ```
1057
1058 - Description example: Define the One-time set as ViewContentSet.
1059 ```shell
1060 Constraint SampleConstraint {
1061         runtime: true
1062         Exists {ViewContent1, ViewContentSet1} { x | x.isActive() -> x.isVisible() }
1063 }
1064 ```
1065 ### 10. Scene definition
1066 #### 10.1 Scene
1067 Scene comprehensively expresses the state at the time including the system, and it is used to switch the status of Area/Zone, View/Sound Content by Scene. You can also define the Global scene and share the results of arbitration among multiple RBA Models (Projects).
1068
1069 Syntax:
1070 ```shell
1071 Scene [ID] {
1072   description: [String]
1073   global: [true|false]
1074   [Property]
1075 }
1076 ```
1077
1078 |Syntax element |       Description|
1079 | :---             |    :----     |
1080 |description:   0..1|   Description|
1081 |global:        0..1|   true: Global Scene for sharing arbitration results with other RBA Models (Projects).|
1082 ||false: Local Scene.|
1083 ||If not defined, consider it as "false".|
1084 |[Property]     0..*|   Information for sharing arbitration results with other RBA models (Projects).|
1085 ||Can define only if global is true.|
1086
1087 Description example:
1088 ```shell
1089 Scene AutoDrivingScene {
1090   description: "In auto driving mode"
1091 }
1092
1093 Scene DisplayEventNotification {
1094   global: true
1095   int OverallPriority: 6
1096   int RiskSeverity: 3
1097   int RiskMargin: 1
1098 }
1099 ```
1100 #### 10.2 Property
1101
1102 Property is arbitrary properties which is defined in the Scene.
1103
1104 Syntax:
1105 ```shell
1106 int [String]: [Number]
1107 ```
1108
1109 |Syntax element |       Description|
1110 | :---             |    :----     |
1111 |[String]       1       |Arbitrary Property name|
1112 |[Number]       1       |Default value of Property. Positive integer can be specified.|
1113
1114 Description example:
1115 ```shell
1116 int RiskSeverity: 3
1117 ```
1118
1119 ### 11. Stereotype
1120
1121 Syntax:
1122 ```shell
1123 StereoType<[Target Model Name]> [ID] ([valiable]) @BEGIN@
1124 description: [String]
1125     [Propaties of Element]
1126 @END@
1127 ```
1128
1129 |Syntax element |       Description|
1130 | :---              |    :----     |
1131 |description:   0..1|   Description|
1132 |[Target Model Name]    1|      Identify the applicable model by describing the model element keywords|
1133 ||It can be applied to the Area, ViewContent models|
1134 |[valiable]     0..*|   Describe an arbitrary variable as the parameter to be replaced, which will be set in the property of the model element specified in [Target Model Name].If there are multiple variables, separate them with commas.|
1135 |[Properties of Element]        1..*|   Describe the properties of the model element specified in [Target Model Name].In the property, the value to be replaced is written in @{[variable]} .|
1136 ||The variables must match the variables described in ().|
1137
1138 Description example:
1139 ```shell
1140 Stereotype<ViewContent> display_warnning (name,allocatable,priority) @BEGIN@
1141     description: “@{name}”
1142     allocatable: [@{allocatable}]
1143     Size WarnSize {
1144         width: 300
1145         height: 100
1146     }
1147     State NORMAL { piority: @{priority} }
1148
1149 @END@
1150 ```
1151
1152 ### 12. Tag
1153
1154 Syntax:
1155 ```shell
1156 <<[Stereotype ID]>> | <<[Stereotype ID]>>{“[String]”}
1157 ```
1158
1159 |Syntax element |       Description|
1160 | :---              |    :----     |
1161 |[ID of Stereotype]     0..*|   Can be assigned to Area, ViewContent|
1162 ||If StereoType is defined, then the child elements and attributes defined there will be expanded as child elements and attributes of this object|
1163 ||Multiple definitions can be made for a single model. To define more than one, define them consecutively.|
1164 |[String]       0..*    |Argument value|
1165 ||If there is no argument, it can be omitted|
1166
1167 Description example:
1168 ```shell
1169 ViewContent Warning_1 {
1170     <<display_warning>>{ “Warning_01”,”Area1”,“1” }
1171 }
1172
1173 ViewContent Warning_2 {
1174     <<display_warning>>{ “Warning_02”,”Area2”,”2” }
1175 }
1176
1177 Stereotype<ViewContent> display_warnning (name,allocatable,priority) @BEGIN@
1178     description: “@{name}”
1179     allocatable: [@{allocatable}]
1180     Size WarnSize {
1181         width: 300
1182         height: 100
1183     }
1184     State NORMAL { piority: @{priority} }
1185 @END@
1186 ```
1187
1188 ## Generate .json from .rba file
1189 Download [prebuilt package](https://git.automotivelinux.org/staging/rba-tool/tree/tool_bin)
1190
1191 - If some errors occur, RBAModel.json is not generated (exit code 1).
1192 ````
1193 java -cp ./ -jar JSONGenerator.jar "[path to model directory]" "[path to output directory]"
1194 ````
1195
1196 Example:
1197
1198 - RBAModel.json file is generated in directory same as JSONGenerator.jar
1199 ````
1200 java -cp ./ -jar JSONGenerator.jar "./RBAModel.rba"
1201 ````
1202
1203 - RBAModel.json file is generated in ~/ directory
1204 ````
1205 java -cp ./ -jar JSONGenerator.jar "./RBAModel.rba" "~/"
1206 ````
1207 Note: For the reference .rba file is given under the path [prebuilt package/sample_model](https://git.automotivelinux.org/staging/rba-tool/tree/tool_bin/sample_model)