Save Thermostat and Laser Diode PWR On/Off status
This commit is contained in:
parent
d1cc677668
commit
18dd0a7963
|
@ -50,6 +50,7 @@ impl Settings{
|
||||||
|
|
||||||
#[derive(Deserialize, Serialize, Clone, Copy, Debug, Tree)]
|
#[derive(Deserialize, Serialize, Clone, Copy, Debug, Tree)]
|
||||||
struct Settings {
|
struct Settings {
|
||||||
|
pwr_on: bool,
|
||||||
ld_drive_current: ElectricCurrent,
|
ld_drive_current: ElectricCurrent,
|
||||||
ld_drive_current_limit: ElectricCurrent,
|
ld_drive_current_limit: ElectricCurrent,
|
||||||
pd_responsitivity: pd_responsitivity::Parameters,
|
pd_responsitivity: pd_responsitivity::Parameters,
|
||||||
|
@ -59,6 +60,7 @@ struct Settings {
|
||||||
impl Default for Settings {
|
impl Default for Settings {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
|
pwr_on: false,
|
||||||
ld_drive_current: ElectricCurrent::new::<milliampere>(0.0),
|
ld_drive_current: ElectricCurrent::new::<milliampere>(0.0),
|
||||||
ld_drive_current_limit: ElectricCurrent::new::<milliampere>(0.0),
|
ld_drive_current_limit: ElectricCurrent::new::<milliampere>(0.0),
|
||||||
pd_responsitivity: pd_responsitivity::Parameters::default(),
|
pd_responsitivity: pd_responsitivity::Parameters::default(),
|
||||||
|
@ -124,10 +126,12 @@ impl LdDrive{
|
||||||
// Wait for LD Power Supply to start up before driving current to laser diode
|
// Wait for LD Power Supply to start up before driving current to laser diode
|
||||||
sleep(30);
|
sleep(30);
|
||||||
self.ld_set_i(self.settings.ld_drive_current);
|
self.ld_set_i(self.settings.ld_drive_current);
|
||||||
|
self.settings.pwr_on = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn power_down(&mut self){
|
pub fn power_down(&mut self){
|
||||||
LdPwrExcProtector::pwr_off();
|
LdPwrExcProtector::pwr_off();
|
||||||
|
self.settings.pwr_on = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_pd_i(&mut self) -> ElectricCurrent {
|
pub fn get_pd_i(&mut self) -> ElectricCurrent {
|
||||||
|
@ -205,6 +209,7 @@ impl LdDrive{
|
||||||
pub fn get_settings_summary(&mut self) -> LdSettingsSummary {
|
pub fn get_settings_summary(&mut self) -> LdSettingsSummary {
|
||||||
let settings = self.settings;
|
let settings = self.settings;
|
||||||
LdSettingsSummary {
|
LdSettingsSummary {
|
||||||
|
pwr_on: self.settings.pwr_on,
|
||||||
ld_drive_current: LdSettingsSummaryField { value: settings.ld_drive_current, max: Settings::LD_CURRENT_MAX},
|
ld_drive_current: LdSettingsSummaryField { value: settings.ld_drive_current, max: Settings::LD_CURRENT_MAX},
|
||||||
ld_drive_current_limit: LdSettingsSummaryField { value: settings.ld_drive_current_limit, max: Settings::LD_CURRENT_MAX},
|
ld_drive_current_limit: LdSettingsSummaryField { value: settings.ld_drive_current_limit, max: Settings::LD_CURRENT_MAX},
|
||||||
pd_responsitivity: settings.pd_responsitivity,
|
pd_responsitivity: settings.pd_responsitivity,
|
||||||
|
@ -215,6 +220,7 @@ impl LdDrive{
|
||||||
|
|
||||||
#[derive(Deserialize, Serialize, Copy, Clone, Debug, Tree)]
|
#[derive(Deserialize, Serialize, Copy, Clone, Debug, Tree)]
|
||||||
pub struct LdSettingsSummary {
|
pub struct LdSettingsSummary {
|
||||||
|
pwr_on: bool,
|
||||||
ld_drive_current: LdSettingsSummaryField<ElectricCurrent>,
|
ld_drive_current: LdSettingsSummaryField<ElectricCurrent>,
|
||||||
ld_drive_current_limit: LdSettingsSummaryField<ElectricCurrent>,
|
ld_drive_current_limit: LdSettingsSummaryField<ElectricCurrent>,
|
||||||
pd_responsitivity: pd_responsitivity::Parameters,
|
pd_responsitivity: pd_responsitivity::Parameters,
|
||||||
|
|
|
@ -28,6 +28,7 @@ pub const R_SENSE: ElectricalResistance = ElectricalResistance {
|
||||||
|
|
||||||
#[derive(Deserialize, Serialize, Clone, Copy, Debug, Tree)]
|
#[derive(Deserialize, Serialize, Clone, Copy, Debug, Tree)]
|
||||||
pub struct TecSettings {
|
pub struct TecSettings {
|
||||||
|
pub pwr_on: bool,
|
||||||
pub center_pt: ElectricPotential,
|
pub center_pt: ElectricPotential,
|
||||||
pub max_v_set: ElectricPotential,
|
pub max_v_set: ElectricPotential,
|
||||||
pub max_i_pos_set: ElectricCurrent,
|
pub max_i_pos_set: ElectricCurrent,
|
||||||
|
@ -89,6 +90,7 @@ impl TecSettings{
|
||||||
impl Default for TecSettings {
|
impl Default for TecSettings {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
|
pwr_on: false,
|
||||||
center_pt: ElectricPotential::new::<volt>(1.5),
|
center_pt: ElectricPotential::new::<volt>(1.5),
|
||||||
max_v_set: ElectricPotential::new::<volt>(5.0),
|
max_v_set: ElectricPotential::new::<volt>(5.0),
|
||||||
max_i_pos_set: ElectricCurrent::new::<ampere>(1.0),
|
max_i_pos_set: ElectricCurrent::new::<ampere>(1.0),
|
||||||
|
@ -108,6 +110,7 @@ pub struct Thermostat {
|
||||||
|
|
||||||
#[derive(Deserialize, Serialize, Copy, Clone, Debug, Tree)]
|
#[derive(Deserialize, Serialize, Copy, Clone, Debug, Tree)]
|
||||||
pub struct ThermostatSettingsSummary {
|
pub struct ThermostatSettingsSummary {
|
||||||
|
pwr_on: bool,
|
||||||
tec_settings: TecSettingSummary,
|
tec_settings: TecSettingSummary,
|
||||||
pid_params: PidParams,
|
pid_params: PidParams,
|
||||||
temp_mon_settings: TempMonSettings,
|
temp_mon_settings: TempMonSettings,
|
||||||
|
@ -187,12 +190,14 @@ impl Thermostat{
|
||||||
|
|
||||||
pub fn power_up(&mut self){
|
pub fn power_up(&mut self){
|
||||||
self.max1968.power_up();
|
self.max1968.power_up();
|
||||||
|
self.tec_settings.pwr_on = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn power_down(&mut self){
|
pub fn power_down(&mut self){
|
||||||
self.max1968.power_down();
|
self.max1968.power_down();
|
||||||
self.pid_ctrl_ch0.reset_pid_state();
|
self.pid_ctrl_ch0.reset_pid_state();
|
||||||
self.set_i(ElectricCurrent::new::<ampere>(0.0));
|
self.set_i(ElectricCurrent::new::<ampere>(0.0));
|
||||||
|
self.tec_settings.pwr_on = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_center_pt(&mut self, value: ElectricPotential){
|
fn set_center_pt(&mut self, value: ElectricPotential){
|
||||||
|
@ -384,6 +389,7 @@ impl Thermostat{
|
||||||
|
|
||||||
pub fn get_settings_summary(&mut self) -> ThermostatSettingsSummary {
|
pub fn get_settings_summary(&mut self) -> ThermostatSettingsSummary {
|
||||||
ThermostatSettingsSummary {
|
ThermostatSettingsSummary {
|
||||||
|
pwr_on: self.tec_settings.pwr_on,
|
||||||
tec_settings: self.get_tec_settings(),
|
tec_settings: self.get_tec_settings(),
|
||||||
pid_params: self.get_pid_settings(),
|
pid_params: self.get_pid_settings(),
|
||||||
temp_mon_settings: self.get_temp_mon_settings(),
|
temp_mon_settings: self.get_temp_mon_settings(),
|
||||||
|
|
Loading…
Reference in New Issue