Add test
This commit is contained in:
@@ -30,10 +30,10 @@ pub mod log_direct {
|
||||
#[macro_export]
|
||||
macro_rules! direct_trace {
|
||||
($fmt:expr) => {
|
||||
eprintln!(concat!("TRACE ", $fmt));
|
||||
eprintln!("TRACE {}", format_args!($fmt));
|
||||
};
|
||||
($fmt:expr, $($arg:expr),*) => {
|
||||
eprintln!(concat!("TRACE ", $fmt), $($arg),*);
|
||||
($fmt:expr, $($arg:tt)*) => {
|
||||
eprintln!("TRACE {}", format_args!($fmt, $($arg)*));
|
||||
};
|
||||
}
|
||||
#[allow(unused)]
|
||||
@@ -41,13 +41,13 @@ pub mod log_direct {
|
||||
macro_rules! direct_debug {
|
||||
($fmt:expr) => {
|
||||
// eprintln!(concat!("DEBUG ", $fmt));
|
||||
// eprintln!("DEBUG {}", format_args!($fmt));
|
||||
eprintln!("{}", format_args!(concat!("DEBUG ", $fmt)));
|
||||
// eprintln!("{}", format_args!(concat!("DEBUG ", $fmt)));
|
||||
eprintln!("DEBUG {}", format_args!($fmt));
|
||||
};
|
||||
($fmt:expr, $($arg:expr),*) => {
|
||||
// eprintln!(concat!("DEBUG ", $fmt), $($arg),*);
|
||||
// eprintln!("DEBUG {}", format_args!($fmt, $($arg),*));
|
||||
eprintln!("{}", format_args!(concat!("DEBUG ", $fmt), $($arg),*));
|
||||
// eprintln!("{}", format_args!(concat!("DEBUG ", $fmt), $($arg),*));
|
||||
eprintln!("DEBUG {}", format_args!($fmt, $($arg),*));
|
||||
};
|
||||
}
|
||||
#[allow(unused)]
|
||||
@@ -64,20 +64,20 @@ pub mod log_direct {
|
||||
#[macro_export]
|
||||
macro_rules! direct_warn {
|
||||
($fmt:expr) => {
|
||||
eprintln!(concat!("WARN ", $fmt));
|
||||
eprintln!("WARN {}", format_args!($fmt));
|
||||
};
|
||||
($fmt:expr, $($arg:expr),*) => {
|
||||
eprintln!(concat!("WARN ", $fmt), $($arg),*);
|
||||
eprintln!("WARN {}", format_args!($fmt, $($arg),*));
|
||||
};
|
||||
}
|
||||
#[allow(unused)]
|
||||
#[macro_export]
|
||||
macro_rules! direct_error {
|
||||
($fmt:expr) => {
|
||||
eprintln!(concat!("ERROR ", $fmt));
|
||||
eprintln!("ERROR {}", format_args!($fmt));
|
||||
};
|
||||
($fmt:expr, $($arg:expr),*) => {
|
||||
eprintln!(concat!("ERROR ", $fmt), $($arg),*);
|
||||
eprintln!("ERROR {}", format_args!($fmt, $($arg),*));
|
||||
};
|
||||
}
|
||||
pub use crate::direct_debug as debug;
|
||||
@@ -106,11 +106,11 @@ pub mod log_macros_branch {
|
||||
#[allow(unused)]
|
||||
#[macro_export]
|
||||
macro_rules! branch_trace {
|
||||
($($arg:expr),*) => {
|
||||
($($arg:tt)*) => {
|
||||
if $crate::is_log_direct() {
|
||||
$crate::log_direct::trace!($($arg),*);
|
||||
$crate::log_direct::trace!($($arg)*);
|
||||
} else {
|
||||
$crate::log_tracing::trace!($($arg),*);
|
||||
$crate::log_tracing::trace!($($arg)*);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -163,5 +163,5 @@ pub mod log_macros_branch {
|
||||
pub use branch_info as info;
|
||||
pub use branch_trace as trace;
|
||||
pub use branch_warn as warn;
|
||||
pub use tracing::{self, event, span, Level};
|
||||
pub use tracing::{self, Level, event, span};
|
||||
}
|
||||
|
||||
@@ -54,6 +54,7 @@ use serde_helper::serde_instant::serde_Instant_elapsed_ms;
|
||||
use series::ChannelStatusSeriesId;
|
||||
use series::SeriesId;
|
||||
use serieswriter::binwriter::BinWriter;
|
||||
use serieswriter::binwriter::DiscardFirstOutput;
|
||||
use serieswriter::fixgridwriter::ChannelStatusSeriesWriter;
|
||||
use serieswriter::fixgridwriter::ChannelStatusWriteState;
|
||||
use serieswriter::msptool::MspSplit;
|
||||
@@ -1504,6 +1505,8 @@ impl CaConn {
|
||||
beg,
|
||||
conf.conf.min_quiets(),
|
||||
conf.conf.is_polled(),
|
||||
serieswriter::binwriter::WriteCntZero::default_for_on_the_fly(),
|
||||
DiscardFirstOutput::default_for_on_the_fly(),
|
||||
st2.channel.cssid,
|
||||
writer.series(),
|
||||
st2.channel.scalar_type.clone(),
|
||||
|
||||
@@ -24,18 +24,18 @@ use series::ChannelStatusSeriesId;
|
||||
use series::SeriesId;
|
||||
use series::msp::PrebinnedPartitioning;
|
||||
|
||||
macro_rules! info { ($($arg:expr),*) => ( if true { log::info!($($arg),*); } ) }
|
||||
macro_rules! info { ($($arg:tt)*) => ( if true { log::info!($($arg)*); } ) }
|
||||
|
||||
macro_rules! debug_init { ($t:expr, $($arg:expr),*) => ( if true { if $t { log::info!($($arg),*); } } ) }
|
||||
macro_rules! debug_bin { ($t:expr, $($arg:expr),*) => ( if true { if $t { log::info!($($arg),*); } } ) }
|
||||
macro_rules! debug_init { ($t:expr, $($arg:tt)*) => ( if false { if $t { log::info!($($arg)*); } } ) }
|
||||
macro_rules! debug_bin { ($t:expr, $($arg:tt)*) => ( if false { if $t { log::info!($($arg)*); } } ) }
|
||||
|
||||
macro_rules! trace_ingest { ($t:expr, $($arg:expr),*) => ( if false { if $t { log::trace!($($arg),*); } } ) }
|
||||
macro_rules! trace_tick { ($t:expr, $($arg:expr),*) => ( if true { if $t { log::info!($($arg),*); } } ) }
|
||||
macro_rules! trace_tick_verbose { ($t:expr, $($arg:expr),*) => ( if false { if $t { log::trace!($($arg),*); } } ) }
|
||||
macro_rules! trace_ingest { ($t:expr, $($arg:tt)*) => ( if false { if $t { log::trace!($($arg)*); } } ) }
|
||||
macro_rules! trace_tick { ($t:expr, $($arg:tt)*) => ( if false { if $t { log::info!($($arg)*); } } ) }
|
||||
macro_rules! trace_tick_verbose { ($t:expr, $($arg:tt)*) => ( if false { if $t { log::trace!($($arg)*); } } ) }
|
||||
|
||||
macro_rules! trace_bin { ($t:expr, $($arg:expr),*) => ( if true { if $t { log::info!($($arg),*); } } ) }
|
||||
macro_rules! trace_bin { ($t:expr, $($arg:tt)*) => ( if false { if $t { log::info!($($arg)*); } } ) }
|
||||
|
||||
macro_rules! debug_rebin_ingest { ($t:expr, $($arg:expr),*) => ( if true { if $t { log::debug!($($arg),*); } } ) }
|
||||
macro_rules! debug_rebin_ingest { ($t:expr, $($arg:tt)*) => ( if false { if $t { log::debug!($($arg)*); } } ) }
|
||||
|
||||
autoerr::create_error_v1!(
|
||||
name(Error, "SerieswriterBinwriter"),
|
||||
@@ -54,8 +54,6 @@ autoerr::create_error_v1!(
|
||||
},
|
||||
);
|
||||
|
||||
const DO_DISCARD_FRONT: bool = true;
|
||||
|
||||
fn bin_len_clamp(dur: DtMs) -> PrebinnedPartitioning {
|
||||
if dur < DtMs::from_ms_u64(1000 * 2) {
|
||||
PrebinnedPartitioning::Sec1
|
||||
@@ -72,17 +70,42 @@ fn bin_len_clamp(dur: DtMs) -> PrebinnedPartitioning {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
enum WriteCntZero {
|
||||
#[derive(Debug, Clone, Copy, Serialize)]
|
||||
pub enum WriteCntZero {
|
||||
Enable,
|
||||
Disable,
|
||||
}
|
||||
|
||||
impl WriteCntZero {
|
||||
pub fn default_for_on_the_fly() -> Self {
|
||||
Self::Disable
|
||||
}
|
||||
|
||||
fn enabled(&self) -> bool {
|
||||
use WriteCntZero::*;
|
||||
match self {
|
||||
WriteCntZero::Enable => true,
|
||||
WriteCntZero::Disable => false,
|
||||
Enable => true,
|
||||
Disable => false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, Serialize)]
|
||||
pub enum DiscardFirstOutput {
|
||||
Enable,
|
||||
Disable,
|
||||
}
|
||||
|
||||
impl DiscardFirstOutput {
|
||||
pub fn default_for_on_the_fly() -> Self {
|
||||
Self::Enable
|
||||
}
|
||||
|
||||
fn enabled(&self) -> bool {
|
||||
use DiscardFirstOutput::*;
|
||||
match self {
|
||||
Enable => true,
|
||||
Disable => false,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -138,6 +161,8 @@ pub struct BinWriter {
|
||||
chname: String,
|
||||
cssid: ChannelStatusSeriesId,
|
||||
sid: SeriesId,
|
||||
emit_znt_zero_default: WriteCntZero,
|
||||
do_discard_front: DiscardFirstOutput,
|
||||
scalar_type: ScalarType,
|
||||
shape: Shape,
|
||||
evbuf: ContainerEvents<f32>,
|
||||
@@ -151,6 +176,8 @@ impl BinWriter {
|
||||
beg: TsNano,
|
||||
min_quiets: MinQuiets,
|
||||
is_polled: bool,
|
||||
emit_znt_zero_default: WriteCntZero,
|
||||
do_discard_front: DiscardFirstOutput,
|
||||
cssid: ChannelStatusSeriesId,
|
||||
sid: SeriesId,
|
||||
scalar_type: ScalarType,
|
||||
@@ -165,7 +192,6 @@ impl BinWriter {
|
||||
const DUR_MAX: DtMs = DtMs::from_ms_u64(1000 * 60 * 60 * 24 * 123);
|
||||
let rts = [RetentionTime::Short, RetentionTime::Medium, RetentionTime::Long];
|
||||
let quiets = [min_quiets.st.clone(), min_quiets.mt.clone(), min_quiets.lt.clone()];
|
||||
let cnt_zero_mode = WriteCntZero::Enable;
|
||||
let mut binner_1st = None;
|
||||
let mut binner_others = Vec::new();
|
||||
let mut has_monitor = None;
|
||||
@@ -178,7 +204,7 @@ impl BinWriter {
|
||||
}
|
||||
})
|
||||
.filter(|x| x.1 > DUR_ZERO && x.1 < DUR_MAX)
|
||||
.map(|x| (x.0, bin_len_clamp(x.1), cnt_zero_mode.clone()))
|
||||
.map(|x| (x.0, bin_len_clamp(x.1), emit_znt_zero_default.clone()))
|
||||
.collect();
|
||||
let has_monitor = has_monitor;
|
||||
debug_init!(trd, "has_monitor {:?} is_polled {:?}", has_monitor, is_polled);
|
||||
@@ -194,27 +220,39 @@ impl BinWriter {
|
||||
combs.push((RetentionTime::Long, PrebinnedPartitioning::Day1, WriteCntZero::Enable));
|
||||
}
|
||||
_ => {
|
||||
combs.push((RetentionTime::Long, PrebinnedPartitioning::Hour1, cnt_zero_mode.clone()));
|
||||
combs.push((
|
||||
RetentionTime::Long,
|
||||
PrebinnedPartitioning::Hour1,
|
||||
emit_znt_zero_default.clone(),
|
||||
));
|
||||
combs.push((RetentionTime::Long, PrebinnedPartitioning::Day1, WriteCntZero::Enable));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
match &has_monitor {
|
||||
Some(RetentionTime::Short) => {
|
||||
combs.push((RetentionTime::Short, PrebinnedPartitioning::Min1, cnt_zero_mode.clone()));
|
||||
combs.push((
|
||||
RetentionTime::Short,
|
||||
PrebinnedPartitioning::Min1,
|
||||
emit_znt_zero_default.clone(),
|
||||
));
|
||||
combs.push((
|
||||
RetentionTime::Medium,
|
||||
PrebinnedPartitioning::Hour1,
|
||||
cnt_zero_mode.clone(),
|
||||
emit_znt_zero_default.clone(),
|
||||
));
|
||||
combs.push((RetentionTime::Long, PrebinnedPartitioning::Day1, WriteCntZero::Enable));
|
||||
}
|
||||
Some(RetentionTime::Medium) => {
|
||||
combs.push((RetentionTime::Short, PrebinnedPartitioning::Min1, cnt_zero_mode.clone()));
|
||||
combs.push((
|
||||
RetentionTime::Short,
|
||||
PrebinnedPartitioning::Min1,
|
||||
emit_znt_zero_default.clone(),
|
||||
));
|
||||
combs.push((
|
||||
RetentionTime::Medium,
|
||||
PrebinnedPartitioning::Hour1,
|
||||
cnt_zero_mode.clone(),
|
||||
emit_znt_zero_default.clone(),
|
||||
));
|
||||
combs.push((RetentionTime::Long, PrebinnedPartitioning::Day1, WriteCntZero::Enable));
|
||||
}
|
||||
@@ -222,9 +260,13 @@ impl BinWriter {
|
||||
combs.push((
|
||||
RetentionTime::Medium,
|
||||
PrebinnedPartitioning::Min1,
|
||||
cnt_zero_mode.clone(),
|
||||
emit_znt_zero_default.clone(),
|
||||
));
|
||||
combs.push((
|
||||
RetentionTime::Long,
|
||||
PrebinnedPartitioning::Hour1,
|
||||
emit_znt_zero_default.clone(),
|
||||
));
|
||||
combs.push((RetentionTime::Long, PrebinnedPartitioning::Hour1, cnt_zero_mode.clone()));
|
||||
combs.push((RetentionTime::Long, PrebinnedPartitioning::Day1, WriteCntZero::Enable));
|
||||
}
|
||||
None => {
|
||||
@@ -295,6 +337,8 @@ impl BinWriter {
|
||||
chname,
|
||||
cssid,
|
||||
sid,
|
||||
emit_znt_zero_default,
|
||||
do_discard_front,
|
||||
scalar_type,
|
||||
shape,
|
||||
evbuf: ContainerEvents::new(),
|
||||
@@ -388,6 +432,7 @@ impl BinWriter {
|
||||
&mut st.index_written_1,
|
||||
&mut st.index_written_2,
|
||||
st.pbp.clone(),
|
||||
self.do_discard_front,
|
||||
&mut st.discard_front,
|
||||
iqdqs,
|
||||
)?;
|
||||
@@ -413,6 +458,7 @@ impl BinWriter {
|
||||
&mut st.index_written_1,
|
||||
&mut st.index_written_2,
|
||||
st.pbp.clone(),
|
||||
self.do_discard_front,
|
||||
&mut st.discard_front,
|
||||
iqdqs,
|
||||
)?;
|
||||
@@ -453,6 +499,7 @@ impl BinWriter {
|
||||
iw1: &mut IndexWritten,
|
||||
iw2: &mut Option<IndexWritten>,
|
||||
pbp: PrebinnedPartitioning,
|
||||
do_discard_front: DiscardFirstOutput,
|
||||
discard_front: &mut u8,
|
||||
iqdqs: &mut InsertDeques,
|
||||
) -> Result<(), Error> {
|
||||
@@ -467,7 +514,7 @@ impl BinWriter {
|
||||
}
|
||||
let bins_len = bins.len();
|
||||
for (ts1, ts2, cnt, min, max, avg, lst, fnl) in bins.zip_iter_2() {
|
||||
info!("cnt {}", cnt);
|
||||
trace_tick!(trd, "cnt {}", cnt);
|
||||
let bin_len = DtMs::from_ms_u64(ts2.delta(ts1).ms_u64());
|
||||
if fnl == false {
|
||||
info!("non final bin {:?}", series);
|
||||
@@ -482,7 +529,7 @@ impl BinWriter {
|
||||
let e = Error::UnexpectedBinLen(bin_len, pbp);
|
||||
return Err(e);
|
||||
}
|
||||
if DO_DISCARD_FRONT && *discard_front < 1 {
|
||||
if do_discard_front.enabled() && *discard_front < 1 {
|
||||
*discard_front += 1;
|
||||
debug_bin!(trd, "handle_output_ready discard_front {:?}", rt);
|
||||
} else {
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
use super::BinWriter;
|
||||
use crate::binwriter::DiscardFirstOutput;
|
||||
use crate::binwriter::WriteCntZero;
|
||||
use crate::rtwriter::MinQuiets;
|
||||
use log::*;
|
||||
use log;
|
||||
use netpod::DtMs;
|
||||
use netpod::ScalarType;
|
||||
use netpod::Shape;
|
||||
@@ -34,10 +36,27 @@ macro_rules! debug_item {
|
||||
};
|
||||
}
|
||||
|
||||
macro_rules! trace_binscol {
|
||||
($($arg:tt)*) => { if false { log::trace!($($arg)*); } };
|
||||
}
|
||||
|
||||
macro_rules! trace_iqdqs {
|
||||
($($arg:tt)*) => { if false { log::trace!($($arg)*); } };
|
||||
}
|
||||
|
||||
macro_rules! error_cmp {
|
||||
($($arg:tt)*) => { if false { log::error!($($arg)*); } };
|
||||
}
|
||||
|
||||
macro_rules! take_par {
|
||||
($fmt:expr, $($args:expr),*) => {};
|
||||
}
|
||||
|
||||
struct BinsExp {
|
||||
pbp: PrebinnedPartitioning,
|
||||
curmsp: MspU32,
|
||||
curlsp: LspU32,
|
||||
cnt_zero_default: WriteCntZero,
|
||||
msp: VecDeque<u32>,
|
||||
lsp: VecDeque<u32>,
|
||||
cnt: VecDeque<Option<u32>>,
|
||||
@@ -46,11 +65,12 @@ struct BinsExp {
|
||||
}
|
||||
|
||||
impl BinsExp {
|
||||
fn new(pbp: PrebinnedPartitioning, msp: MspU32, lsp: LspU32) -> Self {
|
||||
fn new(pbp: PrebinnedPartitioning, msp: MspU32, lsp: LspU32, cnt_zero_default: WriteCntZero) -> Self {
|
||||
Self {
|
||||
pbp,
|
||||
curmsp: msp,
|
||||
curlsp: lsp,
|
||||
cnt_zero_default,
|
||||
msp: def(),
|
||||
lsp: def(),
|
||||
cnt: def(),
|
||||
@@ -69,6 +89,12 @@ impl BinsExp {
|
||||
self.curlsp = l2;
|
||||
}
|
||||
|
||||
fn skip_lsp(&mut self, n: u32) {
|
||||
for _ in 0..n {
|
||||
self.inc_lsp();
|
||||
}
|
||||
}
|
||||
|
||||
fn push_back_dont_care(&mut self) {
|
||||
self.msp.push_back(self.curmsp.0);
|
||||
self.lsp.push_back(self.curlsp.0);
|
||||
@@ -96,6 +122,16 @@ impl BinsExp {
|
||||
self.inc_lsp();
|
||||
}
|
||||
|
||||
fn push_cnt_zero(&mut self, n: u32) {
|
||||
if self.cnt_zero_default.enabled() {
|
||||
for _ in 0..n {
|
||||
self.push_back_dont_care();
|
||||
}
|
||||
} else {
|
||||
self.skip_lsp(n);
|
||||
}
|
||||
}
|
||||
|
||||
fn cmp(&self, bins: &VecDeque<TimeBinSimpleF32V02>) -> Result<(), ()> {
|
||||
let mut bad = false;
|
||||
for i in 0..self.msp.len() {
|
||||
@@ -111,38 +147,38 @@ impl BinsExp {
|
||||
let max = self.max[i];
|
||||
if bin.msp as u32 != msp {
|
||||
bad = true;
|
||||
info!("bad msp {} vs {}", bin.msp, msp);
|
||||
error_cmp!("i {i:3} bad msp {} vs {}", bin.msp, msp);
|
||||
}
|
||||
if bin.off as u32 != lsp {
|
||||
bad = true;
|
||||
info!("bad lsp {} vs {}", bin.off, lsp);
|
||||
error_cmp!("i {i:3} bad lsp {} vs {}", bin.off, lsp);
|
||||
}
|
||||
if let Some(cnt) = cnt {
|
||||
if bin.cnt as u32 != cnt {
|
||||
bad = true;
|
||||
info!("bad cnt {} vs {}", bin.cnt, cnt);
|
||||
error_cmp!("i {i:3} bad cnt {} vs {}", bin.cnt, cnt);
|
||||
}
|
||||
}
|
||||
if let Some(min) = min {
|
||||
if !f32_close(bin.min, min) {
|
||||
bad = true;
|
||||
info!("bad min {:.5e} vs {:.5e}", bin.min, min);
|
||||
error_cmp!("i {i:3} bad min {:.5e} vs {:.5e}", bin.min, min);
|
||||
}
|
||||
}
|
||||
if let Some(max) = max {
|
||||
if !f32_close(bin.max, max) {
|
||||
bad = true;
|
||||
info!("bad max {:.5e} vs {:.5e}", bin.max, max);
|
||||
error_cmp!("i {i:3} bad max {:.5e} vs {:.5e}", bin.max, max);
|
||||
}
|
||||
}
|
||||
}
|
||||
if self.len() > bins.len() {
|
||||
bad = true;
|
||||
info!("expect more bins {} vs {}", self.len(), bins.len());
|
||||
error_cmp!("less bins than expected {} vs {}", bins.len(), self.len());
|
||||
}
|
||||
if self.len() < bins.len() {
|
||||
bad = true;
|
||||
info!("expect less bins {} vs {}", self.len(), bins.len());
|
||||
error_cmp!("more bins than expected {} vs {}", bins.len(), self.len());
|
||||
}
|
||||
if bad { Err(()) } else { Ok(()) }
|
||||
}
|
||||
@@ -176,7 +212,7 @@ fn collect_bin_write_only(qu: &VecDeque<QueryItem>) -> VecDeque<TimeBinSimpleF32
|
||||
|
||||
fn print_binscol(rt: &str, binscol: &VecDeque<TimeBinSimpleF32V02>) {
|
||||
for bin in binscol {
|
||||
debug!(
|
||||
trace_binscol!(
|
||||
"{} bl {:5} msp {:4} off {:4} cnt {:3} min {:7.2} max {:7.2} lst {:7.2}",
|
||||
rt,
|
||||
// min = bin.min,
|
||||
@@ -191,9 +227,8 @@ fn print_binscol(rt: &str, binscol: &VecDeque<TimeBinSimpleF32V02>) {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn binwriter_nest01_00() {
|
||||
let _ = PrebinnedPartitioning::Day1;
|
||||
#[allow(unused)]
|
||||
fn format_check() {
|
||||
let _ = format_args!("");
|
||||
let _ = format_args!(concat!("", ""));
|
||||
debug_item!("plain fmt string");
|
||||
@@ -202,7 +237,17 @@ fn binwriter_nest01_00() {
|
||||
let some_string = "some--string123";
|
||||
debug_item!("param interpolated: {some_string:?}");
|
||||
debug_item!("param interpolated: {some_string}");
|
||||
let beg = TsNano::from_ms(1000 * 40);
|
||||
take_par!("fmtstring {par}", par = 123);
|
||||
log::direct_trace!("fmtstring {par}", par = 123);
|
||||
log::trace!("fmtstring {par}", par = 123);
|
||||
log::trace!("fmtstring {par}", par = 123,);
|
||||
log::trace!("fmtstring {}", 123);
|
||||
log::trace!("fmtstring {}", 123,);
|
||||
}
|
||||
|
||||
fn binwriter_nest01_00_case(cnt_zero_default: WriteCntZero, do_discard_front: DiscardFirstOutput) {
|
||||
let _ = PrebinnedPartitioning::Day1;
|
||||
let beg = TsNano::from_ms(1000 * 20);
|
||||
let min_quiets = MinQuiets::test_1_10_60();
|
||||
let is_polled = false;
|
||||
let cssid = ChannelStatusSeriesId::new(50);
|
||||
@@ -211,7 +256,19 @@ fn binwriter_nest01_00() {
|
||||
let shape = Shape::Scalar;
|
||||
let chname2 = String::from("daqbuftest");
|
||||
let mut iqdqs = InsertDeques::new();
|
||||
let mut binwriter = BinWriter::new(beg, min_quiets, is_polled, cssid, sid, scalar_type, shape, chname2).unwrap();
|
||||
let mut binwriter = BinWriter::new(
|
||||
beg,
|
||||
min_quiets,
|
||||
is_polled,
|
||||
cnt_zero_default.clone(),
|
||||
do_discard_front,
|
||||
cssid,
|
||||
sid,
|
||||
scalar_type,
|
||||
shape,
|
||||
chname2,
|
||||
)
|
||||
.unwrap();
|
||||
binwriter.ingest(sec(39.9), 2.2, &mut iqdqs).unwrap();
|
||||
binwriter.ingest(sec(40.0), 2., &mut iqdqs).unwrap();
|
||||
binwriter.ingest(sec(40.1), 2., &mut iqdqs).unwrap();
|
||||
@@ -223,16 +280,19 @@ fn binwriter_nest01_00() {
|
||||
// binwriter.ingest(sec(70.0), 2., &mut iqdqs).unwrap();
|
||||
// binwriter.ingest(sec(70.1), 2., &mut iqdqs).unwrap();
|
||||
binwriter.ingest(sec(80.0), 2., &mut iqdqs).unwrap();
|
||||
// TODO signal input done range final
|
||||
binwriter.ingest(sec(120.0), 0., &mut iqdqs).unwrap();
|
||||
binwriter.ingest(sec(121.0), 0., &mut iqdqs).unwrap();
|
||||
binwriter.tick(&mut iqdqs).unwrap();
|
||||
debug!("iqdqs summary {}", iqdqs.summary());
|
||||
trace_iqdqs!("iqdqs summary {}", iqdqs.summary());
|
||||
for x in &iqdqs.st_rf3_qu {
|
||||
debug!("ST {:?}", x);
|
||||
trace_iqdqs!("ST {:?}", x);
|
||||
}
|
||||
for x in &iqdqs.mt_rf3_qu {
|
||||
debug!("MT {:?}", x);
|
||||
trace_iqdqs!("MT {:?}", x);
|
||||
}
|
||||
for x in &iqdqs.lt_rf3_qu {
|
||||
debug!("LT {:?}", x);
|
||||
trace_iqdqs!("LT {:?}", x);
|
||||
}
|
||||
{
|
||||
let rt = "ST";
|
||||
@@ -243,20 +303,53 @@ fn binwriter_nest01_00() {
|
||||
let msp_exp = T0.ms() / pbp.bin_len().ms() / pbp.patch_len() as u64;
|
||||
assert_eq!(x.0 as u64, msp_exp);
|
||||
{
|
||||
let (msp, lsp) = pbp.msp_lsp(sec(40.0).to_ts_ms());
|
||||
let mut exp = BinsExp::new(pbp.clone(), MspU32(msp), LspU32(lsp));
|
||||
let (msp, lsp) = if do_discard_front.enabled() {
|
||||
pbp.msp_lsp(sec(40.0).to_ts_ms())
|
||||
} else {
|
||||
pbp.msp_lsp(sec(39.0).to_ts_ms())
|
||||
};
|
||||
let mut exp = BinsExp::new(pbp.clone(), MspU32(msp), LspU32(lsp), cnt_zero_default);
|
||||
// exp.push_back_cnt(2);
|
||||
exp.push_back_cmm(2, 2.0, 2.0);
|
||||
for _ in 0..9 {
|
||||
exp.push_back_dont_care();
|
||||
if do_discard_front.enabled() {
|
||||
} else {
|
||||
exp.push_back_cnt(1);
|
||||
}
|
||||
exp.push_back_cmm(2, 2.0, 2.0);
|
||||
for _ in 0..9 {
|
||||
exp.push_back_dont_care();
|
||||
if cnt_zero_default.enabled() {
|
||||
for _ in 0..9 {
|
||||
exp.push_back_dont_care();
|
||||
}
|
||||
} else {
|
||||
exp.skip_lsp(9);
|
||||
}
|
||||
for _ in 0..20 {
|
||||
exp.push_back_dont_care();
|
||||
exp.push_back_cmm(2, 2.0, 2.0);
|
||||
exp.push_back_cmm(2, 2.0, 2.0);
|
||||
// if cnt_zero_default.enabled() {
|
||||
// for _ in 0..8 {
|
||||
// exp.push_back_dont_care();
|
||||
// }
|
||||
// } else {
|
||||
// exp.skip_lsp(8);
|
||||
// }
|
||||
exp.push_cnt_zero(8);
|
||||
exp.push_back_cmm(1, 2.0, 2.0);
|
||||
if cnt_zero_default.enabled() {
|
||||
for _ in 0..19 {
|
||||
exp.push_back_dont_care();
|
||||
}
|
||||
} else {
|
||||
exp.skip_lsp(19);
|
||||
}
|
||||
exp.push_back_cmm(1, 2.0, 2.0);
|
||||
if cnt_zero_default.enabled() {
|
||||
for _ in 0..39 {
|
||||
exp.push_back_dont_care();
|
||||
}
|
||||
} else {
|
||||
exp.skip_lsp(39);
|
||||
}
|
||||
assert_eq!(exp.curlsp.0, 120);
|
||||
exp.push_back_cmm(1, 0., 0.);
|
||||
exp.cmp(&binscol).unwrap();
|
||||
}
|
||||
}
|
||||
@@ -268,6 +361,38 @@ fn binwriter_nest01_00() {
|
||||
let x = pbp.msp_lsp(T0);
|
||||
let msp_exp = T0.ms() / pbp.bin_len().ms() / pbp.patch_len() as u64;
|
||||
assert_eq!(x.0 as u64, msp_exp);
|
||||
{
|
||||
let (msp, lsp) = if do_discard_front.enabled() {
|
||||
pbp.msp_lsp(sec(40.0).to_ts_ms())
|
||||
} else {
|
||||
pbp.msp_lsp(sec(30.0).to_ts_ms())
|
||||
};
|
||||
let mut exp = BinsExp::new(pbp.clone(), MspU32(msp), LspU32(lsp), cnt_zero_default);
|
||||
if do_discard_front.enabled() {
|
||||
} else {
|
||||
exp.push_back_cmm(1, 2.2, 2.2);
|
||||
}
|
||||
exp.push_back_cmm(2, 2.0, 2.0);
|
||||
exp.push_back_cmm(4, 2.0, 2.0);
|
||||
// assert 60s
|
||||
assert_eq!(exp.curlsp.0, 6);
|
||||
exp.push_back_cmm(1, 2.0, 2.0);
|
||||
if cnt_zero_default.enabled() {
|
||||
exp.push_back_cmm(0, 2.0, 2.0);
|
||||
} else {
|
||||
exp.skip_lsp(1);
|
||||
}
|
||||
assert_eq!(exp.curlsp.0, 8);
|
||||
exp.push_back_cmm(1, 2.0, 2.0);
|
||||
if cnt_zero_default.enabled() {
|
||||
exp.push_back_cmm(0, 2.0, 2.0);
|
||||
exp.push_back_cmm(0, 2.0, 2.0);
|
||||
exp.push_back_cmm(0, 2.0, 2.0);
|
||||
} else {
|
||||
exp.skip_lsp(3);
|
||||
}
|
||||
exp.cmp(&binscol).unwrap();
|
||||
}
|
||||
}
|
||||
{
|
||||
let rt = "LT";
|
||||
@@ -278,12 +403,24 @@ fn binwriter_nest01_00() {
|
||||
let msp_exp = T0.ms() / pbp.bin_len().ms() / pbp.patch_len() as u64;
|
||||
assert_eq!(x.0 as u64, msp_exp);
|
||||
}
|
||||
{
|
||||
let pbp = PrebinnedPartitioning::Sec10;
|
||||
debug!(
|
||||
"expect MT msp at T0 {}",
|
||||
T0.ms() / pbp.bin_len().ms() / pbp.patch_len() as u64
|
||||
);
|
||||
}
|
||||
log_v2_trace!("ARG-1 {}", 42);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn binwriter_nest01_00_ed() {
|
||||
binwriter_nest01_00_case(WriteCntZero::Enable, DiscardFirstOutput::Disable);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn binwriter_nest01_00_ee() {
|
||||
binwriter_nest01_00_case(WriteCntZero::Enable, DiscardFirstOutput::Enable);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn binwriter_nest01_00_dd() {
|
||||
binwriter_nest01_00_case(WriteCntZero::Disable, DiscardFirstOutput::Disable);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn binwriter_nest01_00_de() {
|
||||
binwriter_nest01_00_case(WriteCntZero::Disable, DiscardFirstOutput::Enable);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user