cleaned up code
Some checks failed
Rust/sat-rs/pipeline/pr-main There was a failure building this commit
Some checks failed
Rust/sat-rs/pipeline/pr-main There was a failure building this commit
This commit is contained in:
parent
d8d7c86f0c
commit
7c76f609bd
@ -11,6 +11,7 @@ mod tmtc;
|
|||||||
mod udp;
|
mod udp;
|
||||||
|
|
||||||
use crate::events::EventHandler;
|
use crate::events::EventHandler;
|
||||||
|
use crate::pus::stack::PusStack;
|
||||||
use crate::tm_funnel::TmFunnel;
|
use crate::tm_funnel::TmFunnel;
|
||||||
use log::info;
|
use log::info;
|
||||||
use satrs_core::hal::std::tcp_server::ServerConfig;
|
use satrs_core::hal::std::tcp_server::ServerConfig;
|
||||||
@ -19,33 +20,26 @@ use satrs_core::hal::std::udp_server::UdpTcServer;
|
|||||||
use crate::acs::AcsTask;
|
use crate::acs::AcsTask;
|
||||||
use crate::ccsds::CcsdsReceiver;
|
use crate::ccsds::CcsdsReceiver;
|
||||||
use crate::logger::setup_logger;
|
use crate::logger::setup_logger;
|
||||||
use crate::pus::action::{Pus8Wrapper, PusService8ActionHandler};
|
use crate::pus::action::create_action_service;
|
||||||
use crate::pus::event::Pus5Wrapper;
|
use crate::pus::event::create_event_service;
|
||||||
use crate::pus::hk::{Pus3Wrapper, PusService3HkHandler};
|
use crate::pus::hk::create_hk_service;
|
||||||
use crate::pus::scheduler::Pus11Wrapper;
|
use crate::pus::scheduler::create_scheduler_service;
|
||||||
use crate::pus::test::Service17CustomWrapper;
|
use crate::pus::test::create_test_service;
|
||||||
use crate::pus::{PusReceiver, PusTcMpscRouter};
|
use crate::pus::{PusReceiver, PusTcMpscRouter};
|
||||||
use crate::requests::RequestWithToken;
|
use crate::requests::RequestWithToken;
|
||||||
use crate::tcp::{SyncTcpTmSource, TcpTask};
|
use crate::tcp::{SyncTcpTmSource, TcpTask};
|
||||||
use crate::tmtc::{PusTcSource, TcArgs, TcStore, TmArgs, TmtcTask};
|
use crate::tmtc::{PusTcSource, SharedTcPool, TcArgs, TmArgs, TmtcTask};
|
||||||
use crate::udp::UdpTmtcServer;
|
use crate::udp::UdpTmtcServer;
|
||||||
use satrs_core::pool::{StaticMemoryPool, StaticPoolConfig};
|
use satrs_core::pool::{StaticMemoryPool, StaticPoolConfig};
|
||||||
use satrs_core::pus::event_man::EventRequestWithToken;
|
use satrs_core::pus::event_man::EventRequestWithToken;
|
||||||
use satrs_core::pus::event_srv::PusService5EventHandler;
|
|
||||||
use satrs_core::pus::scheduler::PusScheduler;
|
|
||||||
use satrs_core::pus::scheduler_srv::PusService11SchedHandler;
|
|
||||||
use satrs_core::pus::test::PusService17TestHandler;
|
|
||||||
use satrs_core::pus::verification::{VerificationReporterCfg, VerificationReporterWithSender};
|
use satrs_core::pus::verification::{VerificationReporterCfg, VerificationReporterWithSender};
|
||||||
use satrs_core::pus::{
|
use satrs_core::pus::MpscTmInStoreSender;
|
||||||
EcssTcInSharedStoreConverter, MpscTcReceiver, MpscTmInStoreSender, PusServiceHelper,
|
|
||||||
};
|
|
||||||
use satrs_core::spacepackets::{time::cds::TimeProvider, time::TimeWriter};
|
use satrs_core::spacepackets::{time::cds::TimeProvider, time::TimeWriter};
|
||||||
use satrs_core::tmtc::tm_helper::SharedTmStore;
|
use satrs_core::tmtc::tm_helper::SharedTmStore;
|
||||||
use satrs_core::tmtc::{CcsdsDistributor, TargetId};
|
use satrs_core::tmtc::{CcsdsDistributor, TargetId};
|
||||||
use satrs_core::ChannelId;
|
use satrs_core::ChannelId;
|
||||||
use satrs_example::{
|
use satrs_example::{
|
||||||
RequestTargetId, TargetIdWithApid, TcReceiverId, TmSenderId, OBSW_SERVER_ADDR, PUS_APID,
|
RequestTargetId, TargetIdWithApid, TmSenderId, OBSW_SERVER_ADDR, PUS_APID, SERVER_PORT,
|
||||||
SERVER_PORT,
|
|
||||||
};
|
};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::net::{IpAddr, SocketAddr};
|
use std::net::{IpAddr, SocketAddr};
|
||||||
@ -74,7 +68,7 @@ fn main() {
|
|||||||
(15, 1024),
|
(15, 1024),
|
||||||
(15, 2048),
|
(15, 2048),
|
||||||
]));
|
]));
|
||||||
let tc_store = TcStore {
|
let shared_tc_pool = SharedTcPool {
|
||||||
pool: Arc::new(RwLock::new(tc_pool)),
|
pool: Arc::new(RwLock::new(tc_pool)),
|
||||||
};
|
};
|
||||||
let sched_tc_pool = StaticMemoryPool::new(StaticPoolConfig::new(vec![
|
let sched_tc_pool = StaticMemoryPool::new(StaticPoolConfig::new(vec![
|
||||||
@ -86,7 +80,6 @@ fn main() {
|
|||||||
(15, 2048),
|
(15, 2048),
|
||||||
]));
|
]));
|
||||||
|
|
||||||
let sock_addr = SocketAddr::new(IpAddr::V4(OBSW_SERVER_ADDR), SERVER_PORT);
|
|
||||||
let (tc_source_tx, tc_source_rx) = channel();
|
let (tc_source_tx, tc_source_rx) = channel();
|
||||||
let (tm_funnel_tx, tm_funnel_rx) = channel();
|
let (tm_funnel_tx, tm_funnel_rx) = channel();
|
||||||
let (tm_server_tx, tm_server_rx) = channel();
|
let (tm_server_tx, tm_server_rx) = channel();
|
||||||
@ -108,7 +101,7 @@ fn main() {
|
|||||||
request_map.insert(target_apid, acs_thread_tx);
|
request_map.insert(target_apid, acs_thread_tx);
|
||||||
|
|
||||||
let tc_source_wrapper = PusTcSource {
|
let tc_source_wrapper = PusTcSource {
|
||||||
tc_store: tc_store.clone(),
|
tc_store: shared_tc_pool.clone(),
|
||||||
tc_source: tc_source_tx,
|
tc_source: tc_source_tx,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -148,119 +141,53 @@ fn main() {
|
|||||||
hk_service_receiver: pus_hk_tx,
|
hk_service_receiver: pus_hk_tx,
|
||||||
action_service_receiver: pus_action_tx,
|
action_service_receiver: pus_action_tx,
|
||||||
};
|
};
|
||||||
let test_srv_tm_sender = MpscTmInStoreSender::new(
|
let pus_test_service = create_test_service(
|
||||||
TmSenderId::PusTest as ChannelId,
|
|
||||||
"PUS_17_TM_SENDER",
|
|
||||||
shared_tm_store.clone(),
|
shared_tm_store.clone(),
|
||||||
tm_funnel_tx.clone(),
|
tm_funnel_tx.clone(),
|
||||||
);
|
verif_reporter.clone(),
|
||||||
let test_srv_receiver = MpscTcReceiver::new(
|
shared_tc_pool.pool.clone(),
|
||||||
TcReceiverId::PusTest as ChannelId,
|
event_handler.clone_event_sender(),
|
||||||
"PUS_17_TC_RECV",
|
|
||||||
pus_test_rx,
|
pus_test_rx,
|
||||||
);
|
);
|
||||||
let pus17_handler = PusService17TestHandler::new(PusServiceHelper::new(
|
let pus_scheduler_service = create_scheduler_service(
|
||||||
Box::new(test_srv_receiver),
|
shared_tm_store.clone(),
|
||||||
Box::new(test_srv_tm_sender),
|
tm_funnel_tx.clone(),
|
||||||
PUS_APID,
|
|
||||||
verif_reporter.clone(),
|
verif_reporter.clone(),
|
||||||
EcssTcInSharedStoreConverter::new(tc_store.pool.clone(), 2048),
|
|
||||||
));
|
|
||||||
let mut pus_17_wrapper = Service17CustomWrapper {
|
|
||||||
pus17_handler,
|
|
||||||
test_srv_event_sender: event_handler.clone_event_sender(),
|
|
||||||
};
|
|
||||||
|
|
||||||
let sched_srv_tm_sender = MpscTmInStoreSender::new(
|
|
||||||
TmSenderId::PusSched as ChannelId,
|
|
||||||
"PUS_11_TM_SENDER",
|
|
||||||
shared_tm_store.clone(),
|
|
||||||
tm_funnel_tx.clone(),
|
|
||||||
);
|
|
||||||
let sched_srv_receiver = MpscTcReceiver::new(
|
|
||||||
TcReceiverId::PusSched as ChannelId,
|
|
||||||
"PUS_11_TC_RECV",
|
|
||||||
pus_sched_rx,
|
|
||||||
);
|
|
||||||
let scheduler = PusScheduler::new_with_current_init_time(Duration::from_secs(5))
|
|
||||||
.expect("Creating PUS Scheduler failed");
|
|
||||||
let pus_11_handler = PusService11SchedHandler::new(
|
|
||||||
PusServiceHelper::new(
|
|
||||||
Box::new(sched_srv_receiver),
|
|
||||||
Box::new(sched_srv_tm_sender),
|
|
||||||
PUS_APID,
|
|
||||||
verif_reporter.clone(),
|
|
||||||
EcssTcInSharedStoreConverter::new(tc_store.pool.clone(), 2048),
|
|
||||||
),
|
|
||||||
scheduler,
|
|
||||||
);
|
|
||||||
let mut pus_11_wrapper = Pus11Wrapper {
|
|
||||||
pus_11_handler,
|
|
||||||
sched_tc_pool,
|
|
||||||
tc_source_wrapper,
|
tc_source_wrapper,
|
||||||
};
|
pus_sched_rx,
|
||||||
|
sched_tc_pool,
|
||||||
let event_srv_tm_sender = MpscTmInStoreSender::new(
|
);
|
||||||
TmSenderId::PusEvent as ChannelId,
|
let pus_event_service = create_event_service(
|
||||||
"PUS_5_TM_SENDER",
|
|
||||||
shared_tm_store.clone(),
|
shared_tm_store.clone(),
|
||||||
tm_funnel_tx.clone(),
|
tm_funnel_tx.clone(),
|
||||||
);
|
verif_reporter.clone(),
|
||||||
let event_srv_receiver = MpscTcReceiver::new(
|
shared_tc_pool.pool.clone(),
|
||||||
TcReceiverId::PusEvent as ChannelId,
|
|
||||||
"PUS_5_TC_RECV",
|
|
||||||
pus_event_rx,
|
pus_event_rx,
|
||||||
);
|
|
||||||
let pus_5_handler = PusService5EventHandler::new(
|
|
||||||
PusServiceHelper::new(
|
|
||||||
Box::new(event_srv_receiver),
|
|
||||||
Box::new(event_srv_tm_sender),
|
|
||||||
PUS_APID,
|
|
||||||
verif_reporter.clone(),
|
|
||||||
EcssTcInSharedStoreConverter::new(tc_store.pool.clone(), 2048),
|
|
||||||
),
|
|
||||||
event_request_tx,
|
event_request_tx,
|
||||||
);
|
);
|
||||||
let mut pus_5_wrapper = Pus5Wrapper { pus_5_handler };
|
let pus_action_service = create_action_service(
|
||||||
|
|
||||||
let action_srv_tm_sender = MpscTmInStoreSender::new(
|
|
||||||
TmSenderId::PusAction as ChannelId,
|
|
||||||
"PUS_8_TM_SENDER",
|
|
||||||
shared_tm_store.clone(),
|
shared_tm_store.clone(),
|
||||||
tm_funnel_tx.clone(),
|
tm_funnel_tx.clone(),
|
||||||
);
|
|
||||||
let action_srv_receiver = MpscTcReceiver::new(
|
|
||||||
TcReceiverId::PusAction as ChannelId,
|
|
||||||
"PUS_8_TC_RECV",
|
|
||||||
pus_action_rx,
|
|
||||||
);
|
|
||||||
let pus_8_handler = PusService8ActionHandler::new(
|
|
||||||
Box::new(action_srv_receiver),
|
|
||||||
Box::new(action_srv_tm_sender),
|
|
||||||
PUS_APID,
|
|
||||||
verif_reporter.clone(),
|
verif_reporter.clone(),
|
||||||
EcssTcInSharedStoreConverter::new(tc_store.pool.clone(), 2048),
|
shared_tc_pool.pool.clone(),
|
||||||
|
pus_action_rx,
|
||||||
request_map.clone(),
|
request_map.clone(),
|
||||||
);
|
);
|
||||||
let mut pus_8_wrapper = Pus8Wrapper { pus_8_handler };
|
let pus_hk_service = create_hk_service(
|
||||||
|
|
||||||
let hk_srv_tm_sender = MpscTmInStoreSender::new(
|
|
||||||
TmSenderId::PusHk as ChannelId,
|
|
||||||
"PUS_3_TM_SENDER",
|
|
||||||
shared_tm_store.clone(),
|
shared_tm_store.clone(),
|
||||||
tm_funnel_tx.clone(),
|
tm_funnel_tx.clone(),
|
||||||
);
|
|
||||||
let hk_srv_receiver =
|
|
||||||
MpscTcReceiver::new(TcReceiverId::PusHk as ChannelId, "PUS_8_TC_RECV", pus_hk_rx);
|
|
||||||
let pus_3_handler = PusService3HkHandler::new(
|
|
||||||
Box::new(hk_srv_receiver),
|
|
||||||
Box::new(hk_srv_tm_sender),
|
|
||||||
PUS_APID,
|
|
||||||
verif_reporter.clone(),
|
verif_reporter.clone(),
|
||||||
EcssTcInSharedStoreConverter::new(tc_store.pool.clone(), 2048),
|
shared_tc_pool.pool.clone(),
|
||||||
|
pus_hk_rx,
|
||||||
request_map,
|
request_map,
|
||||||
);
|
);
|
||||||
let mut pus_3_wrapper = Pus3Wrapper { pus_3_handler };
|
let mut pus_stack = PusStack::new(
|
||||||
|
pus_hk_service,
|
||||||
|
pus_event_service,
|
||||||
|
pus_action_service,
|
||||||
|
pus_scheduler_service,
|
||||||
|
pus_test_service,
|
||||||
|
);
|
||||||
|
|
||||||
let ccsds_receiver = CcsdsReceiver {
|
let ccsds_receiver = CcsdsReceiver {
|
||||||
tc_source: tc_args.tc_source.clone(),
|
tc_source: tc_args.tc_source.clone(),
|
||||||
@ -270,6 +197,7 @@ fn main() {
|
|||||||
PusReceiver::new(verif_reporter.clone(), pus_router),
|
PusReceiver::new(verif_reporter.clone(), pus_router),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
let sock_addr = SocketAddr::new(IpAddr::V4(OBSW_SERVER_ADDR), SERVER_PORT);
|
||||||
let udp_ccsds_distributor = CcsdsDistributor::new(Box::new(ccsds_receiver.clone()));
|
let udp_ccsds_distributor = CcsdsDistributor::new(Box::new(ccsds_receiver.clone()));
|
||||||
let udp_tc_server = UdpTcServer::new(sock_addr, 2048, Box::new(udp_ccsds_distributor))
|
let udp_tc_server = UdpTcServer::new(sock_addr, 2048, Box::new(udp_ccsds_distributor))
|
||||||
.expect("creating UDP TMTC server failed");
|
.expect("creating UDP TMTC server failed");
|
||||||
@ -279,13 +207,6 @@ fn main() {
|
|||||||
tm_store: tm_args.tm_store.clone_backing_pool(),
|
tm_store: tm_args.tm_store.clone_backing_pool(),
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut acs_task = AcsTask::new(
|
|
||||||
shared_tm_store.clone(),
|
|
||||||
tm_funnel_tx.clone(),
|
|
||||||
acs_thread_rx,
|
|
||||||
verif_reporter,
|
|
||||||
);
|
|
||||||
|
|
||||||
let tcp_ccsds_distributor = CcsdsDistributor::new(Box::new(ccsds_receiver));
|
let tcp_ccsds_distributor = CcsdsDistributor::new(Box::new(ccsds_receiver));
|
||||||
let tcp_server_cfg = ServerConfig::new(sock_addr, Duration::from_millis(400), 4096, 8192);
|
let tcp_server_cfg = ServerConfig::new(sock_addr, Duration::from_millis(400), 4096, 8192);
|
||||||
let sync_tm_tcp_source = SyncTcpTmSource::new(200);
|
let sync_tm_tcp_source = SyncTcpTmSource::new(200);
|
||||||
@ -296,6 +217,13 @@ fn main() {
|
|||||||
)
|
)
|
||||||
.expect("tcp server creation failed");
|
.expect("tcp server creation failed");
|
||||||
|
|
||||||
|
let mut acs_task = AcsTask::new(
|
||||||
|
shared_tm_store.clone(),
|
||||||
|
tm_funnel_tx.clone(),
|
||||||
|
acs_thread_rx,
|
||||||
|
verif_reporter,
|
||||||
|
);
|
||||||
|
|
||||||
let mut tm_funnel = TmFunnel::new(
|
let mut tm_funnel = TmFunnel::new(
|
||||||
shared_tm_store,
|
shared_tm_store,
|
||||||
sync_tm_tcp_source,
|
sync_tm_tcp_source,
|
||||||
@ -357,23 +285,7 @@ fn main() {
|
|||||||
let jh4 = thread::Builder::new()
|
let jh4 = thread::Builder::new()
|
||||||
.name("PUS".to_string())
|
.name("PUS".to_string())
|
||||||
.spawn(move || loop {
|
.spawn(move || loop {
|
||||||
pus_11_wrapper.release_tcs();
|
pus_stack.periodic_operation();
|
||||||
loop {
|
|
||||||
let mut all_queues_empty = true;
|
|
||||||
let mut is_srv_finished = |srv_handler_finished: bool| {
|
|
||||||
if !srv_handler_finished {
|
|
||||||
all_queues_empty = false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
is_srv_finished(pus_17_wrapper.handle_next_packet());
|
|
||||||
is_srv_finished(pus_11_wrapper.handle_next_packet());
|
|
||||||
is_srv_finished(pus_5_wrapper.handle_next_packet());
|
|
||||||
is_srv_finished(pus_8_wrapper.handle_next_packet());
|
|
||||||
is_srv_finished(pus_3_wrapper.handle_next_packet());
|
|
||||||
if all_queues_empty {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
thread::sleep(Duration::from_millis(200));
|
thread::sleep(Duration::from_millis(200));
|
||||||
})
|
})
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
@ -1,17 +1,51 @@
|
|||||||
use crate::requests::{ActionRequest, Request, RequestWithToken};
|
use crate::requests::{ActionRequest, Request, RequestWithToken};
|
||||||
use log::{error, warn};
|
use log::{error, warn};
|
||||||
|
use satrs_core::pool::{SharedStaticMemoryPool, StoreAddr};
|
||||||
use satrs_core::pus::verification::{
|
use satrs_core::pus::verification::{
|
||||||
FailParams, TcStateAccepted, VerificationReporterWithSender, VerificationToken,
|
FailParams, TcStateAccepted, VerificationReporterWithSender, VerificationToken,
|
||||||
};
|
};
|
||||||
use satrs_core::pus::{
|
use satrs_core::pus::{
|
||||||
EcssTcInMemConverter, EcssTcInSharedStoreConverter, EcssTcReceiver, EcssTmSender,
|
EcssTcAndToken, EcssTcInMemConverter, EcssTcInSharedStoreConverter, EcssTcReceiver,
|
||||||
PusPacketHandlerResult, PusPacketHandlingError, PusServiceBase, PusServiceHelper,
|
EcssTmSender, MpscTcReceiver, MpscTmInStoreSender, PusPacketHandlerResult,
|
||||||
|
PusPacketHandlingError, PusServiceBase, PusServiceHelper,
|
||||||
};
|
};
|
||||||
use satrs_core::spacepackets::ecss::tc::PusTcReader;
|
use satrs_core::spacepackets::ecss::tc::PusTcReader;
|
||||||
use satrs_core::spacepackets::ecss::PusPacket;
|
use satrs_core::spacepackets::ecss::PusPacket;
|
||||||
use satrs_example::{tmtc_err, TargetIdWithApid};
|
use satrs_core::tmtc::tm_helper::SharedTmStore;
|
||||||
|
use satrs_core::ChannelId;
|
||||||
|
use satrs_example::{tmtc_err, TargetIdWithApid, TcReceiverId, TmSenderId, PUS_APID};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::sync::mpsc::Sender;
|
use std::sync::mpsc::{self, Sender};
|
||||||
|
|
||||||
|
pub fn create_action_service(
|
||||||
|
shared_tm_store: SharedTmStore,
|
||||||
|
tm_funnel_tx: mpsc::Sender<StoreAddr>,
|
||||||
|
verif_reporter: VerificationReporterWithSender,
|
||||||
|
tc_pool: SharedStaticMemoryPool,
|
||||||
|
pus_action_rx: mpsc::Receiver<EcssTcAndToken>,
|
||||||
|
request_map: HashMap<TargetIdWithApid, mpsc::Sender<RequestWithToken>>,
|
||||||
|
) -> Pus8Wrapper {
|
||||||
|
let action_srv_tm_sender = MpscTmInStoreSender::new(
|
||||||
|
TmSenderId::PusAction as ChannelId,
|
||||||
|
"PUS_8_TM_SENDER",
|
||||||
|
shared_tm_store.clone(),
|
||||||
|
tm_funnel_tx.clone(),
|
||||||
|
);
|
||||||
|
let action_srv_receiver = MpscTcReceiver::new(
|
||||||
|
TcReceiverId::PusAction as ChannelId,
|
||||||
|
"PUS_8_TC_RECV",
|
||||||
|
pus_action_rx,
|
||||||
|
);
|
||||||
|
let pus_8_handler = PusService8ActionHandler::new(
|
||||||
|
Box::new(action_srv_receiver),
|
||||||
|
Box::new(action_srv_tm_sender),
|
||||||
|
PUS_APID,
|
||||||
|
verif_reporter.clone(),
|
||||||
|
EcssTcInSharedStoreConverter::new(tc_pool.clone(), 2048),
|
||||||
|
request_map.clone(),
|
||||||
|
);
|
||||||
|
Pus8Wrapper { pus_8_handler }
|
||||||
|
}
|
||||||
|
|
||||||
pub struct PusService8ActionHandler<TcInMemConverter: EcssTcInMemConverter> {
|
pub struct PusService8ActionHandler<TcInMemConverter: EcssTcInMemConverter> {
|
||||||
service_helper: PusServiceHelper<TcInMemConverter>,
|
service_helper: PusServiceHelper<TcInMemConverter>,
|
||||||
|
@ -1,6 +1,49 @@
|
|||||||
|
use std::sync::mpsc;
|
||||||
|
|
||||||
use log::{error, warn};
|
use log::{error, warn};
|
||||||
|
use satrs_core::pool::{SharedStaticMemoryPool, StoreAddr};
|
||||||
|
use satrs_core::pus::event_man::EventRequestWithToken;
|
||||||
use satrs_core::pus::event_srv::PusService5EventHandler;
|
use satrs_core::pus::event_srv::PusService5EventHandler;
|
||||||
use satrs_core::pus::{EcssTcInSharedStoreConverter, PusPacketHandlerResult};
|
use satrs_core::pus::verification::VerificationReporterWithSender;
|
||||||
|
use satrs_core::pus::{
|
||||||
|
EcssTcAndToken, EcssTcInSharedStoreConverter, MpscTcReceiver, MpscTmInStoreSender,
|
||||||
|
PusPacketHandlerResult, PusServiceHelper,
|
||||||
|
};
|
||||||
|
use satrs_core::tmtc::tm_helper::SharedTmStore;
|
||||||
|
use satrs_core::ChannelId;
|
||||||
|
use satrs_example::{TcReceiverId, TmSenderId, PUS_APID};
|
||||||
|
|
||||||
|
pub fn create_event_service(
|
||||||
|
shared_tm_store: SharedTmStore,
|
||||||
|
tm_funnel_tx: mpsc::Sender<StoreAddr>,
|
||||||
|
verif_reporter: VerificationReporterWithSender,
|
||||||
|
tc_pool: SharedStaticMemoryPool,
|
||||||
|
pus_event_rx: mpsc::Receiver<EcssTcAndToken>,
|
||||||
|
event_request_tx: mpsc::Sender<EventRequestWithToken>,
|
||||||
|
) -> Pus5Wrapper {
|
||||||
|
let event_srv_tm_sender = MpscTmInStoreSender::new(
|
||||||
|
TmSenderId::PusEvent as ChannelId,
|
||||||
|
"PUS_5_TM_SENDER",
|
||||||
|
shared_tm_store.clone(),
|
||||||
|
tm_funnel_tx.clone(),
|
||||||
|
);
|
||||||
|
let event_srv_receiver = MpscTcReceiver::new(
|
||||||
|
TcReceiverId::PusEvent as ChannelId,
|
||||||
|
"PUS_5_TC_RECV",
|
||||||
|
pus_event_rx,
|
||||||
|
);
|
||||||
|
let pus_5_handler = PusService5EventHandler::new(
|
||||||
|
PusServiceHelper::new(
|
||||||
|
Box::new(event_srv_receiver),
|
||||||
|
Box::new(event_srv_tm_sender),
|
||||||
|
PUS_APID,
|
||||||
|
verif_reporter.clone(),
|
||||||
|
EcssTcInSharedStoreConverter::new(tc_pool.clone(), 2048),
|
||||||
|
),
|
||||||
|
event_request_tx,
|
||||||
|
);
|
||||||
|
Pus5Wrapper { pus_5_handler }
|
||||||
|
}
|
||||||
|
|
||||||
pub struct Pus5Wrapper {
|
pub struct Pus5Wrapper {
|
||||||
pub pus_5_handler: PusService5EventHandler<EcssTcInSharedStoreConverter>,
|
pub pus_5_handler: PusService5EventHandler<EcssTcInSharedStoreConverter>,
|
||||||
|
@ -1,15 +1,48 @@
|
|||||||
use crate::requests::{Request, RequestWithToken};
|
use crate::requests::{Request, RequestWithToken};
|
||||||
use log::{error, warn};
|
use log::{error, warn};
|
||||||
use satrs_core::hk::{CollectionIntervalFactor, HkRequest};
|
use satrs_core::hk::{CollectionIntervalFactor, HkRequest};
|
||||||
use satrs_core::pus::verification::{FailParams, StdVerifReporterWithSender};
|
use satrs_core::pool::{SharedStaticMemoryPool, StoreAddr};
|
||||||
|
use satrs_core::pus::verification::{
|
||||||
|
FailParams, StdVerifReporterWithSender, VerificationReporterWithSender,
|
||||||
|
};
|
||||||
use satrs_core::pus::{
|
use satrs_core::pus::{
|
||||||
EcssTcInMemConverter, EcssTcInSharedStoreConverter, EcssTcReceiver, EcssTmSender,
|
EcssTcAndToken, EcssTcInMemConverter, EcssTcInSharedStoreConverter, EcssTcReceiver,
|
||||||
PusPacketHandlerResult, PusPacketHandlingError, PusServiceBase, PusServiceHelper,
|
EcssTmSender, MpscTcReceiver, MpscTmInStoreSender, PusPacketHandlerResult,
|
||||||
|
PusPacketHandlingError, PusServiceBase, PusServiceHelper,
|
||||||
};
|
};
|
||||||
use satrs_core::spacepackets::ecss::{hk, PusPacket};
|
use satrs_core::spacepackets::ecss::{hk, PusPacket};
|
||||||
use satrs_example::{hk_err, tmtc_err, TargetIdWithApid};
|
use satrs_core::tmtc::tm_helper::SharedTmStore;
|
||||||
|
use satrs_core::ChannelId;
|
||||||
|
use satrs_example::{hk_err, tmtc_err, TargetIdWithApid, TcReceiverId, TmSenderId, PUS_APID};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::sync::mpsc::Sender;
|
use std::sync::mpsc::{self, Sender};
|
||||||
|
|
||||||
|
pub fn create_hk_service(
|
||||||
|
shared_tm_store: SharedTmStore,
|
||||||
|
tm_funnel_tx: mpsc::Sender<StoreAddr>,
|
||||||
|
verif_reporter: VerificationReporterWithSender,
|
||||||
|
tc_pool: SharedStaticMemoryPool,
|
||||||
|
pus_hk_rx: mpsc::Receiver<EcssTcAndToken>,
|
||||||
|
request_map: HashMap<TargetIdWithApid, mpsc::Sender<RequestWithToken>>,
|
||||||
|
) -> Pus3Wrapper {
|
||||||
|
let hk_srv_tm_sender = MpscTmInStoreSender::new(
|
||||||
|
TmSenderId::PusHk as ChannelId,
|
||||||
|
"PUS_3_TM_SENDER",
|
||||||
|
shared_tm_store.clone(),
|
||||||
|
tm_funnel_tx.clone(),
|
||||||
|
);
|
||||||
|
let hk_srv_receiver =
|
||||||
|
MpscTcReceiver::new(TcReceiverId::PusHk as ChannelId, "PUS_8_TC_RECV", pus_hk_rx);
|
||||||
|
let pus_3_handler = PusService3HkHandler::new(
|
||||||
|
Box::new(hk_srv_receiver),
|
||||||
|
Box::new(hk_srv_tm_sender),
|
||||||
|
PUS_APID,
|
||||||
|
verif_reporter.clone(),
|
||||||
|
EcssTcInSharedStoreConverter::new(tc_pool, 2048),
|
||||||
|
request_map,
|
||||||
|
);
|
||||||
|
Pus3Wrapper { pus_3_handler }
|
||||||
|
}
|
||||||
|
|
||||||
pub struct PusService3HkHandler<TcInMemConverter: EcssTcInMemConverter> {
|
pub struct PusService3HkHandler<TcInMemConverter: EcssTcInMemConverter> {
|
||||||
psb: PusServiceHelper<TcInMemConverter>,
|
psb: PusServiceHelper<TcInMemConverter>,
|
||||||
|
@ -1,9 +1,19 @@
|
|||||||
|
use std::sync::mpsc;
|
||||||
|
use std::time::Duration;
|
||||||
|
|
||||||
use crate::tmtc::PusTcSource;
|
use crate::tmtc::PusTcSource;
|
||||||
use log::{error, info, warn};
|
use log::{error, info, warn};
|
||||||
use satrs_core::pool::{PoolProviderMemInPlace, StaticMemoryPool};
|
use satrs_core::pool::{PoolProviderMemInPlace, StaticMemoryPool, StoreAddr};
|
||||||
use satrs_core::pus::scheduler::{PusScheduler, TcInfo};
|
use satrs_core::pus::scheduler::{PusScheduler, TcInfo};
|
||||||
use satrs_core::pus::scheduler_srv::PusService11SchedHandler;
|
use satrs_core::pus::scheduler_srv::PusService11SchedHandler;
|
||||||
use satrs_core::pus::{EcssTcInSharedStoreConverter, PusPacketHandlerResult};
|
use satrs_core::pus::verification::VerificationReporterWithSender;
|
||||||
|
use satrs_core::pus::{
|
||||||
|
EcssTcAndToken, EcssTcInSharedStoreConverter, MpscTcReceiver, MpscTmInStoreSender,
|
||||||
|
PusPacketHandlerResult, PusServiceHelper,
|
||||||
|
};
|
||||||
|
use satrs_core::tmtc::tm_helper::SharedTmStore;
|
||||||
|
use satrs_core::ChannelId;
|
||||||
|
use satrs_example::{TcReceiverId, TmSenderId, PUS_APID};
|
||||||
|
|
||||||
pub struct Pus11Wrapper {
|
pub struct Pus11Wrapper {
|
||||||
pub pus_11_handler: PusService11SchedHandler<EcssTcInSharedStoreConverter, PusScheduler>,
|
pub pus_11_handler: PusService11SchedHandler<EcssTcInSharedStoreConverter, PusScheduler>,
|
||||||
@ -11,6 +21,44 @@ pub struct Pus11Wrapper {
|
|||||||
pub tc_source_wrapper: PusTcSource,
|
pub tc_source_wrapper: PusTcSource,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn create_scheduler_service(
|
||||||
|
shared_tm_store: SharedTmStore,
|
||||||
|
tm_funnel_tx: mpsc::Sender<StoreAddr>,
|
||||||
|
verif_reporter: VerificationReporterWithSender,
|
||||||
|
tc_source_wrapper: PusTcSource,
|
||||||
|
pus_sched_rx: mpsc::Receiver<EcssTcAndToken>,
|
||||||
|
sched_tc_pool: StaticMemoryPool,
|
||||||
|
) -> Pus11Wrapper {
|
||||||
|
let sched_srv_tm_sender = MpscTmInStoreSender::new(
|
||||||
|
TmSenderId::PusSched as ChannelId,
|
||||||
|
"PUS_11_TM_SENDER",
|
||||||
|
shared_tm_store.clone(),
|
||||||
|
tm_funnel_tx.clone(),
|
||||||
|
);
|
||||||
|
let sched_srv_receiver = MpscTcReceiver::new(
|
||||||
|
TcReceiverId::PusSched as ChannelId,
|
||||||
|
"PUS_11_TC_RECV",
|
||||||
|
pus_sched_rx,
|
||||||
|
);
|
||||||
|
let scheduler = PusScheduler::new_with_current_init_time(Duration::from_secs(5))
|
||||||
|
.expect("Creating PUS Scheduler failed");
|
||||||
|
let pus_11_handler = PusService11SchedHandler::new(
|
||||||
|
PusServiceHelper::new(
|
||||||
|
Box::new(sched_srv_receiver),
|
||||||
|
Box::new(sched_srv_tm_sender),
|
||||||
|
PUS_APID,
|
||||||
|
verif_reporter.clone(),
|
||||||
|
EcssTcInSharedStoreConverter::new(tc_source_wrapper.clone_backing_pool(), 2048),
|
||||||
|
),
|
||||||
|
scheduler,
|
||||||
|
);
|
||||||
|
Pus11Wrapper {
|
||||||
|
pus_11_handler,
|
||||||
|
sched_tc_pool,
|
||||||
|
tc_source_wrapper,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Pus11Wrapper {
|
impl Pus11Wrapper {
|
||||||
pub fn release_tcs(&mut self) {
|
pub fn release_tcs(&mut self) {
|
||||||
let releaser = |enabled: bool, _info: &TcInfo, tc: &[u8]| -> bool {
|
let releaser = |enabled: bool, _info: &TcInfo, tc: &[u8]| -> bool {
|
||||||
|
@ -1,32 +1,6 @@
|
|||||||
// Prototyping software.
|
|
||||||
/*
|
|
||||||
use std::{collections::HashMap, sync::mpsc, time::Duration};
|
|
||||||
|
|
||||||
use satrs_core::{
|
|
||||||
events::EventU32,
|
|
||||||
params::Params,
|
|
||||||
pool::{SharedStaticMemoryPool, StaticMemoryPool, StoreAddr},
|
|
||||||
pus::{
|
|
||||||
event_man::EventRequestWithToken, event_srv::PusService5EventHandler,
|
|
||||||
scheduler::PusScheduler, scheduler_srv::PusService11SchedHandler,
|
|
||||||
test::PusService17TestHandler, verification::VerificationReporterWithSender,
|
|
||||||
EcssTcAndToken, EcssTcInSharedStoreConverter, MpscTcReceiver, MpscTmInStoreSender,
|
|
||||||
PusServiceHelper,
|
|
||||||
},
|
|
||||||
tmtc::tm_helper::SharedTmStore,
|
|
||||||
ChannelId,
|
|
||||||
};
|
|
||||||
use satrs_example::{TargetIdWithApid, TcReceiverId, TmSenderId, PUS_APID};
|
|
||||||
|
|
||||||
use crate::{requests::RequestWithToken, tmtc::PusTcSource};
|
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
action::{Pus8Wrapper, PusService8ActionHandler},
|
action::Pus8Wrapper, event::Pus5Wrapper, hk::Pus3Wrapper, scheduler::Pus11Wrapper,
|
||||||
event::Pus5Wrapper,
|
|
||||||
hk::{Pus3Wrapper, PusService3HkHandler},
|
|
||||||
scheduler::Pus11Wrapper,
|
|
||||||
test::Service17CustomWrapper,
|
test::Service17CustomWrapper,
|
||||||
PusTcMpscRouter,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct PusStack {
|
pub struct PusStack {
|
||||||
@ -38,164 +12,20 @@ pub struct PusStack {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl PusStack {
|
impl PusStack {
|
||||||
pub fn test_service(
|
|
||||||
shared_tm_store: SharedTmStore,
|
|
||||||
tm_funnel_tx: mpsc::Sender<StoreAddr>,
|
|
||||||
verif_reporter: VerificationReporterWithSender,
|
|
||||||
tc_pool: SharedStaticMemoryPool,
|
|
||||||
event_sender: mpsc::Sender<(EventU32, Option<Params>)>,
|
|
||||||
) -> (Service17CustomWrapper, mpsc::Sender<EcssTcAndToken>) {
|
|
||||||
let (pus_test_tx, pus_test_rx) = mpsc::channel();
|
|
||||||
let test_srv_tm_sender = MpscTmInStoreSender::new(
|
|
||||||
TmSenderId::PusTest as ChannelId,
|
|
||||||
"PUS_17_TM_SENDER",
|
|
||||||
shared_tm_store.clone(),
|
|
||||||
tm_funnel_tx.clone(),
|
|
||||||
);
|
|
||||||
let test_srv_receiver = MpscTcReceiver::new(
|
|
||||||
TcReceiverId::PusTest as ChannelId,
|
|
||||||
"PUS_17_TC_RECV",
|
|
||||||
pus_test_rx,
|
|
||||||
);
|
|
||||||
let pus17_handler = PusService17TestHandler::new(PusServiceHelper::new(
|
|
||||||
Box::new(test_srv_receiver),
|
|
||||||
Box::new(test_srv_tm_sender),
|
|
||||||
PUS_APID,
|
|
||||||
verif_reporter.clone(),
|
|
||||||
EcssTcInSharedStoreConverter::new(tc_pool, 2048),
|
|
||||||
));
|
|
||||||
(
|
|
||||||
Service17CustomWrapper {
|
|
||||||
pus17_handler,
|
|
||||||
test_srv_event_sender: event_sender,
|
|
||||||
},
|
|
||||||
pus_test_tx,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn new(
|
pub fn new(
|
||||||
shared_tm_store: SharedTmStore,
|
hk_srv: Pus3Wrapper,
|
||||||
tm_funnel_tx: mpsc::Sender<StoreAddr>,
|
event_srv: Pus5Wrapper,
|
||||||
sched_tc_pool: StaticMemoryPool,
|
action_srv: Pus8Wrapper,
|
||||||
tc_source_wrapper: PusTcSource,
|
schedule_srv: Pus11Wrapper,
|
||||||
verif_reporter: VerificationReporterWithSender,
|
test_srv: Service17CustomWrapper,
|
||||||
event_sender: mpsc::Sender<(EventU32, Option<Params>)>,
|
) -> Self {
|
||||||
event_request_tx: mpsc::Sender<EventRequestWithToken>,
|
Self {
|
||||||
request_map: HashMap<TargetIdWithApid, mpsc::Sender<RequestWithToken>>,
|
event_srv,
|
||||||
) -> (Self, PusTcMpscRouter) {
|
action_srv,
|
||||||
let (pus_event_tx, pus_event_rx) = mpsc::channel();
|
schedule_srv,
|
||||||
let (pus_sched_tx, pus_sched_rx) = mpsc::channel();
|
test_srv,
|
||||||
let (pus_hk_tx, pus_hk_rx) = mpsc::channel();
|
hk_srv
|
||||||
let (pus_action_tx, pus_action_rx) = mpsc::channel();
|
}
|
||||||
let tc_pool = tc_source_wrapper.clone_backing_pool();
|
|
||||||
let pus_router = PusTcMpscRouter {
|
|
||||||
test_service_receiver: pus_test_tx,
|
|
||||||
event_service_receiver: pus_event_tx,
|
|
||||||
sched_service_receiver: pus_sched_tx,
|
|
||||||
hk_service_receiver: pus_hk_tx,
|
|
||||||
action_service_receiver: pus_action_tx,
|
|
||||||
};
|
|
||||||
|
|
||||||
let sched_srv_tm_sender = MpscTmInStoreSender::new(
|
|
||||||
TmSenderId::PusSched as ChannelId,
|
|
||||||
"PUS_11_TM_SENDER",
|
|
||||||
shared_tm_store.clone(),
|
|
||||||
tm_funnel_tx.clone(),
|
|
||||||
);
|
|
||||||
let sched_srv_receiver = MpscTcReceiver::new(
|
|
||||||
TcReceiverId::PusSched as ChannelId,
|
|
||||||
"PUS_11_TC_RECV",
|
|
||||||
pus_sched_rx,
|
|
||||||
);
|
|
||||||
let scheduler = PusScheduler::new_with_current_init_time(Duration::from_secs(5))
|
|
||||||
.expect("Creating PUS Scheduler failed");
|
|
||||||
let pus_11_handler = PusService11SchedHandler::new(
|
|
||||||
PusServiceHelper::new(
|
|
||||||
Box::new(sched_srv_receiver),
|
|
||||||
Box::new(sched_srv_tm_sender),
|
|
||||||
PUS_APID,
|
|
||||||
verif_reporter.clone(),
|
|
||||||
EcssTcInSharedStoreConverter::new(tc_source_wrapper.clone_backing_pool(), 2048),
|
|
||||||
),
|
|
||||||
scheduler,
|
|
||||||
);
|
|
||||||
let pus_11_wrapper = Pus11Wrapper {
|
|
||||||
pus_11_handler,
|
|
||||||
sched_tc_pool,
|
|
||||||
tc_source_wrapper,
|
|
||||||
};
|
|
||||||
|
|
||||||
let event_srv_tm_sender = MpscTmInStoreSender::new(
|
|
||||||
TmSenderId::PusEvent as ChannelId,
|
|
||||||
"PUS_5_TM_SENDER",
|
|
||||||
shared_tm_store.clone(),
|
|
||||||
tm_funnel_tx.clone(),
|
|
||||||
);
|
|
||||||
let event_srv_receiver = MpscTcReceiver::new(
|
|
||||||
TcReceiverId::PusEvent as ChannelId,
|
|
||||||
"PUS_5_TC_RECV",
|
|
||||||
pus_event_rx,
|
|
||||||
);
|
|
||||||
let pus_5_handler = PusService5EventHandler::new(
|
|
||||||
PusServiceHelper::new(
|
|
||||||
Box::new(event_srv_receiver),
|
|
||||||
Box::new(event_srv_tm_sender),
|
|
||||||
PUS_APID,
|
|
||||||
verif_reporter.clone(),
|
|
||||||
EcssTcInSharedStoreConverter::new(tc_pool.clone(), 2048),
|
|
||||||
),
|
|
||||||
event_request_tx,
|
|
||||||
);
|
|
||||||
let pus_5_wrapper = Pus5Wrapper { pus_5_handler };
|
|
||||||
|
|
||||||
let action_srv_tm_sender = MpscTmInStoreSender::new(
|
|
||||||
TmSenderId::PusAction as ChannelId,
|
|
||||||
"PUS_8_TM_SENDER",
|
|
||||||
shared_tm_store.clone(),
|
|
||||||
tm_funnel_tx.clone(),
|
|
||||||
);
|
|
||||||
let action_srv_receiver = MpscTcReceiver::new(
|
|
||||||
TcReceiverId::PusAction as ChannelId,
|
|
||||||
"PUS_8_TC_RECV",
|
|
||||||
pus_action_rx,
|
|
||||||
);
|
|
||||||
let pus_8_handler = PusService8ActionHandler::new(
|
|
||||||
Box::new(action_srv_receiver),
|
|
||||||
Box::new(action_srv_tm_sender),
|
|
||||||
PUS_APID,
|
|
||||||
verif_reporter.clone(),
|
|
||||||
EcssTcInSharedStoreConverter::new(tc_pool.clone(), 2048),
|
|
||||||
request_map.clone(),
|
|
||||||
);
|
|
||||||
let pus_8_wrapper = Pus8Wrapper { pus_8_handler };
|
|
||||||
|
|
||||||
let hk_srv_tm_sender = MpscTmInStoreSender::new(
|
|
||||||
TmSenderId::PusHk as ChannelId,
|
|
||||||
"PUS_3_TM_SENDER",
|
|
||||||
shared_tm_store.clone(),
|
|
||||||
tm_funnel_tx.clone(),
|
|
||||||
);
|
|
||||||
let hk_srv_receiver =
|
|
||||||
MpscTcReceiver::new(TcReceiverId::PusHk as ChannelId, "PUS_8_TC_RECV", pus_hk_rx);
|
|
||||||
let pus_3_handler = PusService3HkHandler::new(
|
|
||||||
Box::new(hk_srv_receiver),
|
|
||||||
Box::new(hk_srv_tm_sender),
|
|
||||||
PUS_APID,
|
|
||||||
verif_reporter.clone(),
|
|
||||||
EcssTcInSharedStoreConverter::new(tc_pool, 2048),
|
|
||||||
request_map,
|
|
||||||
);
|
|
||||||
let pus_3_wrapper = Pus3Wrapper { pus_3_handler };
|
|
||||||
(
|
|
||||||
Self {
|
|
||||||
event_srv: pus_5_wrapper,
|
|
||||||
hk_srv: pus_3_wrapper,
|
|
||||||
action_srv: pus_8_wrapper,
|
|
||||||
schedule_srv: pus_11_wrapper,
|
|
||||||
test_srv: pus_17_wrapper,
|
|
||||||
},
|
|
||||||
pus_router,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn periodic_operation(&mut self) {
|
pub fn periodic_operation(&mut self) {
|
||||||
@ -218,4 +48,3 @@ impl PusStack {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
@ -1,15 +1,53 @@
|
|||||||
use log::{info, warn};
|
use log::{info, warn};
|
||||||
use satrs_core::params::Params;
|
use satrs_core::params::Params;
|
||||||
|
use satrs_core::pool::{SharedStaticMemoryPool, StoreAddr};
|
||||||
use satrs_core::pus::test::PusService17TestHandler;
|
use satrs_core::pus::test::PusService17TestHandler;
|
||||||
use satrs_core::pus::verification::FailParams;
|
use satrs_core::pus::verification::{FailParams, VerificationReporterWithSender};
|
||||||
use satrs_core::pus::{EcssTcInMemConverter, PusPacketHandlerResult};
|
use satrs_core::pus::{
|
||||||
|
EcssTcAndToken, EcssTcInMemConverter, MpscTcReceiver, MpscTmInStoreSender,
|
||||||
|
PusPacketHandlerResult, PusServiceHelper,
|
||||||
|
};
|
||||||
use satrs_core::spacepackets::ecss::tc::PusTcReader;
|
use satrs_core::spacepackets::ecss::tc::PusTcReader;
|
||||||
use satrs_core::spacepackets::ecss::PusPacket;
|
use satrs_core::spacepackets::ecss::PusPacket;
|
||||||
use satrs_core::spacepackets::time::cds::TimeProvider;
|
use satrs_core::spacepackets::time::cds::TimeProvider;
|
||||||
use satrs_core::spacepackets::time::TimeWriter;
|
use satrs_core::spacepackets::time::TimeWriter;
|
||||||
|
use satrs_core::tmtc::tm_helper::SharedTmStore;
|
||||||
|
use satrs_core::ChannelId;
|
||||||
use satrs_core::{events::EventU32, pus::EcssTcInSharedStoreConverter};
|
use satrs_core::{events::EventU32, pus::EcssTcInSharedStoreConverter};
|
||||||
use satrs_example::{tmtc_err, TEST_EVENT};
|
use satrs_example::{tmtc_err, TcReceiverId, TmSenderId, PUS_APID, TEST_EVENT};
|
||||||
use std::sync::mpsc::Sender;
|
use std::sync::mpsc::{self, Sender};
|
||||||
|
|
||||||
|
pub fn create_test_service(
|
||||||
|
shared_tm_store: SharedTmStore,
|
||||||
|
tm_funnel_tx: mpsc::Sender<StoreAddr>,
|
||||||
|
verif_reporter: VerificationReporterWithSender,
|
||||||
|
tc_pool: SharedStaticMemoryPool,
|
||||||
|
event_sender: mpsc::Sender<(EventU32, Option<Params>)>,
|
||||||
|
pus_test_rx: mpsc::Receiver<EcssTcAndToken>,
|
||||||
|
) -> Service17CustomWrapper {
|
||||||
|
let test_srv_tm_sender = MpscTmInStoreSender::new(
|
||||||
|
TmSenderId::PusTest as ChannelId,
|
||||||
|
"PUS_17_TM_SENDER",
|
||||||
|
shared_tm_store.clone(),
|
||||||
|
tm_funnel_tx.clone(),
|
||||||
|
);
|
||||||
|
let test_srv_receiver = MpscTcReceiver::new(
|
||||||
|
TcReceiverId::PusTest as ChannelId,
|
||||||
|
"PUS_17_TC_RECV",
|
||||||
|
pus_test_rx,
|
||||||
|
);
|
||||||
|
let pus17_handler = PusService17TestHandler::new(PusServiceHelper::new(
|
||||||
|
Box::new(test_srv_receiver),
|
||||||
|
Box::new(test_srv_tm_sender),
|
||||||
|
PUS_APID,
|
||||||
|
verif_reporter.clone(),
|
||||||
|
EcssTcInSharedStoreConverter::new(tc_pool, 2048),
|
||||||
|
));
|
||||||
|
Service17CustomWrapper {
|
||||||
|
pus17_handler,
|
||||||
|
test_srv_event_sender: event_sender,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub struct Service17CustomWrapper {
|
pub struct Service17CustomWrapper {
|
||||||
pub pus17_handler: PusService17TestHandler<EcssTcInSharedStoreConverter>,
|
pub pus17_handler: PusService17TestHandler<EcssTcInSharedStoreConverter>,
|
||||||
|
@ -40,11 +40,11 @@ pub enum MpscStoreAndSendError {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct TcStore {
|
pub struct SharedTcPool {
|
||||||
pub pool: SharedStaticMemoryPool,
|
pub pool: SharedStaticMemoryPool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TcStore {
|
impl SharedTcPool {
|
||||||
pub fn add_pus_tc(&mut self, pus_tc: &PusTcReader) -> Result<StoreAddr, StoreError> {
|
pub fn add_pus_tc(&mut self, pus_tc: &PusTcReader) -> Result<StoreAddr, StoreError> {
|
||||||
let mut pg = self.pool.write().expect("error locking TC store");
|
let mut pg = self.pool.write().expect("error locking TC store");
|
||||||
let (addr, buf) = pg.free_element(pus_tc.len_packed())?;
|
let (addr, buf) = pg.free_element(pus_tc.len_packed())?;
|
||||||
@ -56,7 +56,7 @@ impl TcStore {
|
|||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct PusTcSource {
|
pub struct PusTcSource {
|
||||||
pub tc_source: Sender<StoreAddr>,
|
pub tc_source: Sender<StoreAddr>,
|
||||||
pub tc_store: TcStore,
|
pub tc_store: SharedTcPool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PusTcSource {
|
impl PusTcSource {
|
||||||
|
Loading…
Reference in New Issue
Block a user