from src.Functions_General import *
from src.Functions_Energy_Model import *
from src.Functions_Financial_Model import *
from src.Functions_Load_Emulator_and_DSM import *

generate_calendar()
kill_excel_processes()
initialization_users()

# Per adesso tutte le opzioni sono di default, revisione con Luca per adesso necessaria
flag_last_dict = False # if false we create the appliance start time dictionary; if true we import the last one created (default: False)
flag_optDSM = False # if true we simulate the optimized DSM case (default: False)
flag_all_appliance = True # if true we use all appliance for the load profile emulation (default: True)
flag_daily_activation = True # if false we dont'use a daily usage activation for some specified appliances (only washing machine at the moment, default: True)
flag_multi_use = True # if true we activate the possibility to have multiple activations for the selected appliances during the day (default: True)

create_emulated_users(flag_last_dict, flag_optDSM, flag_all_appliance, flag_daily_activation, flag_multi_use)

load_profile_all_users()
simulate_configuration_productivity()
CACER_energy_flows()
create_users_bill()

case_denomination = "Magnano"
CACER_type = "CER" # CER; AUD; AID; NO_CACER
repartition_scheme = "Egualitario" # Egualitario; Prosumer; PNRR; Equitario; Misto CER; Misto AUC; Misto - ESCo; Social Fund; Misto - Social Fund; Misto - Social Fund 2; Misto - Social Fund PA; Misto - PA; CACER
setting_CACER_scenario(case_denomination, CACER_type, repartition_scheme)

CACER_shared_energy()

RID_calculation()
aggregate_CACER_bills()
aggregate_CACER_RID()
FM_initialization()
incentives()
cash_flows_for_all_plants() # plants first...
cash_flows_for_all_users() # ...then users...
aggregate_FM() # ...then configurations!

organize_simulation_results_for_reporting()
save_simulation_results(simulation_name = case_denomination)