fastsim_core/vehicle/
hvac.rs1use super::*;
2
3pub mod hvac_utils;
4pub use hvac_utils::*;
5
6pub mod hvac_sys_for_lumped_cabin;
7pub use hvac_sys_for_lumped_cabin::*;
8
9pub mod hvac_sys_for_lumped_cabin_and_res;
10pub use hvac_sys_for_lumped_cabin_and_res::*;
11
12#[derive(
14 Clone,
15 Default,
16 Debug,
17 Serialize,
18 Deserialize,
19 PartialEq,
20 IsVariant,
21 derive_more::From,
22 TryInto,
23 derive_more::Display,
24)]
25pub enum HVACOption {
26 #[display("LumpedCabin")]
28 LumpedCabin(Box<HVACSystemForLumpedCabin>),
29 #[display("LumpedCabinAndRES")]
31 LumpedCabinAndRES(Box<HVACSystemForLumpedCabinAndRES>),
32 #[display("LumpedCabinWithShell")]
34 LumpedCabinWithShell,
35 #[display("ReversibleEnergyStorageOnly")]
37 ReversibleEnergyStorageOnly,
38 #[default]
40 #[display("None")]
41 None,
42}
43impl Init for HVACOption {
44 fn init(&mut self) -> Result<(), Error> {
45 match self {
46 Self::LumpedCabin(cab) => cab.init()?,
47 Self::LumpedCabinAndRES(cab) => cab.init()?,
48 Self::LumpedCabinWithShell => {
49 todo!()
50 }
51 Self::ReversibleEnergyStorageOnly => {
52 todo!()
53 }
54 Self::None => {}
55 }
56 Ok(())
57 }
58}
59impl SerdeAPI for HVACOption {}
60impl SetCumulative for HVACOption {
61 fn set_cumulative<F: Fn() -> String>(&mut self, dt: si::Time, loc: F) -> anyhow::Result<()> {
62 match self {
63 HVACOption::LumpedCabin(lc) => {
64 lc.set_cumulative(dt, || format!("{}\n{}", loc(), format_dbg!()))?
65 }
66 HVACOption::LumpedCabinAndRES(lcr) => {
67 lcr.set_cumulative(dt, || format!("{}\n{}", loc(), format_dbg!()))?
68 }
69 HVACOption::LumpedCabinWithShell => todo!(),
70 HVACOption::ReversibleEnergyStorageOnly => todo!(),
71 HVACOption::None => {}
72 }
73 Ok(())
74 }
75
76 fn reset_cumulative<F: Fn() -> String>(&mut self, loc: F) -> anyhow::Result<()> {
77 match self {
78 HVACOption::LumpedCabin(lc) => {
79 lc.reset_cumulative(|| format!("{}\n{}", loc(), format_dbg!()))?
80 }
81 HVACOption::LumpedCabinAndRES(lcr) => {
82 lcr.reset_cumulative(|| format!("{}\n{}", loc(), format_dbg!()))?
83 }
84 HVACOption::LumpedCabinWithShell => todo!(),
85 HVACOption::ReversibleEnergyStorageOnly => todo!(),
86 HVACOption::None => {}
87 }
88 Ok(())
89 }
90}
91impl HistoryMethods for HVACOption {
92 fn save_interval(&self) -> anyhow::Result<Option<usize>> {
93 match self {
94 HVACOption::LumpedCabin(lc) => lc.save_interval(),
95 HVACOption::LumpedCabinAndRES(lcr) => lcr.save_interval(),
96 HVACOption::LumpedCabinWithShell => todo!(),
97 HVACOption::ReversibleEnergyStorageOnly => todo!(),
98 HVACOption::None => Ok(None),
99 }
100 }
101 fn set_save_interval(&mut self, save_interval: Option<usize>) -> anyhow::Result<()> {
102 match self {
103 HVACOption::LumpedCabin(lc) => lc.set_save_interval(save_interval),
104 HVACOption::LumpedCabinAndRES(lcr) => lcr.set_save_interval(save_interval),
105 HVACOption::LumpedCabinWithShell => todo!(),
106 HVACOption::ReversibleEnergyStorageOnly => todo!(),
107 HVACOption::None => Ok(()),
108 }
109 }
110 fn clear(&mut self) {
111 match self {
112 HVACOption::LumpedCabin(lc) => lc.clear(),
113 HVACOption::LumpedCabinAndRES(lcr) => lcr.clear(),
114 HVACOption::LumpedCabinWithShell => todo!(),
115 HVACOption::ReversibleEnergyStorageOnly => todo!(),
116 HVACOption::None => {}
117 }
118 }
119}
120
121impl StateMethods for HVACOption {}
122
123impl SaveState for HVACOption {
124 fn save_state<F: Fn() -> String>(&mut self, loc: F) -> anyhow::Result<()> {
125 match self {
126 Self::LumpedCabin(lc) => lc.save_state(loc)?,
127 Self::LumpedCabinAndRES(lcr) => lcr.save_state(loc)?,
128 Self::LumpedCabinWithShell => {
129 todo!()
130 }
131 Self::ReversibleEnergyStorageOnly => todo!(),
132 Self::None => {}
133 }
134 Ok(())
135 }
136}
137impl TrackedStateMethods for HVACOption {
138 fn check_and_reset<F: Fn() -> String>(&mut self, loc: F) -> anyhow::Result<()> {
139 match self {
140 Self::LumpedCabin(lc) => {
141 lc.check_and_reset(|| format!("{}\n{}", loc(), format_dbg!()))?
142 }
143 Self::LumpedCabinAndRES(lcr) => {
144 lcr.check_and_reset(|| format!("{}\n{}", loc(), format_dbg!()))?
145 }
146 Self::LumpedCabinWithShell => {
147 todo!()
148 }
149 Self::ReversibleEnergyStorageOnly => todo!(),
150 Self::None => {}
151 }
152 Ok(())
153 }
154
155 fn mark_fresh<F: Fn() -> String>(&mut self, loc: F) -> anyhow::Result<()> {
156 match self {
157 Self::LumpedCabin(lc) => lc.mark_fresh(|| format!("{}\n{}", loc(), format_dbg!()))?,
158 Self::LumpedCabinAndRES(lcr) => {
159 lcr.mark_fresh(|| format!("{}\n{}", loc(), format_dbg!()))?
160 }
161 Self::LumpedCabinWithShell => {
162 todo!()
163 }
164 Self::ReversibleEnergyStorageOnly => todo!(),
165 Self::None => {}
166 }
167 Ok(())
168 }
169}
170impl Step for HVACOption {
171 fn step<F: Fn() -> String>(&mut self, loc: F) -> anyhow::Result<()> {
172 match self {
173 Self::LumpedCabin(lc) => lc.step(|| format!("{}\n{}", loc(), format_dbg!())),
174 Self::LumpedCabinAndRES(lcr) => lcr.step(|| format!("{}\n{}", loc(), format_dbg!())),
175 Self::LumpedCabinWithShell => {
176 todo!()
177 }
178 Self::ReversibleEnergyStorageOnly => todo!(),
179 Self::None => Ok(()),
180 }
181 }
182
183 fn reset_step<F: Fn() -> String>(&mut self, loc: F) -> anyhow::Result<()> {
184 match self {
185 Self::LumpedCabin(lc) => lc.reset_step(|| format!("{}\n{}", loc(), format_dbg!())),
186 Self::LumpedCabinAndRES(lcr) => {
187 lcr.reset_step(|| format!("{}\n{}", loc(), format_dbg!()))
188 }
189 Self::LumpedCabinWithShell => {
190 todo!()
191 }
192 Self::ReversibleEnergyStorageOnly => todo!(),
193 Self::None => Ok(()),
194 }
195 }
196}