from django.db import models
from paredes.models import Parede
from vidros.models import Vidro
from portas.models import Porta
from telhados.models import Telhado
from termicos.models import DadosTermicos
from projeto.models import Projeto

class Ambiente(models.Model):
    nome_ambiente = models.CharField(max_length=100)
    projeto = models.ForeignKey(Projeto, on_delete=models.CASCADE, related_name='ambientes')

    # Relacionamentos opcionais com outros modelos
    parede = models.OneToOneField(Parede, on_delete=models.CASCADE, null=True, blank=True, related_name='parede_ambiente_n')
    vidro = models.OneToOneField(Vidro, on_delete=models.CASCADE, null=True, blank=True, related_name='vidro_ambiente_n')
    porta = models.OneToOneField(Porta, on_delete=models.CASCADE, null=True, blank=True, related_name='porta_ambiente_n')
    telhado = models.OneToOneField(Telhado, on_delete=models.CASCADE, null=True, blank=True, related_name='telhado_ambiente_n')
    dados_termicos = models.OneToOneField(DadosTermicos, on_delete=models.CASCADE, null=True, blank=True, related_name='dados_termicos_ambiente_n')
    tipo_aparelho = models.CharField(max_length=20, choices=[
        ("hiwall", "Hi-Wall"),
        ("tipoduto", "Tipo Duto"),
        ("cassete4vias", "Cassete 4 Vias"),
    ], default="hiwall")
    # Campo para armazenar a carga térmica total
    carga_termica_total_ambiente = models.FloatField(null=True, blank=True)
    equipamento_existente = models.BooleanField(default=False)
    modelo_aparelho = models.CharField(max_length=100, null=True, blank=True)
    modelo_aparelho = models.CharField(max_length=100, blank=True, null=True)
    capacidade_resfriamento_btu = models.CharField(max_length=50, blank=True, null=True)
    capacidade_aquecimento_btu = models.CharField(max_length=50, blank=True, null=True)
    fonte_alimentacao = models.CharField(max_length=100, blank=True, null=True)
    tubulacao_refrigerante_liquido_gas_mm = models.CharField(max_length=50, blank=True, null=True)
    potencia_motor_w = models.CharField(max_length=50, blank=True, null=True)

    
    def __str__(self):
        return self.nome_ambiente
