this should be good for now
This commit is contained in:
parent
1e867a51f5
commit
88d4384beb
42
Cargo.lock
generated
42
Cargo.lock
generated
@ -360,7 +360,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.59",
|
"syn 2.0.60",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -834,21 +834,21 @@ dependencies = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
<<<<<<< HEAD
|
|
||||||
name = "slab"
|
|
||||||
version = "0.4.9"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67"
|
|
||||||
dependencies = [
|
|
||||||
"autocfg",
|
|
||||||
=======
|
|
||||||
name = "serde_spanned"
|
name = "serde_spanned"
|
||||||
version = "0.6.5"
|
version = "0.6.5"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "eb3622f419d1296904700073ea6cc23ad690adbd66f13ea683df73298736f0c1"
|
checksum = "eb3622f419d1296904700073ea6cc23ad690adbd66f13ea683df73298736f0c1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"serde",
|
"serde",
|
||||||
>>>>>>> main
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "slab"
|
||||||
|
version = "0.4.9"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67"
|
||||||
|
dependencies = [
|
||||||
|
"autocfg",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -1114,7 +1114,7 @@ checksum = "12168c33176773b86799be25e2a2ba07c7aab9968b37541f1094dbd7a60c8946"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.59",
|
"syn 2.0.60",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -1125,7 +1125,7 @@ checksum = "9d8dc32e0095a7eeccebd0e3f09e9509365ecb3fc6ac4d6f5f14a3f6392942d1"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.59",
|
"syn 2.0.60",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -1277,7 +1277,15 @@ dependencies = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
<<<<<<< HEAD
|
name = "winnow"
|
||||||
|
version = "0.6.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f0c976aaaa0e1f90dbb21e9587cdaf1d9679a1cde8875c0d6bd83ab96a208352"
|
||||||
|
dependencies = [
|
||||||
|
"memchr",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
name = "wmi"
|
name = "wmi"
|
||||||
version = "0.13.3"
|
version = "0.13.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
@ -1289,14 +1297,6 @@ dependencies = [
|
|||||||
"serde",
|
"serde",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
"windows",
|
"windows",
|
||||||
=======
|
|
||||||
name = "winnow"
|
|
||||||
version = "0.6.6"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "f0c976aaaa0e1f90dbb21e9587cdaf1d9679a1cde8875c0d6bd83ab96a208352"
|
|
||||||
dependencies = [
|
|
||||||
"memchr",
|
|
||||||
>>>>>>> main
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -3,13 +3,12 @@ use num_enum::{IntoPrimitive, TryFromPrimitive};
|
|||||||
use satrs::spacepackets::PacketId;
|
use satrs::spacepackets::PacketId;
|
||||||
use satrs_mib::res_code::ResultU16Info;
|
use satrs_mib::res_code::ResultU16Info;
|
||||||
use satrs_mib::resultcode;
|
use satrs_mib::resultcode;
|
||||||
use std::env;
|
|
||||||
use std::net::Ipv4Addr;
|
use std::net::Ipv4Addr;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
|
|
||||||
pub const STOP_FILE_NAME: &str = "stop-experiment";
|
pub const STOP_FILE_NAME: &str = "stop-experiment";
|
||||||
pub const CONFIG_FILE_NAME: &str = "exp278.toml";
|
pub const CONFIG_FILE_NAME: &str = "exp278.toml";
|
||||||
pub const HOME_FOLER_EXPERIMENT: &str = "/home/exp278";
|
pub const HOME_FOLDER_EXPERIMENT: &str = "/home/exp278";
|
||||||
pub const LOG_FOLDER: &str = "logs";
|
pub const LOG_FOLDER: &str = "logs";
|
||||||
|
|
||||||
pub const OBSW_SERVER_ADDR: Ipv4Addr = Ipv4Addr::UNSPECIFIED;
|
pub const OBSW_SERVER_ADDR: Ipv4Addr = Ipv4Addr::UNSPECIFIED;
|
||||||
@ -43,7 +42,7 @@ pub enum GroupId {
|
|||||||
lazy_static! {
|
lazy_static! {
|
||||||
pub static ref HOME_PATH: PathBuf = {
|
pub static ref HOME_PATH: PathBuf = {
|
||||||
let mut home_path = PathBuf::new();
|
let mut home_path = PathBuf::new();
|
||||||
let mut home_path_default = homedir::get_my_home().expect("Getting home dir from OS failed.").expect("No home dir found.");
|
let home_path_default = homedir::get_my_home().expect("Getting home dir from OS failed.").expect("No home dir found.");
|
||||||
|
|
||||||
home_path.push(if Path::new(HOME_FOLDER_EXPERIMENT).exists() {
|
home_path.push(if Path::new(HOME_FOLDER_EXPERIMENT).exists() {
|
||||||
HOME_FOLDER_EXPERIMENT
|
HOME_FOLDER_EXPERIMENT
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
use std::fmt;
|
||||||
|
use std::fmt::Formatter;
|
||||||
/// Device handler implementation for the IMS-100 Imager used on the OPS-SAT mission.
|
/// Device handler implementation for the IMS-100 Imager used on the OPS-SAT mission.
|
||||||
///
|
///
|
||||||
/// from the [OPSSAT Experimenter Wiki](https://opssat1.esoc.esa.int/projects/experimenter-information/wiki/Camera_Introduction):
|
/// from the [OPSSAT Experimenter Wiki](https://opssat1.esoc.esa.int/projects/experimenter-information/wiki/Camera_Introduction):
|
||||||
@ -26,14 +28,13 @@
|
|||||||
/// see also https://opssat1.esoc.esa.int/dmsf/files/6/view
|
/// see also https://opssat1.esoc.esa.int/dmsf/files/6/view
|
||||||
use crate::requests::CompositeRequest;
|
use crate::requests::CompositeRequest;
|
||||||
use derive_new::new;
|
use derive_new::new;
|
||||||
use log::debug;
|
use log::{debug, info};
|
||||||
use ops_sat_rs::TimeStampHelper;
|
use ops_sat_rs::TimeStampHelper;
|
||||||
use satrs::action::{ActionRequest, ActionRequestVariant};
|
use satrs::action::{ActionRequest, ActionRequestVariant};
|
||||||
use satrs::hk::HkRequest;
|
use satrs::hk::HkRequest;
|
||||||
use satrs::request::{GenericMessage, MessageMetadata, UniqueApidTargetId};
|
use satrs::request::{GenericMessage, MessageMetadata, UniqueApidTargetId};
|
||||||
use satrs::tmtc::PacketAsVec;
|
use satrs::tmtc::PacketAsVec;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::io::Error;
|
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
use std::sync::mpsc;
|
use std::sync::mpsc;
|
||||||
use satrs::pus::action::{ActionReplyPus, ActionReplyVariant};
|
use satrs::pus::action::{ActionReplyPus, ActionReplyVariant};
|
||||||
@ -131,6 +132,48 @@ pub struct CameraPictureParameters {
|
|||||||
pub W: u32, // wait time between pictures in ms, max: 40000
|
pub W: u32, // wait time between pictures in ms, max: 40000
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
#[allow(dead_code)]
|
||||||
|
pub enum CameraError {
|
||||||
|
TakeImageError,
|
||||||
|
NoDataSent,
|
||||||
|
VariantNotImplemented,
|
||||||
|
DeserializeError,
|
||||||
|
ListFileError,
|
||||||
|
IoError(std::io::Error),
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<std::io::Error> for CameraError {
|
||||||
|
fn from(value: std::io::Error) -> Self {
|
||||||
|
Self::IoError(value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl fmt::Display for CameraError {
|
||||||
|
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
|
||||||
|
match self {
|
||||||
|
CameraError::TakeImageError => {
|
||||||
|
write!(f, "Error taking image.")
|
||||||
|
}
|
||||||
|
CameraError::NoDataSent => {
|
||||||
|
write!(f, "No data sent.")
|
||||||
|
}
|
||||||
|
CameraError::VariantNotImplemented => {
|
||||||
|
write!(f, "Request variant not implemented.")
|
||||||
|
}
|
||||||
|
CameraError::DeserializeError => {
|
||||||
|
write!(f, "Unable to deserialize parameters.")
|
||||||
|
}
|
||||||
|
CameraError::ListFileError => {
|
||||||
|
write!(f, "Error listing image files.")
|
||||||
|
}
|
||||||
|
CameraError::IoError(io_error) => {
|
||||||
|
write!(f, "{}", io_error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct IMS100BatchHandler {
|
pub struct IMS100BatchHandler {
|
||||||
@ -207,20 +250,18 @@ impl IMS100BatchHandler {
|
|||||||
&mut self,
|
&mut self,
|
||||||
requestor_info: &MessageMetadata,
|
requestor_info: &MessageMetadata,
|
||||||
action_request: &ActionRequest,
|
action_request: &ActionRequest,
|
||||||
) -> std::io::Result<()> {
|
) -> Result<(), CameraError> {
|
||||||
let param = match CameraActionId::try_from(action_request.action_id).expect("Invalid action id") {
|
let param = match CameraActionId::try_from(action_request.action_id).expect("Invalid action id") {
|
||||||
CameraActionId::DefaultSingle => DEFAULT_SINGLE_CAM_PARAMS,
|
CameraActionId::DefaultSingle => DEFAULT_SINGLE_CAM_PARAMS,
|
||||||
CameraActionId::BalancedSingle => BALANCED_SINGLE_CAM_PARAMS,
|
CameraActionId::BalancedSingle => BALANCED_SINGLE_CAM_PARAMS,
|
||||||
CameraActionId::DefaultSingleFlatSat => DEFAULT_SINGLE_FLATSAT_CAM_PARAMS,
|
CameraActionId::DefaultSingleFlatSat => DEFAULT_SINGLE_FLATSAT_CAM_PARAMS,
|
||||||
CameraActionId::BalancedSingleFlatSat => BALANCED_SINGLE_FLATSAT_CAM_PARAMS,
|
CameraActionId::BalancedSingleFlatSat => BALANCED_SINGLE_FLATSAT_CAM_PARAMS,
|
||||||
CameraActionId::CustomParameters => match &action_request.variant {
|
CameraActionId::CustomParameters => match &action_request.variant {
|
||||||
ActionRequestVariant::NoData => return Err(Error::other("No Data sent!")),
|
ActionRequestVariant::NoData => return Err(CameraError::NoDataSent),
|
||||||
ActionRequestVariant::StoreData(_) => {
|
ActionRequestVariant::StoreData(_) => {
|
||||||
// let param = serde_json::from_slice()
|
// let param = serde_json::from_slice()
|
||||||
// TODO implement non dynamic version
|
// TODO implement non dynamic version
|
||||||
return Err(Error::other(
|
return Err(CameraError::VariantNotImplemented);
|
||||||
"Static parameter transfer not implemented yet!",
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
ActionRequestVariant::VecData(data) => {
|
ActionRequestVariant::VecData(data) => {
|
||||||
let param: serde_json::Result<CameraPictureParameters> =
|
let param: serde_json::Result<CameraPictureParameters> =
|
||||||
@ -228,11 +269,11 @@ impl IMS100BatchHandler {
|
|||||||
match param {
|
match param {
|
||||||
Ok(param) => param,
|
Ok(param) => param,
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
return Err(Error::other("Unable to deserialize parameters"));
|
return Err(CameraError::DeserializeError);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => return Err(Error::other("Invalid Action Request Variant!")),
|
_ => return Err(CameraError::VariantNotImplemented),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
self.take_picture(param)?;
|
self.take_picture(param)?;
|
||||||
@ -240,7 +281,8 @@ impl IMS100BatchHandler {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn take_picture(&mut self, param: CameraPictureParameters) -> std::io::Result<()> {
|
pub fn take_picture(&mut self, param: CameraPictureParameters) -> Result<(), CameraError> {
|
||||||
|
info!("Taking image!");
|
||||||
let mut cmd = Command::new(IMS_TESTAPP);
|
let mut cmd = Command::new(IMS_TESTAPP);
|
||||||
cmd.arg("-R")
|
cmd.arg("-R")
|
||||||
.arg(¶m.R.to_string())
|
.arg(¶m.R.to_string())
|
||||||
@ -271,7 +313,7 @@ impl IMS100BatchHandler {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn list_current_images(&self) -> std::io::Result<Vec<String>> {
|
pub fn list_current_images(&self) -> Result<Vec<String>, CameraError> {
|
||||||
let output = Command::new("ls").arg("-l")
|
let output = Command::new("ls").arg("-l")
|
||||||
.arg("*.png")
|
.arg("*.png")
|
||||||
.output()?;
|
.output()?;
|
||||||
@ -282,7 +324,7 @@ impl IMS100BatchHandler {
|
|||||||
Ok(files)
|
Ok(files)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Err(Error::other("Error getting file list."))
|
Err(CameraError::ListFileError)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -295,7 +337,7 @@ impl IMS100BatchHandler {
|
|||||||
P: &str,
|
P: &str,
|
||||||
E: &str,
|
E: &str,
|
||||||
W: &str,
|
W: &str,
|
||||||
) -> std::io::Result<()> {
|
) -> Result<(), CameraError> {
|
||||||
let mut cmd = Command::new("ims100_testapp");
|
let mut cmd = Command::new("ims100_testapp");
|
||||||
cmd.arg("-R")
|
cmd.arg("-R")
|
||||||
.arg(R)
|
.arg(R)
|
||||||
|
Loading…
Reference in New Issue
Block a user