2024-01-13 15:21:17 +11:00
|
|
|
|
2024-01-24 22:01:33 +11:00
|
|
|
#include <sys/time.h>
|
|
|
|
|
2024-01-25 00:35:39 +11:00
|
|
|
#include <random>
|
2024-01-25 00:52:02 +11:00
|
|
|
#include <sstream>
|
2024-01-25 00:35:39 +11:00
|
|
|
#include <cmath>
|
|
|
|
|
|
|
|
#include "reactor/coolant/vessel.hpp"
|
|
|
|
#include "coolant/fluid_t.hpp"
|
|
|
|
#include "coolant/valve.hpp"
|
|
|
|
#include "coolant/pump.hpp"
|
|
|
|
|
2024-01-21 01:36:21 +11:00
|
|
|
#include "graphics/window.hpp"
|
2024-01-24 22:01:33 +11:00
|
|
|
#include "graphics/camera.hpp"
|
2024-01-13 15:21:17 +11:00
|
|
|
|
2024-01-26 00:30:14 +11:00
|
|
|
#include "parts.hpp"
|
|
|
|
|
2024-01-21 01:36:21 +11:00
|
|
|
using namespace sim;
|
2024-01-13 21:54:21 +11:00
|
|
|
|
2024-01-24 22:01:33 +11:00
|
|
|
unsigned long get_now()
|
|
|
|
{
|
|
|
|
struct timeval tv;
|
|
|
|
gettimeofday(&tv, nullptr);
|
|
|
|
return (unsigned long)tv.tv_sec * 1000000 + tv.tv_usec;
|
|
|
|
}
|
|
|
|
|
2024-01-13 15:21:17 +11:00
|
|
|
int main()
|
|
|
|
{
|
2024-01-25 00:35:39 +11:00
|
|
|
std::random_device rd;
|
|
|
|
std::mt19937 rand(rd());
|
|
|
|
|
2024-01-26 00:30:14 +11:00
|
|
|
parts::init();
|
2024-01-21 01:36:21 +11:00
|
|
|
graphics::window::create();
|
2024-01-14 23:44:36 +11:00
|
|
|
|
2024-01-24 22:01:33 +11:00
|
|
|
long clock = get_now();
|
|
|
|
|
2024-01-21 01:36:21 +11:00
|
|
|
while(!graphics::window::should_close())
|
2024-01-13 15:21:17 +11:00
|
|
|
{
|
2024-01-24 22:01:33 +11:00
|
|
|
long now = get_now();
|
|
|
|
long passed = now - clock;
|
|
|
|
double dt = (double)passed / 1e6;
|
|
|
|
clock += passed;
|
2024-01-25 00:52:02 +11:00
|
|
|
|
2024-01-26 00:30:14 +11:00
|
|
|
parts::reactor->update(rand, dt);
|
|
|
|
parts::pump->update(dt);
|
|
|
|
parts::valve->update(dt);
|
|
|
|
parts::vessel->update(dt);
|
2024-01-24 22:01:33 +11:00
|
|
|
|
|
|
|
graphics::camera::update(dt);
|
2024-01-26 00:30:14 +11:00
|
|
|
graphics::window::loop();
|
2024-01-13 15:21:17 +11:00
|
|
|
}
|
|
|
|
|
2024-01-21 01:36:21 +11:00
|
|
|
graphics::window::destroy();
|
2024-01-13 15:21:17 +11:00
|
|
|
}
|
|
|
|
|