implemented action req handling

This commit is contained in:
2024-04-10 15:37:24 +02:00
parent 443995fe5e
commit 5d87cab9cc
4 changed files with 113 additions and 14 deletions

@ -9,7 +9,7 @@ use log::info;
use ops_sat_rs::config::{
components::CONTROLLER_ID,
tasks::{FREQ_MS_CTRL, FREQ_MS_PUS_STACK},
EXPERIMENT_APID, STOP_FILE_NAME,
EXPERIMENT_APID,
};
use ops_sat_rs::config::{tasks::FREQ_MS_UDP_TMTC, OBSW_SERVER_ADDR, SERVER_PORT};
use satrs::{
@ -18,10 +18,10 @@ use satrs::{
tmtc::CcsdsDistributor,
};
use crate::pus::test::create_test_service;
use crate::pus::{PusReceiver, PusTcMpscRouter};
use crate::tmtc::tm_funnel::TmFunnelDynamic;
use crate::tmtc::TcSourceTaskDynamic;
use crate::{controller::ExperimentController, pus::test::create_test_service};
use crate::{
interface::tcp::{SyncTcpTmSource, TcpTask},
interface::udp::{DynamicUdpTmHandler, UdpTmtcServer},
@ -34,6 +34,7 @@ use crate::{
requests::GenericRequestRouter,
};
mod controller;
mod interface;
mod logger;
mod pus;
@ -59,10 +60,11 @@ fn main() {
let (pus_action_tx, pus_action_rx) = mpsc::channel();
// let (pus_mode_tx, pus_mode_rx) = mpsc::channel();
let (_pus_action_reply_tx, pus_action_reply_rx) = mpsc::channel();
let (pus_action_reply_tx, pus_action_reply_rx) = mpsc::channel();
// let (pus_hk_reply_tx, pus_hk_reply_rx) = mpsc::channel();
// let (pus_mode_reply_tx, pus_mode_reply_rx) = mpsc::channel();
let (controller_composite_tx, _controller_composite_rx) = mpsc::channel();
let (controller_composite_tx, controller_composite_rx) = mpsc::channel();
// let (controller_action_reply_tx, controller_action_reply_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();
@ -157,17 +159,19 @@ fn main() {
stop_signal.clone(),
);
let mut controller = ExperimentController::new(
controller_composite_rx,
pus_action_reply_tx,
stop_signal.clone(),
);
info!("Starting CTRL task");
let ctrl_stop_signal = stop_signal.clone();
let jh_ctrl_thread = thread::Builder::new()
.name("ops-sat ctrl".to_string())
.spawn(move || loop {
if std::path::Path::new(STOP_FILE_NAME).exists() {
log::warn!(
"Detected stop file name at {}. Initiating experiment shutdown",
STOP_FILE_NAME
);
ctrl_stop_signal.store(true, std::sync::atomic::Ordering::Relaxed);
controller.perform_operation();
if ctrl_stop_signal.load(std::sync::atomic::Ordering::Relaxed) {
break;
}
thread::sleep(Duration::from_millis(FREQ_MS_CTRL));