mirror of
https://github.com/italicsjenga/mppt-modbus.git
synced 2024-12-23 16:51:30 +11:00
stinko mode
This commit is contained in:
parent
1eea528d5d
commit
2192d86c31
412
src/main.rs
412
src/main.rs
|
@ -16,104 +16,104 @@ const EEPROM_DATA_SIZE: u16 = 0x0021;
|
||||||
#[derive(Serialize, Deserialize, Debug)]
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
struct MpptRam {
|
struct MpptRam {
|
||||||
// scaling values
|
// scaling values
|
||||||
V_PU: f32,
|
v_pu: f32,
|
||||||
I_PU: f32,
|
i_pu: f32,
|
||||||
VER_SW: u16,
|
ver_sw: u16,
|
||||||
// filtered ADC
|
// filtered ADC
|
||||||
ADC_VB_F_MED: f32,
|
adc_vb_f_med: f32,
|
||||||
ADC_VBTERM_F: f32,
|
adc_vbterm_f: f32,
|
||||||
ADC_VBS_F: f32,
|
adc_vbs_f: f32,
|
||||||
ADC_VA_F: f32,
|
adc_va_f: f32,
|
||||||
ADC_IB_F_SHADOW: f32,
|
adc_ib_f_shadow: f32,
|
||||||
ADC_IA_F_SHADOW: f32,
|
adc_ia_f_shadow: f32,
|
||||||
ADC_P12_F: f32,
|
adc_p12_f: f32,
|
||||||
ADC_P3_F: f32,
|
adc_p3_f: f32,
|
||||||
ADC_PMETER_F: f32,
|
adc_pmeter_f: f32,
|
||||||
ADC_P18_F: f32,
|
adc_p18_f: f32,
|
||||||
ADC_V_REF: f32,
|
adc_v_ref: f32,
|
||||||
// temperatures
|
// temperatures
|
||||||
T_HS: u16,
|
t_hs: u16,
|
||||||
T_RTS: u16,
|
t_rts: u16,
|
||||||
T_BATT: u16,
|
t_batt: u16,
|
||||||
// status
|
// status
|
||||||
ADC_VB_F_1M: f32,
|
adc_vb_f_1m: f32,
|
||||||
ADC_IB_F_1M: f32,
|
adc_ib_f_1m: f32,
|
||||||
VB_MIN: f32,
|
vb_min: f32,
|
||||||
VB_MAX: f32,
|
vb_max: f32,
|
||||||
HOURMETER_HI: u16,
|
hourmeter_hi: u16,
|
||||||
HOURMETER_LO: u16,
|
hourmeter_lo: u16,
|
||||||
FAULT_ALL: u16,
|
fault_all: u16,
|
||||||
ALARM_HI: u16,
|
alarm_hi: u16,
|
||||||
ALARM_LO: u16,
|
alarm_lo: u16,
|
||||||
DIP_ALL: u16,
|
dip_all: u16,
|
||||||
LED_STATE: u16,
|
led_state: u16,
|
||||||
// charger
|
// charger
|
||||||
CHARGE_STATE: u16,
|
charge_state: u16,
|
||||||
VB_REF: f32,
|
vb_ref: f32,
|
||||||
AHC_R_HI: u16,
|
ahc_r_hi: u16,
|
||||||
AHC_R_LO: u16,
|
ahc_r_lo: u16,
|
||||||
AHC_T_HI: u16,
|
ahc_t_hi: u16,
|
||||||
AHC_T_LO: u16,
|
ahc_t_lo: u16,
|
||||||
KWHC_R: u16,
|
kwhc_r: u16,
|
||||||
KWHC_T: u16,
|
kwhc_t: u16,
|
||||||
// MpptRam
|
// MpptRam
|
||||||
POWER_OUT_SHADOW: f32,
|
power_out_shadow: f32,
|
||||||
POWER_IN_SHADOW: f32,
|
power_in_shadow: f32,
|
||||||
SWEEP_PIN_MAX: f32,
|
sweep_pin_max: f32,
|
||||||
SWEEP_VMP: f32,
|
sweep_vmp: f32,
|
||||||
SWEEP_VOC: f32,
|
sweep_voc: f32,
|
||||||
// logger - today's values
|
// logger - today's values
|
||||||
VB_MIN_DAILY: f32,
|
vb_min_daily: f32,
|
||||||
VB_MAX_DAILY: f32,
|
vb_max_daily: f32,
|
||||||
VA_MAX_DAILY: f32,
|
va_max_daily: f32,
|
||||||
AHC_DAILY: f32,
|
ahc_daily: f32,
|
||||||
WHC_DAILY: u16,
|
whc_daily: u16,
|
||||||
FLAGS_DAILY: u16,
|
flags_daily: u16,
|
||||||
POUT_MAX_DAILY: f32,
|
pout_max_daily: f32,
|
||||||
TB_MIN_DAILY: u16,
|
tb_min_daily: u16,
|
||||||
TB_MAX_DAILY: u16,
|
tb_max_daily: u16,
|
||||||
FAULT_DAILY: u16,
|
fault_daily: u16,
|
||||||
ALARM_DAILY_HI: u16,
|
alarm_daily_hi: u16,
|
||||||
ALARM_DAILY_LO: u16,
|
alarm_daily_lo: u16,
|
||||||
TIME_AB_DAILY: u16,
|
time_ab_daily: u16,
|
||||||
TIME_EQ_DAILY: u16,
|
time_eq_daily: u16,
|
||||||
TIME_FL_DAILY: u16,
|
time_fl_daily: u16,
|
||||||
// manual control
|
// manual control
|
||||||
IB_REF_SLAVE: f32,
|
ib_ref_slave: f32,
|
||||||
VB_REF_SLAVE: f32,
|
vb_ref_slave: f32,
|
||||||
VA_REF_FIXED: f32,
|
va_ref_fixed: f32,
|
||||||
VA_REF_FIXED_PCT: f32,
|
va_ref_fixed_pct: f32,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug)]
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
struct MpptEeprom {
|
struct MpptEeprom {
|
||||||
EV_absorp: Voltage,
|
ev_absorp: Voltage,
|
||||||
EV_float: Voltage,
|
ev_float: Voltage,
|
||||||
Et_absorp: Raw,
|
et_absorp: Raw,
|
||||||
Et_absorp_ext: Raw,
|
et_absorp_ext: Raw,
|
||||||
EV_absorp_ext: Voltage,
|
ev_absorp_ext: Voltage,
|
||||||
EV_float_cancel: Voltage,
|
ev_float_cancel: Voltage,
|
||||||
Et_float_exit_cum: Raw,
|
et_float_exit_cum: Raw,
|
||||||
EV_eq: Voltage,
|
ev_eq: Voltage,
|
||||||
Et_eqcalendar: Raw,
|
et_eqcalendar: Raw,
|
||||||
Et_eq_above: Raw,
|
et_eq_above: Raw,
|
||||||
Et_eq_reg: Raw,
|
et_eq_reg: Raw,
|
||||||
Et_batt_service: Raw,
|
et_batt_service: Raw,
|
||||||
EV_tempcomp: Tempcomp,
|
ev_tempcomp: Tempcomp,
|
||||||
EV_hvd: Voltage,
|
ev_hvd: Voltage,
|
||||||
EV_hvr: Voltage,
|
ev_hvr: Voltage,
|
||||||
Evb_ref_lim: Voltage,
|
evb_ref_lim: Voltage,
|
||||||
ETb_max: Raw,
|
etb_max: Raw,
|
||||||
ETb_min: Raw,
|
etb_min: Raw,
|
||||||
EV_soc_g_gy: Voltage,
|
ev_soc_g_gy: Voltage,
|
||||||
EV_soc_gy_y: Voltage,
|
ev_soc_gy_y: Voltage,
|
||||||
EV_soc_y_yr: Voltage,
|
ev_soc_y_yr: Voltage,
|
||||||
EV_soc_yr_r: Voltage,
|
ev_soc_yr_r: Voltage,
|
||||||
Emodbus_id: Raw,
|
emodbus_id: Raw,
|
||||||
Emeterbus_id: Raw,
|
emeterbus_id: Raw,
|
||||||
EIb_lim: Current,
|
eib_lim: Current,
|
||||||
EVa_ref_fixed_init: Voltage,
|
eva_ref_fixed_init: Voltage,
|
||||||
EVa_ref_fixed_pct_init: VoltagePercentage,
|
eva_ref_fixed_pct_init: VoltagePercentage,
|
||||||
}
|
}
|
||||||
|
|
||||||
trait Scaled {
|
trait Scaled {
|
||||||
|
@ -161,11 +161,11 @@ struct VoltagePercentage {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Scaled for VoltagePercentage {
|
impl Scaled for VoltagePercentage {
|
||||||
fn get_scaled(&self, info: &Info) -> f32 {
|
fn get_scaled(&self, _: &Info) -> f32 {
|
||||||
self.data as f32 * 100. * f32::powf(2., -16.)
|
self.data as f32 * 100. * f32::powf(2., -16.)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn new(input: f32, info: &Info) -> Self {
|
fn new(input: f32, _: &Info) -> Self {
|
||||||
Self {
|
Self {
|
||||||
data: ((input / f32::powf(2., -16.)) / 100.) as u16,
|
data: ((input / f32::powf(2., -16.)) / 100.) as u16,
|
||||||
}
|
}
|
||||||
|
@ -195,11 +195,11 @@ struct Raw {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Scaled for Raw {
|
impl Scaled for Raw {
|
||||||
fn get_scaled(&self, info: &Info) -> f32 {
|
fn get_scaled(&self, _: &Info) -> f32 {
|
||||||
self.data as f32
|
self.data as f32
|
||||||
}
|
}
|
||||||
|
|
||||||
fn new(input: f32, info: &Info) -> Self {
|
fn new(input: f32, _: &Info) -> Self {
|
||||||
Self { data: input as u16 }
|
Self { data: input as u16 }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -313,72 +313,72 @@ fn main() {
|
||||||
.expect("couldnt");
|
.expect("couldnt");
|
||||||
let info = Info::from(&data_in);
|
let info = Info::from(&data_in);
|
||||||
let ram_data = MpptRam {
|
let ram_data = MpptRam {
|
||||||
V_PU: info.scale_voltage_f(
|
v_pu: info.scale_voltage_f(
|
||||||
data_in[OffsetsRam::V_PU_HI] as f32
|
data_in[OffsetsRam::V_PU_HI] as f32
|
||||||
+ (data_in[OffsetsRam::V_PU_LO] as f32 / f32::powf(2., 16.)),
|
+ (data_in[OffsetsRam::V_PU_LO] as f32 / f32::powf(2., 16.)),
|
||||||
),
|
),
|
||||||
I_PU: info.scale_current_f(
|
i_pu: info.scale_current_f(
|
||||||
data_in[OffsetsRam::I_PU_HI] as f32
|
data_in[OffsetsRam::I_PU_HI] as f32
|
||||||
+ (data_in[OffsetsRam::I_PU_LO] as f32 / f32::powf(2., 16.)),
|
+ (data_in[OffsetsRam::I_PU_LO] as f32 / f32::powf(2., 16.)),
|
||||||
),
|
),
|
||||||
VER_SW: data_in[OffsetsRam::VER_SW],
|
ver_sw: data_in[OffsetsRam::VER_SW],
|
||||||
ADC_VB_F_MED: info.scale_voltage(&data_in[OffsetsRam::ADC_VB_F_MED]),
|
adc_vb_f_med: info.scale_voltage(&data_in[OffsetsRam::ADC_VB_F_MED]),
|
||||||
ADC_VBTERM_F: info.scale_voltage(&data_in[OffsetsRam::ADC_VBTERM_F]),
|
adc_vbterm_f: info.scale_voltage(&data_in[OffsetsRam::ADC_VBTERM_F]),
|
||||||
ADC_VBS_F: info.scale_voltage(&data_in[OffsetsRam::ADC_VBS_F]),
|
adc_vbs_f: info.scale_voltage(&data_in[OffsetsRam::ADC_VBS_F]),
|
||||||
ADC_VA_F: info.scale_voltage(&data_in[OffsetsRam::ADC_VA_F]),
|
adc_va_f: info.scale_voltage(&data_in[OffsetsRam::ADC_VA_F]),
|
||||||
ADC_IB_F_SHADOW: info.scale_current(&data_in[OffsetsRam::ADC_IB_F_SHADOW]),
|
adc_ib_f_shadow: info.scale_current(&data_in[OffsetsRam::ADC_IB_F_SHADOW]),
|
||||||
ADC_IA_F_SHADOW: info.scale_current(&data_in[OffsetsRam::ADC_IA_F_SHADOW]),
|
adc_ia_f_shadow: info.scale_current(&data_in[OffsetsRam::ADC_IA_F_SHADOW]),
|
||||||
ADC_P12_F: data_in[OffsetsRam::ADC_P12_F] as f32 * 18.618 * f32::powf(2., -15.),
|
adc_p12_f: data_in[OffsetsRam::ADC_P12_F] as f32 * 18.618 * f32::powf(2., -15.),
|
||||||
ADC_P3_F: data_in[OffsetsRam::ADC_P3_F] as f32 * 6.6 * f32::powf(2., -15.),
|
adc_p3_f: data_in[OffsetsRam::ADC_P3_F] as f32 * 6.6 * f32::powf(2., -15.),
|
||||||
ADC_PMETER_F: data_in[OffsetsRam::ADC_PMETER_F] as f32 * 18.618 * f32::powf(2., -15.),
|
adc_pmeter_f: data_in[OffsetsRam::ADC_PMETER_F] as f32 * 18.618 * f32::powf(2., -15.),
|
||||||
ADC_P18_F: data_in[OffsetsRam::ADC_P18_F] as f32 * 3. * f32::powf(2., -15.),
|
adc_p18_f: data_in[OffsetsRam::ADC_P18_F] as f32 * 3. * f32::powf(2., -15.),
|
||||||
ADC_V_REF: data_in[OffsetsRam::ADC_V_REF] as f32 * 3. * f32::powf(2., -15.),
|
adc_v_ref: data_in[OffsetsRam::ADC_V_REF] as f32 * 3. * f32::powf(2., -15.),
|
||||||
T_HS: data_in[OffsetsRam::T_HS],
|
t_hs: data_in[OffsetsRam::T_HS],
|
||||||
T_RTS: data_in[OffsetsRam::T_RTS],
|
t_rts: data_in[OffsetsRam::T_RTS],
|
||||||
T_BATT: data_in[OffsetsRam::T_BATT],
|
t_batt: data_in[OffsetsRam::T_BATT],
|
||||||
ADC_VB_F_1M: info.scale_voltage(&data_in[OffsetsRam::ADC_VB_F_1M]),
|
adc_vb_f_1m: info.scale_voltage(&data_in[OffsetsRam::ADC_VB_F_1M]),
|
||||||
ADC_IB_F_1M: info.scale_current(&data_in[OffsetsRam::ADC_IB_F_1M]),
|
adc_ib_f_1m: info.scale_current(&data_in[OffsetsRam::ADC_IB_F_1M]),
|
||||||
VB_MIN: info.scale_voltage(&data_in[OffsetsRam::VB_MIN]),
|
vb_min: info.scale_voltage(&data_in[OffsetsRam::VB_MIN]),
|
||||||
VB_MAX: info.scale_voltage(&data_in[OffsetsRam::VB_MAX]),
|
vb_max: info.scale_voltage(&data_in[OffsetsRam::VB_MAX]),
|
||||||
HOURMETER_HI: data_in[OffsetsRam::HOURMETER_HI],
|
hourmeter_hi: data_in[OffsetsRam::HOURMETER_HI],
|
||||||
HOURMETER_LO: data_in[OffsetsRam::HOURMETER_LO],
|
hourmeter_lo: data_in[OffsetsRam::HOURMETER_LO],
|
||||||
FAULT_ALL: data_in[OffsetsRam::FAULT_ALL],
|
fault_all: data_in[OffsetsRam::FAULT_ALL],
|
||||||
ALARM_HI: data_in[OffsetsRam::ALARM_HI],
|
alarm_hi: data_in[OffsetsRam::ALARM_HI],
|
||||||
ALARM_LO: data_in[OffsetsRam::ALARM_LO],
|
alarm_lo: data_in[OffsetsRam::ALARM_LO],
|
||||||
DIP_ALL: data_in[OffsetsRam::DIP_ALL],
|
dip_all: data_in[OffsetsRam::DIP_ALL],
|
||||||
LED_STATE: data_in[OffsetsRam::LED_STATE],
|
led_state: data_in[OffsetsRam::LED_STATE],
|
||||||
CHARGE_STATE: data_in[OffsetsRam::CHARGE_STATE],
|
charge_state: data_in[OffsetsRam::CHARGE_STATE],
|
||||||
VB_REF: info.scale_voltage(&data_in[OffsetsRam::VB_REF]),
|
vb_ref: info.scale_voltage(&data_in[OffsetsRam::VB_REF]),
|
||||||
AHC_R_HI: data_in[OffsetsRam::AHC_R_HI],
|
ahc_r_hi: data_in[OffsetsRam::AHC_R_HI],
|
||||||
AHC_R_LO: data_in[OffsetsRam::AHC_R_LO],
|
ahc_r_lo: data_in[OffsetsRam::AHC_R_LO],
|
||||||
AHC_T_HI: data_in[OffsetsRam::AHC_T_HI],
|
ahc_t_hi: data_in[OffsetsRam::AHC_T_HI],
|
||||||
AHC_T_LO: data_in[OffsetsRam::AHC_T_LO],
|
ahc_t_lo: data_in[OffsetsRam::AHC_T_LO],
|
||||||
KWHC_R: data_in[OffsetsRam::KWHC_R],
|
kwhc_r: data_in[OffsetsRam::KWHC_R],
|
||||||
KWHC_T: data_in[OffsetsRam::KWHC_T],
|
kwhc_t: data_in[OffsetsRam::KWHC_T],
|
||||||
POWER_OUT_SHADOW: info.scale_power(&data_in[OffsetsRam::AHC_R_HI]),
|
power_out_shadow: info.scale_power(&data_in[OffsetsRam::POWER_OUT_SHADOW]),
|
||||||
POWER_IN_SHADOW: info.scale_power(&data_in[OffsetsRam::POWER_IN_SHADOW]),
|
power_in_shadow: info.scale_power(&data_in[OffsetsRam::POWER_IN_SHADOW]),
|
||||||
SWEEP_PIN_MAX: info.scale_power(&data_in[OffsetsRam::SWEEP_PIN_MAX]),
|
sweep_pin_max: info.scale_power(&data_in[OffsetsRam::SWEEP_PIN_MAX]),
|
||||||
SWEEP_VMP: info.scale_voltage(&data_in[OffsetsRam::SWEEP_VMP]),
|
sweep_vmp: info.scale_voltage(&data_in[OffsetsRam::SWEEP_VMP]),
|
||||||
SWEEP_VOC: info.scale_voltage(&data_in[OffsetsRam::SWEEP_VOC]),
|
sweep_voc: info.scale_voltage(&data_in[OffsetsRam::SWEEP_VOC]),
|
||||||
VB_MIN_DAILY: info.scale_voltage(&data_in[OffsetsRam::VB_MIN_DAILY]),
|
vb_min_daily: info.scale_voltage(&data_in[OffsetsRam::VB_MIN_DAILY]),
|
||||||
VB_MAX_DAILY: info.scale_voltage(&data_in[OffsetsRam::VB_MAX_DAILY]),
|
vb_max_daily: info.scale_voltage(&data_in[OffsetsRam::VB_MAX_DAILY]),
|
||||||
VA_MAX_DAILY: info.scale_voltage(&data_in[OffsetsRam::VA_MAX_DAILY]),
|
va_max_daily: info.scale_voltage(&data_in[OffsetsRam::VA_MAX_DAILY]),
|
||||||
AHC_DAILY: data_in[OffsetsRam::AHC_DAILY] as f32 * 0.1,
|
ahc_daily: data_in[OffsetsRam::AHC_DAILY] as f32 * 0.1,
|
||||||
WHC_DAILY: data_in[OffsetsRam::WHC_DAILY],
|
whc_daily: data_in[OffsetsRam::WHC_DAILY],
|
||||||
FLAGS_DAILY: data_in[OffsetsRam::FLAGS_DAILY],
|
flags_daily: data_in[OffsetsRam::FLAGS_DAILY],
|
||||||
POUT_MAX_DAILY: info.scale_power(&data_in[OffsetsRam::POUT_MAX_DAILY]),
|
pout_max_daily: info.scale_power(&data_in[OffsetsRam::POUT_MAX_DAILY]),
|
||||||
TB_MIN_DAILY: data_in[OffsetsRam::TB_MIN_DAILY],
|
tb_min_daily: data_in[OffsetsRam::TB_MIN_DAILY],
|
||||||
TB_MAX_DAILY: data_in[OffsetsRam::TB_MAX_DAILY],
|
tb_max_daily: data_in[OffsetsRam::TB_MAX_DAILY],
|
||||||
FAULT_DAILY: data_in[OffsetsRam::FAULT_DAILY],
|
fault_daily: data_in[OffsetsRam::FAULT_DAILY],
|
||||||
ALARM_DAILY_HI: data_in[OffsetsRam::ALARM_DAILY_HI],
|
alarm_daily_hi: data_in[OffsetsRam::ALARM_DAILY_HI],
|
||||||
ALARM_DAILY_LO: data_in[OffsetsRam::ALARM_DAILY_LO],
|
alarm_daily_lo: data_in[OffsetsRam::ALARM_DAILY_LO],
|
||||||
TIME_AB_DAILY: data_in[OffsetsRam::TIME_AB_DAILY],
|
time_ab_daily: data_in[OffsetsRam::TIME_AB_DAILY],
|
||||||
TIME_EQ_DAILY: data_in[OffsetsRam::TIME_EQ_DAILY],
|
time_eq_daily: data_in[OffsetsRam::TIME_EQ_DAILY],
|
||||||
TIME_FL_DAILY: data_in[OffsetsRam::TIME_FL_DAILY],
|
time_fl_daily: data_in[OffsetsRam::TIME_FL_DAILY],
|
||||||
IB_REF_SLAVE: data_in[OffsetsRam::IB_REF_SLAVE] as f32 * 80. * f32::powf(2., -15.),
|
ib_ref_slave: data_in[OffsetsRam::IB_REF_SLAVE] as f32 * 80. * f32::powf(2., -15.),
|
||||||
VB_REF_SLAVE: info.scale_voltage(&data_in[OffsetsRam::VB_REF_SLAVE]),
|
vb_ref_slave: info.scale_voltage(&data_in[OffsetsRam::VB_REF_SLAVE]),
|
||||||
VA_REF_FIXED: info.scale_voltage(&data_in[OffsetsRam::VA_REF_FIXED]),
|
va_ref_fixed: info.scale_voltage(&data_in[OffsetsRam::VA_REF_FIXED]),
|
||||||
VA_REF_FIXED_PCT: data_in[OffsetsRam::VA_REF_FIXED_PCT] as f32 * 100. * f32::powf(2., -16.),
|
va_ref_fixed_pct: data_in[OffsetsRam::VA_REF_FIXED_PCT] as f32 * 100. * f32::powf(2., -16.),
|
||||||
};
|
};
|
||||||
println!("ram: {:#?}", ram_data);
|
println!("ram: {:#?}", ram_data);
|
||||||
|
|
||||||
|
@ -388,92 +388,92 @@ fn main() {
|
||||||
.expect("could not get eeprom data");
|
.expect("could not get eeprom data");
|
||||||
|
|
||||||
let eeprom_data = MpptEeprom {
|
let eeprom_data = MpptEeprom {
|
||||||
EV_absorp: Voltage {
|
ev_absorp: Voltage {
|
||||||
data: data_in[OffsetsEeprom::EV_absorp],
|
data: data_in[OffsetsEeprom::EV_ABSORP],
|
||||||
},
|
},
|
||||||
EV_float: Voltage {
|
ev_float: Voltage {
|
||||||
data: data_in[OffsetsEeprom::EV_float],
|
data: data_in[OffsetsEeprom::EV_FLOAT],
|
||||||
},
|
},
|
||||||
Et_absorp: Raw {
|
et_absorp: Raw {
|
||||||
data: data_in[OffsetsEeprom::Et_absorp],
|
data: data_in[OffsetsEeprom::ET_ABSORP],
|
||||||
},
|
},
|
||||||
Et_absorp_ext: Raw {
|
et_absorp_ext: Raw {
|
||||||
data: data_in[OffsetsEeprom::Et_absorp_ext],
|
data: data_in[OffsetsEeprom::ET_ABSORP_EXT],
|
||||||
},
|
},
|
||||||
EV_absorp_ext: Voltage {
|
ev_absorp_ext: Voltage {
|
||||||
data: data_in[OffsetsEeprom::EV_absorp_ext],
|
data: data_in[OffsetsEeprom::EV_ABSORP_EXT],
|
||||||
},
|
},
|
||||||
EV_float_cancel: Voltage {
|
ev_float_cancel: Voltage {
|
||||||
data: data_in[OffsetsEeprom::EV_float_cancel],
|
data: data_in[OffsetsEeprom::EV_FLOAT_CANCEL],
|
||||||
},
|
},
|
||||||
Et_float_exit_cum: Raw {
|
et_float_exit_cum: Raw {
|
||||||
data: data_in[OffsetsEeprom::Et_float_exit_cum],
|
data: data_in[OffsetsEeprom::ET_FLOAT_EXIT_CUM],
|
||||||
},
|
},
|
||||||
EV_eq: Voltage {
|
ev_eq: Voltage {
|
||||||
data: data_in[OffsetsEeprom::EV_eq],
|
data: data_in[OffsetsEeprom::EV_EQ],
|
||||||
},
|
},
|
||||||
Et_eqcalendar: Raw {
|
et_eqcalendar: Raw {
|
||||||
data: data_in[OffsetsEeprom::Et_eqcalendar],
|
data: data_in[OffsetsEeprom::ET_EQCALENDAR],
|
||||||
},
|
},
|
||||||
Et_eq_above: Raw {
|
et_eq_above: Raw {
|
||||||
data: data_in[OffsetsEeprom::Et_eq_above],
|
data: data_in[OffsetsEeprom::ET_EQ_ABOVE],
|
||||||
},
|
},
|
||||||
Et_eq_reg: Raw {
|
et_eq_reg: Raw {
|
||||||
data: data_in[OffsetsEeprom::Et_eq_reg],
|
data: data_in[OffsetsEeprom::ET_EQ_REG],
|
||||||
},
|
},
|
||||||
Et_batt_service: Raw {
|
et_batt_service: Raw {
|
||||||
data: data_in[OffsetsEeprom::Et_batt_service],
|
data: data_in[OffsetsEeprom::ET_BATT_SERVICE],
|
||||||
},
|
},
|
||||||
EV_tempcomp: Tempcomp {
|
ev_tempcomp: Tempcomp {
|
||||||
data: data_in[OffsetsEeprom::EV_tempcomp],
|
data: data_in[OffsetsEeprom::EV_TEMPCOMP],
|
||||||
},
|
},
|
||||||
EV_hvd: Voltage {
|
ev_hvd: Voltage {
|
||||||
data: data_in[OffsetsEeprom::EV_hvd],
|
data: data_in[OffsetsEeprom::EV_HVD],
|
||||||
},
|
},
|
||||||
EV_hvr: Voltage {
|
ev_hvr: Voltage {
|
||||||
data: data_in[OffsetsEeprom::EV_hvr],
|
data: data_in[OffsetsEeprom::EV_HVR],
|
||||||
},
|
},
|
||||||
Evb_ref_lim: Voltage {
|
evb_ref_lim: Voltage {
|
||||||
data: data_in[OffsetsEeprom::Evb_ref_lim],
|
data: data_in[OffsetsEeprom::EVB_REF_LIM],
|
||||||
},
|
},
|
||||||
ETb_max: Raw {
|
etb_max: Raw {
|
||||||
data: data_in[OffsetsEeprom::ETb_max],
|
data: data_in[OffsetsEeprom::ETB_MAX],
|
||||||
},
|
},
|
||||||
ETb_min: Raw {
|
etb_min: Raw {
|
||||||
data: data_in[OffsetsEeprom::ETb_min],
|
data: data_in[OffsetsEeprom::ETB_MIN],
|
||||||
},
|
},
|
||||||
EV_soc_g_gy: Voltage {
|
ev_soc_g_gy: Voltage {
|
||||||
data: data_in[OffsetsEeprom::EV_soc_g_gy],
|
data: data_in[OffsetsEeprom::EV_SOC_G_GY],
|
||||||
},
|
},
|
||||||
EV_soc_gy_y: Voltage {
|
ev_soc_gy_y: Voltage {
|
||||||
data: data_in[OffsetsEeprom::EV_soc_gy_y],
|
data: data_in[OffsetsEeprom::EV_SOC_GY_Y],
|
||||||
},
|
},
|
||||||
EV_soc_y_yr: Voltage {
|
ev_soc_y_yr: Voltage {
|
||||||
data: data_in[OffsetsEeprom::EV_soc_y_yr],
|
data: data_in[OffsetsEeprom::EV_SOC_Y_YR],
|
||||||
},
|
},
|
||||||
EV_soc_yr_r: Voltage {
|
ev_soc_yr_r: Voltage {
|
||||||
data: data_in[OffsetsEeprom::EV_soc_yr_r],
|
data: data_in[OffsetsEeprom::EV_SOC_YR_R],
|
||||||
},
|
},
|
||||||
Emodbus_id: Raw {
|
emodbus_id: Raw {
|
||||||
data: data_in[OffsetsEeprom::Emodbus_id],
|
data: data_in[OffsetsEeprom::EMODBUS_ID],
|
||||||
},
|
},
|
||||||
Emeterbus_id: Raw {
|
emeterbus_id: Raw {
|
||||||
data: data_in[OffsetsEeprom::Emeterbus_id],
|
data: data_in[OffsetsEeprom::EMETERBUS_ID],
|
||||||
},
|
},
|
||||||
EIb_lim: Current {
|
eib_lim: Current {
|
||||||
data: data_in[OffsetsEeprom::EIb_lim],
|
data: data_in[OffsetsEeprom::EIB_LIM],
|
||||||
},
|
},
|
||||||
EVa_ref_fixed_init: Voltage {
|
eva_ref_fixed_init: Voltage {
|
||||||
data: data_in[OffsetsEeprom::EVa_ref_fixed_init],
|
data: data_in[OffsetsEeprom::EVA_REF_FIXED_INIT],
|
||||||
},
|
},
|
||||||
EVa_ref_fixed_pct_init: VoltagePercentage {
|
eva_ref_fixed_pct_init: VoltagePercentage {
|
||||||
data: data_in[OffsetsEeprom::EVa_ref_fixed_pct_init],
|
data: data_in[OffsetsEeprom::EVA_REF_FIXED_PCT_INIT],
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
println!("eeprom: {:#?}", eeprom_data);
|
println!("eeprom: {:#?}", eeprom_data);
|
||||||
let value = 50.;
|
let value = 50.;
|
||||||
let value_scaled = ((value / info.v_scale) / f32::powf(2., -15.)) as u16;
|
let _value_scaled = ((value / info.v_scale) / f32::powf(2., -15.)) as u16;
|
||||||
// modbus
|
// modbus
|
||||||
// .write_register(EEPROM_BEGIN as u16 + OffsetsEeprom::EV_soc_g_gy as u16, value_scaled)
|
// .write_register(EEPROM_BEGIN as u16 + OffsetsEeprom::EV_soc_g_gy as u16, value_scaled)
|
||||||
// .expect("could not set value");
|
// .expect("could not set value");
|
||||||
|
|
|
@ -76,31 +76,31 @@ impl OffsetsRam {
|
||||||
pub struct OffsetsEeprom {}
|
pub struct OffsetsEeprom {}
|
||||||
|
|
||||||
impl OffsetsEeprom {
|
impl OffsetsEeprom {
|
||||||
pub const EV_absorp: usize = 0x0000;
|
pub const EV_ABSORP: usize = 0x0000;
|
||||||
pub const EV_float: usize = 0x0001;
|
pub const EV_FLOAT: usize = 0x0001;
|
||||||
pub const Et_absorp: usize = 0x0002;
|
pub const ET_ABSORP: usize = 0x0002;
|
||||||
pub const Et_absorp_ext: usize = 0x0003;
|
pub const ET_ABSORP_EXT: usize = 0x0003;
|
||||||
pub const EV_absorp_ext: usize = 0x0004;
|
pub const EV_ABSORP_EXT: usize = 0x0004;
|
||||||
pub const EV_float_cancel: usize = 0x0005;
|
pub const EV_FLOAT_CANCEL: usize = 0x0005;
|
||||||
pub const Et_float_exit_cum: usize = 0x0006;
|
pub const ET_FLOAT_EXIT_CUM: usize = 0x0006;
|
||||||
pub const EV_eq: usize = 0x0007;
|
pub const EV_EQ: usize = 0x0007;
|
||||||
pub const Et_eqcalendar: usize = 0x0008;
|
pub const ET_EQCALENDAR: usize = 0x0008;
|
||||||
pub const Et_eq_above: usize = 0x0009;
|
pub const ET_EQ_ABOVE: usize = 0x0009;
|
||||||
pub const Et_eq_reg: usize = 0x000A;
|
pub const ET_EQ_REG: usize = 0x000A;
|
||||||
pub const Et_batt_service: usize = 0x000B;
|
pub const ET_BATT_SERVICE: usize = 0x000B;
|
||||||
pub const EV_tempcomp: usize = 0x000D;
|
pub const EV_TEMPCOMP: usize = 0x000D;
|
||||||
pub const EV_hvd: usize = 0x000E;
|
pub const EV_HVD: usize = 0x000E;
|
||||||
pub const EV_hvr: usize = 0x000F;
|
pub const EV_HVR: usize = 0x000F;
|
||||||
pub const Evb_ref_lim: usize = 0x0010;
|
pub const EVB_REF_LIM: usize = 0x0010;
|
||||||
pub const ETb_max: usize = 0x0011;
|
pub const ETB_MAX: usize = 0x0011;
|
||||||
pub const ETb_min: usize = 0x0012;
|
pub const ETB_MIN: usize = 0x0012;
|
||||||
pub const EV_soc_g_gy: usize = 0x0015;
|
pub const EV_SOC_G_GY: usize = 0x0015;
|
||||||
pub const EV_soc_gy_y: usize = 0x0016;
|
pub const EV_SOC_GY_Y: usize = 0x0016;
|
||||||
pub const EV_soc_y_yr: usize = 0x0017;
|
pub const EV_SOC_Y_YR: usize = 0x0017;
|
||||||
pub const EV_soc_yr_r: usize = 0x0018;
|
pub const EV_SOC_YR_R: usize = 0x0018;
|
||||||
pub const Emodbus_id: usize = 0x0019;
|
pub const EMODBUS_ID: usize = 0x0019;
|
||||||
pub const Emeterbus_id: usize = 0x001A;
|
pub const EMETERBUS_ID: usize = 0x001A;
|
||||||
pub const EIb_lim: usize = 0x001D;
|
pub const EIB_LIM: usize = 0x001D;
|
||||||
pub const EVa_ref_fixed_init: usize = 0x0020;
|
pub const EVA_REF_FIXED_INIT: usize = 0x0020;
|
||||||
pub const EVa_ref_fixed_pct_init: usize = 0x0021;
|
pub const EVA_REF_FIXED_PCT_INIT: usize = 0x0021;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue