纲要:
SWC属于AUTOSAR的Component文件夹下,而Composition属于Composition文件夹下。
目录
1. Import "Data Type" and "Interface" information
2. Creat Software Component(SWC)
4. Add "Internal Behavior" for this SWC
1. Import "Data Type" and "Interface" information
Copy the "01_TypesAndInterface.arxml" file into the project, which contains
- Sender receiver Interface
- Data Element
- Application data type
- Implementation Data Type
which will be used in the "SWC creation". [0][0.1]
2. Creat Software Component(SWC)
Right click on the project, create "Component - Element/Sensor Actuator Sw Component Type". Then name the SWC, which will create "02_WiperControl_100us.arxml" file to save the SWC information.
3. Create "Port" for this SWC
Right click on the "02_WiperControl_100us.arxml" file and Open with “Component Editor", there will be option to create Pport/Rport. And also which Interface to be added under the port.[0.2](Interface is defined under 01_TypesAndInterface.arxml)
4. Add "Internal Behavior" for this SWC
- Runnable Entity(RE) [1]
- DataAccessPoint: DataReadAccess/DataWriteAccess [2][2.1]
- Timing Event[3]
- DataTypeMappingSet[4][5]
1个SWC下面可以有多个 runnable【也就是函数】和多个Interface。 runnable下的DataAccessPoint 实现了将指定的interface分配给该runnable/函数
注:
[0] 说明新建SWC port的前提是要提前定义好Interface库,port只能从现有的库里面去绑定Interface
![](https://i-blog.csdnimg.cn/blog_migrate/c1de972a0a39fa51734df0b95d059d69.png)
[0]: 每次在新建SWC之前,都应该去看看有哪些Interface可用,这是新建SWC的基础和前提条件。因为SWC的port只能与现有的Interface相连,而Interface下面的Data Element则代表着SWC可用的variable
[0.1]: Application data type 和 Implementation Data Type 存在“01_TypesAndInterface.arxml”文件,但AUTOSAR platform types存在"ISOLAR_PlatformTypes.arxml"文件里面
[0.2]: 用户去决定是Pport还是Rport,因为Interface是不分方向的
[1] 每个SWC下面可以有多个runnables
[2] 是Read还是Write基于之前给该SWC新建的Ports来确定,软件会自动识别这步分配的是Pport还是Rport,从而确定是Read还是Write AccessPoint
[2.1] DataAccessPoint是在Function/Runnable下面的一个子tab,说白了就是一个SWC可以有多个runnable,在DataAccessPoint这个tab来规定各个port到底分配到哪个runnable
[3] 新建TimingEvent后软件会问和哪个runnable绑定,即TimingEvent可以看作是runnable的子tab
[4] DataTypeMappingSet is under "Internal Behavior', 所以说是基于SWC去绑定一个个相互独立的DataTypeMappingSet
[5] 之前在“01_TypesAndInterface.arxml” 文件里面只会去创建Application data type和Implementation data type(并声明IDT和哪种AUTOSAR base type相连)(Data Element在Interface下面和ADT相连),在这里(02_WiperControl_100us.arxml)才会将 Application data type和Implementation data type连接起来(可附加ComputeMethoud)
![](https://i-blog.csdnimg.cn/blog_migrate/16c23bdb5c3d33fc3d1af9b5320a428f.png)
[6] 但在实际生成的代码中,SWC变量/DataElement 用的是Implementation data type
![](https://i-blog.csdnimg.cn/blog_migrate/00d566abbac2cabe1d5e3a65354ff9ac.png)
[7] 之所以搞ADT出来,是为了Interface的复用,因为IDT是和AUTOSAR Platform Type绑定的,而AUTOSAR Platform Type与硬件有关(Int是16还是32-bit), 而在创建Interface的时候如果直接用IDT换了硬件就没法复用了,所以选用ADT和Data Element绑定,然后再在SWC的Internal Behavior里面用DataTypeMapping将ADT和IDT对应起来
问
1. RTE.c 里面的function name 是由 Internal behavior/Function这儿的命名一样吗?