Skip to content

Commit

Permalink
fix: Sync class properties
Browse files Browse the repository at this point in the history
  • Loading branch information
huyenngn committed Apr 2, 2024
1 parent 7a4a6af commit 3d60eec
Show file tree
Hide file tree
Showing 12 changed files with 148 additions and 16,267 deletions.
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"args": [
"export",
"-m",
"tests/data/melody_model_60",
"local_data/melody_model_60",
"-l",
"la",
"-o",
Expand Down
28 changes: 17 additions & 11 deletions capella_ros_tools/importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,17 +122,22 @@ def _convert_class(
self._promise_id_refs[promise_ref] = None
prop_yml = {
"promise_id": prop_promise_id,
"name": field_def.name,
"type": decl.Promise(promise_ref),
"kind": "COMPOSITION",
"description": field_def.description,
"min_card": decl.NewObject(
"LiteralNumericValue", value=field_def.type.card.min
),
"max_card": decl.NewObject(
"LiteralNumericValue", value=field_def.type.card.max
),
"find": {
"name": field_def.name,
},
"set": {
"type": decl.Promise(promise_ref),
"kind": "COMPOSITION",
"description": field_def.description,
"min_card": decl.NewObject(
"LiteralNumericValue", value=field_def.type.card.min
),
"max_card": decl.NewObject(
"LiteralNumericValue", value=field_def.type.card.max
),
},
}
props.append(prop_yml)

associations.append(
{
Expand All @@ -155,7 +160,6 @@ def _convert_class(
},
}
)
props.append(prop_yml)

yml = {
"promise_id": promise_id,
Expand All @@ -164,6 +168,8 @@ def _convert_class(
},
"set": {
"description": msg_def.description,
},
"sync": {
"properties": props,
},
}
Expand Down
178 changes: 98 additions & 80 deletions tests/data/data_model/example_msgs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,62 +13,73 @@
name: SampleClass
set:
description: "SampleClass.msg The first comment block at the top of the file is added to the class description of SampleClass. "
sync:
properties:
- promise_id: package1.SampleClass.sample_field1
name: sample_field1
description: "This block comment is added to the property description of sample_field1. This block comment is also added to the property description of sample_field1. "
type: !promise package1.uint8
kind: COMPOSITION
min_card: !new_object
_type: LiteralNumericValue
value: "0"
max_card: !new_object
_type: LiteralNumericValue
value: "10"
find:
name: sample_field1
set:
description: "This block comment is added to the property description of sample_field1. This block comment is also added to the property description of sample_field1. "
type: !promise package1.uint8
kind: COMPOSITION
min_card: !new_object
_type: LiteralNumericValue
value: "0"
max_card: !new_object
_type: LiteralNumericValue
value: "10"
- promise_id: package1.SampleClass.sample_field2
name: sample_field2
description: "This block comment is added to the property descriptions of sample_field2 and sample_field3. "
type: !promise package2.SampleClassEnum
kind: COMPOSITION
min_card: !new_object
_type: LiteralNumericValue
value: "0"
max_card: !new_object
_type: LiteralNumericValue
value: "*"
find:
name: sample_field2
set:
description: "This block comment is added to the property descriptions of sample_field2 and sample_field3. "
type: !promise package2.SampleClassEnum
kind: COMPOSITION
min_card: !new_object
_type: LiteralNumericValue
value: "0"
max_card: !new_object
_type: LiteralNumericValue
value: "*"
- promise_id: package1.SampleClass.sample_field3
name: sample_field3
description: "This block comment is added to the property descriptions of sample_field2 and sample_field3. "
type: !promise package1.uint8
kind: COMPOSITION
min_card: !new_object
_type: LiteralNumericValue
value: "3"
max_card: !new_object
_type: LiteralNumericValue
value: "3"
find:
name: sample_field3
set:
description: "This block comment is added to the property descriptions of sample_field2 and sample_field3. "
type: !promise package1.uint8
kind: COMPOSITION
min_card: !new_object
_type: LiteralNumericValue
value: "3"
max_card: !new_object
_type: LiteralNumericValue
value: "3"
- promise_id: package1.SampleClass.sample_field4
name: sample_field4
description: "This block comment is added to the property descriptions of sample_field4 and sample_field5. Fields in SampleClass can reference enums in other files. The property sample_field4 is of type SampleEnum. cf. SampleEnum "
type: !promise SampleEnum.SampleEnum
kind: COMPOSITION
min_card: !new_object
_type: LiteralNumericValue
value: "1"
max_card: !new_object
_type: LiteralNumericValue
value: "1"
find:
name: sample_field4
set:
description: "This block comment is added to the property descriptions of sample_field4 and sample_field5. Fields in SampleClass can reference enums in other files. The property sample_field4 is of type SampleEnum. cf. SampleEnum "
type: !promise SampleEnum.SampleEnum
kind: COMPOSITION
min_card: !new_object
_type: LiteralNumericValue
value: "1"
max_card: !new_object
_type: LiteralNumericValue
value: "1"
- promise_id: package1.SampleClass.sample_field5
name: sample_field5
description: "This block comment is added to the property descriptions of sample_field4 and sample_field5. This inline comment is added to the property description of sample_field5. The property sample_field5 is of type SampleEnumValue. cf. SampleEnum, SAMPLE_ENUM_VALUE_XXX "
type: !promise SampleEnum.SampleEnumValue
kind: COMPOSITION
min_card: !new_object
_type: LiteralNumericValue
value: "1"
max_card: !new_object
_type: LiteralNumericValue
value: "1"
find:
name: sample_field5
set:
description: "This block comment is added to the property descriptions of sample_field4 and sample_field5. This inline comment is added to the property description of sample_field5. The property sample_field5 is of type SampleEnumValue. cf. SampleEnum, SAMPLE_ENUM_VALUE_XXX "
type: !promise SampleEnum.SampleEnumValue
kind: COMPOSITION
min_card: !new_object
_type: LiteralNumericValue
value: "1"
max_card: !new_object
_type: LiteralNumericValue
value: "1"
enumerations:
- promise_id: SampleEnum.SampleEnumValue
find:
Expand Down Expand Up @@ -207,40 +218,47 @@
name: SampleClassEnum
set:
description: "SampleClassEnum.msg Properties in SampleClassEnum can reference enums in the same file. "
sync:
properties:
- promise_id: package2.SampleClassEnum.status
name: status
description: "The property status is of type SampleClassEnumStatus. "
type: !promise SampleClassEnum.SampleClassEnumStatus
kind: COMPOSITION
min_card: !new_object
_type: LiteralNumericValue
value: "1"
max_card: !new_object
_type: LiteralNumericValue
value: "1"
find:
name: status
set:
description: "The property status is of type SampleClassEnumStatus. "
type: !promise SampleClassEnum.SampleClassEnumStatus
kind: COMPOSITION
min_card: !new_object
_type: LiteralNumericValue
value: "1"
max_card: !new_object
_type: LiteralNumericValue
value: "1"
- promise_id: package2.SampleClassEnum.color
name: color
description: "The property color is of type Color. "
type: !promise SampleClassEnum.Color
kind: COMPOSITION
min_card: !new_object
_type: LiteralNumericValue
value: "1"
max_card: !new_object
_type: LiteralNumericValue
value: "1"
find:
name: color
set:
description: "The property color is of type Color. "
type: !promise SampleClassEnum.Color
kind: COMPOSITION
min_card: !new_object
_type: LiteralNumericValue
value: "1"
max_card: !new_object
_type: LiteralNumericValue
value: "1"
- promise_id: package2.SampleClassEnum.field
name: field
description: ""
type: !promise package2.uint8
kind: COMPOSITION
min_card: !new_object
_type: LiteralNumericValue
value: "1"
max_card: !new_object
_type: LiteralNumericValue
value: "1"
find:
name: field
set:
description: ""
type: !promise package2.uint8
kind: COMPOSITION
min_card: !new_object
_type: LiteralNumericValue
value: "1"
max_card: !new_object
_type: LiteralNumericValue
value: "1"
enumerations:
- promise_id: SampleClassEnum.SampleClassEnumStatus
find:
Expand Down
11 changes: 0 additions & 11 deletions tests/data/melody_model_60/.project

This file was deleted.

2 changes: 0 additions & 2 deletions tests/data/melody_model_60/.project.license

This file was deleted.

6 changes: 0 additions & 6 deletions tests/data/melody_model_60/Melody Model Test.afm

This file was deleted.

2 changes: 0 additions & 2 deletions tests/data/melody_model_60/Melody Model Test.afm.license

This file was deleted.

Loading

0 comments on commit 3d60eec

Please sign in to comment.