some minor cleaning up plus initial image file handling

This commit is contained in:
lkoester
2024-04-19 22:05:57 +02:00
parent 4f94e9cade
commit 0f391c2087
5 changed files with 131 additions and 33 deletions

View File

@ -6,6 +6,7 @@ use std::{
};
use log::info;
use ops_sat_rs::config::components::CAMERA_HANDLER;
use ops_sat_rs::config::{
components::{CONTROLLER_ID, TCP_SERVER, TCP_SPP_CLIENT, UDP_SERVER},
tasks::{FREQ_MS_CTRL, FREQ_MS_PUS_STACK},
@ -13,7 +14,9 @@ use ops_sat_rs::config::{
};
use ops_sat_rs::config::{tasks::FREQ_MS_UDP_TMTC, OBSW_SERVER_ADDR, SERVER_PORT};
use satrs::hal::std::{tcp_server::ServerConfig, udp_server::UdpTcServer};
use ops_sat_rs::TimeStampHelper;
use crate::handlers::camera::IMS100BatchHandler;
use crate::tmtc::tc_source::TcSourceTaskDynamic;
use crate::tmtc::tm_sink::TmFunnelDynamic;
use crate::{controller::ExperimentController, pus::test::create_test_service};
@ -62,12 +65,16 @@ fn main() {
// let (pus_mode_reply_tx, pus_mode_reply_rx) = mpsc::channel();
let (controller_composite_tx, controller_composite_rx) = mpsc::channel();
// let (controller_action_reply_tx, controller_action_reply_rx) = mpsc::channel();
let (camera_composite_tx, camera_composite_rx) = mpsc::channel();
// Some request are targetable. This map is used to retrieve sender handles based on a target ID.
let mut request_map = GenericRequestRouter::default();
request_map
.composite_router_map
.insert(CONTROLLER_ID.id(), controller_composite_tx);
request_map
.composite_router_map
.insert(CAMERA_HANDLER.id(), camera_composite_tx);
let pus_router = PusTcMpscRouter {
test_tc_sender: pus_test_tx,
@ -161,7 +168,7 @@ fn main() {
let mut controller = ExperimentController::new(
controller_composite_rx,
pus_action_reply_tx,
pus_action_reply_tx.clone(),
stop_signal.clone(),
);
@ -173,6 +180,13 @@ fn main() {
)
.expect("creating TCP SPP client failed");
let timestamp_helper = TimeStampHelper::default();
let mut camera_handler: IMS100BatchHandler =
IMS100BatchHandler::new(CAMERA_HANDLER, camera_composite_rx, tm_funnel_tx.clone(), pus_action_reply_tx.clone(), timestamp_helper);
// Main Task Thread Definitions
// Main Experiment Control Task
info!("Starting CTRL task");
let ctrl_stop_signal = stop_signal.clone();
let jh_ctrl_thread = thread::Builder::new()
@ -186,6 +200,7 @@ fn main() {
})
.unwrap();
// TMTC and UDP Task
info!("Starting TMTC and UDP task");
let tmtc_stop_signal = stop_signal.clone();
let jh_udp_tmtc = thread::Builder::new()
@ -203,6 +218,7 @@ fn main() {
})
.unwrap();
// TCP Server Task
let tcp_server_stop_signal = stop_signal.clone();
info!("Starting TCP server task");
let jh_tcp_server = thread::Builder::new()
@ -218,6 +234,7 @@ fn main() {
})
.unwrap();
// TCP SPP Client Task
// We could also move this to the existing TCP server thread, but we would have to adapt
// the server code for this so we do not block anymore and we pause manually if both the client
// and server are IDLE and have nothing to do..
@ -236,6 +253,7 @@ fn main() {
})
.unwrap();
// TM Funnel Task
info!("Starting TM funnel task");
let funnel_stop_signal = stop_signal.clone();
let jh_tm_funnel = thread::Builder::new()
@ -248,7 +266,8 @@ fn main() {
})
.unwrap();
info!("Starting PUS handlers thread");
// PUS Handler Task
info!("Starting PUS handlers task");
let pus_stop_signal = stop_signal.clone();
let jh_pus_handler = thread::Builder::new()
.name("ops-sat pus".to_string())
@ -261,6 +280,20 @@ fn main() {
})
.unwrap();
// Camera Handler Task
info!("Starting camera handler task");
let camera_stop_signal = stop_signal.clone();
let jh_camera_handler = thread::Builder::new()
.name("ops-sat camera".to_string())
.spawn(move || loop {
camera_handler.periodic_operation();
if camera_stop_signal.load(std::sync::atomic::Ordering::Relaxed) {
break;
}
})
.unwrap();
// Join Threads
jh_ctrl_thread
.join()
.expect("Joining Controller thread failed");
@ -279,4 +312,7 @@ fn main() {
jh_pus_handler
.join()
.expect("Joining PUS handlers thread failed");
jh_camera_handler
.join()
.expect("Joining camera handler thread failed");
}