Skip to content

Commit

Permalink
Support compu methods
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielT committed Aug 14, 2024
1 parent bdb8d86 commit ba3d314
Show file tree
Hide file tree
Showing 5 changed files with 1,279 additions and 30 deletions.
6 changes: 3 additions & 3 deletions autosar-data-abstraction/src/communication/signal/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -511,16 +511,16 @@ reflist_iterator!(ISignalToIPduMappingsIterator, ISignalToIPduMapping);
#[cfg(test)]
mod tests {
use super::*;
use crate::datatype::{BaseTypeEncoding, SwBaseType, Unit};
use crate::datatype::{BaseTypeEncoding, CompuMethodContent, SwBaseType, Unit};
use autosar_data::{AutosarModel, AutosarVersion};

#[test]
fn test_signal() {
let model = AutosarModel::new();
let _file = model.create_file("test.arxml", AutosarVersion::LATEST).unwrap();
let package = ArPackage::get_or_create(&model, "/test").unwrap();
let unit = Unit::new("unit", &package).unwrap();
let compu_method = CompuMethod::new("compu_method", &package).unwrap();
let unit = Unit::new("unit", &package, Some("Unit Name")).unwrap();
let compu_method = CompuMethod::new("compu_method", &package, CompuMethodContent::Identical).unwrap();
let data_constr = DataConstr::new("data_constr", &package).unwrap();
let sw_base_type =
SwBaseType::new("sw_base_type", &package, 8, BaseTypeEncoding::None, None, None, None).unwrap();
Expand Down
17 changes: 15 additions & 2 deletions autosar-data-abstraction/src/datatype/applicationtype.rs
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,7 @@ element_iterator!(ApplicationRecordElementIterator, ApplicationRecordElement, So
mod tests {
use super::*;
use autosar_data::AutosarVersion;
use datatype::{CompuMethodContent, CompuMethodLinearContent};

#[test]
fn test_application_array_data_type() {
Expand Down Expand Up @@ -457,8 +458,20 @@ mod tests {
let model = AutosarModel::new();
let _file = model.create_file("filename", AutosarVersion::LATEST).unwrap();
let package = ArPackage::get_or_create(&model, "/DataTypes").unwrap();
let compu_method = CompuMethod::new("CompuMethod", &package).unwrap();
let unit = Unit::new("Unit", &package).unwrap();
let compu_method = CompuMethod::new(
"CompuMethod",
&package,
CompuMethodContent::Linear(CompuMethodLinearContent {
direction: datatype::CompuScaleDirection::IntToPhys,
offset: 0.0,
factor: 100.0,
divisor: 1.0,
lower_limit: None,
upper_limit: None,
}),
)
.unwrap();
let unit = Unit::new("Unit", &package, Some("Unit name")).unwrap();
let data_constraint = DataConstr::new("DataConstraint", &package).unwrap();
let primitive_data_type = ApplicationPrimitiveDataType::new(
"Primitive",
Expand Down
Loading

0 comments on commit ba3d314

Please sign in to comment.