From e07bb7c4a181ae19d934bb5e02cc4e2e990f0994 Mon Sep 17 00:00:00 2001 From: Thomas Faour Date: Thu, 19 Jun 2025 11:09:32 -0400 Subject: [PATCH] added logging, and started simulator struct --- Cargo.toml | 2 ++ src/config.rs | 10 +++++----- src/main.rs | 23 +++++++++++++++++++---- src/simulator.rs | 23 +++++++++++++++++++++++ 4 files changed, 49 insertions(+), 9 deletions(-) create mode 100644 src/simulator.rs diff --git a/Cargo.toml b/Cargo.toml index 55f0a64..c85be0c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,5 +8,7 @@ authors = ["thomas"] [dependencies] clap = { version = "4.5.39", features = ["derive"] } +env_logger = "0.11.8" +log = "0.4.27" serde = { version = "1.0.219", features = ["derive"] } serde_json = "1.0.140" diff --git a/src/config.rs b/src/config.rs index a244c5c..92c784d 100644 --- a/src/config.rs +++ b/src/config.rs @@ -3,13 +3,13 @@ use serde::Deserialize; #[derive(Debug, Deserialize)] pub struct Body { - name: String, - mass: types::Mass, - position: types::Position, - velocity: types::Velocity, + pub name: String, + pub mass: types::Mass, + pub position: types::Position, + pub velocity: types::Velocity, } #[derive(Debug, Deserialize)] pub struct ConfigFile { - bodies: Vec, + pub bodies: Vec, } \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 6de29c8..6f065cb 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,13 +1,20 @@ -use clap::Parser; - +// Standard library use std::error::Error; use std::fs::File; use std::io::BufReader; use std::path::Path; +// External crates +use clap::Parser; +use log::{info, warn, error, debug, trace}; +// Internal modules mod types; mod config; +mod simulator; + +// Specific uses from modules +use crate::simulator::Simulator; #[derive(Parser, Debug)] #[command( @@ -37,10 +44,18 @@ fn read_config>(path: P) -> Result, + step_size: f32, +} + +impl Simulator { + pub fn new(bodies: Vec, step_size: f32) -> Self{ + Self {bodies, step_size} + } + + pub fn run(&mut self, steps: usize){ + for i in 0..steps { + debug!("Step: {}", i); + // for b in &self.bodies { + // println!("Body: {}", b.name); + // } + } + } +} \ No newline at end of file