fdepl文件
定義獨立於中間件(vSomeIp/D-Bus)的C++ API的一個問題是,需要針對API的各個部分使用不同的配置參數,這部分需要取決於中間件。例如,參數,數組或字符串的最大長度等。
Franca IDL可以根據中間件或特定於平臺的部署模型(*.fdepl文件)中使用的中間件來指定部署參數。
一個明確的目標是,針對Common API編寫的應用程序可以與不同的Common API IPC後端鏈接,而無需更改應用程序代碼。
因此,有一個重要的隱性限制:Franca IDL(*.fidl文件)中定義的接口只與CommonAPI以及用戶調用相關。專用於IPC後端的部署模型(.fdepl)不得影響所生成的API。但是允許使用非特定的部署模型。
fdepl文件的基本構成
類別1 | 類別2 | 說明 | 舉例 |
---|---|---|---|
for interface | 對接口進行一些部署,設置ServiceID值,也可以設置枚舉支持的類型 | *Reliable = false表示使用UDP協議,Reliable = true表示使用TCP協議 | |
attribute | 爲屬性的getter, setter等方法提供ID值 | attribute x { SomeIpGetterID = 3000 SomeIpSetterID = 3001 SomeIpNotifierID = 33010 SomeIpEventGroups = { 33010 } SomeIpGetterReliable = false SomeIpSetterReliable = false SomeIpNotifierReliable = false} | |
method | 設置method的ID值,並設置輸入輸出字符串類型的編碼/解碼格式;也可以訂閱方法調用的超時 | method foo { SomeIpMethodID = 30000 SomeIpReliable = false in { x2 { SomeIpStringEncoding = utf16le } } out { y2 {SomeIpStringEncoding =utf16le} } } | |
broadcast | 設置廣播事件以及廣播事件組的ID值,並設置輸出字符串類型的編碼/解碼格式 | broadcast myStatus { SomeIpEventID = 33020 SomeIpEventGroups = { 33020 } } | |
array | 定義數組的長度 | SomeIpArrayLengthWidth = 2 | |
enumeration | 設置枚舉的數據類型 | EnumBackingType = UInt64 | |
for provider | 提供實例 | ||
instance | 設置實例名稱以及實例ID值,並設置實例的地址和端口號 | instance commonapi.mthd.Method { InstanceId = “commonapi.mthd.Method” SomeIpInstanceID = 22136 SomeIpUnicastAddress = “192.168.0.2” SomeIpReliableUnicastPort = 30500 SomeIpUnreliableUnicastPort = 30501 } | |
for typeCollection | 用戶自己定義的各種數據類型的集合 | ||
array | 定義數組的長度 | SomeIpArrayLengthWidth = 2 | |
enumeration | 設置枚舉的數據類型 | EnumBackingType = UInt64 |
使用實例展示:
/* Copyright (C) 2015 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
import "platform:/plugin/org.genivi.commonapi.someip/deployment/CommonAPI-4-SOMEIP_deployment_spec.fdepl"
import "E01HelloWorld.fidl"
define org.genivi.commonapi.someip.deployment for interface commonapi.examples.E01HelloWorld {
SomeIpServiceID = 4660
method sayHello {
SomeIpMethodID = 30000
SomeIpReliable = true
in {
name {
SomeIpStringEncoding = utf16le
}
}
}
}
define org.genivi.commonapi.someip.deployment for provider as Service {
instance commonapi.examples.E01HelloWorld {
InstanceId = "commonapi.examples.HelloWorld"
SomeIpInstanceID = 22136
SomeIpUnicastAddress = "192.168.0.2"
SomeIpReliableUnicastPort = 30499
SomeIpUnreliableUnicastPort = 30499
}
}
for interface
for interface,對應於*.fidl文件中的interface,在這裏面主要是配置中間件的ServiceID,以及其他method,broadcast,attribute等使用的methodID,eventID值等。
設置ServiceID:
SomeIpServiceID = 4660
也可以在此定義整個接口的CommonAPI C++級別上定義枚舉支持的類型,默認是UInt32:
DefaultEnumBackingType: { UInt8, UInt16, UInt32, UInt64, Int8, Int16, Int32, Int64 } (default: UInt32);
例如:
DefaultEnumBackingType = UInt8
attribute
爲每個屬性所使用的getter, setter等方法設置ID值,並設置這些方法的可靠性。
method
爲方法method設置methodID值,並設置可靠性,
也可以爲in, out的輸入輸出參數的字符串類型設置編碼/解碼格式,也可以不設置,從而使用默認設置。
也可以在此處設置超時:
Timeout : Integer (default: 0);
例如:
Timeout = 1
broadcast
爲broadcast事件設置EventID值,Event Groups值(這個是將自己想要劃分爲一組的事件ID寫在一起),設置可靠性,也可以定義out參數裏面字符串類型的編碼/解碼格式。
for typeCollection
array
SomeIpArrayLengthWidth是決定長度字段的大小,表示數組序列化時在數組前面用於表示數組長度的字節數。
即SomeIpArrayLengthWidth =2表示數組在序列化時,前面需要加2個字節,用於表示數組的長度,允許的值是0、1、2、4。
0表示沒有長度字段。
array myArray {
SomeIpArrayLengthWidth = 2
}
enumeration
可以在此設置枚舉使用的數據類型:
EnumBackingType : {UInt8, UInt16, UInt32, UInt64, Int8, Int16, Int32, Int64} (optional);
例如:
EnumBackingType = UInt64
for provider
在此提供程序所依賴的所有服務實例(如果有),併爲實例設置名稱,ID值以及IP地址和端口號。