Skip to content

Commit

Permalink
in progress faults
Browse files Browse the repository at this point in the history
  • Loading branch information
jr1221 committed Dec 20, 2024
1 parent 87b0986 commit 128b451
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 24 deletions.
19 changes: 10 additions & 9 deletions scylla-server/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions scylla-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ axum-extra = { version = "0.9.3", features = ["query"] }
chrono = { version = "0.4.38", features = ["serde"] }
serde_json = "1.0.128"
diesel_migrations = { version = "2.2.0", features = ["postgres"] }
regex = "1.11.1"

[features]
top = ["dep:console-subscriber"]
Expand Down
33 changes: 18 additions & 15 deletions scylla-server/src/socket_handler.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use std::{collections::HashMap, sync::atomic::Ordering, time::Duration};

use chrono::{DateTime, Utc};
use regex::Regex;
use ringbuffer::AllocRingBuffer;
use serde::Serialize;
use socketioxide::SocketIo;
use tokio::sync::broadcast;
Expand Down Expand Up @@ -43,13 +45,13 @@ const TIMERS_TOPICS: &[&str] = &[
"BMS/Charging/Control",
];

// #[derive(Serialize)]
// struct FaultData {
// pub topic: &'static str,
// pub name: String,
// pub occured_at: DateTime<Utc>,
// }
// const FAULT_SOCKET_KEY: &str = "faults";
#[derive(Serialize)]
struct FaultData {
pub topic: &'static str,
pub name: String,
pub occured_at: DateTime<Utc>,
}
const FAULT_SOCKET_KEY: &str = "faults";

pub async fn socket_handler_with_metadata(
cancel_token: CancellationToken,
Expand Down Expand Up @@ -77,10 +79,10 @@ pub async fn socket_handler_with_metadata(
}

// init faults
// let fault_regex: Regex = Regex::new(r"(BMS/Status/F/*|Charger/Box/F_*|MPU/Fault/F_*")
// .expect("Could not compile regex!");
// const FAULT_BINS: &[&str] = &["DTI/Fault/FaultCode"];
// let mut fault_ringbuffer = AllocRingBuffer::<FaultData>::new(25);
let fault_regex: Regex = Regex::new(r"(BMS/Status/F/*|Charger/Box/F_*|MPU/Fault/F_*")
.expect("Could not compile regex!");
const FAULT_BINS: &[&str] = &["DTI/Fault/FaultCode"];
let mut fault_ringbuffer = AllocRingBuffer::<FaultData>::new(25);

loop {
tokio::select! {
Expand All @@ -106,11 +108,12 @@ pub async fn socket_handler_with_metadata(
}
continue;
}
// if fault_regex.is_match(&data.name) {
// fault_ringbuffer.push()
// } else {

// }
if fault_regex.is_match(&data.name) {
//fault_ringbuffer.push()
} else {

}

}
_ = timers_interval.tick() => {
Expand Down

0 comments on commit 128b451

Please sign in to comment.