Simplify filter
This commit is contained in:
@@ -118,9 +118,15 @@ pub const DATETIME_FMT_9MS: &str = "%Y-%m-%dT%H:%M:%S.%9fZ";
|
||||
const TEST_BACKEND: &str = "testbackend-00";
|
||||
|
||||
#[allow(non_upper_case_globals)]
|
||||
pub const trigger: [&'static str; 1] = [
|
||||
pub const trigger: [&'static str; 2] = [
|
||||
//
|
||||
"S30CB05-VMCP-A010:PRESSURE",
|
||||
"ATSRF-CAV:TUN-DETUNING-REL-ACT",
|
||||
];
|
||||
|
||||
pub const TRACE_SERIES_ID: [u64; 1] = [
|
||||
//
|
||||
4985969403507503043,
|
||||
];
|
||||
|
||||
pub struct OnDrop<F>
|
||||
@@ -1784,8 +1790,8 @@ impl TsNano {
|
||||
Self(ns)
|
||||
}
|
||||
|
||||
pub const fn from_ms(ns: u64) -> Self {
|
||||
Self(1000000 * ns)
|
||||
pub const fn from_ms(ms: u64) -> Self {
|
||||
Self(1000000 * ms)
|
||||
}
|
||||
|
||||
pub const fn ns(&self) -> u64 {
|
||||
@@ -1829,6 +1835,10 @@ impl TsNano {
|
||||
let x = tsunix.as_secs() * 1000000000 + tsunix.subsec_nanos() as u64;
|
||||
Self::from_ns(x)
|
||||
}
|
||||
|
||||
pub fn fmt(&self) -> TsNanoFmt {
|
||||
TsNanoFmt { ts: self.clone() }
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Debug for TsNano {
|
||||
@@ -1853,6 +1863,25 @@ impl fmt::Display for TsNano {
|
||||
}
|
||||
}
|
||||
|
||||
pub struct TsNanoFmt {
|
||||
ts: TsNano,
|
||||
}
|
||||
|
||||
impl fmt::Display for TsNanoFmt {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
chrono::DateTime::from_timestamp_millis(self.ts.ms() as i64)
|
||||
.unwrap()
|
||||
.format(DATETIME_FMT_3MS)
|
||||
.fmt(fmt)
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Debug for TsNanoFmt {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
fmt::Display::fmt(self, fmt)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, PartialOrd)]
|
||||
pub struct PulseId(u64);
|
||||
|
||||
@@ -2677,6 +2706,20 @@ impl TsMs {
|
||||
let lsp = DtMs(self.0 - msp.0);
|
||||
(msp, lsp)
|
||||
}
|
||||
|
||||
pub fn bump_epsilon(&self) -> TsMs {
|
||||
Self(self.0 + 1)
|
||||
}
|
||||
|
||||
pub fn fmt(&self) -> TsMsFmt {
|
||||
TsMsFmt { ts: self.clone() }
|
||||
}
|
||||
}
|
||||
|
||||
impl AsRef<TsMs> for TsMs {
|
||||
fn as_ref(&self) -> &TsMs {
|
||||
&self
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for TsMs {
|
||||
@@ -2693,6 +2736,45 @@ impl core::ops::Sub for TsMs {
|
||||
}
|
||||
}
|
||||
|
||||
pub struct TsMsFmt {
|
||||
ts: TsMs,
|
||||
}
|
||||
|
||||
impl fmt::Debug for TsMsFmt {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
chrono::DateTime::from_timestamp_millis(self.ts.ms() as i64)
|
||||
.unwrap()
|
||||
.format(DATETIME_FMT_3MS)
|
||||
.fmt(fmt)
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for TsMsFmt {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
chrono::DateTime::from_timestamp_millis(self.ts.ms() as i64)
|
||||
.unwrap()
|
||||
.format(DATETIME_FMT_3MS)
|
||||
.fmt(fmt)
|
||||
}
|
||||
}
|
||||
|
||||
pub struct TsMsVecFmt<I>(pub I);
|
||||
|
||||
impl<I, T> fmt::Display for TsMsVecFmt<I>
|
||||
where
|
||||
I: Clone + IntoIterator<Item = T>,
|
||||
T: AsRef<TsMs>,
|
||||
{
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(fmt, "[")?;
|
||||
for ts in self.0.clone().into_iter() {
|
||||
write!(fmt, " {}", ts.as_ref().fmt())?;
|
||||
}
|
||||
write!(fmt, " ]")?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
pub trait RetStreamExt: Stream {
|
||||
fn only_first_error(self) -> OnlyFirstError<Self>
|
||||
where
|
||||
|
||||
@@ -29,11 +29,15 @@ pub struct NanoRange {
|
||||
}
|
||||
|
||||
impl fmt::Debug for NanoRange {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
if true {
|
||||
let beg = TsNano(self.beg);
|
||||
let end = TsNano(self.end);
|
||||
f.debug_struct("NanoRange")
|
||||
write!(fmt, "NanoRange {{ beg: {}, end: {} }}", beg.fmt(), end.fmt())
|
||||
} else if false {
|
||||
let beg = TsNano(self.beg);
|
||||
let end = TsNano(self.end);
|
||||
fmt.debug_struct("NanoRange")
|
||||
.field("beg", &beg)
|
||||
.field("end", &end)
|
||||
.finish()
|
||||
@@ -45,9 +49,9 @@ impl fmt::Debug for NanoRange {
|
||||
.timestamp_opt((self.end / SEC) as i64, (self.end % SEC) as u32)
|
||||
.earliest();
|
||||
if let (Some(a), Some(b)) = (beg, end) {
|
||||
f.debug_struct("NanoRange").field("beg", &a).field("end", &b).finish()
|
||||
fmt.debug_struct("NanoRange").field("beg", &a).field("end", &b).finish()
|
||||
} else {
|
||||
f.debug_struct("NanoRange")
|
||||
fmt.debug_struct("NanoRange")
|
||||
.field("beg", &beg)
|
||||
.field("end", &end)
|
||||
.finish()
|
||||
|
||||
Reference in New Issue
Block a user