init commit
This commit is contained in:
commit
e37e4b4d54
10 changed files with 3072 additions and 0 deletions
110
src/auto_events/auto_events.rs
Normal file
110
src/auto_events/auto_events.rs
Normal 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
2
src/auto_events/mod.rs
Normal file
|
@ -0,0 +1,2 @@
|
|||
pub mod auto_events;
|
||||
pub use auto_events::*;
|
Loading…
Add table
Add a link
Reference in a new issue