|
|
|
|
@ -95,7 +95,7 @@ from .utils import generate_down_periods
|
|
|
|
|
|
|
|
|
|
# return filtered_aggregated_result
|
|
|
|
|
|
|
|
|
|
def get_eaf_timeline(eaf_input: float, oh_session_id: str) -> List[dict]:
|
|
|
|
|
def get_eaf_timeline(eaf_input: float, oh_session_id: str, oh_duration = 8000) -> List[dict]:
|
|
|
|
|
"""
|
|
|
|
|
Generate a timeline of EAF values based on input parameters.
|
|
|
|
|
|
|
|
|
|
@ -112,7 +112,7 @@ def get_eaf_timeline(eaf_input: float, oh_session_id: str) -> List[dict]:
|
|
|
|
|
|
|
|
|
|
# Dummy OH session dates
|
|
|
|
|
oh_session_start = datetime(2024, 1, 1)
|
|
|
|
|
oh_session_end = datetime(2025, 12, 30)
|
|
|
|
|
oh_session_end = oh_session_start + timedelta(hours=oh_duration)
|
|
|
|
|
|
|
|
|
|
# Initialize result set
|
|
|
|
|
results = []
|
|
|
|
|
@ -130,30 +130,51 @@ def get_eaf_timeline(eaf_input: float, oh_session_id: str) -> List[dict]:
|
|
|
|
|
start_date = oh_session_start
|
|
|
|
|
end_date = oh_session_end - timedelta(days=180)
|
|
|
|
|
|
|
|
|
|
total_hours = (end_date - start_date).total_seconds() / 3600
|
|
|
|
|
|
|
|
|
|
# Generate random down periods
|
|
|
|
|
down_periods = generate_down_periods(start_date, end_date, 5, min_duration=21, max_duration=90)
|
|
|
|
|
results = []
|
|
|
|
|
|
|
|
|
|
# Generate down periods for each EAF scenario
|
|
|
|
|
down_periods = {
|
|
|
|
|
'eaf1': generate_down_periods(start_date, end_date, 5, min_duration=1, max_duration=7),
|
|
|
|
|
'eaf2': generate_down_periods(start_date, end_date, 5, min_duration=1, max_duration=7),
|
|
|
|
|
'eaf3': generate_down_periods(start_date, end_date, 5, min_duration=1, max_duration=7),
|
|
|
|
|
'eaf4': generate_down_periods(start_date, end_date, 5, min_duration=1, max_duration=7)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Define EAF values for downtime periods
|
|
|
|
|
eaf_downtime_values = {
|
|
|
|
|
'eaf1': 0.8,
|
|
|
|
|
'eaf2': 0.65,
|
|
|
|
|
'eaf3': 0.35,
|
|
|
|
|
'eaf4': 0
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Generate daily entries
|
|
|
|
|
current_date = start_date
|
|
|
|
|
while current_date <= end_date:
|
|
|
|
|
# Convert date to string format
|
|
|
|
|
date_str = current_date.strftime('%Y-%m-%d')
|
|
|
|
|
|
|
|
|
|
# Set default EAF value to 1 (system up)
|
|
|
|
|
eaf_value = 1.0
|
|
|
|
|
|
|
|
|
|
# Check if current date is in any down period
|
|
|
|
|
for period_start, period_end in down_periods:
|
|
|
|
|
if period_start <= current_date <= period_end:
|
|
|
|
|
eaf_value = 0.8
|
|
|
|
|
current_time = start_date
|
|
|
|
|
while current_time <= end_date:
|
|
|
|
|
time_str = current_time.strftime('%Y-%m-%d %H:00:00')
|
|
|
|
|
|
|
|
|
|
# Initialize dictionary for this hour with default values (system up)
|
|
|
|
|
hourly_entry = {
|
|
|
|
|
'date': time_str,
|
|
|
|
|
'eaf1_value': 1.0,
|
|
|
|
|
'eaf2_value': 0.75,
|
|
|
|
|
'eaf3_value': 0.6,
|
|
|
|
|
'eaf4_value': 0.3
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Check each EAF scenario
|
|
|
|
|
for eaf_key in down_periods:
|
|
|
|
|
# Check if current hour is in any down period for this EAF
|
|
|
|
|
for period_start, period_end in down_periods[eaf_key]:
|
|
|
|
|
if period_start <= current_time <= period_end:
|
|
|
|
|
hourly_entry[f'{eaf_key}_value'] = eaf_downtime_values[eaf_key]
|
|
|
|
|
break
|
|
|
|
|
|
|
|
|
|
# Add entry to timeline
|
|
|
|
|
results.append({
|
|
|
|
|
'date': date_str,
|
|
|
|
|
'eaf_value': eaf_value
|
|
|
|
|
})
|
|
|
|
|
results.append(hourly_entry)
|
|
|
|
|
current_time += timedelta(hours=1)
|
|
|
|
|
|
|
|
|
|
current_date += timedelta(days=1)
|
|
|
|
|
|
|
|
|
|
return results
|
|
|
|
|
|