restore MGM handlers
This commit is contained in:
@@ -3,7 +3,7 @@ use arbitrary_int::u11;
|
||||
use clap::Parser as _;
|
||||
use models::{Apid, TcHeader};
|
||||
use satrs_example::config::{OBSW_SERVER_ADDR, SERVER_PORT};
|
||||
use spacepackets::{CcsdsPacketIdAndPsc, CcsdsPacketReader, SpacePacketHeader};
|
||||
use spacepackets::{CcsdsPacketIdAndPsc, SpacePacketHeader};
|
||||
use std::{
|
||||
net::{IpAddr, SocketAddr, UdpSocket},
|
||||
sync::{
|
||||
@@ -114,7 +114,7 @@ fn handle_raw_tm_packet(data: &[u8]) -> anyhow::Result<()> {
|
||||
log::info!("Received response from controller: {:?}", response.unwrap());
|
||||
}
|
||||
models::ComponentId::AcsSubsystem => todo!(),
|
||||
models::ComponentId::AcsAssembly => todo!(),
|
||||
models::ComponentId::AcsMgmAssembly => todo!(),
|
||||
models::ComponentId::AcsMgm0 => todo!(),
|
||||
models::ComponentId::AcsMgm1 => todo!(),
|
||||
models::ComponentId::EpsSubsystem => todo!(),
|
||||
|
||||
@@ -25,7 +25,7 @@ pub enum ComponentId {
|
||||
Controller,
|
||||
|
||||
AcsSubsystem,
|
||||
AcsAssembly,
|
||||
AcsMgmAssembly,
|
||||
AcsMgm0,
|
||||
AcsMgm1,
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/*
|
||||
use derive_new::new;
|
||||
use models::ccsds::{CcsdsTcPacketOwned, CcsdsTmPacketOwned};
|
||||
use models::ComponentId;
|
||||
use satrs::hk::{HkRequest, HkRequestVariant};
|
||||
use satrs::mode_tree::{ModeChild, ModeNode};
|
||||
use satrs::power::{PowerSwitchInfo, PowerSwitcherCommandSender};
|
||||
use satrs_example::ids::generic_pus::PUS_MODE;
|
||||
use satrs_example::{DeviceMode, TimestampHelper};
|
||||
use satrs_minisim::acs::lis3mdl::{
|
||||
MgmLis3MdlReply, MgmLis3RawValues, FIELD_LSB_PER_GAUSS_4_SENS, GAUSS_TO_MICROTESLA_FACTOR,
|
||||
@@ -25,8 +25,6 @@ use satrs::request::{GenericMessage, MessageMetadata, UniqueApidTargetId};
|
||||
use satrs_example::config::components::NO_SENDER;
|
||||
|
||||
use crate::hk::PusHkHelper;
|
||||
use crate::pus::hk::{HkReply, HkReplyVariant};
|
||||
use crate::requests::CompositeRequest;
|
||||
use crate::spi::SpiInterface;
|
||||
use crate::tmtc::sender::TmTcSender;
|
||||
|
||||
@@ -155,28 +153,22 @@ impl Default for ModeHelpers {
|
||||
}
|
||||
|
||||
/// Example MGM device handler strongly based on the LIS3MDL MEMS device.
|
||||
#[derive(new)]
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub struct MgmHandlerLis3Mdl<
|
||||
ComInterface: SpiInterface,
|
||||
SwitchHelper: PowerSwitchInfo<PcduSwitch> + PowerSwitcherCommandSender<PcduSwitch>,
|
||||
> {
|
||||
id: UniqueApidTargetId,
|
||||
id: ComponentId,
|
||||
dev_str: &'static str,
|
||||
mode_node: ModeRequestHandlerMpscBounded,
|
||||
composite_request_rx: mpsc::Receiver<GenericMessage<CompositeRequest>>,
|
||||
hk_reply_tx: mpsc::SyncSender<GenericMessage<HkReply>>,
|
||||
tc_rx: mpsc::Receiver<CcsdsTcPacketOwned>,
|
||||
tm_tx: mpsc::SyncSender<CcsdsTmPacketOwned>,
|
||||
switch_helper: SwitchHelper,
|
||||
tm_sender: TmTcSender,
|
||||
pub com_interface: ComInterface,
|
||||
shared_mgm_set: Arc<Mutex<MgmData>>,
|
||||
#[new(value = "PusHkHelper::new(id)")]
|
||||
hk_helper: PusHkHelper,
|
||||
#[new(default)]
|
||||
//hk_helper: PusHkHelper,
|
||||
mode_helpers: ModeHelpers,
|
||||
#[new(default)]
|
||||
bufs: BufWrapper,
|
||||
#[new(default)]
|
||||
stamp_helper: TimestampHelper,
|
||||
}
|
||||
|
||||
@@ -185,10 +177,34 @@ impl<
|
||||
SwitchHelper: PowerSwitchInfo<PcduSwitch> + PowerSwitcherCommandSender<PcduSwitch>,
|
||||
> MgmHandlerLis3Mdl<ComInterface, SwitchHelper>
|
||||
{
|
||||
pub fn new(
|
||||
id: ComponentId,
|
||||
dev_str: &'static str,
|
||||
mode_node: ModeRequestHandlerMpscBounded,
|
||||
tc_rx: mpsc::Receiver<CcsdsTcPacketOwned>,
|
||||
tm_tx: mpsc::SyncSender<CcsdsTmPacketOwned>,
|
||||
switch_helper: SwitchHelper,
|
||||
com_interface: ComInterface,
|
||||
shared_mgm_set: Arc<Mutex<MgmData>>,
|
||||
) -> Self {
|
||||
Self {
|
||||
id,
|
||||
dev_str,
|
||||
mode_node,
|
||||
tc_rx,
|
||||
tm_tx,
|
||||
switch_helper,
|
||||
com_interface,
|
||||
shared_mgm_set,
|
||||
mode_helpers: ModeHelpers::default(),
|
||||
bufs: BufWrapper::default(),
|
||||
stamp_helper: TimestampHelper::default(),
|
||||
}
|
||||
}
|
||||
pub fn periodic_operation(&mut self) {
|
||||
self.stamp_helper.update_from_now();
|
||||
// Handle requests.
|
||||
self.handle_composite_requests();
|
||||
self.handle_tc();
|
||||
self.handle_mode_requests();
|
||||
if let Some(target_mode_submode) = self.mode_helpers.target {
|
||||
self.handle_mode_transition(target_mode_submode);
|
||||
@@ -199,36 +215,39 @@ impl<
|
||||
}
|
||||
}
|
||||
|
||||
pub fn handle_composite_requests(&mut self) {
|
||||
pub fn handle_tc(&mut self) {
|
||||
loop {
|
||||
match self.composite_request_rx.try_recv() {
|
||||
Ok(ref msg) => match &msg.message {
|
||||
CompositeRequest::Hk(hk_request) => {
|
||||
self.handle_hk_request(&msg.requestor_info, hk_request)
|
||||
}
|
||||
// TODO: This object does not have actions (yet).. Still send back completion failure
|
||||
// reply.
|
||||
CompositeRequest::Action(_action_req) => {}
|
||||
},
|
||||
//match self.tc_rx.try_recv() {
|
||||
/*
|
||||
Ok(ref msg) => match &msg.message {
|
||||
CompositeRequest::Hk(hk_request) => {
|
||||
self.handle_hk_request(&msg.requestor_info, hk_request)
|
||||
}
|
||||
// TODO: This object does not have actions (yet).. Still send back completion failure
|
||||
// reply.
|
||||
CompositeRequest::Action(_action_req) => {}
|
||||
},
|
||||
|
||||
Err(e) => {
|
||||
if e != mpsc::TryRecvError::Empty {
|
||||
log::warn!(
|
||||
"{}: failed to receive composite request: {:?}",
|
||||
self.dev_str,
|
||||
e
|
||||
);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
Err(e) => {
|
||||
if e != mpsc::TryRecvError::Empty {
|
||||
log::warn!(
|
||||
"{}: failed to receive composite request: {:?}",
|
||||
self.dev_str,
|
||||
e
|
||||
);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
*/
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn handle_hk_request(&mut self, requestor_info: &MessageMetadata, hk_request: &HkRequest) {
|
||||
match hk_request.variant {
|
||||
HkRequestVariant::OneShot => {
|
||||
/*
|
||||
let mgm_snapshot = *self.shared_mgm_set.lock().unwrap();
|
||||
if let Ok(hk_tm) = self.hk_helper.generate_hk_report_packet(
|
||||
self.stamp_helper.stamp(),
|
||||
@@ -256,6 +275,7 @@ impl<
|
||||
// TODO: Send back failure reply. Need result code for this.
|
||||
log::error!("TM buffer too small to generate HK data");
|
||||
}
|
||||
*/
|
||||
}
|
||||
HkRequestVariant::EnablePeriodic => todo!(),
|
||||
HkRequestVariant::DisablePeriodic => todo!(),
|
||||
@@ -332,7 +352,7 @@ impl<
|
||||
if self.mode_helpers.transition_state == TransitionState::Idle {
|
||||
let result = self
|
||||
.switch_helper
|
||||
.send_switch_on_cmd(MessageMetadata::new(0, self.id.id()), PcduSwitch::Mgm);
|
||||
.send_switch_on_cmd(MessageMetadata::new(0, self.id as u32), PcduSwitch::Mgm);
|
||||
if result.is_err() {
|
||||
// Could not send switch command.. still continue with transition.
|
||||
log::error!("failed to send switch on command");
|
||||
@@ -418,7 +438,7 @@ impl<
|
||||
if requestor.sender_id() == NO_SENDER {
|
||||
return Ok(());
|
||||
}
|
||||
if requestor.sender_id() != PUS_MODE.id() {
|
||||
if requestor.sender_id() != ComponentId::Ground as u32 {
|
||||
log::warn!(
|
||||
"can not send back mode reply to sender {:x}",
|
||||
requestor.sender_id()
|
||||
@@ -435,7 +455,7 @@ impl<
|
||||
requestor: MessageMetadata,
|
||||
reply: ModeReply,
|
||||
) -> Result<(), Self::Error> {
|
||||
if requestor.sender_id() != PUS_MODE.id() {
|
||||
if requestor.sender_id() != ComponentId::Ground as u32 {
|
||||
log::warn!(
|
||||
"can not send back mode reply to sender {}",
|
||||
requestor.sender_id()
|
||||
@@ -462,7 +482,7 @@ impl<
|
||||
> ModeNode for MgmHandlerLis3Mdl<ComInterface, SwitchHelper>
|
||||
{
|
||||
fn id(&self) -> satrs::ComponentId {
|
||||
self.id.into()
|
||||
self.id as u32
|
||||
}
|
||||
}
|
||||
|
||||
@@ -485,19 +505,17 @@ mod tests {
|
||||
sync::{mpsc, Arc},
|
||||
};
|
||||
|
||||
use arbitrary_int::u21;
|
||||
use models::ComponentId;
|
||||
use satrs::{
|
||||
mode::{ModeReply, ModeRequest},
|
||||
mode_tree::ModeParent,
|
||||
power::SwitchStateBinary,
|
||||
request::{GenericMessage, UniqueApidTargetId},
|
||||
request::GenericMessage,
|
||||
tmtc::PacketAsVec,
|
||||
ComponentId,
|
||||
};
|
||||
use satrs_example::ids::{acs::ASSEMBLY, Apid};
|
||||
use satrs_minisim::acs::lis3mdl::MgmLis3RawValues;
|
||||
|
||||
use crate::{eps::TestSwitchHelper, pus::hk::HkReply, requests::CompositeRequest};
|
||||
use crate::eps::TestSwitchHelper;
|
||||
|
||||
use super::*;
|
||||
|
||||
@@ -527,20 +545,19 @@ mod tests {
|
||||
pub mode_request_tx: mpsc::SyncSender<GenericMessage<ModeRequest>>,
|
||||
pub mode_reply_rx_to_pus: mpsc::Receiver<GenericMessage<ModeReply>>,
|
||||
pub mode_reply_rx_to_parent: mpsc::Receiver<GenericMessage<ModeReply>>,
|
||||
pub composite_request_tx: mpsc::Sender<GenericMessage<CompositeRequest>>,
|
||||
pub hk_reply_rx: mpsc::Receiver<GenericMessage<HkReply>>,
|
||||
pub tc_tx: mpsc::SyncSender<CcsdsTcPacketOwned>,
|
||||
pub tm_rx: mpsc::Receiver<PacketAsVec>,
|
||||
pub handler: MgmHandlerLis3Mdl<TestSpiInterface, TestSwitchHelper>,
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct MgmAssemblyMock(
|
||||
pub HashMap<ComponentId, mpsc::SyncSender<GenericMessage<ModeRequest>>>,
|
||||
pub HashMap<satrs::ComponentId, mpsc::SyncSender<GenericMessage<ModeRequest>>>,
|
||||
);
|
||||
|
||||
impl ModeNode for MgmAssemblyMock {
|
||||
fn id(&self) -> satrs::ComponentId {
|
||||
PUS_MODE.into()
|
||||
ComponentId::AcsMgmAssembly as u32
|
||||
}
|
||||
}
|
||||
|
||||
@@ -553,17 +570,18 @@ mod tests {
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct PusMock {
|
||||
pub request_sender_map: HashMap<ComponentId, mpsc::SyncSender<GenericMessage<ModeRequest>>>,
|
||||
pub struct GroundMock {
|
||||
pub request_sender_map:
|
||||
HashMap<satrs::ComponentId, mpsc::SyncSender<GenericMessage<ModeRequest>>>,
|
||||
}
|
||||
|
||||
impl ModeNode for PusMock {
|
||||
impl ModeNode for GroundMock {
|
||||
fn id(&self) -> satrs::ComponentId {
|
||||
PUS_MODE.into()
|
||||
ComponentId::Ground as u32
|
||||
}
|
||||
}
|
||||
|
||||
impl ModeParent for PusMock {
|
||||
impl ModeParent for GroundMock {
|
||||
type Sender = mpsc::SyncSender<GenericMessage<ModeRequest>>;
|
||||
|
||||
fn add_mode_child(&mut self, id: satrs::ComponentId, request_sender: Self::Sender) {
|
||||
@@ -574,36 +592,33 @@ mod tests {
|
||||
impl MgmTestbench {
|
||||
pub fn new() -> Self {
|
||||
let (request_tx, request_rx) = mpsc::sync_channel(5);
|
||||
let (reply_tx_to_pus, reply_rx_to_pus) = mpsc::sync_channel(5);
|
||||
let (reply_tx_to_ground, reply_rx_to_ground) = mpsc::sync_channel(5);
|
||||
let (reply_tx_to_parent, reply_rx_to_parent) = mpsc::sync_channel(5);
|
||||
let id = UniqueApidTargetId::new(Apid::Acs.raw_value(), u21::new(1));
|
||||
let mode_node = ModeRequestHandlerMpscBounded::new(id.into(), request_rx);
|
||||
let (composite_request_tx, composite_request_rx) = mpsc::channel();
|
||||
let mode_node =
|
||||
ModeRequestHandlerMpscBounded::new(ComponentId::Ground as u32, request_rx);
|
||||
let (tc_tx, tc_rx) = mpsc::sync_channel(10);
|
||||
let (hk_reply_tx, hk_reply_rx) = mpsc::sync_channel(10);
|
||||
let (tm_tx, tm_rx) = mpsc::sync_channel(10);
|
||||
let tm_sender = TmTcSender::Heap(tm_tx);
|
||||
let shared_mgm_set = Arc::default();
|
||||
let mut handler = MgmHandlerLis3Mdl::new(
|
||||
id,
|
||||
ComponentId::AcsMgm0,
|
||||
"TEST_MGM",
|
||||
mode_node,
|
||||
composite_request_rx,
|
||||
tc_rx,
|
||||
hk_reply_tx,
|
||||
TestSwitchHelper::default(),
|
||||
tm_sender,
|
||||
TestSpiInterface::default(),
|
||||
shared_mgm_set,
|
||||
);
|
||||
handler.add_mode_parent(PUS_MODE.into(), reply_tx_to_pus);
|
||||
handler.add_mode_parent(ASSEMBLY.into(), reply_tx_to_parent);
|
||||
handler.add_mode_parent(ComponentId::Ground as u32, reply_tx_to_ground);
|
||||
handler.add_mode_parent(ComponentId::AcsMgmAssembly as u32, reply_tx_to_parent);
|
||||
Self {
|
||||
mode_request_tx: request_tx,
|
||||
mode_reply_rx_to_pus: reply_rx_to_pus,
|
||||
mode_reply_rx_to_pus: reply_rx_to_ground,
|
||||
mode_reply_rx_to_parent: reply_rx_to_parent,
|
||||
composite_request_tx,
|
||||
handler,
|
||||
tm_rx,
|
||||
hk_reply_rx,
|
||||
tc_tx,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -633,7 +648,7 @@ mod tests {
|
||||
testbench
|
||||
.mode_request_tx
|
||||
.send(GenericMessage::new(
|
||||
MessageMetadata::new(0, PUS_MODE.id()),
|
||||
MessageMetadata::new(0, ComponentId::Ground as u32),
|
||||
ModeRequest::SetMode {
|
||||
mode_and_submode: ModeAndSubmode::new(DeviceMode::Normal as u32, 0),
|
||||
forced: false,
|
||||
@@ -694,7 +709,7 @@ mod tests {
|
||||
testbench
|
||||
.mode_request_tx
|
||||
.send(GenericMessage::new(
|
||||
MessageMetadata::new(0, PUS_MODE.id()),
|
||||
MessageMetadata::new(0, ComponentId::Ground as u32),
|
||||
ModeRequest::SetMode {
|
||||
mode_and_submode: ModeAndSubmode::new(DeviceMode::Normal as u32, 0),
|
||||
forced: false,
|
||||
@@ -718,4 +733,3 @@ mod tests {
|
||||
assert!(mgm_set.valid);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
@@ -235,7 +235,7 @@ impl<ComInterface: SerialInterface> PcduHandler<ComInterface> {
|
||||
OpCode::RegularOp => {
|
||||
self.stamp_helper.update_from_now();
|
||||
// Handle requests.
|
||||
self.handle_composite_requests();
|
||||
//self.handle_composite_requests();
|
||||
self.handle_mode_requests();
|
||||
self.handle_switch_requests();
|
||||
// Poll the switch states and/or telemetry regularly here.
|
||||
@@ -250,17 +250,6 @@ impl<ComInterface: SerialInterface> PcduHandler<ComInterface> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn handle_composite_requests(&mut self) {}
|
||||
|
||||
pub fn handle_hk_request(&mut self, _requestor_info: &MessageMetadata, hk_request: &HkRequest) {
|
||||
match hk_request.variant {
|
||||
HkRequestVariant::OneShot => todo!(),
|
||||
HkRequestVariant::EnablePeriodic => todo!(),
|
||||
HkRequestVariant::DisablePeriodic => todo!(),
|
||||
HkRequestVariant::ModifyCollectionInterval(_) => todo!(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn handle_periodic_commands(&self) {
|
||||
let pcdu_req = PcduRequest::RequestSwitchInfo;
|
||||
let pcdu_req_ser = serde_json::to_string(&pcdu_req).unwrap();
|
||||
|
||||
+73
-104
@@ -37,7 +37,10 @@ use tmtc::sender::TmTcSender;
|
||||
use tmtc::{tc_source::TcSourceTask, tm_sink::TmSink};
|
||||
|
||||
use crate::{
|
||||
control::Controller, interface::udp::UdpTmHandlerWithChannel, tmtc::tc_source::CcsdsDistributor,
|
||||
acs::mgm::{MgmHandlerLis3Mdl, SpiDummyInterface, SpiSimInterface, SpiSimInterfaceWrapper},
|
||||
control::Controller,
|
||||
interface::udp::UdpTmHandlerWithChannel,
|
||||
tmtc::tc_source::CcsdsDistributor,
|
||||
};
|
||||
|
||||
mod acs;
|
||||
@@ -59,13 +62,13 @@ fn main() {
|
||||
let (tm_server_tx, tm_server_rx) = mpsc::sync_channel(50);
|
||||
|
||||
let (sim_request_tx, sim_request_rx) = mpsc::channel();
|
||||
//let (mgm_0_sim_reply_tx, mgm_0_sim_reply_rx) = mpsc::channel();
|
||||
//let (mgm_1_sim_reply_tx, mgm_1_sim_reply_rx) = mpsc::channel();
|
||||
let (mgm_0_sim_reply_tx, mgm_0_sim_reply_rx) = mpsc::channel();
|
||||
let (mgm_1_sim_reply_tx, mgm_1_sim_reply_rx) = mpsc::channel();
|
||||
let (pcdu_sim_reply_tx, pcdu_sim_reply_rx) = mpsc::channel();
|
||||
let mut opt_sim_client = create_sim_client(sim_request_rx);
|
||||
|
||||
//let (mgm_0_handler_composite_tx, mgm_0_handler_composite_rx) = mpsc::sync_channel(10);
|
||||
//let (mgm_1_handler_composite_tx, mgm_1_handler_composite_rx) = mpsc::sync_channel(10);
|
||||
let (mgm_0_handler_tc_tx, mgm_0_handler_tc_rx) = mpsc::sync_channel(10);
|
||||
let (mgm_1_handler_tc_tx, mgm_1_handler_tc_rx) = mpsc::sync_channel(10);
|
||||
let (pcdu_handler_tc_tx, pcdu_handler_tc_rx) = mpsc::sync_channel(30);
|
||||
let (controller_tc_tx, controller_tc_rx) = mpsc::sync_channel(10);
|
||||
|
||||
@@ -73,51 +76,19 @@ fn main() {
|
||||
let (_mgm_1_handler_mode_tx, mgm_1_handler_mode_rx) = mpsc::sync_channel(5);
|
||||
let (pcdu_handler_mode_tx, pcdu_handler_mode_rx) = mpsc::sync_channel(5);
|
||||
|
||||
// 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(MGM0.id(), mgm_0_handler_composite_tx);
|
||||
request_map
|
||||
.composite_router_map
|
||||
.insert(MGM1.id(), mgm_1_handler_composite_tx);
|
||||
request_map
|
||||
.composite_router_map
|
||||
.insert(PCDU.id(), pcdu_handler_composite_tx);
|
||||
*/
|
||||
|
||||
// Create event handling components
|
||||
// These sender handles are used to send event requests, for example to enable or disable
|
||||
// certain events.
|
||||
//let (event_tx, event_rx) = mpsc::sync_channel(100);
|
||||
let (_event_request_tx, _event_request_rx) = mpsc::channel::<EventRequestWithToken>();
|
||||
|
||||
// The event task is the core handler to perform the event routing and TM handling as specified
|
||||
// in the sat-rs documentation.
|
||||
//let mut event_handler = EventHandler::new(tm_sink_tx.clone(), event_rx, event_request_rx);
|
||||
|
||||
//let (pus_test_tx, pus_test_rx) = mpsc::sync_channel(20);
|
||||
//let (pus_event_tx, pus_event_rx) = mpsc::sync_channel(10);
|
||||
//let (pus_sched_tx, pus_sched_rx) = mpsc::sync_channel(50);
|
||||
//let (pus_hk_tx, pus_hk_rx) = mpsc::sync_channel(50);
|
||||
//let (pus_action_tx, pus_action_rx) = mpsc::sync_channel(50);
|
||||
//let (pus_mode_tx, pus_mode_rx) = mpsc::sync_channel(50);
|
||||
|
||||
//let (_pus_action_reply_tx, pus_action_reply_rx) = mpsc::channel();
|
||||
//let (pus_hk_reply_tx, pus_hk_reply_rx) = mpsc::sync_channel(50);
|
||||
//let (pus_mode_reply_tx, pus_mode_reply_rx) = mpsc::sync_channel(30);
|
||||
|
||||
let mut controller = Controller::new(controller_tc_rx, tm_sink_tx.clone());
|
||||
|
||||
let ccsds_distributor = CcsdsDistributor::default();
|
||||
let mut tmtc_task = TcSourceTask::new(
|
||||
tc_source_rx,
|
||||
ccsds_distributor,
|
||||
//PusTcDistributor::new(tm_sender.clone(), pus_router),
|
||||
);
|
||||
let mut tmtc_task = TcSourceTask::new(tc_source_rx, ccsds_distributor);
|
||||
tmtc_task.add_target(ComponentId::EpsPcdu, pcdu_handler_tc_tx);
|
||||
tmtc_task.add_target(ComponentId::Controller, controller_tc_tx);
|
||||
tmtc_task.add_target(ComponentId::AcsMgm0, mgm_0_handler_tc_tx);
|
||||
tmtc_task.add_target(ComponentId::AcsMgm1, mgm_1_handler_tc_tx);
|
||||
|
||||
let tc_sender = TmTcSender::Normal(tc_source_tx.clone());
|
||||
let udp_tm_handler = UdpTmHandlerWithChannel {
|
||||
@@ -157,72 +128,70 @@ fn main() {
|
||||
|
||||
let shared_switch_set = Arc::new(Mutex::default());
|
||||
let (switch_request_tx, switch_request_rx) = mpsc::sync_channel(20);
|
||||
let _switch_helper = PowerSwitchHelper::new(switch_request_tx, shared_switch_set.clone());
|
||||
let switch_helper = PowerSwitchHelper::new(switch_request_tx, shared_switch_set.clone());
|
||||
|
||||
//let shared_mgm_0_set = Arc::default();
|
||||
//let shared_mgm_1_set = Arc::default();
|
||||
let _mgm_0_mode_node =
|
||||
let shared_mgm_0_set = Arc::default();
|
||||
let shared_mgm_1_set = Arc::default();
|
||||
let mgm_0_mode_node =
|
||||
ModeRequestHandlerMpscBounded::new(ComponentId::AcsMgm0 as u32, mgm_0_handler_mode_rx);
|
||||
let _mgm_1_mode_node =
|
||||
let mgm_1_mode_node =
|
||||
ModeRequestHandlerMpscBounded::new(ComponentId::AcsMgm1 as u32, mgm_1_handler_mode_rx);
|
||||
let (mgm_0_spi_interface, mgm_1_spi_interface) =
|
||||
if let Some(sim_client) = opt_sim_client.as_mut() {
|
||||
sim_client
|
||||
.add_reply_recipient(satrs_minisim::SimComponent::Mgm0Lis3Mdl, mgm_0_sim_reply_tx);
|
||||
sim_client
|
||||
.add_reply_recipient(satrs_minisim::SimComponent::Mgm1Lis3Mdl, mgm_1_sim_reply_tx);
|
||||
(
|
||||
SpiSimInterfaceWrapper::Sim(SpiSimInterface {
|
||||
sim_request_tx: sim_request_tx.clone(),
|
||||
sim_reply_rx: mgm_0_sim_reply_rx,
|
||||
}),
|
||||
SpiSimInterfaceWrapper::Sim(SpiSimInterface {
|
||||
sim_request_tx: sim_request_tx.clone(),
|
||||
sim_reply_rx: mgm_1_sim_reply_rx,
|
||||
}),
|
||||
)
|
||||
} else {
|
||||
(
|
||||
SpiSimInterfaceWrapper::Dummy(SpiDummyInterface::default()),
|
||||
SpiSimInterfaceWrapper::Dummy(SpiDummyInterface::default()),
|
||||
)
|
||||
};
|
||||
let mut mgm_0_handler = MgmHandlerLis3Mdl::new(
|
||||
ComponentId::AcsMgm0,
|
||||
"MGM_0",
|
||||
mgm_0_mode_node,
|
||||
mgm_0_handler_tc_rx,
|
||||
tm_sink_tx.clone(),
|
||||
switch_helper.clone(),
|
||||
mgm_0_spi_interface,
|
||||
shared_mgm_0_set,
|
||||
);
|
||||
let mut mgm_1_handler = MgmHandlerLis3Mdl::new(
|
||||
ComponentId::AcsMgm1,
|
||||
"MGM_1",
|
||||
mgm_1_mode_node,
|
||||
mgm_1_handler_tc_rx,
|
||||
tm_sink_tx.clone(),
|
||||
switch_helper.clone(),
|
||||
mgm_1_spi_interface,
|
||||
shared_mgm_1_set,
|
||||
);
|
||||
// Connect PUS service to device handlers.
|
||||
/*
|
||||
let (mgm_0_spi_interface, mgm_1_spi_interface) =
|
||||
if let Some(sim_client) = opt_sim_client.as_mut() {
|
||||
sim_client
|
||||
.add_reply_recipient(satrs_minisim::SimComponent::Mgm0Lis3Mdl, mgm_0_sim_reply_tx);
|
||||
sim_client
|
||||
.add_reply_recipient(satrs_minisim::SimComponent::Mgm1Lis3Mdl, mgm_1_sim_reply_tx);
|
||||
(
|
||||
SpiSimInterfaceWrapper::Sim(SpiSimInterface {
|
||||
sim_request_tx: sim_request_tx.clone(),
|
||||
sim_reply_rx: mgm_0_sim_reply_rx,
|
||||
}),
|
||||
SpiSimInterfaceWrapper::Sim(SpiSimInterface {
|
||||
sim_request_tx: sim_request_tx.clone(),
|
||||
sim_reply_rx: mgm_1_sim_reply_rx,
|
||||
}),
|
||||
)
|
||||
} else {
|
||||
(
|
||||
SpiSimInterfaceWrapper::Dummy(SpiDummyInterface::default()),
|
||||
SpiSimInterfaceWrapper::Dummy(SpiDummyInterface::default()),
|
||||
)
|
||||
};
|
||||
let mut mgm_0_handler = MgmHandlerLis3Mdl::new(
|
||||
MGM0,
|
||||
"MGM_0",
|
||||
mgm_0_mode_node,
|
||||
mgm_0_handler_composite_rx,
|
||||
pus_hk_reply_tx.clone(),
|
||||
switch_helper.clone(),
|
||||
tm_sender.clone(),
|
||||
mgm_0_spi_interface,
|
||||
shared_mgm_0_set,
|
||||
);
|
||||
let mut mgm_1_handler = MgmHandlerLis3Mdl::new(
|
||||
MGM1,
|
||||
"MGM_1",
|
||||
mgm_1_mode_node,
|
||||
mgm_1_handler_composite_rx,
|
||||
pus_hk_reply_tx.clone(),
|
||||
switch_helper.clone(),
|
||||
tm_sender.clone(),
|
||||
mgm_1_spi_interface,
|
||||
shared_mgm_1_set,
|
||||
);
|
||||
// Connect PUS service to device handlers.
|
||||
connect_mode_nodes(
|
||||
&mut pus_stack.mode_srv,
|
||||
mgm_0_handler_mode_tx,
|
||||
&mut mgm_0_handler,
|
||||
pus_mode_reply_tx.clone(),
|
||||
);
|
||||
connect_mode_nodes(
|
||||
&mut pus_stack.mode_srv,
|
||||
mgm_1_handler_mode_tx,
|
||||
&mut mgm_1_handler,
|
||||
pus_mode_reply_tx.clone(),
|
||||
);
|
||||
connect_mode_nodes(
|
||||
&mut pus_stack.mode_srv,
|
||||
mgm_0_handler_mode_tx,
|
||||
&mut mgm_0_handler,
|
||||
pus_mode_reply_tx.clone(),
|
||||
);
|
||||
connect_mode_nodes(
|
||||
&mut pus_stack.mode_srv,
|
||||
mgm_1_handler_mode_tx,
|
||||
&mut mgm_1_handler,
|
||||
pus_mode_reply_tx.clone(),
|
||||
);
|
||||
*/
|
||||
|
||||
let pcdu_serial_interface = if let Some(sim_client) = opt_sim_client.as_mut() {
|
||||
@@ -315,8 +284,8 @@ fn main() {
|
||||
let jh_aocs = thread::Builder::new()
|
||||
.name("AOCS".to_string())
|
||||
.spawn(move || loop {
|
||||
//mgm_0_handler.periodic_operation();
|
||||
//mgm_1_handler.periodic_operation();
|
||||
mgm_0_handler.periodic_operation();
|
||||
mgm_1_handler.periodic_operation();
|
||||
thread::sleep(Duration::from_millis(FREQ_MS_AOCS));
|
||||
})
|
||||
.unwrap();
|
||||
|
||||
Reference in New Issue
Block a user