Public Class CZone

    Public Event PBarSet(ByVal min As Integer, ByVal max As Integer) '//프로그레시브바 초기화
    Public Event Message(ByVal Msg As String)    '//메세지표시
    Public Event PBarVal(ByVal Value As Integer) '//프로그레시브 값설정

    ''' <summary>
    ''' (main)에너지요구량 계산
    ''' </summary>
    ''' <param name="Calc_Use">에너지소요량을 추가로 계산하려면 True 를 입력</param>
    ''' <param name="Log">로그가 입력될 스트링빌더</param>
    ''' <remarks></remarks>
    Public Overridable Function Calc_LoadOfZones() As Boolean
        Dim Title As String = "에너지요구량을 계산합니다"
        RaiseEvent Message(Title & vbCrLf & "잠시만 기다려주세요")
        RaiseEvent PBarSet(0, 100)

        RaiseEvent Message(Title & vbCrLf & "데이터저장소를 확보하는중.")
        'i_count_OpWe As Integer, d_we_month As Integer, Q_h_b_we as decimal,  ==================================2010.2.21 삭제

        Dim t_24 As Integer, f_wind As Integer, t_NA As Integer, t_h_op_d As Integer, i_count_Is As Integer
        Dim Delta_theta_er As Decimal, Delta_theta_i_NA As Decimal, Delta_theta_i_WE As Decimal, theta_i As Decimal, theta_i_h As Decimal, theta_i_c As Decimal, F_f As Decimal, F__F As Decimal, F_W As Decimal, F_S As Decimal, F_V As Decimal, h_r As Decimal, c_p_arhoa As Decimal, e_wind As Decimal, n_50 As Decimal, n_ue As Decimal, n_mech As Decimal, n_inf As Decimal, A_B As Decimal, A_u As Decimal, h_u As Decimal, V As Decimal, V_ue As Decimal
        Dim H_V_inf As Decimal, H_V_mech As Decimal, H_V_ue As Decimal, H_V_z As Decimal, theta_z As Decimal, theta_u As Decimal, H_T_D As Decimal, H_T_iu As Decimal, H_T_iz As Decimal, H_T_s As Decimal, Delta_U_WB As Decimal, H_V_mech_theta As Decimal, theta_i_h_soll As Decimal, theta_i_c_soll As Decimal, theta_V_mech As Decimal ', theta_e_min as decimal, theta_e_max as decimal
        Dim C_wirk As Decimal, tau As Decimal, a As Decimal, a_tb As Decimal, A_beheizt As Decimal, f_we As Decimal, f_NA As Decimal, f_tb As Decimal, Q_h_max As Decimal, theta_i_NA As Decimal, eta_V_mech As Decimal, theta_V_mech_RLT As Decimal
        Dim Q_V_inf_sink As Decimal, Q_V_mech_sink As Decimal, Q_V_z_sink As Decimal, Q_V_sink As Decimal, Q_T_e_sink As Decimal, Q_T_u_sink As Decimal, Q_T_z_sink As Decimal, Q_T_s_sink As Decimal, Q_T_sink As Decimal, Q_S_sink As Decimal, R_se As Decimal, Q_source As Decimal, Q_sink As Decimal, Q_I_source As Decimal
        Dim Q_V_inf_source As Decimal, Q_V_mech_source As Decimal, Q_V_z_source As Decimal, Q_V_source As Decimal, Q_T_e_source As Decimal, Q_T_u_source As Decimal, Q_T_z_source As Decimal, Q_T_s_source As Decimal, Q_T_source As Decimal, Q_S_source As Decimal
        Dim Q_I_source_p As Decimal, Q_I_source_fac As Decimal, Q_I_L As Decimal, Q_l_b As Decimal, Q_w_b As Decimal, gamma As Decimal, eta As Decimal, Q_h_b As Decimal, Q_h_b_op As Decimal, g_TI As Decimal
        Dim V_mech As Decimal
        'Dim d_op_month As Integer, theta_e_month as decimal
        'Dim A_H as decimal, A_C as decimal, A_L as decimal, A_W as decimal, A_V as decimal
        Dim Q_vh_b_op As Decimal
        Dim g_blinds As Decimal, tau_e_B As Decimal, rho_e_B As Decimal, U_blinds As Decimal, tau_e_B_corr As Decimal, rho_e_B_corr As Decimal 'EN 13363-1 적용
        Dim g As Decimal, alpa As Decimal
        'Dim i_sub_wall As Integer
        Dim V_mech_outdoor As Decimal

        '//2010.02.04추가
        Dim i_count_AHU As Integer
        Dim Phi As Decimal
        '//2010.02.21추가
        Dim d_op_mth As Integer
        Dim d_full_mth As Integer
        '//2011.04.04 추가
        Dim Q_V_win_sink As Decimal, Q_V_win_source As Decimal, H_V_win As Decimal, n_win As Decimal
        Dim zone_count As Decimal '//2012.07.08 추가


        Dim priod_value As Single = 0
        Dim age As Single '//준공연도에 의한 경년변화값
        For Each DRpriod As DS.tbl_DescRow In DSET.tbl_Desc.Select("cname<>'0'", "cname")
            priod_value = CSng(DRpriod.priod)
        Next
        If priod_value = 0 Then
            age = 1
        Else
            age = 1 / (1 - priod_value * 0.0012)
        End If



        RaiseEvent Message(Title & vbCrLf & "저장소 기본값을 설정하는중.")
        t_24 = 24
        F_f = 0.5 '구조체와 하늘과의 형태계수
        F__F = 0.7 '창 프레임 감소계수 __필요
        F_W = 0.9 '수직입사가 아닌경우에 대한 감소계수
        F_S = 1 '주변환경에 의한 그늘짐
        F_V = 1 '0.9 '우선 먼지팩터는 없는 것으로 가정
        h_r = 5 * 0.9 '= 5*e(모를경우 e=0.9)
        Delta_theta_er = 10
        Delta_theta_i_NA = 4 '(용도별조건)
        'theta_i = 21
        'theta_i_h = 21
        theta_i_h_soll = 20
        theta_i_c = 24
        theta_i_c_soll = 26
        theta_V_mech_RLT = 27
        'theta_e_min = -11.3
        'theta_e_max = 31.5
        c_p_arhoa = 0.34    '//먼지모름
        'n_50 = 1.5
        n_ue = 0.6
        e_wind = 0.07
        f_wind = 15
        R_se = 0.043 '외기에 직접 열전달저항 확인요망
        g_TI = 0.35 '(2-113)
        alpa = 0.4 '우선 0.4으로 설정 표면흡수율 도표 2-6 참조
        n_mech = 1 '임시
        A_u = 1
        h_u = 1 '임시

        RaiseEvent Message(Title & vbCrLf & "결과저장소 초기화")

        Work_msg("요구량계산중...")
        Frm_Work.ProgressBar1.Maximum = 26
        Frm_Work.ProgressBar1.Minimum = 0
        Frm_Work.ProgressBar1.Value = 0
        Frm_Work.TopMost = True
        Frm_Work.Show()

        '/////////////////////////////////////////////////////
        For i_count_HeatCool As Integer = 1 To 2 '(1)   루프회전 난방/냉방 구분해서 회전한다. 둘의 산식이 거의 비슷하므로 루프를 이용해서 계산

            For i_count_month As Short = 0 To 12 '(2)    --월전체의 루프?

                Work_msg("요구량계산중..." & CStr(IIf(i_count_HeatCool = 1, "난방", "냉방")) & "(" & i_count_month & "/12)") : Work_plus()
                Dim Mon As String = "M" & Format(i_count_month, "00")   '//저장소의 필드명이 M00 식으로되어있다.

                If i_count_month = 0 Then '//난방이라면? '//최소외기온도 난방기(theta_e_min)
                    Calc.Pub.theta_e(i_count_month) = TOSG(IIf(i_count_HeatCool = 1, Calc.Pub.theta_e_min, Calc.Pub.theta_e_max))
                End If

                '//존 루프
                For Each DR존 As DS.tbl_zoneRow In DSET.tbl_zone.Select("code<>'0'", "code") ' DSET.tbl_zone.Rows.Count '(3)
                    '//방식이나 공조는 ZZ는 사용안함이다 V=환기  외기부하처리여부의경우 0001 은 예이다.
                    zone_count = TOSG(DR존.입력존의수)
                    If DR존.냉난방방식 <> "기능없음" Or (DR존.냉난방공조 <> "기능없음" And (DR존.냉난방공조 <> "환기" Or DR존.외기부하처리여부 = "예")) Then
                        Q_vh_b_op = 0

                        '//i_count_OpWe 1은 평일 2는 주말이다ㅡㅡ/
                        '======================================2010.2.21 삭제
                        'For i_count_OpWe = 1 To 2
                        '======================================2010.2.21 삭제
                        Q_V_inf_sink = 0
                        Q_V_inf_source = 0
                        Q_V_mech_sink = 0
                        Q_V_mech_source = 0
                        Q_V_z_sink = 0
                        Q_V_z_source = 0
                        Q_V_win_sink = 0 '//2011.04.04 추가
                        Q_V_win_source = 0 '//2011.04.04 추가

                        Q_T_e_sink = 0
                        Q_T_e_source = 0
                        Q_T_u_sink = 0
                        Q_T_u_source = 0
                        Q_T_z_sink = 0
                        Q_T_z_source = 0
                        Q_T_s_sink = 0
                        Q_T_s_source = 0

                        A_B = TOSG(DR존.면적) * zone_count ' Worksheets("입력존").Range("전용면적1").Offset(0, i_count_zone - 1)
                        V = TOSG(DR존.순실체적) * zone_count ' Worksheets("입력존").Range("체적1").Offset(0, i_count_zone - 1)
                        V_ue = A_u * h_u
                        'Log.AppendLine("               >>  V_ue = A_u * h_u =  // au와 hu 는 선언부에서 1값으로 고정되어있음 v_ue는 항상 1")

                        '//존의 프로필설정에대한 실제 프로필의 데이터를 가져옴
                        Dim DR프로필() As DS.tbl_profileRow = CType(DSET.tbl_profile.Select("code='" & DR존.프로필 & "' and code <> '0'"), DS.tbl_profileRow())
                        If DR프로필.GetUpperBound(0) = -1 Then
                            MsgBox("존=" & DR존.code & " 의 프로필=" & DR존.프로필 & " 의 데이터가 존재하지않습니다", MsgBoxStyle.Critical, "확인")
                        Else
                            'Log.AppendLine("               >>  존의 프로필코드(" & DR존.프로필 & ") 에 해당하는 프로필정보를 가져옵니다")
                            t_h_op_d = TOIT(DR프로필(0).운전시간난방) '  Worksheets("설정조건").Range("사용시작시간1").Offset(5, i_count_profile)
                            '===================================================================================2010.2.21 추가
                            If i_count_month = 0 Then
                                d_op_mth = 0
                            Else
                                d_op_mth = CInt(TOSG(DR프로필(0)("day" & Format(i_count_month, "00"))))
                            End If
                            '===================================================================================2010.2.21 추가
                            theta_i_h_soll = TOSG(DR프로필(0).난방설정온도) ' Worksheets("설정조건").Range("난방설정온도1").Offset(0, i_count_profile)
                            theta_i_c_soll = TOSG(DR프로필(0).냉방설정온도) ' Worksheets("설정조건").Range("냉방설정온도1").Offset(0, i_count_profile)
                            Delta_theta_i_NA = TOSG(DR프로필(0).야간최저허용온도) ' Worksheets("설정조건").Range("야간최저허용온도1").Offset(0, i_count_profile)
                            Delta_theta_i_WE = TOSG(DR프로필(0).주말최저허용온도) ' Worksheets("설정조건").Range("주말최저허용온도1").Offset(0, i_count_profile)
                            '  If i_count_OpWe = 1 Then=============================================================2010.2.21 삭제
                            'Log.AppendLine("               >>  i_count_OpWe = 1 >> Q_I_source_p/Q_I_source_fac/V_mech 계산됨")
                            Q_I_source_p = TOSG(DR프로필(0).사람) * A_B '  Worksheets("설정조건").Range("사람1").Offset(0, i_count_profile) * A_B '(2-118)
                            Q_I_source_fac = TOSG(DR프로필(0).작업보조기기) * A_B ' Worksheets("설정조건").Range("작업보조기기1").Offset(0, i_count_profile) * A_B '(2-119)
                            V_mech = TOSG(DR프로필(0).최소도입외기량) * A_B '  Worksheets("설정조건").Range("최소도입외기량1").Offset(0, i_count_profile) * A_B
                            '    Else   '=============================================================2010.2.21 삭제
                            '    Log.AppendLine("               >>  i_count_OpWe <> 1 >> Q_I_source_p/Q_I_source_fac 는 0입니다")
                            '    Q_I_source_p = 0 '주말 사람없음
                            '    Q_I_source_fac = 0 '주말 기기발열 없음
                            'End If
                            'Q_I_L = 0 'mu_L*Q_I_L_elektr (2-123)추후 추가
                        End If

                        V_mech_outdoor = 1 '외기처리 관련 (ZZ=사용안함 Y=예)
                        If DR존.냉난방방식 <> "기능없음" And DR존.냉난방공조 <> "기능없음" And DR존.외기부하처리여부 = "예" Then
                            If i_count_HeatCool = 1 Then    '//난방이라면
                                If DR존.냉난방공조 <> "난방" AndAlso DR존.냉난방공조 <> "냉난방" Then '난방/냉난방 이 아니면!
                                    If theta_i_h_soll > Calc.Pub.theta_e(i_count_month) Then    '//난방설정온도 > 외기온도(난방기)
                                        Q_vh_b_op = V_mech * (theta_i_h_soll - Calc.Pub.theta_e(i_count_month)) * t_h_op_d * c_p_arhoa * d_op_mth '===============d_op(i_count_month) 2010.2.21 수정
                                        V_mech_outdoor = 0 ' 외기처리된 상태인 경우
                                        'Log.AppendLine("               >>  외기처리됨")
                                    End If
                                End If
                            Else
                                If DR존.냉난방공조 <> "냉방" AndAlso DR존.냉난방공조 <> "냉난방" Then '냉방/냉난방이 아닐경우
                                    If theta_i_c_soll < Calc.Pub.theta_e(i_count_month) Then
                                        Q_vh_b_op = V_mech * (Calc.Pub.theta_e(i_count_month) - theta_i_c_soll) * t_h_op_d * c_p_arhoa * d_op_mth '===============d_op(i_count_month) 2010.2.21 수정
                                        V_mech_outdoor = 0 ' 외기처리된 상태인 경우
                                        'Log.AppendLine("               >>  외기처리됨")
                                    End If
                                End If
                            End If
                        End If



                        n_50 = TOSG(DR존.침기율)    '//tosg 는 빈값일경우 0을 반환
                        n_inf = n_50 * e_wind '(2-59) 환기기기 없는 경우
                        'n_inf = n_50 * e_wind * (1 + f_V_mech * t_V_mech / 24) '(2-60) 급기 및 배기에 대한 환기회수 필요
                        '///////////////////////////////////////////////////////////////////////////////////////////////////////2011.04.04 추가
                        'If n_nutz < 1.2 Then
                        '    Delta_n_win = n_nutz - (n_nutz - 0.2) * n_inf - 0.1
                        'Else
                        '    Delta_n_win = n_nutz - n_inf - 0.1
                        'End If
                        'If Delta_n_win < 0 Then
                        '    Delta_n_win = 0
                        'End If
                        'n_win = 0.1 + Delta_n_win * t_h_op_d / 24
                        n_win = 0.1 ' 최소외기 도입량은 환기기기 유무와 상관없이 적용되는 것으로 평가하기 때문에 자연환기 기본값만 적용
                        '///////////////////////////////////////////////////////////////////////////////////////////////////////2011.04.04 추가


                        H_T_D = 0
                        H_T_iu = 0
                        H_T_iz = 0


                        Dim Drow프로필 As DS.tbl_profileRow = CType(DSET.tbl_profile.Select("code='" & DR존.프로필 & "' and code <> '0'")(0), DS.tbl_profileRow)
                        If DR존.조명부하산출방법 = "계산치" Then
                            Q_I_L = TOSG(DR존.조명에너지부하율계산치) * TOSG(Drow프로필.일일사용시간) * A_B
                        Else
                            Q_I_L = TOSG(DR존.조명에너지부하율입력치) * TOSG(Drow프로필.일일사용시간) * A_B
                        End If
                        'Q_I_L = TOSG(IIf(DR존.조명부하산출방법 = "계산치", TOSG(DR존.조명에너지부하율계산치), TOSG(DR존.조명에너지부하율입력치))) * TOSG(Drow프로필.일일사용시간) * A_B
                        Q_w_b = TOSG(Drow프로필.일일급탕요구량) * A_B * d_op_mth
                        '===================================2010.2.21 삭제
                        'If DR존.조명부하산출방법 = "CALC" Then    '//OpWe의 2번은 주말인거 같다.
                        '    '//부하율계산치?입력치구분
                        '    Q_w_b = TOSG(DR존.급탕요구량) * A_B * Calc.Pub.d_op_mth(i_count_month)
                        'Else
                        '    Q_I_L = 0 '주말 소등으로 설정
                        '    Q_w_b = 0 '주말은 급탕사용안함
                        'End If
                        '===================================2010.2.21 삭제

                        'Log.AppendLine("               >>  현재존을 사용하는 각 입력면(" & DSET.tbl_myoun.Select("존분류='" & DR존.code & "'").GetUpperBound(0) & ")으로부터 데이터를 누적")
                        For Each Dr입력면 As DS.tbl_myounRow In DSET.tbl_myoun.Select("존분류='" & DR존.code & "'")
                            If Dr입력면.code <> "0" Then
                                If DR존.열교가산치 = "내단열" Then
                                    Delta_U_WB = 0.15                            '내단열(=0001) Worksheets("입력존").Range("열교1").Offset(0, i_count_zone - 1) = "내단열" Then
                                Else
                                    Delta_U_WB = 0.1                               '내단열(=0001) Worksheets("입력존").Range("열교1").Offset(0, i_count_zone - 1) = "내단열" Then
                                End If
                                Select Case Dr입력면.건축부위방식.Trim ' Case Worksheets("입력면").Range("입력부위" & i_sub_wall & "").Offset(0, i_count_wall)
                                    Case "외벽" '"외벽"
                                        'Dr입력면.열관류율 >> Calc.Get_열관류율(Dr입력면)
                                        H_T_D = H_T_D + Calc.Get_열관류율(Dr입력면) * age * TOSG(Dr입력면.건축부위면적) * zone_count + Delta_U_WB * TOSG(Dr입력면.건축부위면적) * zone_count ' Worksheets("입력면").Range("부위면적" & i_sub_wall & "").Offset(0, i_count_wall) '(2-44) Delta_U_WB는 외단열 0.1, 내단열 0.15
                                    Case "외부창", "내부창" '=================2010.03.20 수정
                                        If Dr입력면.블라인드유무 = "유" Then ' '0001(=유) Range("에너지투과율" & i_sub_wall & "").Offset(3, i_count_wall) = "유" Then   
                                            If Calc.Get_열관류율(Dr입력면) = 0 Then
                                                MsgBox("블라인드 사용이지만 열관류율 수치가 입력되지 않았습니다", MsgBoxStyle.Critical, "확인")
                                            Else
                                                Select Case Dr입력면.블라인드위치.Trim ' Range("에너지투과율" & i_sub_wall & "").Offset(4, i_count_wall)
                                                    Case "내부" '"내부"
                                                        U_blinds = TOSG(1 / (1 / (Calc.Get_열관류율(Dr입력면) * age) + 1 / 30))
                                                    Case "중간" '중간"
                                                        U_blinds = TOSG(1 / (1 / (Calc.Get_열관류율(Dr입력면) * age) + 1 / 3))
                                                    Case "외부" ' '외부"
                                                        U_blinds = TOSG(1 / (1 / (Calc.Get_열관류율(Dr입력면) * age) + 1 / 5 + 1 / 10))
                                                End Select
                                            End If

                                        Else
                                            U_blinds = Calc.Get_열관류율(Dr입력면) * age 'Worksheets("입력면").Range("열관류율" & i_sub_wall & "").Offset(0, i_count_wall)
                                        End If

                                        '=========================================================================================================2010.03.20 수정
                                        If Dr입력면.건축부위방식.Trim = "외부창" Then
                                            H_T_D = H_T_D + U_blinds * TOSG(Dr입력면.건축부위면적) * zone_count + Delta_U_WB * TOSG(Dr입력면.건축부위면적) * zone_count '(2-44) Delta_U_WB는 외단열 0.1, 내단열 0.15
                                        Else
                                            H_T_iu = H_T_iu + U_blinds * TOSG(Dr입력면.건축부위면적) * zone_count
                                        End If
                                        '=========================================================================================================2010.03.20 수정
                                    Case "내벽" ' "내벽"
                                        H_T_iu = H_T_iu + Calc.Get_열관류율(Dr입력면) * age * TOSG(Dr입력면.건축부위면적) * zone_count '(2-48)
                                    Case "간벽" '"간벽"
                                        H_T_iz = H_T_iz + Calc.Get_열관류율(Dr입력면) * age * TOSG(Dr입력면.건축부위면적) * zone_count '(2-52)
                                    Case Else
                                        MsgBox("입력면 건축부위방식이 없습니다", MsgBoxStyle.Critical, "확인")
                                        Return False
                                End Select
                            End If
                        Next


                        If H_T_D = 0 Then
                            H_V_inf = 0
                        Else
                            H_V_inf = n_inf * V * c_p_arhoa '(2-58) c_p_arhoa는 0.34 V는 존의 체적
                        End If
                        H_V_win = n_win * V * c_p_arhoa '//2011.04.04 추가
                        H_V_mech = V_mech * c_p_arhoa 'n_mech * V * c_p_arhoa '(2-83)
                        H_V_ue = n_ue * V_ue * c_p_arhoa '(2-94)
                        'H_V_z = n_z_d * c_p_arhoa '(2-99)

                        If DR존.열저장능력 = "" Then
                            MsgBox(DR존.설명 & "의 열저장능력이 입력되어 있지않습니다", MsgBoxStyle.Critical, "확인")
                            C_wirk = 0
                        Else
                            C_wirk = TOSG(DR존.열저장능력) * A_B ' .Worksheets("입력존").Range("열저장능력1").Offset(0, i_count_zone - 1) * A_B
                        End If

                        If i_count_HeatCool = 1 Then
                            H_V_mech_theta = 0 'H_V_mech * (theta_i_h_soll - theta_V_mech) / 6 '(2-130) 우선 고려안함
                        Else
                            H_V_mech_theta = 0 'H_V_mech * (theta_i_c_soll - theta_V_mech) / 6 '(2-130)
                        End If
                        tau = C_wirk / ((H_T_D + H_T_iu + H_T_iz) + (H_V_inf + H_V_mech + H_V_ue + H_V_win) + H_V_mech_theta) '(2-22, 129) 추후 H_V_z 추가 '//2011.04.04 H_V_win 추가
                        If tau < 48 Then tau = 48

                        a = 1 + tau / 16 '(2-25)

                        a_tb = 1 ' =A_beheizt / A_B 'A_beheizt는 난방면적, A_B는 전용면적

                        t_NA = 24 - t_h_op_d
                        f_tb = TOSG(0.8 * (1 - Math.Exp(-Q_h_max / (A_B * 35))) * a_tb ^ 2) '(2-34)

                        '================================================2010.2.21 삭제
                        'If i_count_OpWe = 1 Then
                        '================================================2010.2.21 삭제
                        Select Case DR존.야간운전방식.Trim '공통1002 Worksheets("입력존").Range("야간가동1").Offset(0, i_count_zone - 1)
                            Case "정상가동" '정상가동"
                                f_NA = 0
                            Case "감소가동" '감소가동"
                                f_NA = TOSG(0.13 * t_NA * Math.Exp(-tau / 250) / 24) '(2-28) 감소가동
                            Case "가동정지" '가동정지"
                                f_NA = TOSG(0.26 * t_NA * Math.Exp(-tau / 250) / 24) '(2-29) 가동정지
                        End Select
                        theta_i_h = theta_i_h_soll - f_NA * (theta_i_h_soll - Calc.Pub.theta_e(i_count_month))
                        If theta_i_h < theta_i_h_soll - Delta_theta_i_NA * t_NA / 24 Then theta_i_h = theta_i_h_soll - Delta_theta_i_NA * t_NA / 24 '(2-27) 야간감소
                        '================================================2010.2.21 삭제
                        'Else
                        '================================================2010.2.21 삭제
                        Select Case DR존.주말운전방식.Trim ' Worksheets("입력존").Range("주말가동1").Offset(0, i_count_zone - 1)
                            Case "정상가동" '정상가동"
                                f_we = 0
                            Case "감소가동" '감소가동"
                                f_we = TOSG(0.2 * (1 - 0.4 * tau / 250)) '(2-31) 난방감소
                            Case "가동정지" '가동정지"
                                f_we = TOSG(0.3 * (1 - 0.2 * tau / 250)) '(2-32) 난방정지식
                        End Select
                        theta_i_h = theta_i_h_soll - f_we * (theta_i_h_soll - Calc.Pub.theta_e(i_count_month))
                        If theta_i_h < theta_i_h_soll - Delta_theta_i_WE Then theta_i_h = theta_i_h_soll - Delta_theta_i_WE '(2-30) 주말감소식 변형
                        '================================================2010.2.21 삭제
                        'End If
                        '================================================2010.2.21 삭제

                        If i_count_HeatCool = 1 Then
                            theta_i = theta_i_h
                            theta_z = theta_i_h
                            theta_u = TOSG(theta_i_h_soll - 0.7 * (theta_i_h_soll - Calc.Pub.theta_e(i_count_month)))
                        Else
                            theta_i = theta_i_c_soll '24'에너지 사용량 계산할때 24 사용
                            theta_z = theta_i_c_soll
                            theta_u = TOSG(theta_i_c_soll - 0.7 * (theta_i_c_soll - Calc.Pub.theta_e(i_count_month)))
                        End If

                        'theta_i_h = theta_i_h_soll - f_tb * (theta_i_h_soll - theta_e(i_count_month)) '(2-33) 공간적제한
                        'theta_i_h = theta_i_NA - f_tb * (theta_i_NA - theta_e(i_count_month)) '(2-35) 공간적 시간적 제한

                        'theta_V_mech = theta_e(i_count_month) '(2-90) 공조처리 없는 경우
                        'theta_V_mech = theta_e(i_count_month) + eta_V_mech * (theta_i - theta_e(i_count_month)) '(2-91) 비제어적 열교환 eta_V_mech은 사용자입력
                        theta_V_mech_RLT = TOSG(IIf(i_count_HeatCool = 1, 27, 16))

                        theta_V_mech = Calc.Pub.theta_e(i_count_month) 'theta_V_mech_RLT '(2-92) 공조처리된 급기온도(도표 3-3, 3-4, 7-5) 난방 27, 냉방 16으로 설정


                        '=======================================================================2010.02.04 추가부분 시작
                        If DR존.냉난방공조처리시스템 <> "0" And DR존.냉난방공조 = "환기" Then   '//냉난방공조처리시스템이 선택되어있고 공조가 환기라면
                            '//공조처리스템과 일치하는 공조기기(tbl_kongjo) 를 찾아서 계산한다.
                            Dim DR() As DS.tbl_kongjoRow = CType(DSET.tbl_kongjo.Select("code='" & DR존.냉난방공조처리시스템 & "' and code <> '0'"), DS.tbl_kongjoRow())
                            If DR.GetUpperBound(0) = 0 Then
                                Select Case DR(0).열교환기유형.Trim
                                    Case "현열교환", "전열교환" '//현열교환,전열교환
                                        Phi = TOSG(DR(0).열회수율) ' Worksheets("공조처리시스템").Range("열교환기1").Offset(1, i_count_AHU - 1)
                                    Case Else
                                        Phi = 0
                                End Select
                                theta_V_mech = Calc.Pub.theta_e(i_count_month) + Phi * (theta_i - Calc.Pub.theta_e(i_count_month))
                            Else
                                MsgBox(DR존.설명 & "존의 냉난방공조처리스템(" & DR존.냉난방공조처리시스템 & ") 의값이 일치하지않습니다", MsgBoxStyle.Critical, "확인")
                            End If
                        End If
                        '=======================================================================2010.02.04 추가부분 끝

                        If theta_i > Calc.Pub.theta_e(i_count_month) Then
                            Q_V_inf_sink = H_V_inf * (theta_i - Calc.Pub.theta_e(i_count_month)) * t_24 '(2-56)
                            Q_V_win_sink = H_V_win * (theta_i - Calc.Pub.theta_e(i_count_month)) * t_24 '//2011.04.04 추가
                        Else
                            Q_V_inf_source = H_V_inf * (Calc.Pub.theta_e(i_count_month) - theta_i) * t_24 '(2-
                            Q_V_win_source = H_V_win * (Calc.Pub.theta_e(i_count_month) - theta_i) * t_24 '//2011.04.04 추가
                        End If
                        '================================================2010.2.21 삭제
                        'If i_count_OpWe = 1 Then
                        '================================================2010.2.21 삭제
                        If theta_i > theta_V_mech Then
                            Q_V_mech_sink = H_V_mech * V_mech_outdoor * (theta_i - theta_V_mech) * t_h_op_d '(2-81)
                        Else
                            Q_V_mech_source = H_V_mech * V_mech_outdoor * (theta_V_mech - theta_i) * t_h_op_d '(2-
                        End If
                        '================================================2010.2.21 삭제
                        'Else
                        'If theta_i > theta_V_mech Then
                        '    Q_V_mech_sink = 0
                        'Else
                        '    Q_V_mech_source = 0
                        'End If
                        'End If
                        '================================================2010.2.21 삭제

                        If theta_i > theta_z Then
                            Q_V_z_sink = H_V_z * (theta_i - theta_z) * t_24 '(2-97)
                        Else
                            Q_V_z_source = H_V_z * (theta_z - theta_i) * t_24 '(2-
                        End If

                        Q_V_sink = Q_V_inf_sink + Q_V_mech_sink + Q_V_z_sink + Q_V_win_sink '(2-13) '//2011.04.04 추가
                        Q_V_source = Q_V_inf_source + Q_V_mech_source + Q_V_z_source + Q_V_win_source '(2-  '//2011.04.04 추가

                        If theta_i > Calc.Pub.theta_e(i_count_month) Then
                            Q_T_e_sink = H_T_D * (theta_i - Calc.Pub.theta_e(i_count_month)) * t_24 '(2-42)
                        Else
                            Q_T_e_source = H_T_D * (Calc.Pub.theta_e(i_count_month) - theta_i) * t_24 '(2-
                        End If

                        If theta_i > theta_u Then
                            Q_T_u_sink = H_T_iu * (theta_i - theta_u) * t_24 '(2-46)
                        Else
                            Q_T_u_source = H_T_iu * (theta_u - theta_i) * t_24 '(2-
                        End If

                        If theta_i > theta_z Then
                            Q_T_z_sink = H_T_iz * (theta_i - theta_z) * t_24 '(2-50)
                        Else
                            Q_T_z_source = H_T_iz * (theta_z - theta_i) * t_24 '(2-
                        End If

                        If theta_i > Calc.Pub.theta_e(i_count_month) Then
                            Q_T_s_sink = H_T_s * (theta_i - Calc.Pub.theta_e(i_count_month)) * t_24 '(2-53) 추후수정
                        Else
                            Q_T_s_source = H_T_s * (Calc.Pub.theta_e(i_count_month) - theta_i) * t_24 '(2-53) 추후수정
                        End If

                        Q_T_sink = Q_T_e_sink + Q_T_u_sink + Q_T_z_sink + Q_T_s_sink '(2-12)
                        Q_T_source = Q_T_e_source + Q_T_u_source + Q_T_z_source + Q_T_s_source '(2-12)

                        Q_S_sink = 0
                        Q_S_source = 0

                        For Each DRF입력면 As DS.tbl_myounRow In DSET.tbl_myoun.Select("존분류='" & DR존.code & "' and code <> '0'")    '//해당존을 사용하는 모든 입력면을 가져옴
                            Select Case DRF입력면.방위.Trim ' Worksheets("입력면").Range("방위" & i_sub_wall & "").Offset(0, i_count_wall)
                                Case "수평" '"수평"
                                    i_count_Is = 0
                                Case "남" '"남"
                                    i_count_Is = 1
                                Case "남동" '"남동"
                                    i_count_Is = 2
                                Case "남서" '"남서"
                                    i_count_Is = 3
                                Case "동" '"동"
                                    i_count_Is = 4
                                Case "서" '"서"
                                    i_count_Is = 5
                                Case "북동" '"북동"
                                    i_count_Is = 6
                                Case "북서" '"북서"
                                    i_count_Is = 7
                                Case "북" '"북"
                                    i_count_Is = 8
                                    '==========================================================2010.03.20 추가
                                Case Else
                                    i_count_Is = -1
                                    '==========================================================2010.03.20 추가
                            End Select

                            If i_count_Is <> -1 Then '=====================================2010.03.20 추가


                                Select Case DRF입력면.건축부위방식.Trim ' Range("입력부위" & i_sub_wall & "").Offset(0, i_count_wall)
                                    Case "외벽" '외벽
                                        If alpa * Calc.Pub.I_s(i_count_Is, i_count_month) < F_f * h_r * Delta_theta_er Then
                                            Q_S_sink = Q_S_sink + R_se * Calc.Get_열관류율(DRF입력면) * age * TOSG(DRF입력면.건축부위면적) * zone_count * (F_f * h_r * Delta_theta_er - alpa * Calc.Pub.I_s(i_count_Is, i_count_month)) * t_24 '(2-111)
                                        Else
                                            'Log.AppendLine("외벽 if else = " & Q_S_source)
                                            Q_S_source = Q_S_source + R_se * Calc.Get_열관류율(DRF입력면) * age * TOSG(DRF입력면.건축부위면적) * zone_count * (alpa * Calc.Pub.I_s(i_count_Is, i_count_month) - F_f * h_r * Delta_theta_er) * t_24 '(2-
                                            'Log.AppendLine(">>" & Q_S_source)
                                        End If

                                    Case "외부창", "내부창" '=====================================2010.03.20 수정
                                        If TOSG(DRF입력면.수평차양각) < 67.5 Then 'Range("에너지투과율" & i_sub_wall & "").Offset(1, i_count_wall) < 67.5 Then

                                            If DRF입력면.블라인드유무 = "유" Then ' Range("에너지투과율" & i_sub_wall & "").Offset(3, i_count_wall) = "유" Then
                                                Select Case DRF입력면.블라인드빛종류.Trim ' Range("에너지투과율" & i_sub_wall & "").Offset(6, i_count_wall)
                                                    Case "불투과(t=0.0)" '불투과(t=0.0)"
                                                        tau_e_B = 0
                                                        Select Case DRF입력면.블라인드색상.Trim ' Range("에너지투과율" & i_sub_wall & "").Offset(7, i_count_wall)
                                                            Case "흰색" '흰색"
                                                                rho_e_B = 0.7
                                                            Case "밝은색" '밝은색"
                                                                rho_e_B = 0.5
                                                            Case "어두운색" '어두운색"
                                                                rho_e_B = 0.3
                                                            Case "검은색" '검은색"
                                                                rho_e_B = 0.1
                                                            Case Else
                                                                MsgBox("불투과 블라인드색상이 없습니다", MsgBoxStyle.Critical, "확인")
                                                        End Select
                                                    Case "약투과(t=0.2)" '약투과(t=0.2)"
                                                        tau_e_B = 0.2
                                                        Select Case DRF입력면.블라인드색상.Trim 'Range("에너지투과율" & i_sub_wall & "").Offset(7, i_count_wall)
                                                            Case "흰색"
                                                                rho_e_B = 0.6
                                                            Case "밝은색"
                                                                rho_e_B = 0.4
                                                            Case "어두운색"
                                                                rho_e_B = 0.2
                                                            Case "검은색"
                                                                rho_e_B = 0.1
                                                            Case Else
                                                                MsgBox("약투과 블라인드색상이 없습니다", MsgBoxStyle.Critical, "확인")
                                                        End Select
                                                    Case "반투과(t=0.4)" '반투과(t=0.4)"
                                                        tau_e_B = 0.4
                                                        Select Case DRF입력면.블라인드색상.Trim 'Range("에너지투과율" & i_sub_wall & "").Offset(7, i_count_wall)
                                                            Case "흰색"
                                                                rho_e_B = 0.4
                                                            Case "밝은색"
                                                                rho_e_B = 0.3
                                                            Case "어두운색"
                                                                rho_e_B = 0.2
                                                            Case "검은색"
                                                                rho_e_B = 0.1
                                                            Case Else
                                                                MsgBox("반투과 블라인드색상이 없습니다", MsgBoxStyle.Critical, "확인")
                                                        End Select
                                                End Select

                                                If DRF입력면.블라인드각도 = "45도" Then ' Range("에너지투과율" & i_sub_wall & "").Offset(5, i_count_wall) = "45도" Then
                                                    tau_e_B_corr = TOSG(0.65 * tau_e_B + 0.15 * rho_e_B)
                                                    rho_e_B_corr = TOSG(rho_e_B * (0.75 + 0.7 * tau_e_B))
                                                    tau_e_B = tau_e_B_corr
                                                    rho_e_B = rho_e_B_corr
                                                End If

                                                g = TOSG(DRF입력면.투과율) ' Range("에너지투과율" & i_sub_wall & "").Offset(0, i_count_wall)
                                                If DRF입력면.블라인드위치.Trim <> "" AndAlso Calc.Get_열관류율(DRF입력면) = 0 Then
                                                    MsgBox(DRF입력면.설명 & "의 열관류율이 0입니다", MsgBoxStyle.Critical, "확인")
                                                Else
                                                    Select Case DRF입력면.블라인드위치.Trim 'Range("에너지투과율" & i_sub_wall & "").Offset(4, i_count_wall)
                                                        Case "내부" '내부"
                                                            U_blinds = TOSG(1 / (1 / (Calc.Get_열관류율(DRF입력면) * age) + 1 / 30))
                                                            g_blinds = g * (1 - g * rho_e_B - (1 - tau_e_B - rho_e_B) * U_blinds / 30)
                                                        Case "중간" '중간"
                                                            U_blinds = TOSG(1 / (1 / (Calc.Get_열관류율(DRF입력면) * age) + 1 / 3))
                                                            g_blinds = g * tau_e_B + g * ((1 - tau_e_B - rho_e_B) + (1 - g) * rho_e_B) * U_blinds / 3
                                                        Case "외부" '외부"
                                                            U_blinds = TOSG(1 / (1 / (Calc.Get_열관류율(DRF입력면) * age) + 1 / 5 + 1 / 10))
                                                            g_blinds = tau_e_B * g + (1 - tau_e_B - rho_e_B) * U_blinds / 10 + tau_e_B * (1 - g) * g / 5
                                                        Case Else
                                                            MsgBox("블라인드위치가 없습니다", MsgBoxStyle.Critical, "확인")
                                                    End Select
                                                End If
                                                '===========================================================================2010.02.27 추가
                                                If i_count_month = 0 Then
                                                    If i_count_HeatCool = 1 Then
                                                        g_blinds = (1 - Calc.Pub.F_sh_gl(i_count_Is - 1, 1 - 1)) * g + Calc.Pub.F_sh_gl(i_count_Is - 1, 1 - 1) * g_blinds
                                                    Else
                                                        g_blinds = (1 - Calc.Pub.F_sh_gl(i_count_Is - 1, 7 - 1)) * g + Calc.Pub.F_sh_gl(i_count_Is - 1, 7 - 1) * g_blinds
                                                    End If
                                                Else
                                                    g_blinds = (1 - Calc.Pub.F_sh_gl(i_count_Is - 1, i_count_month - 1)) * g + Calc.Pub.F_sh_gl(i_count_Is - 1, i_count_month - 1) * g_blinds
                                                End If
                                                '===========================================================================2010.02.27 추가

                                            Else
                                                g_blinds = TOSG(DRF입력면.투과율) ' Range("에너지투과율" & i_sub_wall & "").Offset(0, i_count_wall)

                                            End If
                                            Q_S_source = TOSG(Q_S_source + F__F * TOSG(DRF입력면.건축부위면적) * zone_count * F_S * F_W * F_V * g_blinds * Math.Cos(1.33 * TOSG(DRF입력면.수평차양각) * 3.141592 / 180) * (1 - TOSG(DRF입력면.수직차양각) / 300) * Calc.Pub.I_s(i_count_Is, i_count_month) * t_24) '(2-113)
                                        End If
                                End Select
                            End If '==========================================================2010.03.20 추가
                        Next

                        Q_I_source = Q_I_source_p + Q_I_source_fac + Q_I_L '(2-20)
                        Q_source = Q_S_source + Q_T_source + Q_V_source + Q_I_source '(2-16)
                        If i_count_month = 0 AndAlso i_count_HeatCool = 1 Then Q_source = 0 ' 난방 최대부하 계산
                        Q_sink = Q_T_sink + Q_V_sink + Q_S_sink '(2-11) Q_I_sink는 현재 고려안함

                        If Q_sink = 0 Then
                            eta = 0
                        Else
                            gamma = Q_source / Q_sink '(2-21)
                            'If gamma > 1.1 And a > 100 Then
                            If gamma ^ a > 1000000 Then
                                eta = 1 / gamma
                            Else
                                If gamma = 1 Then
                                    eta = a / (a + 1) '(2-24)
                                Else
                                    eta = TOSG((1 - gamma ^ a) / (1 - gamma ^ (a + 1))) '(2-23)
                                End If
                            End If

                            If 1 - (eta * gamma) < 0.01 Then eta = 1 / gamma '(2-137)
                            If (1 - eta) * gamma < 0.01 Then eta = 1 '(2-138)
                            'If V_mech >= Q_C_max / (c_p_arhoa * (theta_i - theta_mech)) Then eta = 1 '(2-139) 추후 고민
                        End If

                        If i_count_HeatCool = 1 Then
                            Q_h_b = Q_sink - eta * Q_source '(2-1)
                        Else
                            Q_h_b = (1 - eta) * Q_source '(2-7)
                        End If


                        If Q_h_b < 0.001 Then Q_h_b = 0 '1W 미만 제거

                        '========================================================2010.2.21 수정 And i_count_OpWe = 1  삭제
                        If i_count_month = 0 Then
                            If t_h_op_d <> 0 Then
                                Q_h_b_op = Q_h_b / t_h_op_d
                            Else
                                Q_h_b_op = Q_h_b
                            End If
                        Else
                            '=================================================2010.2.21 삭제
                            'If i_count_OpWe = 1 Then
                            '=================================================2010.2.21 삭제
                            Q_h_b_op = Q_h_b * d_op_mth
                            ' MsgBox(i_count_month & "    " & Q_h_b & "     " & d_op(i_count_month) & "     " & Q_h_b_op)
                            '=================================================2010.2.21 삭제
                            'Else
                            'Q_h_b_we = Q_h_b * Calc.Pub.d_we(i_count_month)
                            '=================================================2010.2.21 삭제
                            Dim DRProf As DS.tbl_profileRow = CType(DSET.tbl_profile.Select("code='" & DR존.프로필 & "' and code <> '0'")(0), DS.tbl_profileRow)
                            If DR존.조명부하산출방법 = "계산치" Then 'Worksheets("조명").Range("조명부하산출방법1").Offset(0, i_count_zone - 1) = "계산치" Then
                                Q_l_b = TOSG(DR존.조명에너지부하율계산치) * TOSG(DRProf.일일사용시간) * A_B * d_op_mth
                            Else
                                Q_l_b = TOSG(DR존.조명에너지부하율입력치) * TOSG(DRProf.일일사용시간) * A_B * d_op_mth
                            End If
                            Q_w_b = TOSG(DRProf.일일급탕요구량) * A_B * d_op_mth 'Worksheets("입력존").Range("일일급탕요구량1").Offset(0, i_count_zone - 1) * A_B * d_op(i_count_month)
                            '=================================================2010.2.21 삭제
                            'End If
                            '=================================================2010.2.21 삭제
                        End If
                        'Q_h_b_mth = d_op(i_count_month) * (Q_sink_op - eta_op * Q_source_op) + d_we(i_count_month) * (Q_sink_we - eta_we * Q_source_we) '(2-6)
                        '======================================2010.2.21 삭제
                        'Next
                        '======================================2010.2.21 삭제
                    Else
                        A_B = TOSG(DR존.면적) * zone_count ' Worksheets("입력존").Range("전용면적1").Offset(0, i_count_zone - 1)

                        Q_vh_b_op = 0
                        Q_h_b_op = 0
                        'Q_h_b_we = 0

                        '//조명부하산출방법이 계산치(0001)일경우 계산치로 그렇지않을경우 입력치로 계산함
                        Dim DRProf As DS.tbl_profileRow = CType(DSET.tbl_profile.Select("code='" & DR존.프로필 & "' and code <> '0'")(0), DS.tbl_profileRow)

                        If DR존.조명부하산출방법 = "계산치" Then
                            Q_l_b = TOSG(DR존.조명에너지부하율계산치) * TOSG(DRProf.일일사용시간) * A_B * d_op_mth
                        Else
                            Q_l_b = TOSG(DR존.조명에너지부하율입력치) * TOSG(DRProf.일일사용시간) * A_B * d_op_mth
                        End If

                        Q_w_b = TOSG(DRProf.일일급탕요구량) * A_B * d_op_mth '===============d_op(i_count_month) 2010.2.21 수정
                    End If

                    Dim Dr최대부하 As New C최대냉난방부하.Citem(DR존.code) ' DSR.최대냉난방부하Row = CType(DSETR.최대냉난방부하.Select("zone='" & DR존.code & "'")(0), DSR.최대냉난방부하Row)

                    If i_count_HeatCool = 1 Then
                        If i_count_month = 0 Then   '//0번시트는최대 냉난방부하 시트이다.
                            Dr최대부하.최대난방기기부하 = TOSG((Q_h_b_op) / 1000) ''=================== Q_h_b_we 2010.2.21 삭제
                            'Worksheets("" & i_count_month & "").Range("최대난방부하1").Offset(0, i_count_zone - 1) = (Q_h_b_op + Q_h_b_we) / 1000
                            If DR존.야간운전방식 = "가동정지" Then ' Worksheets("입력존").Range("야간가동1").Offset(0, i_count_zone - 1) = "가동정지" Then
                                Dr최대부하.일일난방최대가동시간 = t_h_op_d
                                'Dr최대냉난방부하.난방최대가동시간 = t_h_op_d '  Worksheets("" & i_count_month & "").Range("최대난방부하1").Offset(2, i_count_zone - 1) = t_h_op_d
                            Else
                                Dr최대부하.일일난방최대가동시간 = 24
                                'Dr최대냉난방부하.난방최대가동시간 = 24 ' Worksheets("" & i_count_month & "").Range("최대난방부하1").Offset(2, i_count_zone - 1) = 24
                            End If
                        Else
                            Dim Dr월에너지요구량 As New C에너지분석(i_count_month, DR존.code)

                            'Dim Dr월에너지요구량 As DSR.월별에너지분석Row = CType(DSETR.월별에너지분석.Select("월='" & Mon & "' and 존='" & DR존.code & "'")(0), DSR.월별에너지분석Row)
                            'Dr월에너지요구량 = DSETR.에너지분석및요구량.Rows(i_count_month - 1) '//각 월별 시트에 값을 셋트(에너지분석및요구량 테이블에 들어있다)
                            If DR존.냉난방방식 = "냉난방" Or DR존.냉난방방식 = "난방" Then    '//냉난방,난방
                                Dr월에너지요구량.난방에너지요구량열 = TOSG((Q_h_b_op) / 1000) '=================== Q_h_b_we 2010.2.21 삭제
                                Dr월에너지요구량.난방에너지요구량공조환기 = TOSG(Q_vh_b_op / 1000)
                                '  If i_count_month = 1 Then MsgBox("1")
                                'Log.AppendLine("공조값설정=" & CSng(Q_vh_b_op / 1000))
                            ElseIf DR존.냉난방공조 = "냉난방" Or DR존.냉난방공조 = "난방" Then    '//냉난방,난방
                                Dr월에너지요구량.난방에너지요구량열 = 0
                                Dr월에너지요구량.난방에너지요구량공조환기 = TOSG((Q_h_b_op) / 1000) '=================== Q_h_b_we 2010.2.21 삭제

                                '//오류확인용 존1만 확인한다.
                                'If DR존.code = "0001" Then MsgBox(DR존.냉난방방식 & vbCrLf & DR존.냉난방공조 & vbCrLf & CSng((Q_h_b_op + Q_h_b_we) / 1000), MsgBoxStyle.Information, DR존.code)

                            Else
                                If (DR존.냉난방공조 = "냉방" Or DR존.냉난방공조 = "환기") And DR존.외기부하처리여부 = "예" Then '냉방/환기/"예" Then
                                    Dr월에너지요구량.난방에너지요구량열 = 0
                                    ' If i_count_month = 1 Then MsgBox("3")
                                    Dr월에너지요구량.난방에너지요구량공조환기 = TOSG(Q_vh_b_op / 1000)
                                Else
                                    ' If i_count_month = 1 Then MsgBox("4")
                                    Dr월에너지요구량.난방에너지요구량열 = 0
                                    Dr월에너지요구량.난방에너지요구량공조환기 = 0
                                End If
                            End If

                            Dr월에너지요구량.조명에너지요구량 = Q_l_b / 1000

                            ' Log.AppendLine("i_count_HeatCool=" & i_count_HeatCool & "i_count_month=" & i_count_month & ",급탕에너지요구량=" & CSng(Q_w_b / 1000))
                            Dr월에너지요구량.급탕에너지요구량 = Q_w_b / 1000
                            ' MsgBox("난방요구량" & Dr월에너지요구량.난방요구량공조, MsgBoxStyle.Information, i_count_month & "CZONE")
                        End If

                    Else
                        If i_count_month = 0 Then
                            Dr최대부하.최대냉방기기부하 = TOSG((Q_h_b_op) / 1000) '=================== Q_h_b_we 2010.2.21 삭제
                            'Worksheets("" & i_count_month & "").Range("최대냉방부하1").Offset(0, i_count_zone - 1) = (Q_h_b_op + Q_h_b_we) / 1000
                            If DR존.야간운전방식 = "가동정지" Then  '//가동정지
                                Dr최대부하.일일냉방최대가동시간 = t_h_op_d ' Worksheets("" & i_count_month & "").Range("최대냉방부하1").Offset(2, i_count_zone - 1) = t_h_op_d
                            Else
                                Dr최대부하.일일냉방최대가동시간 = 24 'Worksheets("" & i_count_month & "").Range("최대냉방부하1").Offset(2, i_count_zone - 1) = 24
                            End If

                        Else
                            Dim Dr월에너지요구량 As DSR.월별에너지분석Row = CType(DSETR.월별에너지분석.Select("월='" & Mon & "' and 존='" & DR존.code & "'")(0), DSR.월별에너지분석Row)
                            If DR존.냉난방방식 = "냉난방" Or DR존.냉난방방식 = "냉방" Then    '//냉난방/냉방
                                Dr월에너지요구량.냉방요구량열 = TOSG((Q_h_b_op) / 1000) '=================== Q_h_b_we 2010.2.21 삭제
                                Dr월에너지요구량.냉방요구량공조 = TOSG(Q_vh_b_op / 1000)
                            Else
                                If DR존.냉난방공조 = "냉난방" Or DR존.냉난방공조 = "냉방" Then    '//냉난방/냉방
                                    Dr월에너지요구량.냉방요구량열 = 0
                                    Dr월에너지요구량.냉방요구량공조 = TOSG((Q_h_b_op) / 1000) '=================== Q_h_b_we 2010.2.21 삭제
                                Else
                                    If (DR존.냉난방공조 = "난방" Or DR존.냉난방공조 = "환기") And DR존.냉난방공조 = "예" Then '//난방/환기/예
                                        Dr월에너지요구량.냉방요구량열 = 0
                                        Dr월에너지요구량.냉방요구량공조 = TOSG(Q_vh_b_op / 1000)
                                    Else
                                        Dr월에너지요구량.냉방요구량열 = 0
                                        Dr월에너지요구량.냉방요구량공조 = 0
                                    End If

                                End If
                            End If

                            'MsgBox("냉방요구량" & Dr월에너지요구량.냉방요구량공조, MsgBoxStyle.Information, i_count_month & "CZONE")
                        End If
                    End If
                Next '(3)

                Dim CAir As New CAirHandling
                If i_count_month = 0 Then
                    CAir.Calc_Max_Power(i_count_HeatCool) '//AIR HANDLING 모듈 에 존재함..역시 내용이 크다 ㅠ_ㅠ
                End If

            Next '(2)
        Next '(1)

        Work_msg("에너지분석데이터 집계중...")
        Frm_Work.ProgressBar1.Maximum = 13
        Frm_Work.ProgressBar1.Minimum = 0
        Frm_Work.ProgressBar1.Value = 0
        Frm_Work.TopMost = True
        Frm_Work.Show()
        '//요구량 계산이 완료되었으므로 Summary 계산한다. (이것이 없어서 소요량이 오류났음)
        For Each Dr As C에너지분석 In Result.E분석 '//12달치의 각존들의 데이터를 가지고 합계내역을 추린다.
            Work_plus()
            Dr.Calc()
        Next
        DSETR.AcceptChanges()
        Return True
    End Function


    ''' <summary>
    ''' (main2)소요량 계산
    ''' </summary>
    ''' <remarks></remarks>
    Public Function Calc_Useage() As Boolean
        'Dim d_op_month As Integer
        Dim theta_e_month As Decimal
        Dim d_full_mth As Integer

        Work_msg("소요량계산중...")
        Frm_Work.ProgressBar1.Maximum = 12
        Frm_Work.ProgressBar1.Minimum = 0
        Frm_Work.ProgressBar1.Value = 0
        Frm_Work.TopMost = True
        Frm_Work.Show()

        For i_count_month As Short = 1 To 12 '//월별로 난/냉방 소요량을 계산
            Work_msg("소요량계산중..." & "(" & i_count_month & "/12)") : Work_plus()
            '===============================================2010.2.21 수정
            'd_op_month = d_op(i_count_month)
            d_full_mth = CInt(Calc.Pub.d_full(i_count_month))
            '===============================================2010.2.21 수정
            theta_e_month = Calc.Pub.theta_e(i_count_month)

            '///난방
            Calc.Heating.Calc_WaterheatingSystem(i_count_month, d_full_mth, theta_e_month)  '//급탕소요량 '========2010.2.21 수정
            Calc.AirHandling.Calc_AirHandling(i_count_month, d_full_mth) '//환기? '========2010.2.21 수정
            If Result.E분석(i_count_month).난방에너지요구량 <> 0 Then Calc.Heating.Calc_HeatingSystem(i_count_month, theta_e_month) '//난방소요량

            '///냉방
            If Result.E분석(i_count_month).냉방에너지요구량 <> 0 Then Calc.Cooling.Calc_CoolingSystem(i_count_month, theta_e_month)
        Next
        DSETR.AcceptChanges()
        Return True
    End Function



End Class

