2024-01-18 18:00:39 +11:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2024-02-02 22:03:47 +11:00
|
|
|
#include "fluid_holder.hpp"
|
2024-02-16 15:07:33 +11:00
|
|
|
#include "../util/pid.hpp"
|
2024-02-02 22:03:47 +11:00
|
|
|
|
2024-01-18 18:00:39 +11:00
|
|
|
namespace sim::coolant
|
|
|
|
{
|
|
|
|
|
|
|
|
class valve
|
|
|
|
{
|
|
|
|
const double max;
|
2024-02-02 22:03:47 +11:00
|
|
|
|
|
|
|
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);
|
2024-02-02 22:03:47 +11:00
|
|
|
|
|
|
|
void update(double secs);
|
2024-02-03 18:12:18 +11:00
|
|
|
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-02 22:03:47 +11:00
|
|
|
|
2024-02-13 22:33:55 +11:00
|
|
|
operator Json::Value() const;
|
|
|
|
|
2024-02-02 22:03:47 +11:00
|
|
|
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
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|