changed default camera parameters to constants

This commit is contained in:
lkoester 2024-04-17 13:03:31 +02:00
parent 9dbdd1ebbc
commit 22584c3f9c

View File

@ -38,6 +38,46 @@ use std::io::Error;
use std::process::Command; use std::process::Command;
use std::sync::mpsc; use std::sync::mpsc;
const DEFAULT_SINGLE_CAM_PARAMS: CameraPictureParameters = CameraPictureParameters {
R: 8,
G: 8,
B: 8,
N: 1,
P: true,
E: 2,
W: 1000,
};
const BALANCED_SINGLE_CAM_PARAMS: CameraPictureParameters = CameraPictureParameters {
R: 13,
G: 7,
B: 8,
N: 1,
P: true,
E: 2,
W: 1000,
};
const DEFAULT_SINGLE_FLATSAT_CAM_PARAMS: CameraPictureParameters = CameraPictureParameters {
R: 8,
G: 8,
B: 8,
N: 1,
P: true,
E: 200,
W: 1000,
};
const BALANCED_SINGLE_FLATSAT_CAM_PARAMS: CameraPictureParameters = CameraPictureParameters {
R: 13,
G: 7,
B: 8,
N: 1,
P: true,
E: 200,
W: 1000,
};
#[derive(Debug)] #[derive(Debug)]
pub enum CameraActionIds { pub enum CameraActionIds {
DefaultSingle = 1, DefaultSingle = 1,
@ -85,57 +125,6 @@ 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
} }
#[allow(dead_code)]
impl CameraPictureParameters {
pub fn default_single() -> Self {
Self {
R: 8,
G: 8,
B: 8,
N: 1,
P: true,
E: 2,
W: 1000,
}
}
pub fn balanced_single() -> Self {
Self {
R: 13,
G: 7,
B: 8,
N: 1,
P: true,
E: 2,
W: 1000,
}
}
pub fn default_single_flatsat() -> Self {
Self {
R: 8,
G: 8,
B: 8,
N: 1,
P: true,
E: 200,
W: 1000,
}
}
pub fn balanced_single_flatsat() -> Self {
Self {
R: 13,
G: 7,
B: 8,
N: 1,
P: true,
E: 200,
W: 1000,
}
}
}
#[allow(dead_code)] #[allow(dead_code)]
#[derive(new)] #[derive(new)]
pub struct IMS100BatchHandler { pub struct IMS100BatchHandler {
@ -187,14 +176,10 @@ impl IMS100BatchHandler {
action_request: &ActionRequest, action_request: &ActionRequest,
) -> std::io::Result<()> { ) -> std::io::Result<()> {
let param = match CameraActionIds::try_from(action_request.action_id).unwrap() { let param = match CameraActionIds::try_from(action_request.action_id).unwrap() {
CameraActionIds::DefaultSingle => CameraPictureParameters::default_single(), CameraActionIds::DefaultSingle => DEFAULT_SINGLE_CAM_PARAMS,
CameraActionIds::BalancedSingle => CameraPictureParameters::balanced_single(), CameraActionIds::BalancedSingle => BALANCED_SINGLE_CAM_PARAMS,
CameraActionIds::DefaultSingleFlatSat => { CameraActionIds::DefaultSingleFlatSat => DEFAULT_SINGLE_FLATSAT_CAM_PARAMS,
CameraPictureParameters::default_single_flatsat() CameraActionIds::BalancedSingleFlatSat => BALANCED_SINGLE_FLATSAT_CAM_PARAMS,
}
CameraActionIds::BalancedSingleFlatSat => {
CameraPictureParameters::balanced_single_flatsat()
}
CameraActionIds::CustomParameters => match &action_request.variant { CameraActionIds::CustomParameters => match &action_request.variant {
ActionRequestVariant::NoData => return Err(Error::other("No Data sent!")), ActionRequestVariant::NoData => return Err(Error::other("No Data sent!")),
ActionRequestVariant::StoreData(_) => { ActionRequestVariant::StoreData(_) => {