DEENESPTFRRUARHIKOZHNL
ADAPTIVE Modul: com Rolle: heuristic Konfidenz: 85%

SNIP_ADAPTIVE_COM_FIGURE_Figure_6_3

Quelle: ARAComAPI.pdf (Seite 1) • Ziel-Anforderung: SWS_CORE_01129

Wortlaut

Figure 6.3: Handling of optional data elements on Skeleton side The Proxy in Figure 6.4 consumes the BatteryState structure defined in Figure 6.2. The implementation is aware of both optional labeled elements current and health. Before accessing the value of the optional elements the implementation has to check whether there is really a value contained. Therefore the optional API provides two methods: The operator bool and the has_value method. 1 using namespace ara::com; 2 3 int main() { 4 // some code to acquire handle 5 // ... 6 BatteryStateProxy bms_service(handle); 7 Future<BatteryState> stateFuture = bms_service.GetBatteryState(); 8 // Receice BatteryState 9 BatteryState state = stateFuture.get(); 10 11 // Check the optional contained elements for presence 12 if(state.current) { 13 //Access the value of the optional element with the optional::operator * 14 if(*state.current >= MAX_CURRENT) { 15 // do something with this information 16 } 17 } 18 19 // Check with optional::has_value() method 20 if(state.health.has_value()){ 21 // Access the value of the optional element with the optional::value() method 22 if(state.health.value() >= BAD_HEALTH) { 23 // do something with this information 24 } 25 } 26 }

Versionen & Provenienz · Zugeordnete Anforderungen

Diese Angaben zeigt der Versions-Explorer.

Begründung & Zuweisungs-Evidenz

Optional has_value method usage

Dokumenten-Herkunft & Rückverfolgbarkeit

Spezifikations-Dokument ARAComAPI.pdf
Dokumentseite Seite 1
Ziel-Modul com (adaptive)
Ziel-Anforderung SWS_CORE_01129
Semantische Rolle heuristic
Automatisierungs-Konfidenz 0.85