from src.OptAlgorithm.AutoConfigClass import AutoConfigClass
from numpy import sqrt

class ConstantCalculator(AutoConfigClass):
    
    params_list = []
    def __init__(self, operator_config : dict, system_config : dict):
        
        super().__init__(ConstantCalculator.params_list, operator_config, system_config)
        
        for param, value in self.__dict__.items():
            if value is int and value < 0:
                raise Exception("""Недопустимое значение параметра {param} < 0""")
        
    def calc(self):
        constants = {}
        #self.smin1t = self.smin1 - self.dblock / 2
        #self.smin2t = self.smin2 - self.dblock / 2
        constants["Fprop"] = self.k_prop * self.force_target
        constants["freq"] = sqrt(self.k_hardness_1 / self.mass_1)
        constants["eff_control"] = self.torque_max_1 / self.transmission_ratio_1
        constants["Ftogrow"] = self.force_target * (1 - self.k_prop)
        constants["Fstart_prop"] = 3 * self.force_target / 2 - 1/2 * sqrt(self.force_target*self.force_target + 16  * self.force_target * constants["Fprop"] - 8 * constants["Fprop"]**2)
        return constants