mirror of
https://github.com/cjfranko/NTP-Timeturner.git
synced 2025-11-08 18:32:02 +00:00
Merge pull request #3 from Johnr24/update
double check upload of tested version
This commit is contained in:
commit
aa453c30bc
6 changed files with 2344 additions and 624 deletions
1720
Cargo.lock
generated
Normal file
1720
Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -77,17 +77,6 @@ impl LtcState {
|
|||
match frame.status.as_str() {
|
||||
"LOCK" => {
|
||||
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" => {
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
@ -135,7 +135,7 @@ impl LtcState {
|
|||
&self.last_match_status
|
||||
}
|
||||
}
|
||||
|
||||
// This module provides the logic for handling LTC (Linear Timecode) frames and maintaining state.
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
|
@ -190,7 +190,7 @@ mod tests {
|
|||
assert_eq!(state.lock_count, 0);
|
||||
assert_eq!(state.free_count, 1);
|
||||
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]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue