DSatishchandra's picture
Create scheduler.py
9fe99ef verified
raw
history blame contribute delete
744 Bytes
from datetime import datetime, timedelta
import pandas as pd
from modules.simulator import simulate_data
class DataScheduler:
def __init__(self):
self.last_update = datetime.now() - timedelta(hours=7) # Force initial update
self.data = None
def get_latest_data(self, num_poles, faults):
current_time = datetime.now()
# Update data every 6 hours
if current_time >= self.last_update + timedelta(hours=6):
self.data = simulate_data(num_poles, faults)
self.last_update = current_time
return self.data, self.last_update
# Singleton instance
scheduler = DataScheduler()
def get_latest_data(num_poles, faults):
return scheduler.get_latest_data(num_poles, faults)