Adjust bin partitioning

This commit is contained in:
Dominik Werder
2025-02-26 16:33:04 +01:00
parent f2f8860be9
commit 8c772b208c
2 changed files with 48 additions and 7 deletions
+10
View File
@@ -11,3 +11,13 @@ pub fn dbg_chn(chn: &str) -> bool {
false
}
}
pub fn binwrite2_enable(chn: &str) -> bool {
let chns = [
// "ARS05-RAMP-0230:PLC-COUNT-MON",
// "ARS09-R3HC-0150:TUN1-MOTOR-TEMP",
// "ARS09-R3HC-0150:HOM27-ATT-TEMP",
// "ARIDI-BLM01:LOSS7",
];
chns.contains(&chn)
}
+38 -7
View File
@@ -32,16 +32,35 @@ impl PrebinnedPartitioning {
pub fn msp_div(&self) -> DtMs {
use PrebinnedPartitioning::*;
match self {
Sec1 => DtMs::from_ms_u64(1000 * 60 * 10),
Sec10 => DtMs::from_ms_u64(1000 * 60 * 60 * 2),
Min1 => DtMs::from_ms_u64(1000 * 60 * 60 * 8),
Min10 => DtMs::from_ms_u64(1000 * 60 * 60 * 24 * 4),
Hour1 => DtMs::from_ms_u64(1000 * 60 * 60 * 24 * 28),
Day1 => DtMs::from_ms_u64(1000 * 60 * 60 * 24 * 400),
if true {
match self {
Sec1 => DtMs::from_ms_u64(1000 * 60 * 20),
Sec10 => DtMs::from_ms_u64(1000 * 60 * 60 * 2),
Min1 => DtMs::from_ms_u64(1000 * 60 * 60 * 12),
Min10 => DtMs::from_ms_u64(1000 * 60 * 60 * 24 * 7),
Hour1 => DtMs::from_ms_u64(1000 * 60 * 60 * 24 * 40),
Day1 => DtMs::from_ms_u64(1000 * 60 * 60 * 24 * 800),
}
} else {
match self {
Sec1 => DtMs::from_ms_u64(1000 * 60 * 10),
Sec10 => DtMs::from_ms_u64(1000 * 60 * 60 * 2),
Min1 => DtMs::from_ms_u64(1000 * 60 * 60 * 8),
Min10 => DtMs::from_ms_u64(1000 * 60 * 60 * 24 * 4),
Hour1 => DtMs::from_ms_u64(1000 * 60 * 60 * 24 * 28),
Day1 => DtMs::from_ms_u64(1000 * 60 * 60 * 24 * 400),
}
}
}
pub fn quo_rem(&self, val: DtMs) -> (u64, u32) {
let valms = val.ms();
let divms = self.msp_div().ms();
let quo = valms / divms;
let rem = (valms - divms * quo) / self.bin_len().ms();
(quo, rem as u32)
}
pub fn off_max(&self) -> u32 {
self.msp_div().ms() as u32 / self.bin_len().ms() as u32
}
@@ -49,6 +68,18 @@ impl PrebinnedPartitioning {
pub fn clamp_off(&self, off: u32) -> u32 {
self.off_max().min(off)
}
pub fn uses_index_hour1(&self) -> bool {
use PrebinnedPartitioning::*;
match self {
Sec1 => true,
Sec10 => true,
Min1 => true,
Min10 => false,
Hour1 => false,
Day1 => false,
}
}
}
impl TryFrom<DtMs> for PrebinnedPartitioning {