fast-nuclear-sim/src/coolant/valve.hpp

47 lines
888 B
C++
Raw Normal View History

2024-01-18 18:00:39 +11:00
#pragma once
#include "fluid_holder.hpp"
2024-02-16 15:07:33 +11:00
#include "../util/pid.hpp"
2024-01-18 18:00:39 +11:00
namespace sim::coolant
{
class valve
{
const double max;
fluid_holder* const src;
fluid_holder* const dst;
2024-01-18 18:00:39 +11:00
2024-02-04 23:22:15 +11:00
double speed = 0;
2024-01-18 18:00:39 +11:00
double state = 0;
2024-02-04 23:22:15 +11:00
double flow = 0; // L/s
2024-01-18 18:00:39 +11:00
2024-02-16 15:07:33 +11:00
bool auto_on = false;
double auto_th = 0; // C
util::PID pid {1e-3, -1e-3, 100, 0, 0};
2024-01-18 18:00:39 +11:00
public:
2024-02-05 18:33:31 +11:00
valve(fluid_holder* src, fluid_holder* dst, double state, double max);
2024-02-14 00:38:28 +11:00
valve(const Json::Value& node, fluid_holder* src, fluid_holder* dst);
void update(double secs);
void add_open_speed(double v);
void clear_open_speed();
2024-02-16 15:07:33 +11:00
void set_auto(bool state);
void toggle_auto();
2024-02-13 22:33:55 +11:00
operator Json::Value() const;
constexpr double get_state() const { return state; }
2024-02-04 23:22:15 +11:00
constexpr double get_flow() const { return flow; }
2024-02-16 15:07:33 +11:00
constexpr double get_setpoint() const { return auto_th; }
constexpr bool get_auto() const { return auto_on; }
2024-01-18 18:00:39 +11:00
};
};