import pandas as pd
class pv_config:
    def __init__(self, capacity, cost_per_kW, lifetime, loss):
        self.capacity = capacity
        self.cost_per_kW = cost_per_kW
        self.lifetime = lifetime
        self.loss = loss
class ess_config:
    def __init__(self, capacity, cost_per_kW, lifetime, loss, charge_power, discharge_power):
        self.capacity = capacity
        self.cost_per_kW = cost_per_kW
        self.lifetime = lifetime
        self.loss = loss
        self.storage = 0
        self.charge_power = charge_power
        self.discharge_power = discharge_power

class grid_config:
    def __init__(self, capacity, grid_loss, sell_price):
        # self.price_schedule = price_schedule
        self.loss = grid_loss
        self.sell_price = sell_price
        self.capacity = capacity
    
    def get_price_for_time(self, time):
        hour, minute = map(int, time.split(':'))
        total_minutes = hour * 60 + minute
        for _, row in self.price_schedule.iterrows():
            start_hour, start_minute = map(int, row['time_start'].split(':'))
            end_hour, end_minute = map(int, row['time_end'].split(':'))
            start_total_minutes = start_hour * 60 + start_minute
            end_total_minutes = end_hour * 60 + end_minute
            if start_total_minutes <= total_minutes < end_total_minutes:
                return row['price']
        return 0.1  # 默认电价，以防万一没有匹配的时间段
    


    
