Public Class CCo2발생량OD
    Public Mon As String
    Private ErrMsg As String = "에너지소요량 계산되지 않았습니다"
    Private MIdx As Integer
    Public Sub New(Optional ByVal pmIdx As Integer = 0)
        MIdx = pmIdx
        Mon = "M" & Format(MIdx, "00")
    End Sub
    ReadOnly Property 발생량() As Decimal
        Get
            If MIdx = 0 Then   '//최종합계는 저람량을 제하지않는다?
                Return Me.난방발생량 + Me.냉방발생량 + Me.급탕발생량 + Me.조명발생량 + Me.환기발생량
            Else
                Return Me.난방발생량 + Me.냉방발생량 + Me.급탕발생량 + Me.조명발생량 + Me.환기발생량 - Me.저감량태양광 - Me.저감량열병합
            End If
        End Get
    End Property
    ReadOnly Property 단위면적() As Decimal
        Get '//월구분없음 실제로는 최종합 M00 에만 값이 있다.
            Return Me.난방면적 + Me.냉방면적 + Me.급탕면적 + Me.조명면적 + Me.환기면적
        End Get
    End Property

#Region "난방"
    ReadOnly Property 난방발생량() As Decimal
        Get
            If MIdx = 0 Then
                Dim R As Decimal = Me.난방등유 + Me.난방LNG + Me.난방LPG + Me.난방지역 + Me.난방전력
                Return R - (Me.저감량열병합 + Me.저감량태양광) / (Me.난방전력 + Me.냉방전력 + Me.조명전력 + Me.환기전력 + Me.급탕전력) * Me.난방전력
            Else
                Return Me.난방등유 + Me.난방LNG + Me.난방LPG + Me.난방지역 + Me.난방전력
            End If
        End Get
    End Property
    ReadOnly Property 난방등유() As Decimal
        Get
            If Me.MIdx = 0 Then
                Dim Res As Decimal = 0
                For i As Short = 1 To 12
                    Res += Result1o.Co2발생량(i).난방등유
                Next
                Return Res
            Else
                Return Result1o.일차E소요량(MIdx).난방등유 * Result1o.Co2배출계수.등유
            End If
        End Get
    End Property
    ReadOnly Property 난방LNG() As Decimal
        Get
            If Me.MIdx = 0 Then
                Dim Res As Decimal = 0
                For i As Short = 1 To 12
                    Res += Result1o.Co2발생량(i).난방LNG
                Next
                Return Res
            Else
                Return Result1o.일차E소요량(MIdx).난방LNG * Result1o.Co2배출계수.LNG
            End If
        End Get
    End Property
    ReadOnly Property 난방LPG() As Decimal
        Get
            If Me.MIdx = 0 Then
                Dim Res As Decimal = 0
                For i As Short = 1 To 12
                    Res += Result1o.Co2발생량(i).난방LPG
                Next
                Return Res
            Else
                Return Result1o.일차E소요량(MIdx).난방LPG * Result1o.Co2배출계수.LPG
            End If
        End Get
    End Property
    ReadOnly Property 난방지역() As Decimal
        Get
            If Me.MIdx = 0 Then
                Dim Res As Decimal = 0
                For i As Short = 1 To 12
                    Res += Result1o.Co2발생량(i).난방지역
                Next
                Return Res
            Else
                Return Result1o.일차E소요량(MIdx).난방지역 * Result1o.Co2배출계수.지역난방
            End If
        End Get
    End Property
    ReadOnly Property 난방전력() As Decimal
        Get
            If Me.MIdx = 0 Then
                Dim Res As Decimal = 0
                For i As Short = 1 To 12
                    Res += Result1o.Co2발생량(i).난방전력
                Next
                Return Res
            Else
                Return Result1o.일차E소요량(MIdx).난방전력 * Result1o.Co2배출계수.전력
            End If
        End Get
    End Property
    'ReadOnly Property 난방펠렛() As Decimal
    '    Get
    '        If Me.MIdx = 0 Then
    '            Dim Res As Decimal = 0
    '            For i As Short = 1 To 12
    '                Res += Result1o.Co2발생량(i).난방펠렛
    '            Next
    '            Return Res
    '        Else
    '            Return Result1o.일차E소요량(MIdx).난방펠렛 * Result1o.Co2배출계수.펠렛
    '        End If
    '    End Get
    'End Property
    ReadOnly Property 난방면적() As Decimal
        Get
            If Result1o.사용면적.H = 0 Then
                Return 0
            Else
                Return Me.난방발생량 / Result1o.사용면적.H
            End If
        End Get
    End Property
#End Region

    ReadOnly Property 냉방발생량() As Decimal
        Get
            Dim R As Decimal = Me.냉방등유 + Me.냉방LNG + Me.냉방LPG + Me.냉방지역난방열 + Me.냉방지역냉방열 + Me.냉방전력
            If MIdx = 0 Then
                Return R - (Me.저감량열병합 + Me.저감량태양광) / (Me.난방전력 + Me.냉방전력 + Me.조명전력 + Me.환기전력 + Me.급탕전력) * Me.냉방전력
            Else
                Return R
            End If
        End Get
    End Property
    ReadOnly Property 냉방등유() As Decimal
        Get
            If Me.MIdx = 0 Then
                Dim Res As Decimal = 0
                For i As Short = 1 To 12
                    Res += Result1o.Co2발생량(i).냉방등유
                Next
                Return Res
            Else
                Return Result1o.일차E소요량(MIdx).냉방등유 * Result1o.Co2배출계수.등유
            End If
        End Get
    End Property
    ReadOnly Property 냉방LNG() As Decimal
        Get
            If Me.MIdx = 0 Then
                Dim Res As Decimal = 0
                For i As Short = 1 To 12
                    Res += Result1o.Co2발생량(i).냉방LNG
                Next
                Return Res
            Else
                Return Result1o.일차E소요량(MIdx).냉방LNG * Result1o.Co2배출계수.LNG
            End If
        End Get
    End Property
    'ReadOnly Property 냉방펠렛() As Decimal
    '    Get
    '        If Me.MIdx = 0 Then
    '            Dim Res As Decimal = 0
    '            For i As Short = 1 To 12
    '                Res += Result1o.Co2발생량(i).냉방펠렛
    '            Next
    '            Return Res
    '        Else
    '            Return Result1o.일차E소요량(MIdx).냉방펠렛 * Result1o.Co2배출계수.펠렛
    '        End If
    '    End Get
    'End Property
    ReadOnly Property 냉방LPG() As Decimal
        Get
            If Me.MIdx = 0 Then
                Dim Res As Decimal = 0
                For i As Short = 1 To 12
                    Res += Result1o.Co2발생량(i).냉방LPG
                Next
                Return Res
            Else
                Return Result1o.일차E소요량(MIdx).냉방LPG * Result1o.Co2배출계수.LPG
            End If
        End Get
    End Property
    ReadOnly Property 냉방지역난방열() As Decimal
        Get
            If Me.MIdx = 0 Then
                Dim Res As Decimal = 0
                For i As Short = 1 To 12
                    Res += Result1o.Co2발생량(i).냉방지역난방열
                Next
                Return Res
            Else
                Return Result1o.일차E소요량(MIdx).냉방지역난방열 * Result1o.Co2배출계수.지역난방
            End If
        End Get
    End Property
    ReadOnly Property 냉방지역냉방열() As Decimal
        Get
            If Me.MIdx = 0 Then
                Dim Res As Decimal = 0
                For i As Short = 1 To 12
                    Res += Result1o.Co2발생량(i).냉방지역냉방열
                Next
                Return Res
            Else
                Return Result1o.일차E소요량(MIdx).냉방지역냉방열 * Result1o.Co2배출계수.지역냉방
            End If
        End Get
    End Property
    ReadOnly Property 냉방전력() As Decimal
        Get
            If Me.MIdx = 0 Then
                Dim Res As Decimal = 0
                For i As Short = 1 To 12
                    Res += Result1o.Co2발생량(i).냉방전력
                Next
                Return Res
            Else
                Return Result1o.일차E소요량(MIdx).냉방전력 * Result1o.Co2배출계수.전력
            End If
        End Get
    End Property
    ReadOnly Property 냉방면적() As Decimal
        Get
            If Result1o.사용면적.C = 0 Then
                Return 0
            Else
                Return Me.냉방발생량 / Result1o.사용면적.C
            End If
        End Get
    End Property

    ReadOnly Property 급탕발생량() As Decimal
        Get
            If MIdx = 0 Then
                Dim R As Decimal = Me.급탕등유 + Me.급탕LNG + Me.급탕LPG + Me.급탕지역 + Me.급탕전력
                Return R - (Me.저감량열병합 + Me.저감량태양광) / (Me.난방전력 + Me.냉방전력 + Me.조명전력 + Me.환기전력 + Me.급탕전력) * Me.급탕전력
            Else
                Return Me.급탕등유 + Me.급탕LNG + Me.급탕LPG + Me.급탕지역 + Me.급탕전력
            End If
        End Get
    End Property
    ReadOnly Property 급탕등유() As Decimal
        Get
            If Me.MIdx = 0 Then
                Dim Res As Decimal = 0
                For i As Short = 1 To 12
                    Res += Result1o.Co2발생량(i).급탕등유
                Next
                Return Res
            Else
                Return Result1o.일차E소요량(MIdx).급탕등유 * Result1o.Co2배출계수.등유
            End If
        End Get
    End Property
    'ReadOnly Property 급탕펠렛() As Decimal
    '    Get
    '        If Me.MIdx = 0 Then
    '            Dim Res As Decimal = 0
    '            For i As Short = 1 To 12
    '                Res += Result1o.Co2발생량(i).급탕펠렛
    '            Next
    '            Return Res
    '        Else
    '            Return Result1o.일차E소요량(MIdx).급탕펠렛 * Result1o.Co2배출계수.펠렛
    '        End If
    '    End Get
    'End Property
    ReadOnly Property 급탕LNG() As Decimal
        Get
            If Me.MIdx = 0 Then
                Dim Res As Decimal = 0
                For i As Short = 1 To 12
                    Res += Result1o.Co2발생량(i).급탕LNG
                Next
                Return Res
            Else
                Return Result1o.일차E소요량(MIdx).급탕LNG * Result1o.Co2배출계수.LNG
            End If
        End Get
    End Property
    ReadOnly Property 급탕LPG() As Decimal
        Get
            If Me.MIdx = 0 Then
                Dim Res As Decimal = 0
                For i As Short = 1 To 12
                    Res += Result1o.Co2발생량(i).급탕LPG
                Next
                Return Res
            Else
                Return Result1o.일차E소요량(MIdx).급탕LPG * Result1o.Co2배출계수.LPG
            End If
        End Get
    End Property
    ReadOnly Property 급탕지역() As Decimal
        Get
            If Me.MIdx = 0 Then
                Dim Res As Decimal = 0
                For i As Short = 1 To 12
                    Res += Result1o.Co2발생량(i).급탕지역
                Next
                Return Res
            Else
                Return Result1o.일차E소요량(MIdx).급탕지역 * Result1o.Co2배출계수.지역난방
            End If
        End Get
    End Property
    ReadOnly Property 급탕전력() As Decimal
        Get
            If Me.MIdx = 0 Then
                Dim Res As Decimal = 0
                For i As Short = 1 To 12
                    Res += Result1o.Co2발생량(i).급탕전력
                Next
                Return Res
            Else
                Return Result1o.일차E소요량(MIdx).급탕전력 * Result1o.Co2배출계수.전력
            End If
        End Get
    End Property
    ReadOnly Property 급탕면적() As Decimal
        Get
            If Result1o.사용면적.W = 0 Then
                Return 0
            Else
                Return Me.급탕발생량 / Result1o.사용면적.W
            End If
        End Get
    End Property

    ReadOnly Property 조명발생량() As Decimal
        Get
            If MIdx = 0 Then
                Dim R As Decimal = Me.조명전력
                Return R - (Me.저감량열병합 + Me.저감량태양광) / (Me.난방전력 + Me.냉방전력 + Me.조명전력 + Me.환기전력 + Me.급탕전력) * Me.조명전력
            Else
                Return Me.조명전력
            End If
        End Get
    End Property
    ReadOnly Property 조명전력() As Decimal
        Get
            If Me.MIdx = 0 Then
                Dim Res As Decimal = 0
                For i As Short = 1 To 12
                    Res += Result1o.Co2발생량(i).조명전력
                Next
                Return Res
            Else
                Return Result1o.일차E소요량(MIdx).조명전력 * Result1o.Co2배출계수.전력
            End If
        End Get
    End Property
    ReadOnly Property 조명면적() As Decimal
        Get
            If Result1o.사용면적.L = 0 Then
                Return 0
            Else
                Return Me.조명발생량 / Result1o.사용면적.L
            End If
        End Get
    End Property

    ReadOnly Property 환기발생량() As Decimal
        Get
            If MIdx = 0 Then
                Dim R As Decimal = Me.환기전력
                Return R - (Me.저감량열병합 + Me.저감량태양광) / (Me.난방전력 + Me.냉방전력 + Me.조명전력 + Me.환기전력 + Me.급탕전력) * Me.환기전력
            Else
                Return Me.환기전력
            End If
        End Get
    End Property
    ReadOnly Property 환기전력() As Decimal
        Get
            If Me.MIdx = 0 Then
                Dim Res As Decimal = 0
                For i As Short = 1 To 12
                    Res += Result1o.Co2발생량(i).환기전력
                Next
                Return Res
            Else
                Return Result1o.일차E소요량(MIdx).환기전력 * Result1o.Co2배출계수.전력
            End If
        End Get
    End Property
    ReadOnly Property 환기면적() As Decimal
        Get
            If Result1o.사용면적.V = 0 Then
                Return 0
            Else
                Return Me.환기발생량 / Result1o.사용면적.V
            End If
        End Get
    End Property

    ReadOnly Property 저감량태양광() As Decimal
        Get
            If Me.MIdx = 0 Then
                Dim Res As Decimal = 0
                For i As Short = 1 To 12
                    Res += Result1o.Co2발생량(i).저감량태양광
                Next
                Return Res
            Else
                Return Result1o.생산E(MIdx).태양광전력생산량 * Result1o.Co2배출계수.전력
            End If
        End Get
    End Property
    ReadOnly Property 저감량열병합() As Decimal
        Get
            If Me.MIdx = 0 Then
                Dim Res As Decimal = 0
                For i As Short = 1 To 12
                    Res += Result1o.Co2발생량(i).저감량열병합
                Next
                Return Res
            Else
                Return Result1o.생산E(MIdx).열병합전력생산량 * Result1o.Co2배출계수.전력
            End If
        End Get
    End Property
End Class
