Main Content

importFromARXML

Import compositions and components from ARXML files into AUTOSAR architecture model

Description

importFromARXML(archElementOrModel,ar,compQName) imports the AUTOSAR composition or component compQName from ARXML descriptions provided by ar into the AUTOSAR architecture model, composition, or component archElementOrModel.

example

importFromARXML(archElementOrModel,ar,compQName,Name=Value) specifies additional import options using one or more name-value arguments. For example, among other options, you can create client-server ports when you import AUTOSAR client and server ports in the created AUTOSAR architecture model.

example

Examples

collapse all

Create an AUTOSAR architecture model and import an AUTOSAR composition from an ARXML file.

Access the relevant ARXML file and create an AUTOSAR architecture model.

openExample("ThrottlePositionControlComposition.arxml");
modelName = "myArchModel";
archModel = autosar.arch.createModel(modelName);

Use an arxml.importer object to import an AUTOSAR composition from ARXML file ThrottlePositionControlComposition.arxml.

importerObj = arxml.importer("ThrottlePositionControlComposition.arxml");
importFromARXML(archModel,importerObj, ...
  "/Company/Components/ThrottlePositionControlComposition")
Creating model 'ThrottlePositionSensor' for component 1 of 5:
  /Company/Components/ThrottlePositionSensor
Creating model 'ThrottlePositionMonitor' for component 2 of 5:
  /Company/Components/ThrottlePositionMonitor
Creating model 'Controller' for component 3 of 5:
  /Company/Components/Controller
Creating model 'AccelerationPedalPositionSensor' for component 4 of 5:
  /Company/Components/AccelerationPedalPositionSensor
Creating model 'ThrottlePositionActuator' for component 5 of 5:
  /Company/Components/ThrottlePositionActuator
Importing composition 1 of 1:
  /Company/Components/ThrottlePositionControlComposition

Import AUTOSAR compositions and link them to existing component models.

Create an AUTOSAR architecture model with no functional content.

modelName = "myArchModel";
archModel = autosar.arch.createModel(modelName);

Import AUTOSAR software composition /pkg/rootComposition from ARXML file mySWCs.arxml into the architecture model. For software components mySwc1 and mySwc2 contained within the composition, link existing Simulink® component models rather than creating new ones.

importFromARXML(archModel,"mySWCs.arxml","/pkg/rootComposition", ...
  ComponentModels={'mySwc1','mySwc2'})

This example shows how to import an AUTOSAR composition into an architecture model configured for the AUTOSAR Classic Platform. When you import the ARXML file, Simulink® automatically creates interfaces for both sender-receiver and client-server communication used in the components. The software automatically creates bus element ports for sender-receiver interfaces, and you specify that the importer create client-server ports in the architecture model for client-server interfaces.

The attached ARXML AUTOSARArchitecture.arxml contains an asynchronous client:

<SHORT-NAME>Runnable3</SHORT-NAME>
<MINIMUM-START-INTERVAL>0</MINIMUM-START-INTERVAL>
<ASYNCHRONOUS-SERVER-CALL-RESULT-POINTS>
    <ASYNCHRONOUS-SERVER-CALL-RESULT-POINT UUID="37a7cd8d-7e54-5ad9-7fc2-3cc54aa9207f">
        <SHORT-NAME>SCR_readData_client_readData</SHORT-NAME>
        <ASYNCHRONOUS-SERVER-CALL-POINT-REF DEST="ASYNCHRONOUS-SERVER-CALL-POINT">/Components/clientSWC/clientSWCIB/Runnable3/SC_readData_client_readData</ASYNCHRONOUS-SERVER-CALL-POINT-REF>
    </ASYNCHRONOUS-SERVER-CALL-RESULT-POINT>
</ASYNCHRONOUS-SERVER-CALL-RESULT-POINTS>

To import asynchronous clients from ARXML descriptions to Simulink, the ARXML importer requires that the ASYNCHRONOUS-SERVER-CALL-RESULT-POINT and ASYNCHRONOUS-SERVER-CALL-POINT are defined in the same runnable description, in this case Runnable3. Otherwise, the ServerCallPoint property for the imported client is set to Synchronous after import and model creation. For more information about mapping AUTOSAR client ports, Simulink Function Callers, and configuring the ServerCallPoint property, see Simulink Function Caller to AUTOSAR Client Port Mapping.

Create an AUTOSAR architecture model configured for the AUTOSAR Classic Platform with no functional content.

archModel = autosar.arch.createModel("myArchModel")
archModel = 
  Model with properties:

                  Name: 'myArchModel'
        SimulinkHandle: 149.4736
            Components: [0×0 autosar.arch.Component]
          Compositions: [0×0 autosar.arch.Composition]
    ParameterComponent: [0×0 autosar.arch.ParameterComponent]
                 Ports: [0×0 autosar.arch.PortBase]
            Connectors: [0×0 autosar.arch.Connector]
            Interfaces: [0×0 Simulink.dictionary.archdata.PortInterface]
              Platform: 'Classic'

Import AUTOSAR software composition /Components/ClientServerAUTOSARArchitecture from the ARXML file ClientServerAUTOSARArchitecture.arxml to the empty AUTOSAR architecture model you created. Set the UseFunctionPorts name-value argument to true to automatically create client and server ports.

importFromARXML(archModel,"AUTOSARArchitecture.arxml","/Components/AUTOSARArchitecture",UseFunctionPorts=true)
Created model 'serverSWC' for component 1 of 2: /Components/serverSWC
Created model 'clientSWC' for component 2 of 2: /Components/clientSWC
Importing composition 1 of 1: /Components/AUTOSARArchitecture

Verify that the AUTOSAR client port readData_client invokes a server asynchronously by viewing properties for the mapped function caller readData.

slMap = autosar.api.getSimulinkMapping("clientSWC");
find(slMap,"FunctionCallers")
ans = 
"readData_client.readData"
[arPort,arOp,serverCallPoint] = getFunctionCaller(slMap,"readData_client.readData")
arPort = 
'readData_client'
arOp = 
'readData'
serverCallPoint = 
'Asynchronous'

Import an AUTOSAR composition defined in an arxml.importer object, resolve variation points for the imported composition by providing the full path to a predefined variant in the imported ARXML files.

Create an AUTOSAR architecture model with no functional content.

modelName = "myArchModel";
archModel = autosar.arch.createModel(modelName);

Import AUTOSAR software composition /CompositionType/myComposition from ARXML file myComposition.arxml into the architecture model. For each software component contained within the composition, at component model creation time, use predefined variant Senior to resolve variation points in the component.

importerObj = arxml.importer("MyComposition.arxml"); 
importFromARXML(archModel,importerObj,"/CompositionType/myComposition", ...
  PredefinedVariant="/pkg/body/Variants/Senior");

Input Arguments

collapse all

AUTOSAR architecture model, composition, or component into which the specified composition or component compQName is imported, specified as one of these objects:

AUTOSAR information previously imported from ARXML files, specified as one of these:

  • An arxml.importer object handle.

  • One or more ARXML file names, specified as a character vector, string scalar, cell array of character vectors, or string array.

Example: "AUTOSARswc.arxml"

Example: ["AUTOSARswc.arxml","myDataTypes.arxml"]

Data Types: char | string | cell | function_handle

Absolute short-name path (qualified name) of the composition or component to import into the architecture model, composition, or component specified by ArchElementOrModel.

Example: "/Compositions/AUTOSARComposition"

Example: "/Components/AUTOSARSwComponent"

Data Types: char | string | cell

Name-Value Arguments

collapse all

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Example: importFromARXML(archModel,importerObj,"/CompositionType/myComposition", PredefinedVariant="/pkg/body/Variants/Senior");

Names of existing Simulink behavior component models, specified as a cell array of character vectors. The importer uses these existing component models instead of creating new ones to specify the behavior of the created Simulink composition model.

Example: ComponentModels = ["mySwc1","mySwc2"]

Data Types: cell

Filename of Simulink data dictionary to link to the architecture , composition, and component models, specified as a character vector or string scalar. The importer creates interfaces and data types, used by the models as specified in the imported ARXML files, in the Architectural Data section of the data dictionary.

Example: DataDictionary = "ardata.sldd"

Data Types: char | string

Option to include or exclude software components that define the behavior of the imported composition, specified as numeric or logical 1 (true) or 0 (false). By default, the importer includes internal component behavior within the composition.

When excluding the component model behavior the importer still links models specified by the ComponentModels name-value argument.

Example: ExcludeInternalBehavior = true

Data Types: logical

AUTOSAR composition import type, specified as either "Model" or "Subsystem".

  • "Subsystem" — Imports the composition as a subsystem of the composition or architecture model specified by ArchElementOrModel.

  • "Model" — Creates a separate model for the composition.

Example: ImportCompositionAs = "Model"

Data Types: char | string

Subsystem type for periodic runnables of imported components, specified as one of these values:

  • "Auto" — The importer models periodic runnables as atomic subsystems when possible. If conditions prevent use of atomic subsystems, the importer models periodic runnables as function-call subsystems.

  • "AtomicSubsystem" — The importer models periodic runnables as atomic subsystems with periodic rates. If conditions prevent the use of atomic subsystems, the importer reports an error.

  • "FunctionCallSubsystem" — The importer models periodic runnables as function-call subsystems with periodic rates. If conditions prevent the use of function-call subsystems, the importer reports an error.

For more information, see Import AUTOSAR Software Component with Multiple Runnables.

Example: ModelPeriodicRunnablesAs = "FunctionCallSubsystem"

Data Types: char | string

Option to automatically open architecture model, specified as numeric or logical 1 (true) or 0 (false).

Example: OpenModel=false

Data Types: logical

Path to AUTOSAR predefined variant of imported components, specified as a character vector or string scalar. A predefined variant describes a combination of system constant values to apply to an AUTOSAR software component. Use this argument to resolve variation points during AUTOSAR software component creation.

If specified, the importer uses the predefined variant to initialize software system constant data that controls variation points in the created Simulink behavior model.

For more information, see Control AUTOSAR Variants with Predefined Value Combinations.

Example: PredefinedVariant = "/pkg/body/Variants/Senior"

Data Types: char | string

Paths to one or more AUTOSAR system constant value sets of imported components, specified as a cell array of character vectors or string array. A system constant value set defines a group of system constant values to apply to an AUTOSAR software component. Use this argument to resolve variation points component model creation time.

If specified, the importer uses the software system constant values at the specified path to initialize software system constant data that controls variation points in the created Simulink behavior model.

For more information, see Control AUTOSAR Variants with Predefined Value Combinations.

Example: SystemConstValueSets = ["/pkg/body/SystemConstantValues/A","/pkg/body/SystemConstantValues/B"]

Data Types: char | string | cell

Option to import client-server ports as Simulink function ports, specified as numeric or logical 1 (true) or 0 (false).

  • true — Use port-scoped Simulink functions and function callers.

  • false — Use global Simulink functions and function callers.

Example: UseFunctionPorts=true

Data Types: logical

Option to import AUTOSAR data types as Simulink.ValueType data type objects, specified as numeric or logical 1 (true) or 0 (false).

Example: UseValueTypes=true

Data Types: logical

Version History

Introduced in R2020b

expand all