cmd: Add cmds to config pd_mon params

This commit is contained in:
linuswck 2024-02-22 16:44:45 +08:00
parent 6ee45b4814
commit c4135f6ac3
3 changed files with 44 additions and 13 deletions

View File

@ -168,11 +168,11 @@ impl LdDrive{
}
pub fn set_pd_responsitivity(&mut self, responsitivity: pd_responsitivity::ResponsitivityUnit){
self.settings.pd_responsitivity.responsitivity = responsitivity;
self.settings.pd_responsitivity.set(responsitivity);
}
pub fn set_pd_dark_current(&mut self, i_dark: ElectricCurrent){
self.settings.pd_responsitivity.i_dark = i_dark;
self.settings.pd_responsitivity.set_i_dark(i_dark);
}
pub fn set_ld_power_limit(&mut self, pwr_limit: Power){

View File

@ -14,8 +14,8 @@ pub type ResponsitivityUnit = Quantity<ISQ<N2, N1, P3, P1, Z0, Z0, Z0>, SI<f64>,
#[derive(Clone, Debug, PartialEq, Tree)]
pub struct Parameters {
pub responsitivity: ResponsitivityUnit,
pub i_dark: ElectricCurrent,
responsitivity: ResponsitivityUnit,
i_dark: ElectricCurrent,
}
impl Parameters {
@ -28,6 +28,14 @@ impl Parameters {
let ld_i = pwr * self.responsitivity + self.i_dark;
ld_i
}
pub fn set(&mut self, responsitivity: ResponsitivityUnit) {
self.responsitivity = responsitivity;
}
pub fn set_i_dark(&mut self, i_dark: ElectricCurrent) {
self.i_dark = i_dark;
}
}
impl Default for Parameters {

View File

@ -1,14 +1,16 @@
use core::{default, fmt::Debug};
use core::{fmt::Debug, marker::PhantomData};
use miniconf::{JsonCoreSlash, Tree};
use serde::{Deserialize, Serialize};
use uom::si::{
electric_current::{ampere, milliampere, ElectricCurrent},
electric_current::{ampere, microampere, milliampere, ElectricCurrent},
electric_potential::{volt, ElectricPotential},
electrical_resistance::{ElectricalResistance, ohm},
f64::ThermodynamicTemperature, thermodynamic_temperature::degree_celsius
electrical_resistance::{ohm, ElectricalResistance},
power::{milliwatt, Power},
thermodynamic_temperature::{degree_celsius, ThermodynamicTemperature}
};
use crate::{laser_diode::laser_diode::{
LdDrive, StatusReport as LdStatusReport
use crate::{laser_diode::{laser_diode::{
LdDrive, StatusReport as LdStatusReport},
pd_responsitivity::ResponsitivityUnit
},
net::net,
thermostat::thermostat::StatusReport as TecStatusReport
@ -194,10 +196,24 @@ pub fn execute_cmd(buffer: &mut [u8], buffer_size: usize, mut laser: LdDrive, mu
}
}
Some(LdCmdEnum::SetPdResponsitivity) => {
info!("Not supported Yet")
match cmd.json.data_f64 {
Some(val) => {
laser.set_pd_responsitivity(ResponsitivityUnit {dimension: PhantomData, units: PhantomData, value: val})
}
None => {
info!("Wrong Data type is received")
}
}
}
Some(LdCmdEnum::SetPdDarkCurrent) => {
info!("Not supported Yet")
match cmd.json.data_f64 {
Some(val) => {
laser.set_pd_dark_current(ElectricCurrent::new::<microampere>(val))
}
None => {
info!("Wrong Data type is received")
}
}
}
Some(LdCmdEnum::SetPdILimit) => {
match cmd.json.data_f64 {
@ -210,7 +226,14 @@ pub fn execute_cmd(buffer: &mut [u8], buffer_size: usize, mut laser: LdDrive, mu
}
}
Some(LdCmdEnum::SetLdPwrLimit) => {
info!("Not supported Yet")
match cmd.json.data_f64 {
Some(val) => {
laser.set_ld_power_limit(Power::new::<milliwatt>(val))
}
None => {
info!("Wrong Data type is received")
}
}
}
Some(LdCmdEnum::ClearAlarmStatus) => {
laser.pd_mon_clear_alarm()