Initial commit: Dabit Time Manager project

Python-based time management application with UDP discovery,
TCP protocol communication, time sync, and drift monitoring.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
insulee
2026-02-10 11:10:55 +09:00
commit 3c14e1e401
27 changed files with 2240 additions and 0 deletions

View File

@@ -0,0 +1,38 @@
"""전체 컨트롤러 시간 동기화 서비스"""
from concurrent.futures import ThreadPoolExecutor, as_completed
from datetime import datetime
from models.controller import Controller
from network.tcp_protocol import sync_time
def sync_all(
controllers: list[Controller],
max_workers: int = 8,
) -> list[tuple[Controller, bool, str]]:
"""선택된 컨트롤러에 일괄 시간 동기화.
Returns: [(Controller, 성공여부, 메시지), ...]
"""
targets = [c for c in controllers if c.selected]
if not targets:
return []
dt = datetime.now()
results: list[tuple[Controller, bool, str]] = []
with ThreadPoolExecutor(max_workers=max_workers) as executor:
future_map = {
executor.submit(sync_time, c.ip, c.port, dt): c
for c in targets
}
for future in as_completed(future_map):
ctrl = future_map[future]
try:
ok, msg = future.result()
except Exception as e:
ok, msg = False, str(e)
results.append((ctrl, ok, msg))
return results