This commit is contained in:
parent
f9ee3998fd
commit
dab02a1cc5
@ -52,7 +52,5 @@ pub mod params;
|
||||
|
||||
pub use spacepackets;
|
||||
|
||||
pub use queue::ChannelId;
|
||||
|
||||
/// Generic component ID type.
|
||||
pub type ComponentId = u64;
|
||||
|
@ -305,7 +305,7 @@ pub trait ActiveRequestProvider {
|
||||
}
|
||||
|
||||
/// This trait is an abstraction for the routing of PUS request to a dedicated
|
||||
/// recipient using the generic [TargetId].
|
||||
/// recipient using the generic [ComponentId].
|
||||
pub trait PusRequestRouter<Request> {
|
||||
type Error;
|
||||
|
||||
@ -439,8 +439,9 @@ pub mod alloc_mod {
|
||||
/// type.
|
||||
///
|
||||
/// Having a dedicated trait for this allows maximum flexiblity and tailoring of the standard.
|
||||
/// The only requirement is that a valid [TargetId] and a request instance are returned by the
|
||||
/// core conversion function.
|
||||
/// The only requirement is that a valid active request information instance and a request
|
||||
/// are returned by the core conversion function. The active request type needs to fulfill
|
||||
/// the [ActiveRequestProvider] trait bound.
|
||||
///
|
||||
/// The user should take care of performing the error handling as well. Some of the following
|
||||
/// aspects might be relevant:
|
||||
@ -877,117 +878,6 @@ pub mod std_mod {
|
||||
pub type CrossbeamTcReceiver = cb::Receiver<EcssTcAndToken>;
|
||||
}
|
||||
|
||||
/// This is a high-level handler for the generic PUS services which need to convert PUS
|
||||
/// commands into a request/reply pattern.
|
||||
///
|
||||
/// It performs the following handling steps:
|
||||
///
|
||||
/// 1. Retrieve the next TC packet from the [PusServiceHelper]. The [EcssTcInMemConverter]
|
||||
/// allows to configure the used telecommand memory backend.
|
||||
/// 2. Convert the TC to a targeted action request using the provided
|
||||
/// [PusTcToRequestConverter]. The generic error type is constrained to the
|
||||
/// [PusPacketHandlingError] for the concrete implementation which offers a packet handler.
|
||||
/// 3. Route the action request using the provided [PusRequestRouter].
|
||||
/*
|
||||
pub struct PusTargetedRequestHandler<
|
||||
TcReceiver: EcssTcReceiverCore,
|
||||
TmSender: EcssTmSenderCore,
|
||||
TcInMemConverter: EcssTcInMemConverter,
|
||||
VerificationReporter: VerificationReportingProvider,
|
||||
RequestConverter: PusTcToRequestConverter<Request>,
|
||||
RequestRouter: PusRequestRouter<Request, Error = RoutingError>,
|
||||
Request,
|
||||
RoutingError = GenericRoutingError,
|
||||
> {
|
||||
service_helper:
|
||||
PusServiceHelper<TcReceiver, TmSender, TcInMemConverter, VerificationReporter>,
|
||||
pub request_converter: RequestConverter,
|
||||
pub request_router: RequestRouter,
|
||||
phantom: PhantomData<Request>,
|
||||
}
|
||||
|
||||
// pub trait PusReplyHandlerProvider {
|
||||
// fn add_routed_request(&mut self, request_id: RequestId, active_request: ActiveRequest);
|
||||
// }
|
||||
impl<
|
||||
TcReceiver: EcssTcReceiverCore,
|
||||
TmSender: EcssTmSenderCore,
|
||||
TcInMemConverter: EcssTcInMemConverter,
|
||||
VerificationReporter: VerificationReportingProvider,
|
||||
RequestConverter: PusTcToRequestConverter<Request, Error = PusPacketHandlingError>,
|
||||
RequestRouter: PusRequestRouter<Request, Error = RoutingError>,
|
||||
Request,
|
||||
RoutingError: Clone,
|
||||
>
|
||||
PusTargetedRequestHandler<
|
||||
TcReceiver,
|
||||
TmSender,
|
||||
TcInMemConverter,
|
||||
VerificationReporter,
|
||||
RequestConverter,
|
||||
RequestRouter,
|
||||
Request,
|
||||
RoutingError,
|
||||
>
|
||||
where
|
||||
PusPacketHandlingError: From<RoutingError>,
|
||||
{
|
||||
pub fn new(
|
||||
service_helper: PusServiceHelper<
|
||||
TcReceiver,
|
||||
TmSender,
|
||||
TcInMemConverter,
|
||||
VerificationReporter,
|
||||
>,
|
||||
request_converter: RequestConverter,
|
||||
request_router: RequestRouter,
|
||||
) -> Self {
|
||||
Self {
|
||||
service_helper,
|
||||
request_converter,
|
||||
request_router,
|
||||
phantom: PhantomData,
|
||||
}
|
||||
}
|
||||
|
||||
/// Core function to poll the next TC packet and try to handle it.
|
||||
pub fn handle_one_tc(&mut self) -> Result<PusPacketHandlerResult, PusPacketHandlingError> {
|
||||
let possible_packet = self.service_helper.retrieve_and_accept_next_packet()?;
|
||||
if possible_packet.is_none() {
|
||||
return Ok(PusPacketHandlerResult::Empty);
|
||||
}
|
||||
let ecss_tc_and_token = possible_packet.unwrap();
|
||||
let tc = self
|
||||
.service_helper
|
||||
.tc_in_mem_converter
|
||||
.convert_ecss_tc_in_memory_to_reader(&ecss_tc_and_token.tc_in_memory)?;
|
||||
let mut partial_error = None;
|
||||
let time_stamp = get_current_cds_short_timestamp(&mut partial_error);
|
||||
let (target_id, action_request) = self.request_converter.convert(
|
||||
ecss_tc_and_token.token,
|
||||
&tc,
|
||||
&time_stamp,
|
||||
&self.service_helper.common.verification_handler,
|
||||
)?;
|
||||
if let Err(e) =
|
||||
self.request_router
|
||||
.route(target_id, action_request, ecss_tc_and_token.token)
|
||||
{
|
||||
self.request_router.handle_error(
|
||||
target_id,
|
||||
ecss_tc_and_token.token,
|
||||
&tc,
|
||||
e.clone(),
|
||||
&time_stamp,
|
||||
&self.service_helper.common.verification_handler,
|
||||
);
|
||||
return Err(e.into());
|
||||
}
|
||||
Ok(PusPacketHandlerResult::RequestHandled)
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct ActivePusRequestStd {
|
||||
target_id: ComponentId,
|
||||
|
@ -381,7 +381,7 @@ pub mod alloc_mod {
|
||||
/// a [crate::pool::PoolProvider] API. This data structure just tracks the store
|
||||
/// addresses and their release times and offers a convenient API to insert and release
|
||||
/// telecommands and perform other functionality specified by the ECSS standard in section 6.11.
|
||||
/// The time is tracked as a [spacepackets::time::UnixTimestamp] but the only requirement to
|
||||
/// The time is tracked as a [spacepackets::time::UnixTime] but the only requirement to
|
||||
/// the timekeeping of the user is that it is convertible to that timestamp.
|
||||
///
|
||||
/// The standard also specifies that the PUS scheduler can be enabled and disabled.
|
||||
|
@ -89,6 +89,10 @@ impl fmt::Display for UniqueApidTargetId {
|
||||
}
|
||||
}
|
||||
|
||||
/// This contains metadata information which might be useful when used together with a
|
||||
/// generic message tpye.
|
||||
///
|
||||
/// This could for example be used to build request/reply patterns or state tracking for request.
|
||||
#[derive(Debug, Copy, PartialEq, Eq, Clone)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
pub struct MessageMetadata {
|
||||
@ -113,17 +117,16 @@ impl MessageMetadata {
|
||||
}
|
||||
}
|
||||
|
||||
/// Generic message type which is associated with a sender using a [ChannelId] and associated
|
||||
/// with a request using a [RequestId].
|
||||
/// Generic message type which adds [metadata][MessageMetadata] to a generic message typ.
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
pub struct GenericMessage<MSG> {
|
||||
pub struct GenericMessage<Message> {
|
||||
pub requestor_info: MessageMetadata,
|
||||
pub message: MSG,
|
||||
pub message: Message,
|
||||
}
|
||||
|
||||
impl<MSG> GenericMessage<MSG> {
|
||||
pub fn new(requestor_info: MessageMetadata, message: MSG) -> Self {
|
||||
impl<Message> GenericMessage<Message> {
|
||||
pub fn new(requestor_info: MessageMetadata, message: Message) -> Self {
|
||||
Self {
|
||||
requestor_info,
|
||||
message,
|
||||
|
Loading…
Reference in New Issue
Block a user