Merge pull request #3 from Johnr24/update

double check upload of tested version
This commit is contained in:
Chaos Rogers 2025-07-19 15:52:21 +01:00 committed by GitHub
commit aa453c30bc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 2344 additions and 624 deletions

1720
Cargo.lock generated Normal file

File diff suppressed because it is too large Load diff

View file

@ -77,17 +77,6 @@ impl LtcState {
match frame.status.as_str() { match frame.status.as_str() {
"LOCK" => { "LOCK" => {
self.lock_count += 1; self.lock_count += 1;
// Every 5 seconds, recompute whether HH:MM:SS matches local time
let now_secs = Utc::now().timestamp();
if now_secs - self.last_match_check >= 5 {
self.last_match_status = if frame.matches_system_time() {
"IN SYNC".into()
} else {
"OUT OF SYNC".into()
};
self.last_match_check = now_secs;
}
} }
"FREE" => { "FREE" => {
self.free_count += 1; self.free_count += 1;
@ -97,6 +86,17 @@ impl LtcState {
_ => {} _ => {}
} }
// Every 5 seconds, recompute whether HH:MM:SS matches local time
let now_secs = Utc::now().timestamp();
if now_secs - self.last_match_check >= 5 {
self.last_match_status = if frame.matches_system_time() {
"IN SYNC".into()
} else {
"OUT OF SYNC".into()
};
self.last_match_check = now_secs;
}
self.latest = Some(frame); self.latest = Some(frame);
} }
@ -135,7 +135,7 @@ impl LtcState {
&self.last_match_status &self.last_match_status
} }
} }
// This module provides the logic for handling LTC (Linear Timecode) frames and maintaining state.
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
@ -190,7 +190,7 @@ mod tests {
assert_eq!(state.lock_count, 0); assert_eq!(state.lock_count, 0);
assert_eq!(state.free_count, 1); assert_eq!(state.free_count, 1);
assert!(state.offset_history.is_empty()); // Offsets should be cleared assert!(state.offset_history.is_empty()); // Offsets should be cleared
assert_eq!(state.last_match_status, "UNKNOWN"); assert_eq!(state.last_match_status, "OUT OF SYNC");
} }
#[test] #[test]