from datetime import datetime
import helics as h
from dots_infrastructure.DataClasses import TimeStepInformation, EsdlId, HelicsCalculationInformation, PublicationDescription, SubscriptionDescription
from dots_infrastructure.HelicsFederateHelpers import HelicsSimulationExecutor
from esdl import EnergySystem

# This file is generated, DO NOT edit this file!

class {{name}}(HelicsSimulationExecutor):

    def __init__(self):
        super().__init__()

        {% for calculation in calculations %}
        # Calculation: {{calculation.calculation_function_name}}
        {{calculation.calculation_function_name}}_inputs = [
        {% for input in calculation.inputs %}
            SubscriptionDescription(esdl_type="{{input.esdl_type}}", 
                                    input_name="{{input.python_name}}", 
                                    input_unit="{{input.unit}}", 
                                    input_type=h.HelicsDataType.{{input.data_type}}),

        {%- endfor %}
        ]
        {{calculation.calculation_function_name}}_outputs = [
        {% for output in calculation.outputs %}
            PublicationDescription(global_flag=True, 
                                    esdl_type="{{esdl_type}}",
                                    output_name="{{output.python_name}}",
                                    output_unit="{{output.unit}}", 
                                    output_type="{{output.data_type}}"),

        {%- endfor %}
        ]
        {{calculation.calculation_function_name}}_information = HelicsCalculationInformation(
            time_period_in_seconds={{calculation.time_period_in_seconds}},
            offset={{calculation.offset_in_seconds}}, 
            uninterruptible=False, 
            wait_for_current_time_update=False, 
            terminate_on_error=True, 
            calculation_name="{{calculation.calculation_function_name}}", 
            inputs={{calculation.calculation_function_name}}_inputs, 
            outputs={{calculation.calculation_function_name}}_outputs, 
            calculation_function=self.{{calculation.calculation_function_name}}
        )
        self.add_calculation({{calculation.calculation_function_name}}_information)

        {%- endfor %}

    {% for calculation in calculations %}
    def {{calculation.calculation_function_name}}(self, param_dict : dict, simulation_time : datetime, time_step_number : TimeStepInformation, esdl_id : EsdlId, energy_system : EnergySystem):
        pass
    {% endfor %}
