pub struct CAMTransmissionManagement {
pub btp_handle: BTPRouterHandle,
pub cam_coder: CamCoder,
pub vehicle_data: VehicleData,
pub ca_basic_service_ldm: Option<CABasicServiceLDM>,
pub t_gen_cam_ms: Arc<AtomicU64>,
pub t_gen_cam_dcc_ms: Arc<AtomicU64>,
pub n_gen_cam_counter: Arc<AtomicU32>,
pub state: Arc<Mutex<TransmissionState>>,
pub active: Arc<AtomicBool>,
pub in_vehicle_data: Arc<Mutex<InVehicleData>>,
}Expand description
CAM Transmission Management — ETSI TS 103 900 V2.3.1 §6.1.
Fields§
§btp_handle: BTPRouterHandle§cam_coder: CamCoder§vehicle_data: VehicleData§ca_basic_service_ldm: Option<CABasicServiceLDM>§t_gen_cam_ms: Arc<AtomicU64>§t_gen_cam_dcc_ms: Arc<AtomicU64>T_GenCam_DCC [ms], provided by the management layer (DCC).
n_gen_cam_counter: Arc<AtomicU32>§state: Arc<Mutex<TransmissionState>>§active: Arc<AtomicBool>§in_vehicle_data: Arc<Mutex<InVehicleData>>Latest in-vehicle data (§5.2, §7.1).
Implementations§
Source§impl CAMTransmissionManagement
impl CAMTransmissionManagement
Sourcepub fn new(
btp_handle: BTPRouterHandle,
cam_coder: CamCoder,
vehicle_data: VehicleData,
ca_basic_service_ldm: Option<CABasicServiceLDM>,
) -> Self
pub fn new( btp_handle: BTPRouterHandle, cam_coder: CamCoder, vehicle_data: VehicleData, ca_basic_service_ldm: Option<CABasicServiceLDM>, ) -> Self
Create a new CAMTransmissionManagement instance.
Sourcepub fn update_in_vehicle_data(
&self,
update: impl FnOnce(&mut InVehicleData),
) -> Result<InVehicleData, String>
pub fn update_in_vehicle_data( &self, update: impl FnOnce(&mut InVehicleData), ) -> Result<InVehicleData, String>
Update the latest in-vehicle data (§5.2, §7.1): the next CAM carries the new values. Invalid values return an error and leave the data unchanged.
Sourcepub fn in_vehicle_data(&self) -> InVehicleData
pub fn in_vehicle_data(&self) -> InVehicleData
The latest in-vehicle data.
Sourcepub fn start(&self)
pub fn start(&self)
Activate the CA service (§5.3.1 (CA_Activation)).
Resets per-activation dynamics and timer state.
Sourcepub fn t_gen_cam_dcc(&self) -> u64
pub fn t_gen_cam_dcc(&self) -> u64
Current T_GenCam_DCC value in milliseconds.
Sourcepub fn set_t_gen_cam_dcc(&self, t_gen_cam_dcc_ms: u64)
pub fn set_t_gen_cam_dcc(&self, t_gen_cam_dcc_ms: u64)
Set T_GenCam_DCC (§6.1.2), clamped to [T_GenCamMin, T_GenCamMax].
Shared by all clones of this instance, so it may be called from a DCC entity thread while the transmission thread is running.
Sourcepub fn last_cam_time_ms(&self) -> Option<u64>
pub fn last_cam_time_ms(&self) -> Option<u64>
Timestamp (ms) of the last transmitted CAM.
Sourcepub fn location_service_callback(&self, fix: GpsFix)
pub fn location_service_callback(&self, fix: GpsFix)
Cache the latest position data (§6.1.2).
This method only updates the internal position cache and does not trigger transmission directly.
Sourcepub fn check_dynamics(&self, fix: &GpsFix) -> bool
pub fn check_dynamics(&self, fix: &GpsFix) -> bool
Return true if at least one dynamics threshold is exceeded (§6.1.2 Condition 1).
Thresholds:
- |Δheading| > 4°
- |Δposition| > 4 m (haversine)
- |Δspeed| > 0.5 m/s
Sourcepub fn should_include_lf(&self, now_ms: u64) -> bool
pub fn should_include_lf(&self, now_ms: u64) -> bool
Low-Frequency container: first CAM, then every ≥ 500 ms (§6.1.2).
Sourcepub fn should_include_special_vehicle(&self, now_ms: u64) -> bool
pub fn should_include_special_vehicle(&self, now_ms: u64) -> bool
Special-Vehicle container: first CAM (if role ≠ default), then ≥ 500 ms (§6.1.2).
Sourcepub fn should_include_vlf(
&self,
now_ms: u64,
include_lf: bool,
include_special: bool,
) -> bool
pub fn should_include_vlf( &self, now_ms: u64, include_lf: bool, include_special: bool, ) -> bool
Very-Low-Frequency extension container (§6.1.2):
- Second CAM after activation (cam_count == 1).
- After that: ≥ 10 s elapsed AND LF/special containers NOT included.
Sourcepub fn should_include_two_wheeler(&self) -> bool
pub fn should_include_two_wheeler(&self) -> bool
Two-Wheeler extension container in ALL CAMs for cyclist/moped/motorcycle (§6.1.2).
Sourcepub fn build_lf_container(
&self,
fix: &GpsFix,
now_ms: u64,
) -> LowFrequencyContainer
pub fn build_lf_container( &self, fix: &GpsFix, now_ms: u64, ) -> LowFrequencyContainer
Build the BasicVehicleContainerLowFrequency container.
Sourcepub fn get_path_history(
&self,
current_fix: &GpsFix,
now_ms: u64,
) -> Vec<PathPoint>
pub fn get_path_history( &self, current_fix: &GpsFix, now_ms: u64, ) -> Vec<PathPoint>
Convert stored path history to a list of relative PathPoint entries (capped at 23).
Sourcepub fn evaluate_and_maybe_send(&self, now_ms: u64) -> Option<Cam>
pub fn evaluate_and_maybe_send(&self, now_ms: u64) -> Option<Cam>
Evaluate CAM conditions and generate/send if either condition 1 or 2 is met.
Sourcepub fn generate_and_send_cam(
&self,
fix: &GpsFix,
now_ms: u64,
condition: u8,
) -> Result<Cam, String>
pub fn generate_and_send_cam( &self, fix: &GpsFix, now_ms: u64, condition: u8, ) -> Result<Cam, String>
Build, encode, and transmit a CAM (Annex B.2.4).
Sourcepub fn send_cam(&self, cam: &Cam) -> Result<(), String>
pub fn send_cam(&self, cam: &Cam) -> Result<(), String>
Encode and transmit a CAM PDU via BTP-B/SHB (§6.1.1, §5.3.4; V2.2.1 §5.3.4.1).
Sourcepub fn update_send_state(
&self,
fix: &GpsFix,
now_ms: u64,
elapsed_ms: u64,
condition: u8,
include_lf: bool,
include_special: bool,
include_vlf: bool,
)
pub fn update_send_state( &self, fix: &GpsFix, now_ms: u64, elapsed_ms: u64, condition: u8, include_lf: bool, include_special: bool, include_vlf: bool, )
Update state variables after a successful CAM transmission.
Sourcepub fn spawn(
btp_handle: BTPRouterHandle,
coder: CamCoder,
vehicle_data: VehicleData,
gps_rx: Receiver<GpsFix>,
)
pub fn spawn( btp_handle: BTPRouterHandle, coder: CamCoder, vehicle_data: VehicleData, gps_rx: Receiver<GpsFix>, )
Spawn the transmission management thread.
Trait Implementations§
Source§impl Clone for CAMTransmissionManagement
impl Clone for CAMTransmissionManagement
Source§fn clone(&self) -> CAMTransmissionManagement
fn clone(&self) -> CAMTransmissionManagement
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl !Freeze for CAMTransmissionManagement
impl RefUnwindSafe for CAMTransmissionManagement
impl Send for CAMTransmissionManagement
impl Sync for CAMTransmissionManagement
impl Unpin for CAMTransmissionManagement
impl UnsafeUnpin for CAMTransmissionManagement
impl UnwindSafe for CAMTransmissionManagement
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Conv for T
impl<T> Conv for T
§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.