added some stuff
This commit is contained in:
parent
e7600891ec
commit
1e3aa40a87
12
src/cam.rs
Normal file
12
src/cam.rs
Normal file
@ -0,0 +1,12 @@
|
||||
use satrs_core::tmtc::AddressableId;
|
||||
|
||||
pub type CollectionIntervalFactor = u32;
|
||||
|
||||
//#[derive(Debug, Copy, Clone, PartialEq, Eq)]
|
||||
|
||||
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
|
||||
pub enum CameraRequest {
|
||||
OneShot(AddressableId),
|
||||
OneShotWithTimeStamp(AddressableId),
|
||||
}
|
@ -5,11 +5,11 @@ use std::fs;
|
||||
use std::sync::mpsc::Sender;
|
||||
use std::thread::Thread;
|
||||
|
||||
use crate::device_handler::{DeviceProperties, DeviceState, DeviceType};
|
||||
use num_derive::{FromPrimitive, ToPrimitive};
|
||||
use num_traits::{FromPrimitive, ToPrimitive};
|
||||
use strum::IntoEnumIterator; // 0.17.1
|
||||
use strum_macros::EnumIter; // 0.17.1
|
||||
|
||||
pub use num_derive::{FromPrimitive, ToPrimitive};
|
||||
pub use num_traits::{FromPrimitive, ToPrimitive};
|
||||
pub use strum::IntoEnumIterator; // 0.17.1
|
||||
pub use strum_macros::EnumIter; // 0.17.1
|
||||
|
||||
#[derive(Debug, EnumIter, Eq, Hash, PartialEq, Copy, Clone, FromPrimitive)]
|
||||
pub enum ThreadId {
|
||||
@ -208,6 +208,7 @@ pub fn load_package_ids() -> HashMap<PackageId, SenderReceiverThread> {
|
||||
return package_map;
|
||||
}
|
||||
|
||||
/*
|
||||
pub fn load_device_ids() {
|
||||
let mut package_map: HashMap<DeviceId, DeviceProperties> = HashMap::new();
|
||||
|
||||
@ -238,6 +239,8 @@ pub fn load_device_ids() {
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
//TODO: change ids from u32 to embeddedcan ids
|
||||
pub fn package_id_to_value(packageid: &PackageId) -> u32 {
|
||||
*packageid as u32
|
||||
|
@ -1,7 +1,14 @@
|
||||
use std::collections::HashMap;
|
||||
use log::info;
|
||||
use crate::can_ids::DeviceId;
|
||||
use socketcan::{errors, frame, socket, CanFrame, Socket};
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
pub use num_derive::{FromPrimitive, ToPrimitive};
|
||||
pub use num_traits::{FromPrimitive, ToPrimitive};
|
||||
pub use strum::IntoEnumIterator; // 0.17.1
|
||||
pub use strum_macros::EnumIter; // 0.17.1
|
||||
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
pub enum DeviceState {
|
||||
On,
|
||||
Off,
|
||||
@ -9,29 +16,66 @@ pub enum DeviceState {
|
||||
Unknown,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
pub enum DeviceType {
|
||||
MGM,
|
||||
MGT,
|
||||
RWL,
|
||||
STR,
|
||||
CRS,
|
||||
OBC,
|
||||
PCDU,
|
||||
CAM,
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct DeviceHandler {
|
||||
device_state_map: HashMap<DeviceId, DeviceState>,
|
||||
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
pub struct DeviceProperties {
|
||||
device_type: DeviceType,
|
||||
device_state: DeviceState,
|
||||
}
|
||||
impl DeviceHandler {
|
||||
pub fn new() -> DeviceHandler {
|
||||
let mut device_state_map:HashMap<DeviceId, DeviceState> = HashMap::new();
|
||||
|
||||
impl DeviceProperties {
|
||||
pub fn new(device_type: DeviceType, device_state: DeviceState) -> DeviceProperties {
|
||||
return DeviceProperties {
|
||||
device_type,
|
||||
device_state,
|
||||
};
|
||||
for id in DeviceId::iter() {
|
||||
device_state_map.insert(id, DeviceState::Unknown);
|
||||
}
|
||||
DeviceHandler{ device_state_map }
|
||||
}
|
||||
|
||||
pub fn power_up_seq(&self) {
|
||||
for id in DeviceId::iter() {
|
||||
let power_on_success = self.power_on(id);
|
||||
match power_on_success{
|
||||
Ok(_) => {info!("{:?} powered up successfully.", id)}
|
||||
Err(_) => {info!("{:?} failed to power up.", id)}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn power_on(&self, id: DeviceId) -> Result<(),()> {
|
||||
match id {
|
||||
DeviceId::OBC => {}
|
||||
DeviceId::PCDU => {}
|
||||
DeviceId::MGM1 => {}
|
||||
DeviceId::MGM2 => {}
|
||||
DeviceId::MGM3 => {}
|
||||
DeviceId::MGM4 => {}
|
||||
DeviceId::SunSensor1 => {}
|
||||
DeviceId::SunSensor2 => {}
|
||||
DeviceId::SunSensor3 => {}
|
||||
DeviceId::SunSensor4 => {}
|
||||
DeviceId::SunSensor5 => {}
|
||||
DeviceId::SunSensor6 => {}
|
||||
DeviceId::StarTracker => {}
|
||||
DeviceId::MGT1 => {}
|
||||
DeviceId::MGT2 => {}
|
||||
DeviceId::MGT3 => {}
|
||||
DeviceId::MGT4 => {}
|
||||
DeviceId::RWL1 => {}
|
||||
DeviceId::RWL2 => {}
|
||||
DeviceId::RWL3 => {}
|
||||
DeviceId::RWL4 => {}
|
||||
DeviceId::Camera => {}
|
||||
DeviceId::All => {}
|
||||
}
|
||||
|
||||
self.get_power_state(id)
|
||||
|
||||
}
|
||||
|
||||
pub fn get_power_state(&self, id: DeviceId) -> Result<(),()> {
|
||||
let power_state:DeviceState = DeviceState::Unknown;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -213,6 +213,7 @@ fn example_main() {
|
||||
HkRequest::Disable(_) => {}
|
||||
HkRequest::ModifyCollectionInterval(_, _) => {}
|
||||
},
|
||||
_ => {}
|
||||
}
|
||||
let started_token = reporter_aocs
|
||||
.start_success(request.1, ×tamp)
|
||||
|
@ -6,7 +6,7 @@ use satrs_mib::resultcode;
|
||||
#[derive(Copy, Clone, Eq, PartialEq, Debug)]
|
||||
pub enum RequestTargetId {
|
||||
AcsSubsystem = 1,
|
||||
CanTask = 2,
|
||||
PldSubsystem = 2,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
|
54
src/main.rs
54
src/main.rs
@ -9,6 +9,7 @@ mod pus;
|
||||
mod requests;
|
||||
mod tmtc;
|
||||
mod aocs;
|
||||
mod cam;
|
||||
|
||||
use crate::hk::{AcsHkIds, HkRequest};
|
||||
use crate::requests::{Request, RequestWithToken};
|
||||
@ -50,6 +51,7 @@ use std::sync::mpsc::{channel, TryRecvError};
|
||||
use std::sync::{mpsc, Arc, RwLock};
|
||||
use std::thread;
|
||||
use std::time::Duration;
|
||||
use crate::cam::CameraRequest;
|
||||
|
||||
#[derive(Clone)]
|
||||
struct EventTmSender {
|
||||
@ -142,8 +144,9 @@ fn main() {
|
||||
|
||||
let mut request_map = HashMap::new();
|
||||
let (acs_thread_tx, acs_thread_rx) = channel::<RequestWithToken>();
|
||||
let (can_thread_tx, can_thread_rx) = channel::<RequestWithToken>();
|
||||
let (pld_thread_tx, pld_thread_rx) = channel::<RequestWithToken>();
|
||||
request_map.insert(RequestTargetId::AcsSubsystem as u32, acs_thread_tx);
|
||||
request_map.insert(RequestTargetId::PldSubsystem as u32, pld_thread_tx);
|
||||
//request_map.insert(RequestTargetId::CanTask as u32, can_thread_tx);
|
||||
|
||||
let tc_source = PusTcSource {
|
||||
@ -196,7 +199,8 @@ fn main() {
|
||||
let socket0 = can::CanRxHandler::new_socket("can0", can_senders, package_ids_rx).unwrap();
|
||||
|
||||
info!("Starting TMTC task");
|
||||
let jh0 = thread::spawn(move || {
|
||||
let builder0 = thread::Builder::new().name("TMTCThread".into());
|
||||
let jh0 = builder0.spawn(move || {
|
||||
core_tmtc_task(core_args, tc_args, tm_args);
|
||||
});
|
||||
|
||||
@ -209,16 +213,21 @@ fn main() {
|
||||
}
|
||||
});
|
||||
|
||||
/*
|
||||
let allowed_ids_range = 101..110;
|
||||
let mut allowed_ids_aocs = Vec::new();
|
||||
for id in allowed_ids_range {
|
||||
allowed_ids_aocs.push(Id::Standard(StandardId::new(id).unwrap()));
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
let package_map_aocs_tx = load_package_ids();
|
||||
let aocs_tm_funnel_tx = tm_funnel_tx.clone();
|
||||
let mut aocs_tm_store = tm_store.clone();
|
||||
|
||||
|
||||
// AOCS Thread
|
||||
let socket1 =
|
||||
can::CanTxHandler::new_socket("can0", ThreadId::AOCSThread, package_map_aocs_tx).unwrap();
|
||||
info!("Starting AOCS receiving thread");
|
||||
@ -299,6 +308,7 @@ fn main() {
|
||||
HkRequest::ModifyCollectionInterval(_, _) => {}
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
Err(_) => {}
|
||||
@ -306,8 +316,41 @@ fn main() {
|
||||
}
|
||||
});
|
||||
|
||||
let package_map_pld_tx = load_package_ids();
|
||||
let pld_tm_funnel_tx = tm_funnel_tx.clone();
|
||||
let mut pld_tm_store = tm_store.clone();
|
||||
|
||||
let PLDCanSocket =
|
||||
can::CanTxHandler::new_socket("can0", ThreadId::PLDThread, package_map_pld_tx).unwrap();
|
||||
println!("Starting Payload Handling task");
|
||||
let builder3 = thread::Builder::new().name("PLDThread".into());
|
||||
let jh3 = builder3.spawn(move || {
|
||||
loop {
|
||||
match pld_thread_rx.try_recv() {
|
||||
Ok(request_with_token) => {
|
||||
match request_with_token.0 {
|
||||
Request::CameraRequest(cam_req) => {
|
||||
match cam_req {
|
||||
CameraRequest::OneShot(id) => {
|
||||
|
||||
}
|
||||
CameraRequest::OneShotWithTimeStamp(id) => {}
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
Err(_) => {}
|
||||
}
|
||||
//let addr = pld_tm_store.add_pus_tm(&hk_tm);
|
||||
//pld_tm_funnel_tx.send(a).expect("sending failed");
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
println!("Starting TM funnel task");
|
||||
let jh3 = thread::spawn(move || {
|
||||
let builder4 = thread::Builder::new().name("TMFunnelThread".into());
|
||||
let jh4 = builder4.spawn(move || {
|
||||
let tm_funnel = TmFunnel {
|
||||
tm_server_tx,
|
||||
tm_funnel_rx,
|
||||
@ -322,12 +365,13 @@ fn main() {
|
||||
}
|
||||
});
|
||||
|
||||
jh0.join().expect("Joining UDP TMTC server thread failed");
|
||||
jh0.unwrap().join().expect("Joining UDP TMTC server thread failed");
|
||||
jh1.unwrap()
|
||||
.join()
|
||||
.expect("Joining CAN Bus Listening thread failed");
|
||||
jh2.unwrap().join().expect("Joing AOCS thread failed");
|
||||
jh3.join().expect("Joing AOCS thread failed");
|
||||
jh3.unwrap().join().expect("Joing AOCS thread failed");
|
||||
jh4.unwrap().join().expect("Joing AOCS thread failed");
|
||||
|
||||
/*
|
||||
jh1.join().expect("Joining TM Funnel thread failed");
|
||||
|
@ -79,6 +79,8 @@ impl PusServiceProvider for PusReceiver {
|
||||
self.handle_event_request(pus_tc, accepted_token);
|
||||
} else if service == 3 {
|
||||
self.handle_hk_request(pus_tc, accepted_token);
|
||||
} else if service == 8 {
|
||||
self.handle_function_request(pus_tc, accepted_token);
|
||||
} else {
|
||||
self.update_time_stamp();
|
||||
self.verif_reporter
|
||||
@ -270,4 +272,8 @@ impl PusReceiver {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn handle_function_request(&mut self, pus_tc: &PusTc, token: VerificationToken<TcStateAccepted>) {
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,11 @@
|
||||
use crate::hk::HkRequest;
|
||||
use satrs_core::pus::verification::{TcStateAccepted, VerificationToken};
|
||||
use crate::cam::CameraRequest;
|
||||
|
||||
#[derive(Copy, Clone, Eq, PartialEq, Debug)]
|
||||
pub enum Request {
|
||||
HkRequest(HkRequest),
|
||||
CameraRequest(CameraRequest),
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Eq, PartialEq, Debug)]
|
||||
|
Loading…
Reference in New Issue
Block a user