@@ -90,8 +90,11 @@ def createProvidePort(self, name, portInterfaceRef, **kwargs):
90
90
if portInterface is None :
91
91
raise autosar .base .InvalidPortInterfaceRef (portInterfaceRef )
92
92
if comspecList is None :
93
- comspecList = self ._autoCreateComSpecListFromArgs (ws , portInterface , kwargs )
94
- port = autosar .port .ProvidePort (name , portInterface .ref , comspecList , parent = self )
93
+ comspecDict = kwargs if len (kwargs ) > 0 else None
94
+ port = autosar .port .ProvidePort (name , portInterface .ref , comspecDict , parent = self )
95
+ else :
96
+ port = autosar .port .ProvidePort (name , portInterface .ref , comspecList , parent = self )
97
+ assert (isinstance (port , autosar .port .Port ))
95
98
self .providePorts .append (port )
96
99
return port
97
100
@@ -135,8 +138,11 @@ def createRequirePort(self, name, portInterfaceRef, **kwargs):
135
138
if portInterface is None :
136
139
raise autosar .base .InvalidPortInterfaceRef (portInterfaceRef )
137
140
if comspecList is None :
138
- comspecList = self ._autoCreateComSpecListFromArgs (ws , portInterface , kwargs )
139
- port = autosar .port .RequirePort (name ,portInterface .ref , comspecList , parent = self )
141
+ comspecDict = kwargs if len (kwargs ) > 0 else None
142
+ port = autosar .port .RequirePort (name , portInterface .ref , comspecDict , parent = self )
143
+ else :
144
+ port = autosar .port .RequirePort (name , portInterface .ref , comspecList , parent = self )
145
+ assert (isinstance (port , autosar .port .Port ))
140
146
self .requirePorts .append (port )
141
147
return port
142
148
@@ -163,116 +169,6 @@ def mirrorPort(self, otherPort):
163
169
"""
164
170
self .append (otherPort .mirror ())
165
171
166
- def _autoCreateComSpecListFromArgs (self , ws , portInterface , kwargs ):
167
- """
168
- Attempts to prepare comspec arguments before calling the Port.createComSpecFromDict method
169
- """
170
- comspecList = []
171
- if isinstance (portInterface , autosar .portinterface .SenderReceiverInterface ):
172
- if len (portInterface .dataElements )== 1 :
173
- comspec = {'dataElement' : portInterface .dataElements [0 ].name }
174
- initValue = kwargs .get ('initValue' , None )
175
- initValueRef = kwargs .get ('initValueRef' , None )
176
- queueLength = kwargs .get ('queueLength' , None )
177
-
178
- if initValue is not None :
179
- if initValueRef is not None :
180
- raise ValueError ('A port cannot have both initValue and initValueRef set at the same time' )
181
- comspec ['initValue' ] = initValue
182
- if initValueRef is not None :
183
- if initValue is not None :
184
- raise ValueError ('A port cannot have both initValue and initValueRef set at the same time' )
185
- comspec ['initValueRef' ] = initValueRef
186
- if queueLength is not None :
187
- comspec ['queueLength' ] = queueLength
188
- if ws .version >= 4.0 :
189
- usesEndToEndProtection = kwargs .get ('usesEndToEndProtection' , None )
190
- if usesEndToEndProtection is not None :
191
- comspec ['usesEndToEndProtection' ] = bool (usesEndToEndProtection )
192
- comspecList .append (comspec )
193
- else :
194
- raise RuntimeError ("This feature only works when there is exactly one data element in the port interface" )
195
-
196
- elif isinstance (portInterface ,autosar .portinterface .ClientServerInterface ):
197
- for operation in portInterface .operations :
198
- comspecList .append ({'operation' : operation .name })
199
-
200
- elif isinstance (portInterface ,autosar .portinterface .ParameterInterface ):
201
- if len (portInterface .parameters )== 1 :
202
- initValue = kwargs .get ('initValue' , None )
203
- comspec = {'parameter' : portInterface .parameters [0 ].name }
204
- if initValue is not None :
205
- comspec ['initValue' ] = initValue
206
- comspecList .append (comspec )
207
- else :
208
- raise RuntimeError ("This feature only works when there is exactly one data element in the port interface" )
209
-
210
- elif isinstance (portInterface ,autosar .portinterface .ModeSwitchInterface ):
211
- comspec = {}
212
- enhancedMode = kwargs .get ('enhancedMode' , None )
213
- supportAsync = kwargs .get ('supportAsync' , None )
214
- queueLength = kwargs .get ('queueLength' , None )
215
- modeSwitchAckTimeout = kwargs .get ('modeSwitchAckTimeout' , None )
216
- modeGroup = kwargs .get ('modeGroup' , None )
217
- if enhancedMode is not None :
218
- comspec ['enhancedMode' ]= enhancedMode
219
- if supportAsync is not None :
220
- comspec ['supportAsync' ]= supportAsync
221
- if queueLength is not None :
222
- comspec ['queueLength' ]= queueLength
223
- if modeSwitchAckTimeout is not None :
224
- comspec ['modeSwitchAckTimeout' ]= modeSwitchAckTimeout
225
- if modeGroup is not None :
226
- comspec ['modeGroup' ]= modeGroup
227
- comspecList .append (comspec )
228
- elif isinstance (portInterface ,autosar .portinterface .NvDataInterface ):
229
- if len (portInterface .nvDatas )== 1 :
230
- comspec = {'nvData' : portInterface .nvDatas [0 ].name }
231
- initValue = kwargs .get ('initValue' , None )
232
- initValueRef = kwargs .get ('initValueRef' , None )
233
- ramBlockInitValue = kwargs .get ('ramBlockInitValue' , None )
234
- ramBlockInitValueRef = kwargs .get ('ramBlockInitValueRef' , None )
235
- romBlockInitValue = kwargs .get ('romBlockInitValue' , None )
236
- romBlockInitValueRef = kwargs .get ('romBlockInitValueRef' , None )
237
- queueLength = kwargs .get ('queueLength' , None )
238
-
239
- if initValue is not None :
240
- if initValueRef is not None :
241
- raise ValueError ('A port cannot have both initValue and initValueRef set at the same time' )
242
- comspec ['initValue' ] = initValue
243
- if initValueRef is not None :
244
- if initValue is not None :
245
- raise ValueError ('A port cannot have both initValue and initValueRef set at the same time' )
246
- comspec ['initValueRef' ] = initValueRef
247
-
248
- if ramBlockInitValue is not None :
249
- if ramBlockInitValueRef is not None :
250
- raise ValueError ('A port cannot have both ramBlockInitValue and ramBlockInitValueRef set at the same time' )
251
- comspec ['ramBlockInitValue' ] = ramBlockInitValue
252
-
253
- if ramBlockInitValueRef is not None :
254
- if ramBlockInitValue is not None :
255
- raise ValueError ('A port cannot have both ramBlockInitValue and ramBlockInitValueRef set at the same time' )
256
- comspec ['ramBlockInitValueRef' ] = ramBlockInitValueRef
257
-
258
- if romBlockInitValue is not None :
259
- if romBlockInitValueRef is not None :
260
- raise ValueError ('A port cannot have both romBlockInitValue and romBlockInitValueRef set at the same time' )
261
- comspec ['romBlockInitValue' ] = romBlockInitValue
262
-
263
- if romBlockInitValueRef is not None :
264
- if romBlockInitValue is not None :
265
- raise ValueError ('A port cannot have both romBlockInitValue and romBlockInitValueRef set at the same time' )
266
- comspec ['romBlockInitValueRef' ] = romBlockInitValueRef
267
- comspecList .append (comspec )
268
- else :
269
- raise RuntimeError ("This feature only works when there is exactly one data element in the port interface" )
270
- else :
271
- raise NotImplementedError (type (portInterface ))
272
-
273
- return comspecList if len (comspecList ) > 0 else None
274
-
275
-
276
172
class AtomicSoftwareComponent (ComponentType ):
277
173
"""
278
174
base class for ApplicationSoftwareComponent and ComplexDeviceDriverComponent
0 commit comments