Skip to content

Commit

Permalink
compiles again
Browse files Browse the repository at this point in the history
  • Loading branch information
robamu committed May 18, 2024
1 parent cb0a65c commit 8e89c8d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 23 deletions.
21 changes: 6 additions & 15 deletions satrs-example/src/eps/pcdu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@ use derive_new::new;
use satrs::{
hk::{HkRequest, HkRequestVariant},
mode::{ModeAndSubmode, ModeError, ModeProvider, ModeReply, ModeRequestHandler},
power::{SwitchState, SwitchStateBinary},
pus::EcssTmSender,
queue::{GenericSendError, GenericTargetedMessagingError},
request::{GenericMessage, MessageMetadata, UniqueApidTargetId},
};
use satrs_example::{config::components::PUS_MODE_SERVICE, DeviceMode, TimestampHelper};
use satrs_minisim::{
eps::{PcduReply, PcduRequest, SwitchMap, SwitchMapWrapper},
eps::{PcduReply, PcduRequest, SwitchMap, SwitchMapBinaryWrapper},
SerializableSimMsgPayload, SimReply, SimRequest,
};

Expand Down Expand Up @@ -76,7 +75,7 @@ impl SerialInterface for SerialInterfaceToSim {
#[derive(Default)]
pub struct SerialInterfaceDummy {
// Need interior mutability here for both fields.
pub switch_map: RefCell<SwitchMapWrapper>,
pub switch_map: RefCell<SwitchMapBinaryWrapper>,
pub reply_deque: RefCell<VecDeque<SimReply>>,
}

Expand All @@ -92,20 +91,10 @@ impl SerialInterface for SerialInterfaceDummy {
PcduRequest::SwitchDevice { switch, state } => {
match switch_map_mut.entry(switch) {
std::collections::hash_map::Entry::Occupied(mut val) => {
match state {
SwitchStateBinary::Off => {
*val.get_mut() = SwitchState::Off;
}
SwitchStateBinary::On => {
*val.get_mut() = SwitchState::On;
}
};
*val.get_mut() = state;
}
std::collections::hash_map::Entry::Vacant(vacant) => {
match state {
SwitchStateBinary::Off => vacant.insert(SwitchState::Off),
SwitchStateBinary::On => vacant.insert(SwitchState::On),
};
vacant.insert(state);
}
};
}
Expand Down Expand Up @@ -205,6 +194,8 @@ impl<ComInterface: SerialInterface, TmSender: EcssTmSender> PcduHandler<ComInter
// Handle requests.
self.handle_composite_requests();
self.handle_mode_requests();
// Poll the switch states and telemetry regularly here.
if self.mode() == DeviceMode::Normal as u32 {}
}
OpCode::PollAndRecvReplies => {
self.poll_and_handle_replies();
Expand Down
15 changes: 7 additions & 8 deletions satrs-minisim/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,15 +204,14 @@ pub mod eps {
}
Self(switch_map)
}
}

impl From<SwitchMapBinaryWrapper> for SwitchMapWrapper {
fn from(value: SwitchMapBinaryWrapper) -> Self {
value
.0
.iter()
.map(|(key, value)| (*key, SwitchState::from(value.into())))
.collect()
pub fn from_binary_switch_map_ref(switch_map: &SwitchMapBinary) -> Self {
Self(
switch_map
.iter()
.map(|(key, value)| (*key, SwitchState::from(*value)))
.collect(),
)
}
}

Expand Down

0 comments on commit 8e89c8d

Please sign in to comment.