first conception of MVN TM temperatures parser was done. It is parse one file wcorrectly

This commit is contained in:
Danila Gamkov 2025-01-27 20:40:29 +03:00
commit 3c4a1f4e60
5 changed files with 68462 additions and 0 deletions

8
.gitignore vendored Normal file
View File

@ -0,0 +1,8 @@
/target
*.asotr*
*.csv
*.png
*.swp
*.zip
*.txt
asotr_csv

7
Cargo.lock generated Normal file
View File

@ -0,0 +1,7 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 4
[[package]]
name = "spinx_tm_sens"
version = "0.1.0"

10
Cargo.toml Normal file
View File

@ -0,0 +1,10 @@
[package]
name = "spinx_tm_sens"
version = "0.1.0"
edition = "2021"
[dependencies]
chrono = "0.4"
clap = "4.*"
lazy_static = {version = "1.5.6", features = ["spin_no_std"]}
walkdir = "2.3.2"

68371
src/data.txt Executable file

File diff suppressed because it is too large Load Diff

66
src/main.rs Normal file
View File

@ -0,0 +1,66 @@
use std::fs::File;
use std::io::{BufRead, BufReader};
use std::collections::HashMap;
#[derive(Debug)]
struct tm_data {
idx: String,
val: f32,
timestamp_s: u64,
date: String,
time: String,
}
impl tm_data {
pub fn new(idx: String, val: f32, timestamp_s: u64, date: String, time: String) -> tm_data {
tm_data { idx, val, timestamp_s, date, time }
}
}
fn main() {
let mut buf_raw_sens: Vec<String> = Vec::new();
let mut data = File::open("data.txt").unwrap();
let mut tm_data_v: [Vec<tm_data>; 4] = [Vec::new(), Vec::new(), Vec::new(), Vec::new()];
let reader = BufReader::new(data);
let buf_all: Vec<String> = reader.lines()
.map(|line| line.expect("error"))
.collect();
let mut tm_idx = Vec::new();
tm_idx.push("T1MBH");
tm_idx.push("T2MBH");
tm_idx.push("T3MBH");
tm_idx.push("T4MBH");
let mut val: Vec<String> = Vec::new();
for elem in buf_all {
for (i, idx) in tm_idx.clone().into_iter().enumerate() {
if elem.contains(idx)
{
val = elem.split_whitespace()
.map(|elem| elem.parse::<String>().unwrap())
.collect();
let temp = tm_data::new(idx.to_string(), val[1].parse::<f32>().unwrap(), 0,
val[4].clone(), val[5].clone());
println!("{:#?}", temp);
tm_data_v[i].push(temp);
buf_raw_sens.push(elem.clone());
}
}
}
let val1: Vec<String> = buf_raw_sens[0]
.split_whitespace()
.map(|elem| elem.parse::<String>().unwrap())
.collect();
println!("{:#?}", tm_data_v[0]);
}