1 unstable release
new 0.1.0 | Dec 19, 2024 |
---|
#558 in Network programming
99 downloads per month
1MB
18K
SLoC
autosar-data-abstraction
Warning: This is a prototype
This is an abstraction layer on top of the autosar-data model.
Rather than transforming the element based model into a new form, it only presents a view into the existing model, and provides methods to retrieve and modify the data.
As a result the use of autosar-data-abstraction can be freely mixed with direct manipulation of the model. Allowing the two to be mixed freely is a very important design goal: autosar-data-abstraction only represents a tiny portion of all possible elements in an Autosar file.
lib.rs
:
Crate autosar-data-abstraction
This crate provides an abstraction layer for the AUTOSAR data model.
It is built on top of the crate autosar-data
and provides complex interactions with
the model on top of the elementary operations of autosar-data
.
Since the AUTOSAR data model is very complex and has many different types of elements, this crate does not aim to provide full coverage of all classes. Instead the focus is on the most common classes and their interactions.
Any other data can still be accessed through the basic operations of autosar-data
, because the
calls to autosar-data
and autosar-data-abstraction
can be mixed freely.
Example
let model = AutosarModel::new();
let _file = model.create_file("file.arxml", AutosarVersion::Autosar_00049).unwrap();
let package_1 = ArPackage::get_or_create(&model, "/System").unwrap();
let system = System::new("System", &package_1, SystemCategory::SystemExtract).unwrap();
let package_2 = ArPackage::get_or_create(&model, "/Clusters").unwrap();
// create an Ethernet cluster and a physical channel for VLAN 33
let eth_cluster = system.create_ethernet_cluster("EthCluster", &package_2).unwrap();
let vlan_info = EthernetVlanInfo {
vlan_id: 33,
vlan_name: "VLAN_33".to_string(),
};
let eth_channel = eth_cluster
.create_physical_channel("EthChannel", Some(vlan_info))
.unwrap();
let vlan_info_2 = eth_channel.vlan_info().unwrap();
// create an ECU instance and connect it to the Ethernet channel
let package_3 = ArPackage::get_or_create(&model, "/Ecus").unwrap();
let ecu_instance_a = system.create_ecu_instance("Ecu_A", &package_3).unwrap();
let ethctrl = ecu_instance_a
.create_ethernet_communication_controller(
"EthernetController",
Some("ab:cd:ef:01:02:03".to_string())
)
.unwrap();
let channels_iter = ethctrl.connected_channels();
ethctrl
.connect_physical_channel("Ecu_A_connector", ð_channel)
.unwrap();
let channels_iter = ethctrl.connected_channels();
// ...
Dependencies
~8–13MB
~102K SLoC