init commit

This commit is contained in:
Nicholas Orlowsky 2025-03-20 14:34:38 -04:00
commit e37e4b4d54
No known key found for this signature in database
GPG key ID: A9F3BA4C0AA7A70B
10 changed files with 3072 additions and 0 deletions

View file

@ -0,0 +1,110 @@
use serde::{Serialize, Deserialize};
#[derive(Debug,Serialize,Deserialize,PartialEq,Clone)]
pub struct SpeedEvent {
pub speed: u32
}
#[derive(Debug,Serialize,Deserialize,PartialEq,Clone)]
pub struct GPSSpeedEvent {
pub speed: u32
}
#[derive(Debug,Serialize,Deserialize,PartialEq,Clone)]
pub struct RPMEvent {
pub rpm: u32
}
#[derive(Debug,Serialize,Deserialize,PartialEq,Clone)]
pub struct FuelLevelEvent {
pub level_pct: f32
}
#[derive(Debug,Serialize,Deserialize,PartialEq,Clone)]
pub struct GPSLocationEvent {
pub lat: f64,
pub lng: f64
}
#[derive(Debug,Serialize,Deserialize,PartialEq,Clone)]
pub struct ThrottleEvent {
pub throttle_pct: f32
}
#[derive(Debug,Serialize,Deserialize,PartialEq,Clone)]
pub enum AutoEventType {
Speed(SpeedEvent),
RPM(RPMEvent),
FuelLevel(FuelLevelEvent),
GPSLocation(GPSLocationEvent),
Throttle(ThrottleEvent),
GPSSpeed(GPSSpeedEvent)
}
#[derive(Debug,Serialize,Deserialize,PartialEq,Clone)]
pub struct AutoEvent {
pub content: Vec<AutoEventType>,
pub timestamp: i64
}
impl RPMEvent {
pub fn new(rpm: u32) -> AutoEventType {
return AutoEventType::RPM(
RPMEvent {
rpm
}
);
}
}
impl ThrottleEvent {
pub fn new(throttle_pct: f32) -> AutoEventType {
return AutoEventType::Throttle(
ThrottleEvent {
throttle_pct
}
);
}
}
impl SpeedEvent {
pub fn new(speed: u32) -> AutoEventType {
return AutoEventType::Speed(
SpeedEvent {
speed
}
);
}
}
impl GPSSpeedEvent {
pub fn new(speed: u32) -> AutoEventType {
return AutoEventType::GPSSpeed(
GPSSpeedEvent {
speed
}
);
}
}
impl FuelLevelEvent {
pub fn new(level_pct: f32) -> AutoEventType {
return AutoEventType::FuelLevel(
FuelLevelEvent {
level_pct
}
);
}
}
impl GPSLocationEvent {
pub fn new(lat: f64, lng: f64) -> AutoEventType {
return AutoEventType::GPSLocation(
GPSLocationEvent {
lat,
lng
}
);
}
}

2
src/auto_events/mod.rs Normal file
View file

@ -0,0 +1,2 @@
pub mod auto_events;
pub use auto_events::*;