Skip to content

Commit

Permalink
add support for ethernet connections
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielT committed Jul 23, 2024
1 parent 0dd844a commit ab69a4a
Show file tree
Hide file tree
Showing 5 changed files with 928 additions and 82 deletions.
6 changes: 3 additions & 3 deletions autosar-data-abstraction/src/communication/frame/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ impl Frame {
let pt = ft.add_pdu_triggering(&pdu)?;
for frame_port in ft.frame_ports() {
if let (Some(ecu), Some(direction)) = (frame_port.ecu(), frame_port.communication_direction()) {
pt.connect_to_ecu(&ecu, direction)?;
pt.create_pdu_port(&ecu, direction)?;
}
}
}
Expand Down Expand Up @@ -169,7 +169,7 @@ impl FrameTriggering {

for frame_port in self.frame_ports() {
if let (Some(ecu), Some(direction)) = (frame_port.ecu(), frame_port.communication_direction()) {
pt.connect_to_ecu(&ecu, direction)?;
pt.create_pdu_port(&ecu, direction)?;
}
}

Expand Down Expand Up @@ -226,7 +226,7 @@ impl FrameTriggering {
.set_reference_target(&fp_elem)?;

for pt in self.pdu_triggerings() {
pt.connect_to_ecu(ecu, direction)?;
pt.create_pdu_port(ecu, direction)?;
}

Ok(FramePort(fp_elem))
Expand Down
31 changes: 30 additions & 1 deletion autosar-data-abstraction/src/communication/pdu/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -455,14 +455,24 @@ impl PduTriggering {
Ok(pt)
}

/// get the Pdu that is triggered by this pdu triggering
pub fn pdu(&self) -> Option<Pdu> {
let pdu_elem = self
.element()
.get_sub_element(ElementName::IPduRef)?
.get_reference_target()
.ok()?;
Pdu::try_from(pdu_elem).ok()
}

/// get the physical channel that contains this pdu triggering
pub fn physical_channel(&self) -> Result<PhysicalChannel, AutosarAbstractionError> {
let channel_elem = self.element().named_parent()?.ok_or(AutosarDataError::ItemDeleted)?;
PhysicalChannel::try_from(channel_elem)
}

/// create an IPduPort to connect a PduTriggering to an EcuInstance
pub fn connect_to_ecu(
pub fn create_pdu_port(
&self,
ecu: &EcuInstance,
direction: CommunicationDirection,
Expand Down Expand Up @@ -508,14 +518,17 @@ impl PduTriggering {
Ok(IPduPort(pp_elem))
}

/// create an iterator over the IPduPorts that are connected to this PduTriggering
pub fn pdu_ports(&self) -> IPduPortIterator {
IPduPortIterator::new(self.element().get_sub_element(ElementName::IPduPortRefs))
}

/// create an iterator over the ISignalTriggerings that are triggered by this PduTriggering
pub fn signal_triggerings(&self) -> PtSignalTriggeringsIterator {
PtSignalTriggeringsIterator::new(self.element().get_sub_element(ElementName::ISignalTriggerings))
}

/// add a signal triggering for a signal to this PduTriggering
pub fn add_signal_triggering(&self, signal: &ISignal) -> Result<ISignalTriggering, AutosarAbstractionError> {
let channel = self.physical_channel()?;
let st = ISignalTriggering::new(signal, &channel)?;
Expand All @@ -536,6 +549,7 @@ impl PduTriggering {
Ok(st)
}

/// add a signal triggering for a signal group to this PduTriggering
pub fn add_signal_group_triggering(
&self,
signal_group: &ISignalGroup,
Expand Down Expand Up @@ -601,6 +615,21 @@ impl From<PduCollectionTrigger> for EnumItem {
}
}

impl TryFrom<EnumItem> for PduCollectionTrigger {
type Error = AutosarAbstractionError;

fn try_from(value: EnumItem) -> Result<Self, Self::Error> {
match value {
EnumItem::Always => Ok(PduCollectionTrigger::Always),
EnumItem::Never => Ok(PduCollectionTrigger::Never),
_ => Err(AutosarAbstractionError::ValueConversionError {
value: value.to_string(),
dest: "PduCollectionTrigger".to_string(),
}),
}
}
}

//##################################################################

element_iterator!(
Expand Down
Loading

0 comments on commit ab69a4a

Please sign in to comment.