|
12 | 12 | # through them using IdShorts and IdShortPaths. |
13 | 13 | # |
14 | 14 | # Step-by-Step Guide: |
15 | | -# Step 1: Create a Submodel with a Property, a Property Collection, a Property List and a Collection List |
| 15 | +# Step 1: Create a Submodel with a Property, a SubmodelElementCollection of Properties, a SubmodelElementList of |
| 16 | +# Properties and a SubmodelElementList of SubmodelElementCollections |
| 17 | +# |
| 18 | +# Submodel "https://iat.rwth-aachen.de/Simple_Submodel" |
| 19 | +# ├── Property "MyProperty" |
| 20 | +# │ |
| 21 | +# ├── SubmodelElementCollection "MyPropertyCollection" |
| 22 | +# │ ├── Property "MyProperty0" |
| 23 | +# │ └── Property "MyProperty1" |
| 24 | +# │ |
| 25 | +# ├── SubmodelElementList "MyPropertyList" |
| 26 | +# │ ├── Property [0] |
| 27 | +# │ └── Property [1] |
| 28 | +# │ |
| 29 | +# └── SubmodelElementList "MyCollectionList" |
| 30 | +# ├── SubmodelElementCollection [0] |
| 31 | +# │ └── Property "MyProperty" |
| 32 | +# ├── SubmodelElementCollection [1] |
| 33 | +# │ └── Property "MyProperty" |
| 34 | +# └── SubmodelElementCollection [2] |
| 35 | +# └── Property "MyProperty" |
| 36 | +# |
16 | 37 | # Step 2: Navigate through the Submodel using IdShorts and IdShortPaths |
17 | 38 |
|
18 | 39 |
|
|
31 | 52 | ) |
32 | 53 | submodel.submodel_element.add(my_property) |
33 | 54 |
|
34 | | -# Step 1.3: Add a Property Collection to the Submodel |
| 55 | +# Step 1.3: Add a SubmodelElementCollection of Properties to the Submodel |
35 | 56 | my_property_collection = model.SubmodelElementCollection( |
36 | 57 | id_short="MyPropertyCollection", |
37 | 58 | value={ |
38 | 59 | model.Property( |
39 | 60 | id_short="MyProperty0", |
40 | 61 | value_type=model.datatypes.String, |
41 | | - value="I am the first of two Properties within a Property Collection" |
| 62 | + value="I am the first of two Properties within a SubmodelElementCollection" |
42 | 63 | ), |
43 | 64 | model.Property( |
44 | 65 | id_short="MyProperty1", |
45 | 66 | value_type=model.datatypes.String, |
46 | | - value="I am the second of two Properties within a Property Collection" |
| 67 | + value="I am the second of two Properties within a SubmodelElementCollection" |
47 | 68 | ) |
48 | 69 | } |
49 | 70 | ) |
50 | 71 | submodel.submodel_element.add(my_property_collection) |
51 | 72 |
|
52 | | -# Step 1.4: Add a Property List to the Submodel |
| 73 | +# Step 1.4: Add a SubmodelElementList of Properties to the Submodel |
53 | 74 | my_property_list = model.SubmodelElementList( |
54 | 75 | id_short="MyPropertyList", |
55 | 76 | type_value_list_element=model.Property, |
|
59 | 80 | model.Property( |
60 | 81 | id_short=None, |
61 | 82 | value_type=model.datatypes.String, |
62 | | - value="I am Property 0 within a Property List" |
| 83 | + value="I am Property 0 within a SubmodelElementList" |
63 | 84 | ), |
64 | 85 | model.Property( |
65 | 86 | id_short=None, |
66 | 87 | value_type=model.datatypes.String, |
67 | | - value="I am Property 1 within a Property List" |
| 88 | + value="I am Property 1 within a SubmodelElementList" |
68 | 89 | ) |
69 | 90 | ] |
70 | 91 | ) |
71 | 92 | submodel.submodel_element.add(my_property_list) |
72 | 93 |
|
73 | | -# Step 1.5: Add a Collection List to the Submodel |
| 94 | +# Step 1.5: Add a SubmodelElementList of SubmodelElementCollections to the Submodel |
74 | 95 | my_property_collection_0 = model.SubmodelElementCollection( |
75 | 96 | id_short=None, |
76 | 97 | value={model.Property( |
77 | 98 | id_short="MyProperty", |
78 | 99 | value_type=model.datatypes.String, |
79 | | - value="I am a simple Property within Property Collection 0" |
| 100 | + value="I am a simple Property within SubmodelElementCollection 0" |
80 | 101 | )} |
81 | 102 | ) |
82 | 103 | my_property_collection_1 = model.SubmodelElementCollection( |
83 | 104 | id_short=None, |
84 | 105 | value={model.Property( |
85 | 106 | id_short="MyProperty", |
86 | 107 | value_type=model.datatypes.String, |
87 | | - value="I am a simple Property within Property Collection 1" |
| 108 | + value="I am a simple Property within SubmodelElementCollection 1" |
88 | 109 | )} |
89 | 110 | ) |
90 | 111 | my_property_collection_2 = model.SubmodelElementCollection( |
91 | 112 | id_short=None, |
92 | 113 | value={model.Property( |
93 | 114 | id_short="MyProperty", |
94 | 115 | value_type=model.datatypes.String, |
95 | | - value="I am a simple Property within Property Collection 2" |
| 116 | + value="I am a simple Property within SubmodelElementCollection 2" |
96 | 117 | )} |
97 | 118 | ) |
98 | 119 | my_collection_list = model.SubmodelElementList( |
|
112 | 133 | my_property = cast(model.Property, submodel.get_referable("MyProperty")) |
113 | 134 | print(f"my_property: id_short = {my_property.id_short}, value = {my_property.value}\n") |
114 | 135 |
|
115 | | -# Step 2.2.1: Access a Property within a Property Collection step by step via its IdShort |
| 136 | +# Step 2.2: Navigate through a SubmodelElementCollection of Properties |
| 137 | +# Step 2.2.1: Access a Property within a SubmodelElementCollection step by step via its IdShort |
116 | 138 | my_property_collection = cast(model.SubmodelElementCollection, submodel.get_referable("MyPropertyCollection")) |
117 | 139 | my_property_collection_property_0 = cast(model.Property, my_property_collection.get_referable("MyProperty0")) |
118 | 140 | print( |
|
121 | 143 | f"value = {my_property_collection_property_0.value}" |
122 | 144 | ) |
123 | 145 |
|
124 | | -# Step 2.2.2: Access a Property within a Property Collection via its IdShortPath |
| 146 | +# Step 2.2.2: Access a Property within a SubmodelElementCollection via its IdShortPath |
125 | 147 | my_property_collection_property_1 = cast( |
126 | 148 | model.Property, |
127 | 149 | submodel.get_referable(["MyPropertyCollection", "MyProperty1"]) |
|
132 | 154 | f"value = {my_property_collection_property_1.value}\n" |
133 | 155 | ) |
134 | 156 |
|
135 | | -# Step 2.3.1: Access a Property within a Property List step by step via its index |
| 157 | +# Step 2.3: Navigate through a SubmodelElementList of Properties |
| 158 | +# Step 2.3.1: Access a Property within a SubmodelElementList step by step via its index |
136 | 159 | my_property_list = cast(model.SubmodelElementList, submodel.get_referable("MyPropertyList")) |
137 | 160 | my_property_list_property_0 = cast(model.Property, my_property_list.get_referable("0")) |
138 | 161 | print( |
|
141 | 164 | f"value = {my_property_list_property_0.value}" |
142 | 165 | ) |
143 | 166 |
|
144 | | -# Step 2.3.2: Access a Property within a Property List via its IdShortPath |
| 167 | +# Step 2.3.2: Access a Property within a SubmodelElementList via its IdShortPath |
145 | 168 | my_property_list_property_1 = cast(model.Property, submodel.get_referable(["MyPropertyList", "1"])) |
146 | 169 | print( |
147 | 170 | f"my_property_list_property_1: " |
148 | 171 | f"id_short = {my_property_list_property_1}, " |
149 | 172 | f"value = {my_property_list_property_1.value}\n" |
150 | 173 | ) |
151 | 174 |
|
152 | | -# Step 2.4.1: Access a Property within a Collection List step by step via its index and IdShort |
| 175 | +# Step 2.4: Navigate through a SubmodelElementList of SubmodelElementCollections |
| 176 | +# Step 2.4.1: Access a Property within a SubmodelElementList of SubmodelElementCollections step by step via its index |
| 177 | +# and IdShort |
153 | 178 | my_collection_list = cast(model.SubmodelElementList, submodel.get_referable("MyCollectionList")) |
154 | 179 | my_collection_list_collection_0 = cast(model.SubmodelElementCollection, my_collection_list.get_referable("0")) |
155 | 180 | my_collection_list_collection_0_property_0 = cast( |
|
162 | 187 | f"value = {my_collection_list_collection_0_property_0.value}" |
163 | 188 | ) |
164 | 189 |
|
165 | | -# Step 2.4.2: Access a Property within a Collection List via its IdShortPath |
| 190 | +# Step 2.4.2: Access a Property within a SubmodelElementList of SubmodelElementCollections via its IdShortPath |
166 | 191 | my_collection_list_collection_2_property_0 = cast( |
167 | 192 | model.Property, |
168 | 193 | submodel.get_referable(["MyCollectionList", "2", "MyProperty"]) |
|
0 commit comments