Skip to main content

Data Types

What You Will Do​

In this chapter you create two data types in the project AADesign that you finished in Topology — the Ethernet Connector and Endpoints. You open the DataType editor, review the 13 built-in types that PAIO provides by default (11 primitives and 2 pointer types), then use the + button to add ByteArray (category DYNAMIC_ARRAY, element type uint8, max size 1, C++ namespace aa::type) and String (category STRING, max size 256, C++ namespace aa::type) and save.

When you finish this chapter, a new file design/DATATYPE.io.model exists and holds the two entries ByteArray and String. The 13 built-in types are not written to the file. The VALIDATION panel shows No validation issues. at the start and at the end of this chapter; in between, it shows one finding while ELEMENT TYPE of ByteArray or MAX SIZE of String is still empty. In the later chapter Service Interface you pick ByteArray as the type of the event SensorData.

Before You Begin​

  • Start from the state at the end of Topology — the Ethernet Connector and Endpoints. The title bar reads PAIO [AADesign], the project's design/ folder holds IVC.io.model, SYSTEM.io.model, VFB.io.model plus Module/ and SWC/, and DATATYPE.io.model does not exist yet. The VALIDATION panel shows No validation issues..
  • You may close the tab AADesign:System left open from chapter 3. This chapter starts by opening DataType from DESIGN in the EDITOR view.

The values you type in this chapter are listed below. DESCRIPTION stays empty for both types.

TypeCATEGORYELEMENT TYPEMAX SIZEC++ NAMESPACE
ByteArrayClick DYNAMIC_ARRAYSelect uint8 from the list1aa::type
StringClick STRING(no field)256aa::type

Note. An input field in the CONFIGURATION panel commits its value only when you leave the field. In this chapter you press the Tab key after typing to commit. A choice in the CATEGORY toggle or the ELEMENT TYPE dropdown commits as soon as you click it.

Opening the DataType Editor​

Opening the Editor and Reviewing the Built-in Primitives​

  1. In the EDITOR view on the left, click DataType under DESIGN. The tab AADesign:DataType opens with the four tabs DATA TYPE / UNIT / FUNCTION SIGNATURE / COMPU METHOD at the top, and DATA TYPE is active.

  2. Look at the DATATYPE list on the left. It holds 13 italic entries: boolean, float32, float64, sint8, sint16, sint32, sint64, uint8, uint16, uint32, uint64, each with the badge [PRIMITIVE] at the right of its row, followed by VoidPtr and ConstVoidPtr with the badge [POINTER]. When the editor opens, boolean is selected.

  3. Click uint8 in the list. The CONFIGURATION panel in the middle shows NAME uint8, PRIMITIVE selected (greyed) in the CATEGORY toggle, MIN 0, MAX 255 and DESCRIPTION Unsigned 8-bit integer (0 to 255). All four fields are read-only and cannot be changed.

    The DataType editor just opened, with the built-in primitive uint8 selected

    Figure 4-1. The DataType editor as first opened. ① The DataType row under DESIGN in the EDITOR view, ② the DATATYPE list with the 13 built-in types (uint8 selected), ③ the + button in the list header (tooltip Add DataType). PREVIEW at the top right shows uint8 with the badges UNSIGNED INTEGER and 8 bit and a range slider 0 to 255; VALIDATION at the bottom right shows No validation issues.

The editor has three areas. The DATATYPE list on the left has the buttons + (Add DataType), − (Delete selected DataType) and ⋯ (More actions) at the right of its header, and a search field (hint search...) below it. The middle is CONFIGURATION; on the right, PREVIEW is at the top and VALIDATION at the bottom. This chapter uses only the + button and the CONFIGURATION panel. The UNIT, FUNCTION SIGNATURE and COMPU METHOD tabs, −, ⋯ and the search field are not used.

Note. The 11 primitives are built-in types that PAIO keeps in memory only. They are not written to DATATYPE.io.model, and the exporter always re-inserts them in ARXML Export. VoidPtr and ConstVoidPtr are the two platform pointer types; like the primitives, they are built in, kept in memory only, not written to the file and re-inserted by the exporter. None of the 13 can be renamed or deleted, and the only types you create are ByteArray and String below.

Creating ByteArray — DYNAMIC_ARRAY​

The first type, ByteArray, is shown step by step. The order is: enter the name first, pick the category, then fill in the remaining fields. The C++ NAMESPACE, ELEMENT TYPE and MAX SIZE fields are not visible until a category is picked.

Adding the Entry​

  1. Click the + button in the header of the DATATYPE list. A new entry DataType13 appears at the bottom of the list and is selected immediately. It has no badge yet.

  2. Look at the CONFIGURATION panel. NAME is DataType13, nothing is selected in the CATEGORY toggle, and the red hint Category is required is shown below it. DESCRIPTION is empty.

    The editor right after adding the new entry DataType13 with the + button

    Figure 4-2. The editor right after adding the new entry. ① The DataType13 row at the bottom of the list, ② NAME = DataType13, ③ the CATEGORY toggle with nothing selected and the red Category is required below it. VALIDATION shows 1 error and [13] "DataType13": Category is not set, and the tab AADesign:DataType, outside the figure, carries the modified mark ●. PREVIEW still shows the previously viewed uint8.

The name of a new entry is assigned automatically as DataType followed by the current list length, such as DataType13. The CATEGORY toggle has eleven cells, PRIMITIVE, ALIAS, ENUMERATION, FIXED_ARRAY, DYNAMIC_ARRAY, STRING, STRUCTURE, MAP, UNION, POINTER and FUNCTION_POINTER; PRIMITIVE is reserved for built-in types, so it is greyed and cannot be clicked. The [13] in the VALIDATION area is the entry's index in the list. PREVIEW switches to the new entry once a category is picked.

Entering the Name and Picking the Category​

  1. Change the value of the NAME field to ByteArray and press the Tab key. The row in the list changes to ByteArray as well.

  2. Click DYNAMIC_ARRAY in the CATEGORY toggle. The panel is redrawn: the C++ NAMESPACE field appears to the right of NAME, and the ELEMENT TYPE and MAX SIZE fields appear below CATEGORY. VALIDATION changes to 1 error and [13] "ByteArray": Element Type is required. At the same time the V icon in the footer gets a red badge 1: the project validation reports the error constr_1907 (DYNAMIC_ARRAY datatype "ByteArray" has no element type.) until you pick the element type.

  3. Click the ELEMENT TYPE field. The field shows the hint Type to search... and a dropdown with the 13 built-in types opens. About six rows are visible at a time, so scroll to find uint8.

  4. Click uint8 in the dropdown.

    The CONFIGURATION panel with DYNAMIC_ARRAY picked and the ELEMENT TYPE dropdown open

    Figure 4-3. The CONFIGURATION panel with the ELEMENT TYPE dropdown open. ① DYNAMIC_ARRAY selected in CATEGORY, ② the ELEMENT TYPE field (hint Type to search...), ③ the uint8 row to click in the dropdown. The dropdown shows the rows sint32, sint64, uint8, uint16 and uint32 with a scrollbar on the right. NAME is ByteArray; C++ NAMESPACE and MAX SIZE are still empty (hints C++ Namespace (e.g., paio::api) and Unsigned Integer (0..4294967295)).

The dropdown lists every other type in this project. Right now that is only the 13 built-in types; String is not there because it has not been created yet. Once you pick uint8, the field shows uint8 with a clear × and an expand ⌄, VALIDATION returns to No validation issues, and the badge on the V icon disappears.

Entering the Max Size and the Namespace​

  1. Type 1 in the MAX SIZE field (hint Unsigned Integer (0..4294967295)) and press the Tab key.

  2. Type aa::type in the C++ NAMESPACE field (hint C++ Namespace (e.g., paio::api)) and press the Tab key.

    The editor with every value of ByteArray entered

    Figure 4-4. The editor with ByteArray complete. ① The ByteArray [DYNAMIC_ARRAY] row in the list, ② NAME = ByteArray, ③ CATEGORY = DYNAMIC_ARRAY, ④ ELEMENT TYPE = uint8, ⑤ MAX SIZE = 1, ⑥ C++ NAMESPACE = aa::type. PREVIEW shows ByteArray, the blue text uint8[..1] (Dynamic), a single dashed box [0] uint8 and the hatched bar 0..1 elements | max 1 bytes; VALIDATION shows No validation issues. The tab carries the modified mark ●.

Leave DESCRIPTION empty (hint Text). Confirm that the badge of the list row has changed to [DYNAMIC_ARRAY].

Creating String — STRING​

Create the second type, String, the same way. When the category is STRING there is no ELEMENT TYPE field and MAX SIZE spans the whole row. The values are those in the table under "Before You Begin".

  1. Click the + button in the header of the DATATYPE list. A new entry DataType14 appears at the bottom of the list and is selected.

  2. Change the value of the NAME field to String and press the Tab key.

  3. Click STRING in the CATEGORY toggle. The fields become NAME, C++ NAMESPACE, CATEGORY, MAX SIZE and DESCRIPTION, and VALIDATION shows 1 warning and [14] "String": Max Size not set, default 255 will be applied. The V icon in the footer gets an orange badge 1 for the matching project validation warning constr_1093 (STRING datatype "String" has no maximum size (swMaxTextSize).).

  4. Type 256 in the MAX SIZE field and press the Tab key. VALIDATION returns to No validation issues, and the badge on the V icon disappears.

  5. Type aa::type in the C++ NAMESPACE field and press the Tab key.

    The editor with every value of String entered

    Figure 4-5. The editor with String complete. ① NAME = String, ② CATEGORY = STRING, ③ MAX SIZE = 256, ④ C++ NAMESPACE = aa::type, ⑤ the String [STRING] row in the list. The ByteArray [DYNAMIC_ARRAY] row is above it. PREVIEW shows String with 10 character cells _ and ...+246; VALIDATION shows No validation issues.

Caution. If you leave MAX SIZE empty, you only get a warning, in the editor and as constr_1093 in the VALIDATION panel, and the entry is still saved. In that case, however, the default 255 is applied and the result differs from the reference design, so be sure to enter 256.

Saving​

  1. Click an empty spot in the DATATYPE list, below the last row, to leave the input field. The last value you typed is committed, and String stays selected.

  2. Press Ctrl+S. The modified mark ● on the tab AADesign:DataType disappears and design/DATATYPE.io.model is created.

  3. Look at the list. Below the 13 built-in types are ByteArray [DYNAMIC_ARRAY] and String [STRING], 15 entries in all. String is still selected after the save. Click ByteArray to check that its values were kept.

    The editor after saving, with ByteArray selected again

    Figure 4-6. The editor after saving, with ByteArray clicked again. ① The ByteArray [DYNAMIC_ARRAY] row, ② the String [STRING] row. The tab AADesign:DataType has no modified mark ●, and CONFIGURATION and PREVIEW are the same as in Figure 4-4.

The EDITOR view does not change. The DataType row under DESIGN is always shown whether or not the file exists, so it does not tell you that the file was created. The saved design/DATATYPE.io.model looks like this (date fields omitted).

{
"$schema": "https://autosar.io/schemas/datatype.schema.json",
"version": "2.0.0",
"type": "PAIO-datatype",
"metadata": {},
"data-types": {
"data-type": [
{ "short-name": "ByteArray", "category": "DYNAMIC_ARRAY", "type-reference-ref": "uint8", "array-size": 1, "name-space": "aa::type" },
{ "short-name": "String", "category": "STRING", "max-size": 256, "name-space": "aa::type" }
],
"units": []
}
}

data-type holds only the two entries; the 13 built-in types are absent. An empty DESCRIPTION is not written at all, not even as a key.

Viewing the Validation Result​

  1. Look at the V icon in the footer at the bottom of the window, the fifth icon from the left. It carries no badge, but its tooltip still reads Validation: 0 error(s), 1 warning(s), 0 info(s), the last non-zero count; the VALIDATION panel shows the current result.

  2. Look at the VALIDATION panel. If it is closed, click the V icon in the footer.

    The Validation panel showing No validation issues.

    Figure 4-7. The VALIDATION panel after saving the data types. The header has no badge, and below the column headers ELEMENT TYPE, NAME, DESCRIPTION and CONSTR there is the single line No validation issues..

As at the end of chapter 3, the project validation has no findings. The VALIDATION area at the bottom right of the editor is the DataType editor's own check, while this panel is the project-wide validation; they are two different things. The project validation also re-runs while you edit, before you save, which is why constr_1907 and constr_1093 appeared while ELEMENT TYPE of ByteArray and MAX SIZE of String were still empty.

Why Is It Designed This Way?​

  • ByteArray is a variable-length array of uint8, and it is created before the Service Interface. In the reference design, ByteArray is a VECTOR of uint8_t (ARRAY-SIZE 1) in the namespace aa::type, and the event SensorData of the service interface Sensor uses this type. The type dropdown of the Interface editor lists only the types that exist in the DataType editor, which is why this chapter comes before chapter 5. The editor's uint8 comes out under its C++ name uint8_t in ARXML Export.
  • The 11 primitives are not entered. Of the 13 STD-CPP-IMPLEMENTATION-DATA-TYPE elements in the reference design, 11 (bool, float, double, int8_t … uint64_t) correspond to the editor's built-in primitives boolean, float32, float64, sint8 … uint64. Their names, descriptions and TYPE-EMITTER / HEADER-FILE are rules applied by the exporter, not something you enter. The CP-side elements such as SW-BASE-TYPE, IMPLEMENTATION-DATA-TYPE, APPLICATION-*-DATA-TYPE and DATA-TYPE-MAPPING-SET are also generated automatically by the exporter.
  • String is created although no interface uses it. This keeps the 13 types of the reference design exactly. Without it, the export would contain 12 C++ implementation types.
  • MAX SIZE of String is 256. The String of the reference design has no ARRAY-SIZE, but leaving the field empty applies the default 255. 256 equals the string size of the CP-side mirror in the reference design. In return, your export carries ARRAY-SIZE 256 on STD-CPP-IMPLEMENTATION-DATA-TYPE String and SW-TEXT-PROPS on APPLICATION-PRIMITIVE-DATA-TYPE String, which the reference design does not have. This is a normal difference and is explained again in ARXML Export. The STD-CPP-IMPLEMENTATION-DATA-TYPE ByteArray matches the reference design. The IMPLEMENTATION-DATA-TYPE elements of both types and the APPLICATION-ARRAY-DATA-TYPE ByteArray come out in PAIO's variable-size array form, with the same sizes 1 and 256; that chapter explains this too.
  • The C++ namespace aa::type is entered on both types. This value becomes the NAMESPACES of the export (two SYMBOL-PROPS, aa and type). If you leave it empty, no namespace appears in the export.

Checklist​

  • The DATATYPE list of the tab AADesign:DataType holds 15 entries: below the 11 italic [PRIMITIVE] entries and the 2 italic [POINTER] entries are ByteArray [DYNAMIC_ARRAY] and String [STRING].
  • Clicking ByteArray shows NAME ByteArray, C++ NAMESPACE aa::type, CATEGORY DYNAMIC_ARRAY, ELEMENT TYPE uint8, MAX SIZE 1, and PREVIEW shows uint8[..1] (Dynamic).
  • Clicking String shows NAME String, C++ NAMESPACE aa::type, CATEGORY STRING, MAX SIZE 256, and there is no ELEMENT TYPE field.
  • DESCRIPTION is empty for both types and the editor's VALIDATION area shows No validation issues.
  • The tab AADesign:DataType has no modified mark ● and the file design/DATATYPE.io.model exists.
  • The VALIDATION panel shows No validation issues. and the header has no badge.

Next Step​

In Service Interface you use the Interface editor to create the service interface Sensor and pick the ByteArray created in this chapter as the type of the event SensorData.