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::sync::mpsc::Sender;
|
||||||
use std::thread::Thread;
|
use std::thread::Thread;
|
||||||
|
|
||||||
use crate::device_handler::{DeviceProperties, DeviceState, DeviceType};
|
|
||||||
use num_derive::{FromPrimitive, ToPrimitive};
|
pub use num_derive::{FromPrimitive, ToPrimitive};
|
||||||
use num_traits::{FromPrimitive, ToPrimitive};
|
pub use num_traits::{FromPrimitive, ToPrimitive};
|
||||||
use strum::IntoEnumIterator; // 0.17.1
|
pub use strum::IntoEnumIterator; // 0.17.1
|
||||||
use strum_macros::EnumIter; // 0.17.1
|
pub use strum_macros::EnumIter; // 0.17.1
|
||||||
|
|
||||||
#[derive(Debug, EnumIter, Eq, Hash, PartialEq, Copy, Clone, FromPrimitive)]
|
#[derive(Debug, EnumIter, Eq, Hash, PartialEq, Copy, Clone, FromPrimitive)]
|
||||||
pub enum ThreadId {
|
pub enum ThreadId {
|
||||||
@ -208,6 +208,7 @@ pub fn load_package_ids() -> HashMap<PackageId, SenderReceiverThread> {
|
|||||||
return package_map;
|
return package_map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
pub fn load_device_ids() {
|
pub fn load_device_ids() {
|
||||||
let mut package_map: HashMap<DeviceId, DeviceProperties> = HashMap::new();
|
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
|
//TODO: change ids from u32 to embeddedcan ids
|
||||||
pub fn package_id_to_value(packageid: &PackageId) -> u32 {
|
pub fn package_id_to_value(packageid: &PackageId) -> u32 {
|
||||||
*packageid as u32
|
*packageid as u32
|
||||||
|
@ -1,7 +1,14 @@
|
|||||||
|
use std::collections::HashMap;
|
||||||
|
use log::info;
|
||||||
use crate::can_ids::DeviceId;
|
use crate::can_ids::DeviceId;
|
||||||
use socketcan::{errors, frame, socket, CanFrame, Socket};
|
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 {
|
pub enum DeviceState {
|
||||||
On,
|
On,
|
||||||
Off,
|
Off,
|
||||||
@ -9,29 +16,66 @@ pub enum DeviceState {
|
|||||||
Unknown,
|
Unknown,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone)]
|
#[derive(Clone, Debug)]
|
||||||
pub enum DeviceType {
|
pub struct DeviceHandler {
|
||||||
MGM,
|
device_state_map: HashMap<DeviceId, DeviceState>,
|
||||||
MGT,
|
|
||||||
RWL,
|
|
||||||
STR,
|
|
||||||
CRS,
|
|
||||||
OBC,
|
|
||||||
PCDU,
|
|
||||||
CAM,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone)]
|
impl DeviceHandler {
|
||||||
pub struct DeviceProperties {
|
pub fn new() -> DeviceHandler {
|
||||||
device_type: DeviceType,
|
let mut device_state_map:HashMap<DeviceId, DeviceState> = HashMap::new();
|
||||||
device_state: DeviceState,
|
|
||||||
|
for id in DeviceId::iter() {
|
||||||
|
device_state_map.insert(id, DeviceState::Unknown);
|
||||||
|
}
|
||||||
|
DeviceHandler{ device_state_map }
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DeviceProperties {
|
pub fn power_up_seq(&self) {
|
||||||
pub fn new(device_type: DeviceType, device_state: DeviceState) -> DeviceProperties {
|
for id in DeviceId::iter() {
|
||||||
return DeviceProperties {
|
let power_on_success = self.power_on(id);
|
||||||
device_type,
|
match power_on_success{
|
||||||
device_state,
|
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::Disable(_) => {}
|
||||||
HkRequest::ModifyCollectionInterval(_, _) => {}
|
HkRequest::ModifyCollectionInterval(_, _) => {}
|
||||||
},
|
},
|
||||||
|
_ => {}
|
||||||
}
|
}
|
||||||
let started_token = reporter_aocs
|
let started_token = reporter_aocs
|
||||||
.start_success(request.1, ×tamp)
|
.start_success(request.1, ×tamp)
|
||||||
|
@ -6,7 +6,7 @@ use satrs_mib::resultcode;
|
|||||||
#[derive(Copy, Clone, Eq, PartialEq, Debug)]
|
#[derive(Copy, Clone, Eq, PartialEq, Debug)]
|
||||||
pub enum RequestTargetId {
|
pub enum RequestTargetId {
|
||||||
AcsSubsystem = 1,
|
AcsSubsystem = 1,
|
||||||
CanTask = 2,
|
PldSubsystem = 2,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
54
src/main.rs
54
src/main.rs
@ -9,6 +9,7 @@ mod pus;
|
|||||||
mod requests;
|
mod requests;
|
||||||
mod tmtc;
|
mod tmtc;
|
||||||
mod aocs;
|
mod aocs;
|
||||||
|
mod cam;
|
||||||
|
|
||||||
use crate::hk::{AcsHkIds, HkRequest};
|
use crate::hk::{AcsHkIds, HkRequest};
|
||||||
use crate::requests::{Request, RequestWithToken};
|
use crate::requests::{Request, RequestWithToken};
|
||||||
@ -50,6 +51,7 @@ use std::sync::mpsc::{channel, TryRecvError};
|
|||||||
use std::sync::{mpsc, Arc, RwLock};
|
use std::sync::{mpsc, Arc, RwLock};
|
||||||
use std::thread;
|
use std::thread;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
use crate::cam::CameraRequest;
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
struct EventTmSender {
|
struct EventTmSender {
|
||||||
@ -142,8 +144,9 @@ fn main() {
|
|||||||
|
|
||||||
let mut request_map = HashMap::new();
|
let mut request_map = HashMap::new();
|
||||||
let (acs_thread_tx, acs_thread_rx) = channel::<RequestWithToken>();
|
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::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);
|
//request_map.insert(RequestTargetId::CanTask as u32, can_thread_tx);
|
||||||
|
|
||||||
let tc_source = PusTcSource {
|
let tc_source = PusTcSource {
|
||||||
@ -196,7 +199,8 @@ fn main() {
|
|||||||
let socket0 = can::CanRxHandler::new_socket("can0", can_senders, package_ids_rx).unwrap();
|
let socket0 = can::CanRxHandler::new_socket("can0", can_senders, package_ids_rx).unwrap();
|
||||||
|
|
||||||
info!("Starting TMTC task");
|
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);
|
core_tmtc_task(core_args, tc_args, tm_args);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -209,16 +213,21 @@ fn main() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/*
|
||||||
let allowed_ids_range = 101..110;
|
let allowed_ids_range = 101..110;
|
||||||
let mut allowed_ids_aocs = Vec::new();
|
let mut allowed_ids_aocs = Vec::new();
|
||||||
for id in allowed_ids_range {
|
for id in allowed_ids_range {
|
||||||
allowed_ids_aocs.push(Id::Standard(StandardId::new(id).unwrap()));
|
allowed_ids_aocs.push(Id::Standard(StandardId::new(id).unwrap()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
let package_map_aocs_tx = load_package_ids();
|
let package_map_aocs_tx = load_package_ids();
|
||||||
let aocs_tm_funnel_tx = tm_funnel_tx.clone();
|
let aocs_tm_funnel_tx = tm_funnel_tx.clone();
|
||||||
let mut aocs_tm_store = tm_store.clone();
|
let mut aocs_tm_store = tm_store.clone();
|
||||||
|
|
||||||
|
|
||||||
|
// AOCS Thread
|
||||||
let socket1 =
|
let socket1 =
|
||||||
can::CanTxHandler::new_socket("can0", ThreadId::AOCSThread, package_map_aocs_tx).unwrap();
|
can::CanTxHandler::new_socket("can0", ThreadId::AOCSThread, package_map_aocs_tx).unwrap();
|
||||||
info!("Starting AOCS receiving thread");
|
info!("Starting AOCS receiving thread");
|
||||||
@ -299,6 +308,7 @@ fn main() {
|
|||||||
HkRequest::ModifyCollectionInterval(_, _) => {}
|
HkRequest::ModifyCollectionInterval(_, _) => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(_) => {}
|
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");
|
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 {
|
let tm_funnel = TmFunnel {
|
||||||
tm_server_tx,
|
tm_server_tx,
|
||||||
tm_funnel_rx,
|
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()
|
jh1.unwrap()
|
||||||
.join()
|
.join()
|
||||||
.expect("Joining CAN Bus Listening thread failed");
|
.expect("Joining CAN Bus Listening thread failed");
|
||||||
jh2.unwrap().join().expect("Joing AOCS 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");
|
jh1.join().expect("Joining TM Funnel thread failed");
|
||||||
|
@ -79,6 +79,8 @@ impl PusServiceProvider for PusReceiver {
|
|||||||
self.handle_event_request(pus_tc, accepted_token);
|
self.handle_event_request(pus_tc, accepted_token);
|
||||||
} else if service == 3 {
|
} else if service == 3 {
|
||||||
self.handle_hk_request(pus_tc, accepted_token);
|
self.handle_hk_request(pus_tc, accepted_token);
|
||||||
|
} else if service == 8 {
|
||||||
|
self.handle_function_request(pus_tc, accepted_token);
|
||||||
} else {
|
} else {
|
||||||
self.update_time_stamp();
|
self.update_time_stamp();
|
||||||
self.verif_reporter
|
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 crate::hk::HkRequest;
|
||||||
use satrs_core::pus::verification::{TcStateAccepted, VerificationToken};
|
use satrs_core::pus::verification::{TcStateAccepted, VerificationToken};
|
||||||
|
use crate::cam::CameraRequest;
|
||||||
|
|
||||||
#[derive(Copy, Clone, Eq, PartialEq, Debug)]
|
#[derive(Copy, Clone, Eq, PartialEq, Debug)]
|
||||||
pub enum Request {
|
pub enum Request {
|
||||||
HkRequest(HkRequest),
|
HkRequest(HkRequest),
|
||||||
|
CameraRequest(CameraRequest),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, Eq, PartialEq, Debug)]
|
#[derive(Copy, Clone, Eq, PartialEq, Debug)]
|
||||||
|
Loading…
Reference in New Issue
Block a user