| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486 | 
							- BemsWebApplication.SimulatorIceStorage = function (params, viewInfo) {
 
-     "use strict";
 
-     var endpointSelector = "";
 
-     if (BemsWebApplication.config.mode == "production") {
 
-         endpointSelector = new DevExpress.EndpointSelector(BemsWebApplication.config.endpoints).config.db.production;
 
-     } else {
 
-         endpointSelector = new DevExpress.EndpointSelector(BemsWebApplication.config.endpoints).config.db.local;
 
-     }
 
-     var BemsIceThermalStorageDataSource = BemsWebApplication.db.createDataSource('BemsIceThermalStorageSimulation');
 
-     var timeBoxForSearch = BWA.SearchView.createDateTimeBox($G.TimeTypesForDayOnly);
 
-     var visibleConfigPopup = ko.observable(false);
 
-     var timer;
 
-     var initialized = false;
 
-     var initializedforPopUp = false;
 
-     var iceThermalStorage_SimulationValueGet = new BWA.Chart.IceThermalStorage_SimulationValueGet(BWA.UserInfo.SiteId());
 
-     var chart = BWA.Chart.Instance('chartIS', 'dxChart');
 
-     //  그리드 도표 작업 : 팝업창 추가
 
-     // 팝업창뷰 보이기 속성 제어용 변수 선언
 
-     var DataGridPopup_Visible = ko.observable(false);
 
-     // 그래프 출력 이후 엑셀출력을 위한 팝업창을 위해 임시 저장용 배열 선언
 
-     var dataArrayresult = ko.observableArray();
 
-     //  그리드 도표 작업 : 팝업창 추가
 
-     var dataArrayforPopup = [];     // 도표에 들어갈 변수 
 
-     var visibleHourGlassPopup = ko.observable(false);
 
-     var visibleEditButton = ko.observable(true);    // 수정 버튼 활성화 여부 플래그
 
-     var hasnotModificationPermission = ko.observable(false); // 수정버튼 비활성화 플래그
 
-     var isEditModeInPopup = ko.observable(false);   // 저장버튼 활성화 플래그
 
-     var isNotModifyMode = ko.observable(true);     // 저장버튼 비활성화 플래그
 
-     var visibleCancelButton = ko.observable(false); // 취소버튼 활성화 플래그
 
-     var simulatoricestoragePopupToolbarItems = [
 
-             { location: 'before', text: '사용자 시뮬레이터 변수 설정' },
 
-             { location: 'after', widget: 'button', options: { text: $G('edit'), icon: 'edit', visible: visibleEditButton, disabled: hasnotModificationPermission, clickAction: handlePopupButtonEdit } },
 
-             { location: 'after', widget: 'button', options: { text: $G('cancel'), icon: 'cancel', visible: visibleCancelButton, clickAction: handlePopupButtonCancel } },
 
-             { location: 'after', widget: 'button', options: { text: $G('save'), icon: 'save', visible: isEditModeInPopup, disabled: isNotModifyMode, clickAction: handlePopupButtonSave } },
 
-             { location: 'after', widget: 'button', options: { text: $G('close'), icon: 'close', visible: true, disabled: false, clickAction: PopupButtonClose } }
 
-     ];
 
-     var CurrntRowStatusAsSave = 1;      // 저장했을때 최종 row 인덱스 (취소, 닫기했을때 이전 최종 행 위치를 알기 위함)
 
-     // 편집 중인 행과 활성화 여부 플래그
 
-     var EditingFirstRow = ko.observable(true);
 
-     var EditingSecondRow = ko.observable(false);
 
-     var EditingThirdRow = ko.observable(false);
 
-     var EditingFourthRow = ko.observable(false);
 
-     var EditingFifthRow = ko.observable(false);
 
-     var isSecondRow = ko.observable(false);
 
-     var isThirdRow = ko.observable(false);
 
-     var isFourthRow = ko.observable(false);
 
-     var isFifthRow = ko.observable(false);
 
-     
 
-     //Initial Date는 지금 시점 이후부터 입력(initialDate와 finalDate는 기준 시작, 종료 일시)
 
-     var initialDate = new Date();
 
-     initialDate.setMinutes((parseInt(initialDate.getMinutes() / 15)) * 15);
 
-     var finalDate = new Date();
 
-     if (finalDate.getHours() < 21) {
 
-         finalDate.setHours(0)
 
-         finalDate.setMinutes(45);
 
-         finalDate.setSeconds(0);
 
-         finalDate = moment(finalDate).add(20, 'hours').toDate();
 
-     }
 
-     else {
 
-         finalDate.setHours(0)
 
-         finalDate.setMinutes(45);
 
-         finalDate.setSeconds(0);
 
-         finalDate = moment(finalDate).add(1, 'days').toDate();
 
-         finalDate = moment(finalDate).add(20, 'hours').toDate();
 
-     }
 
-     // 행 추가, 제거시 기억할 변수 선언
 
-     var initDate_prev = new Array();
 
-     var finalDate_prev = new Array();
 
-     var operationMode_prev = new Array();
 
-     var ref1Status_prev = new Array();
 
-     var ref2Status_prev = new Array();
 
-     // 저장시 기억할 변수 선언 (~_asSave)
 
-     var initDate_asSave = new Array(new Date(initialDate), new Date(initialDate), new Date(initialDate), new Date(initialDate), new Date(initialDate));
 
-     var finalDate_asSave = new Array(new Date(finalDate), new Date(finalDate), new Date(finalDate), new Date(finalDate), new Date(finalDate));
 
-     var operationMode_asSave = new Array(null, null, null, null, null);
 
-     var ref1Status_asSave = new Array(null, null, null, null, null);
 
-     var ref2Status_asSave = new Array(null, null, null, null, null);
 
-     var treeOperationMode = [
 
-     {
 
-         id: 0,
 
-         text: "OFF",
 
-         value: 0
 
-     },
 
-     {
 
-         id: 1,
 
-         text: "제빙운전",
 
-         value: 10
 
-     },
 
-     {
 
-         id: 2,
 
-         text: "축단운전",
 
-         value: 20
 
-     },
 
-     {
 
-         id: 3,
 
-         text: "병렬운전",
 
-         value: 30
 
-     },
 
-     {
 
-         id: 4,
 
-         text: "냉단운전",
 
-         value: 40
 
-     }
 
-     ];
 
-     // 현재시점에 최종 수정 row 플래그
 
-     function EditingRowArrange() {
 
-         var Edit_idx = [false, false, false, false, false];
 
-         var EnDis_idx = [false, false, false, false, false];
 
-         Edit_idx[CurrntRowStatusAsSave - 1] = true;
 
-         for (var i = 0; i < CurrntRowStatusAsSave; i++) {
 
-             EnDis_idx[i] = true;
 
-         }
 
-         EditingFirstRow(Edit_idx[0]);
 
-         EditingSecondRow(Edit_idx[1]);
 
-         EditingThirdRow(Edit_idx[2]);
 
-         EditingFourthRow(Edit_idx[3]);
 
-         EditingFifthRow(Edit_idx[4]);
 
-         isSecondRow(EnDis_idx[1]);
 
-         isThirdRow(EnDis_idx[2]);
 
-         isFourthRow(EnDis_idx[3]);
 
-         isFifthRow(EnDis_idx[4]);
 
-     }
 
-     // 팝업뜰 때마다 호출 (수정모드 템플릿)
 
-     function InitializedTemplate() {
 
-         visibleEditButton(true);
 
-         hasnotModificationPermission(false);
 
-         isEditModeInPopup(false);
 
-         isNotModifyMode(true);
 
-         visibleCancelButton(false);
 
-         EditingRowArrange();        // 현재시점에 최종 수정 row 플래그
 
-         // 팝업뜰때는 수정모드가 아니므로 모두 disabled
 
-         for (var i = 0; i < 5; i++) {
 
-             EnableDisableRow(i + 1, true);
 
-         }
 
-     }
 
-     //초기 데이터 initialize
 
-     function InitializedData() {
 
-         var initialDate_ = new Date();
 
-         initialDate_.setMinutes((parseInt(initialDate_.getMinutes() / 15)) * 15); // 15분 단위 맞춰주기 위함
 
-         initialDate_.setSeconds(0);
 
-         var finalDate_ = new Date();
 
-         if (finalDate_.getHours() < 21) {
 
-             finalDate_.setHours(0)
 
-             finalDate_.setMinutes(45);
 
-             finalDate_.setSeconds(0);
 
-             finalDate_ = moment(finalDate_).add(20, 'hours').toDate();
 
-         }
 
-         else {
 
-             finalDate_.setHours(0)
 
-             finalDate_.setMinutes(45);
 
-             finalDate_.setSeconds(0);
 
-             finalDate_ = moment(finalDate_).add(1, 'days').toDate();
 
-             finalDate_ = moment(finalDate_).add(20, 'hours').toDate();
 
-         }
 
-         for (var i = 0; i < 5; i++) {
 
-             BoxInitialize(i + 1, initialDate_, finalDate_);
 
-             EnableDisableRow(i + 1, true);       // 초기는 수정모드가 아니므로 모두 disabled
 
-         }
 
-     }
 
-     
 
-     // 수정 버튼 클릭시 호출 함수
 
-     function handlePopupButtonEdit() {
 
-         visibleEditButton(false);
 
-         hasnotModificationPermission(true);
 
-         isEditModeInPopup(true);
 
-         isNotModifyMode(false);
 
-         visibleCancelButton(true);
 
-         EditingRowArrange();        // 현재시점에 최종 수정 row 플래그
 
-         EnableDisableRow(CurrntRowStatusAsSave, false);        // 현재시점에 최종 수정 row 활성화
 
-     }
 
-     // ~_prev 변수 입력
 
-     function prevDataWrite(row_num) {
 
-         $("#InitialDate" + (row_num).toString()).dxDateBox('instance').option('value', initDate_prev[row_num - 1]);
 
-         $("#InitialTime" + (row_num).toString()).dxDateBox('instance').option('value', initDate_prev[row_num - 1]);
 
-         $("#FinalDate" + (row_num).toString()).dxDateBox('instance').option('value', finalDate_prev[row_num - 1]);
 
-         $("#FinalTime" + (row_num).toString()).dxDateBox('instance').option('value', finalDate_prev[row_num - 1]);
 
-         $("#OperationMode" + (row_num).toString()).dxSelectBox('instance').option('value', operationMode_prev[row_num - 1]);
 
-         $("#Ref1_Status" + (row_num).toString()).dxSwitch('instance').option('value', ref1Status_prev[row_num - 1]);
 
-         $("#Ref2_Status" + (row_num).toString()).dxSwitch('instance').option('value', ref2Status_prev[row_num - 1]);
 
-     }
 
-     function DeleteRow() {
 
-         var now_ = new Date();
 
-         var finalDate_ = new Date(now_.getFullYear(), now_.getMonth(), now_.getDate(), 20, 45, 0);
 
-         if (now_.getHours() >= 21) {
 
-             finalDate_ = moment(finalDate_).add(1, 'days').toDate();
 
-         }
 
-         if (EditingFirstRow() === true) {
 
-             $("#FinalDate1").dxDateBox('instance').option('value', finalDate_);
 
-             $("#FinalTime1").dxDateBox('instance').option('value', finalDate_);
 
-             $("#OperationMode1").dxSelectBox('instance').option('value', null);// 운전 모드 클리어
 
-             $("#Ref1_Status1").dxSwitch('instance').option('value', false);// 냉동기1 운전 모드 클리어
 
-             $("#Ref2_Status1").dxSwitch('instance').option('value', false);// 냉동기2 운전 모드 클리어
 
-             
 
-         }
 
-         else if (EditingSecondRow() === true) {
 
-             $("#FinalDate2").dxDateBox('instance').option('value', finalDate_);
 
-             $("#FinalTime2").dxDateBox('instance').option('value', finalDate_);
 
-             $("#OperationMode2").dxSelectBox('instance').option('value', null);// 운전 모드 클리어
 
-             $("#Ref1_Status2").dxSwitch('instance').option('value', false);// 냉동기1 운전 모드 클리어
 
-             $("#Ref2_Status2").dxSwitch('instance').option('value', false);// 냉동기2 운전 모드 클리어
 
-             EnableDisableRow(1, false);
 
-             EditingFirstRow(true);
 
-             EditingSecondRow(false);
 
-             isSecondRow(false);
 
-             prevDataWrite(1);           // 행 삭제시 이전 행의 변수 초기화로 다시 쓰기
 
-         }
 
-         else if (EditingThirdRow() === true) {
 
-             $("#FinalDate3").dxDateBox('instance').option('value', finalDate_);
 
-             $("#FinalTime3").dxDateBox('instance').option('value', finalDate_);
 
-             $("#OperationMode3").dxSelectBox('instance').option('value', null);// 운전 모드 클리어
 
-             $("#Ref1_Status3").dxSwitch('instance').option('value', false);// 냉동기1 운전 모드 클리어
 
-             $("#Ref2_Status3").dxSwitch('instance').option('value', false);// 냉동기2 운전 모드 클리어
 
-             EnableDisableRow(2, false);
 
-             EditingSecondRow(true);
 
-             EditingThirdRow(false);
 
-             isThirdRow(false);
 
-             prevDataWrite(2);       // 행 삭제시 이전 행의 변수 초기화로 다시 쓰기
 
-         }
 
-         else if (EditingFourthRow() === true) {
 
-             $("#FinalDate4").dxDateBox('instance').option('value', finalDate_);
 
-             $("#FinalTime4").dxDateBox('instance').option('value', finalDate_);
 
-             $("#OperationMode4").dxSelectBox('instance').option('value', null);// 운전 모드 클리어
 
-             $("#Ref1_Status4").dxSwitch('instance').option('value', false);// 냉동기1 운전 모드 클리어
 
-             $("#Ref2_Status4").dxSwitch('instance').option('value', false);// 냉동기2 운전 모드 클리어
 
-             EnableDisableRow(3, false);
 
-             EditingThirdRow(true);
 
-             EditingFourthRow(false);
 
-             isFourthRow(false);
 
-             prevDataWrite(3);       // 행 삭제시 이전 행의 변수 초기화로 다시 쓰기
 
-         }
 
-         else if (EditingFifthRow() === true) {
 
-             $("#FinalDate5").dxDateBox('instance').option('value', finalDate_);
 
-             $("#FinalTime5").dxDateBox('instance').option('value', finalDate_);
 
-             $("#OperationMode5").dxSelectBox('instance').option('value', null);// 운전 모드 클리어
 
-             $("#Ref1_Status5").dxSwitch('instance').option('value', false);// 냉동기1 운전 모드 클리어
 
-             $("#Ref2_Status5").dxSwitch('instance').option('value', false);// 냉동기2 운전 모드 클리어
 
-             EnableDisableRow(4, false);
 
-             EditingFourthRow(true);
 
-             EditingFifthRow(false);
 
-             isFifthRow(false);
 
-             prevDataWrite(4);       // 행 삭제시 이전 행의 변수 초기화로 다시 쓰기
 
-         }
 
-     }
 
-     
 
-     function FilledRow(row_num) {
 
-         $("#InitialDate" + row_num.toString()).dxDateBox('instance').option('value', initDate_asSave[row_num - 1]);
 
-         $("#InitialTime" + row_num.toString()).dxDateBox('instance').option('value', initDate_asSave[row_num - 1]);
 
-         $("#FinalDate" + row_num.toString()).dxDateBox('instance').option('value', finalDate_asSave[row_num - 1]);
 
-         $("#FinalTime" + row_num.toString()).dxDateBox('instance').option('value', finalDate_asSave[row_num - 1]);
 
-         $("#OperationMode" + row_num.toString()).dxSelectBox('instance').option('value', operationMode_asSave[row_num - 1]);
 
-         $("#Ref1_Status" + row_num.toString()).dxSwitch('instance').option('value', ref1Status_asSave[row_num - 1]);
 
-         $("#Ref2_Status" + row_num.toString()).dxSwitch('instance').option('value', ref2Status_asSave[row_num - 1]);
 
-     }
 
-     // 취소 버튼 클릭시 호출 함수
 
-     function handlePopupButtonCancel() {
 
-         // 전체 열에 대해서 모두 삭제하고 저장된 열들만 다시 채워준다
 
-         for (var i = 0; i < 5; i++) {
 
-             DeleteRow();
 
-         }
 
-         for (var i = 0; i < 5; i++) {
 
-             if (operationMode_asSave[i] != null) {
 
-                 FilledRow(i + 1);
 
-             }
 
-         }
 
-         visibleEditButton(true);
 
-         hasnotModificationPermission(false);
 
-         isEditModeInPopup(false);
 
-         isNotModifyMode(true);
 
-         visibleCancelButton(false);
 
-         EditingRowArrange();        // 현재시점에 최종 수정 row 플래그
 
-         for (var i = 0; i < 5; i++) {
 
-             EnableDisableRow(i + 1, true);
 
-         }
 
-     }
 
-     // 데이터 DB 입력 함수
 
-     function insert(postData) {
 
-         BemsIceThermalStorageDataSource.filter([
 
-                 ["SiteId", "=", BWA.UserInfo.SiteId()],
 
-                 "and",
 
-                 ["FacilityCode", "=", postData.FacilityCode],
 
-                 "and",
 
-                 ["PropertyId", "=", postData.PropertyId],
 
-                 "and",
 
-                 ["SimulationCase", "=", postData.SimulationCase],
 
-                 "and",
 
-                 ["TargetDateTime", "=", postData.TargetDateTime]
 
-         ]);
 
-         //BemsIceThermalStorageDataSource.sort({ getter: "TargetDateTime", desc: true });
 
-         BemsIceThermalStorageDataSource.load()
 
-        .done(function (result) {
 
-            var store = new DevExpress.data.ODataStore({
 
-                url: endpointSelector + "/BemsIceThermalStorageSimulation",
 
-                key: ["SiteId", "FacilityCode", "PropertyId", "CreatedDateTime", "TargetDateTime", "SimulationCase"],
 
-                keyType: {
 
-                    SiteId: "Int32", FacilityCode: "Int32", PropertyId: "Int32", CreatedDateTime: "DateTime", TargetDateTime: "DateTime", SimulationCase: "Int32"
 
-                }
 
-            });
 
-            if (result.length != 0) {
 
-                var removeData = {
 
-                    SiteId: result[0].SiteId(),
 
-                    FacilityTypeId: result[0].FacilityTypeId(),
 
-                    FacilityCode: result[0].FacilityCode(),
 
-                    PropertyId: result[0].PropertyId(),
 
-                    CreatedDateTime: new Date(result[0].CreatedDateTime()),
 
-                    TargetDateTime: new Date(result[0].TargetDateTime()),
 
-                    SimulationValue: result[0].SimulationValue(),
 
-                    SimulationCase: result[0].SimulationCase()
 
-                };
 
-                store.remove(removeData).done(function (values, key) {
 
-                    store.insert(postData).done(function (key, result) {
 
-                        //utils.toast.show($G('successDatabaseInsertionMsg'));
 
-                        visibleConfigPopup(false);
 
-                    })
 
-                     .fail(function (error) {
 
-                         utils.toast.show(error, 'error');
 
-                     });
 
-                })
 
-                .fail(function (error) {
 
-                    utils.toast.show(error, 'error');
 
-                });
 
-            }
 
-            else {
 
-                store.insert(postData).done(function (key, result) {
 
-                    //utils.toast.show($G('successDatabaseInsertionMsg'));
 
-                    visibleConfigPopup(false);
 
-                })
 
-                 .fail(function (error) {
 
-                     utils.toast.show(error, 'error');
 
-                 });
 
-            }
 
-        });
 
-     }
 
-     function DataArrange(initialDate_, finalDate_, facilityTypeId, facilityCode, propertyId, value, simulationCase) {
 
-         var now_date = new Date();
 
-         var comparedDate = new Date(initialDate_.getFullYear(), initialDate_.getMonth(), initialDate_.getDate(), initialDate_.getHours(), initialDate_.getMinutes(), 0);
 
-         while (comparedDate <= finalDate_) {
 
-             //insert
 
-             var nowDate_tmp = new Date(now_date.getFullYear(), now_date.getMonth(), now_date.getDate(), now_date.getHours(), now_date.getMinutes(), now_date.getSeconds());
 
-             var tmpDate = new Date(comparedDate.getFullYear(), comparedDate.getMonth(), comparedDate.getDate(), comparedDate.getHours(), comparedDate.getMinutes(), 0);
 
-             var postViewModel = new BemsWebApplication.BemsIceThermalStorageSimulationViewModel();
 
-             postViewModel.SiteId(BWA.UserInfo.SiteId());
 
-             postViewModel.FacilityTypeId(facilityTypeId);
 
-             postViewModel.FacilityCode(facilityCode);
 
-             postViewModel.PropertyId(propertyId);
 
-             postViewModel.CreatedDateTime(nowDate_tmp);
 
-             postViewModel.TargetDateTime(tmpDate);
 
-             postViewModel.SimulationValue(value);
 
-             postViewModel.SimulationCase(simulationCase);
 
-             var postData = postViewModel.toJS();
 
-             insert(postData);
 
-             comparedDate.setMinutes(comparedDate.getMinutes() + 15);
 
-         }
 
-     }
 
-     function DataExtract(row_num) {
 
-         var islastRow = false;
 
-         if (EditingFirstRow() == true && row_num == 1) { islastRow = true; }
 
-         else if (EditingSecondRow() == true && row_num == 2) { islastRow = true; }
 
-         else if (EditingThirdRow() == true && row_num == 3) { islastRow = true; }
 
-         else if (EditingFourthRow() == true && row_num == 4) { islastRow = true; }
 
-         else if (EditingFifthRow() == true && row_num == 5) { islastRow = true; }
 
-         // 데이터 저장
 
-         // 현재 활성화된 마지막 행만 ~_prev 데이터에 저장하고 DB 입력을 위한 부분, 이전행은 '행 추가' 버튼 클릭시 저장됨
 
-         if (islastRow) {
 
-             var tmp_initDate_ = $("#InitialTime" + (row_num).toString()).dxDateBox('instance').option('value');
 
-             initDate_prev[row_num - 1] = new Date(tmp_initDate_.getFullYear(), tmp_initDate_.getMonth(), tmp_initDate_.getDate(), tmp_initDate_.getHours(), tmp_initDate_.getMinutes(), 0);
 
-             initDate_asSave[row_num - 1] = new Date(tmp_initDate_.getFullYear(), tmp_initDate_.getMonth(), tmp_initDate_.getDate(), tmp_initDate_.getHours(), tmp_initDate_.getMinutes(), 0);
 
-             var tmp_finalDate_ = $("#FinalTime" + (row_num).toString()).dxDateBox('instance').option('value');
 
-             finalDate_prev[row_num - 1] = new Date(tmp_finalDate_.getFullYear(), tmp_finalDate_.getMonth(), tmp_finalDate_.getDate(), tmp_finalDate_.getHours(), tmp_finalDate_.getMinutes(), 0);
 
-             finalDate_asSave[row_num - 1] = new Date(tmp_finalDate_.getFullYear(), tmp_finalDate_.getMonth(), tmp_finalDate_.getDate(), tmp_finalDate_.getHours(), tmp_finalDate_.getMinutes(), 0);
 
-             operationMode_prev[row_num - 1] = $("#OperationMode" + (row_num).toString()).dxSelectBox('instance').option('value');
 
-             operationMode_asSave[row_num - 1] = $("#OperationMode" + (row_num).toString()).dxSelectBox('instance').option('value');
 
-             ref1Status_prev[row_num - 1] = $("#Ref1_Status" + (row_num).toString()).dxSwitch('instance').option('value');
 
-             ref1Status_asSave[row_num - 1] = $("#Ref1_Status" + (row_num).toString()).dxSwitch('instance').option('value');
 
-             ref2Status_prev[row_num - 1] = $("#Ref2_Status" + (row_num).toString()).dxSwitch('instance').option('value');
 
-             ref2Status_asSave[row_num - 1] = $("#Ref2_Status" + (row_num).toString()).dxSwitch('instance').option('value');
 
-             if (ref1Status_prev[row_num - 1]) { var ref1Status_int = 1; } else { var ref1Status_int = 0; }
 
-             if (ref2Status_prev[row_num - 1]) { var ref2Status_int = 1; } else { var ref2Status_int = 0; }
 
-             DataArrange(initDate_prev[row_num - 1], finalDate_prev[row_num - 1], 3, 4478, 16, parseInt(operationMode_prev[row_num - 1] * 10), 1);  // 0: OFF, 10: 제빙, 20: 축단, 30:병렬, 40: 냉단
 
-             DataArrange(initDate_prev[row_num - 1], finalDate_prev[row_num - 1], 2, 4479, 15, ref1Status_int, 1);
 
-             DataArrange(initDate_prev[row_num - 1], finalDate_prev[row_num - 1], 2, 4480, 15, ref2Status_int, 1);
 
-         }
 
-         else {
 
-             // 날짜 박스에서 불러올 경우 enable된 열의 날짜를 불러오기때문에 ~_prev 변수에서 불러옴
 
-             var initDate_ = initDate_prev[row_num - 1];
 
-             var finalDate_ = finalDate_prev[row_num - 1];
 
-             initDate_asSave[row_num - 1] = initDate_prev[row_num - 1];
 
-             finalDate_asSave[row_num - 1] = finalDate_prev[row_num - 1];
 
-             var operationMode = $("#OperationMode" + (row_num).toString()).dxSelectBox('instance').option('value');
 
-             operationMode_asSave[row_num - 1] = $("#OperationMode" + (row_num).toString()).dxSelectBox('instance').option('value');
 
-             var ref1Status = $("#Ref1_Status" + (row_num).toString()).dxSwitch('instance').option('value');
 
-             ref1Status_asSave[row_num - 1] = $("#Ref1_Status" + (row_num).toString()).dxSwitch('instance').option('value');
 
-             var ref2Status = $("#Ref2_Status" + (row_num).toString()).dxSwitch('instance').option('value');
 
-             ref2Status_asSave[row_num - 1] = $("#Ref2_Status" + (row_num).toString()).dxSwitch('instance').option('value');
 
-             if (ref1Status) { var ref1Status_int = 1; } else { var ref1Status_int = 0; }
 
-             if (ref2Status) { var ref2Status_int = 1; } else { var ref2Status_int = 0; }
 
-             DataArrange(initDate_, finalDate_, 3, 4478, 16, parseInt(operationMode * 10), 1);  // 0: OFF, 10: 제빙, 20: 축단, 30:병렬, 40: 냉단
 
-             DataArrange(initDate_, finalDate_, 2, 4479, 15, ref1Status_int, 1);
 
-             DataArrange(initDate_, finalDate_, 2, 4480, 15, ref2Status_int, 1);
 
-         }
 
-     }
 
-     function handlePopupButtonSave() {
 
-         var now_date = new Date();
 
-         if (now_date.getHours() != 0 && now_date.getMinutes() % 15 == 1 && now_date.getSeconds() > 0 && now_date.getSeconds() < 40) {
 
-             utils.toast.show('데이터 모델이 업데이트 중입니다. 잠시후 다시 시도해주세요. (약 40초 소요 예정)', 'error');
 
-         }
 
-         else {
 
-             // 0, 4, 8, 12 ...초 시간에만 동작
 
-             visibleHourGlassPopup(true);        // 모래시계 팝업 활성화
 
-             while (1) {
 
-                 var now_ = new Date();
 
-                 if (now_.getSeconds() % 4 == 0) { break; }
 
-                 else { setTimeout(function () { }, 1000); }
 
-             }
 
-             if (EditingFirstRow() === true) {
 
-                 if (enabledDateRange(1, "save")) {
 
-                     initDate_asSave = new Array(new Date(initialDate), new Date(initialDate), new Date(initialDate), new Date(initialDate), new Date(initialDate));
 
-                     finalDate_asSave = new Array(new Date(finalDate), new Date(finalDate), new Date(finalDate), new Date(finalDate), new Date(finalDate));
 
-                     operationMode_asSave = new Array(null, null, null, null, null);
 
-                     ref1Status_asSave = new Array(null, null, null, null, null);
 
-                     ref2Status_asSave = new Array(null, null, null, null, null);
 
-                     DataExtract(1);
 
-                     $("#LoadPanel").dxLoadPanel('instance').option('visible', true);
 
-                     visibleHourGlassPopup(true);        // 모래시계 팝업 활성화
 
-                     // Python에서 데이터 처리하고 DB에서 데이터 불러오는 시간 고려
 
-                     setTimeout(function () {
 
-                         $("#LoadPanel").dxLoadPanel('instance').option('visible', false);
 
-                         visibleHourGlassPopup(false);
 
-                         handleSearchInSearchView();
 
-                     }, 12000);
 
-                     CurrntRowStatusAsSave = 1;
 
-                 }
 
-             }
 
-             else if (EditingSecondRow() === true) {
 
-                 if (enabledDateRange(2, "save")) {
 
-                     initDate_asSave = new Array(new Date(initialDate), new Date(initialDate), new Date(initialDate), new Date(initialDate), new Date(initialDate));
 
-                     finalDate_asSave = new Array(new Date(finalDate), new Date(finalDate), new Date(finalDate), new Date(finalDate), new Date(finalDate));
 
-                     operationMode_asSave = new Array(null, null, null, null, null);
 
-                     ref1Status_asSave = new Array(null, null, null, null, null);
 
-                     ref2Status_asSave = new Array(null, null, null, null, null);
 
-                     DataExtract(1);
 
-                     DataExtract(2);
 
-                     $("#LoadPanel").dxLoadPanel('instance').option('visible', true);
 
-                     visibleHourGlassPopup(true);        // 모래시계 팝업 활성화
 
-                     // Python에서 데이터 처리하고 DB에서 데이터 불러오는 시간 고려
 
-                     setTimeout(function () {
 
-                         $("#LoadPanel").dxLoadPanel('instance').option('visible', false);
 
-                         visibleHourGlassPopup(false);
 
-                         handleSearchInSearchView();
 
-                     }, 12000);
 
-                     CurrntRowStatusAsSave = 2;
 
-                 }
 
-             }
 
-             else if (EditingThirdRow() === true) {
 
-                 if (enabledDateRange(3, "save")) {
 
-                     initDate_asSave = new Array(new Date(initialDate), new Date(initialDate), new Date(initialDate), new Date(initialDate), new Date(initialDate));
 
-                     finalDate_asSave = new Array(new Date(finalDate), new Date(finalDate), new Date(finalDate), new Date(finalDate), new Date(finalDate));
 
-                     operationMode_asSave = new Array(null, null, null, null, null);
 
-                     ref1Status_asSave = new Array(null, null, null, null, null);
 
-                     ref2Status_asSave = new Array(null, null, null, null, null);
 
-                     DataExtract(1);
 
-                     DataExtract(2);
 
-                     DataExtract(3);
 
-                     $("#LoadPanel").dxLoadPanel('instance').option('visible', true);
 
-                     visibleHourGlassPopup(true);        // 모래시계 팝업 활성화
 
-                     // Python에서 데이터 처리하고 DB에서 데이터 불러오는 시간 고려
 
-                     setTimeout(function () {
 
-                         $("#LoadPanel").dxLoadPanel('instance').option('visible', false);
 
-                         visibleHourGlassPopup(false);
 
-                         handleSearchInSearchView();
 
-                     }, 12000);
 
-                     CurrntRowStatusAsSave = 3;
 
-                 }
 
-             }
 
-             else if (EditingFourthRow() === true) {
 
-                 if (enabledDateRange(4, "save")) {
 
-                     initDate_asSave = new Array(new Date(initialDate), new Date(initialDate), new Date(initialDate), new Date(initialDate), new Date(initialDate));
 
-                     finalDate_asSave = new Array(new Date(finalDate), new Date(finalDate), new Date(finalDate), new Date(finalDate), new Date(finalDate));
 
-                     operationMode_asSave = new Array(null, null, null, null, null);
 
-                     ref1Status_asSave = new Array(null, null, null, null, null);
 
-                     ref2Status_asSave = new Array(null, null, null, null, null);
 
-                     DataExtract(1);
 
-                     DataExtract(2);
 
-                     DataExtract(3);
 
-                     DataExtract(4);
 
-                     $("#LoadPanel").dxLoadPanel('instance').option('visible', true);
 
-                     visibleHourGlassPopup(true);        // 모래시계 팝업 활성화
 
-                     // Python에서 데이터 처리하고 DB에서 데이터 불러오는 시간 고려
 
-                     setTimeout(function () {
 
-                         $("#LoadPanel").dxLoadPanel('instance').option('visible', false);
 
-                         visibleHourGlassPopup(false);
 
-                         handleSearchInSearchView();
 
-                     }, 12000);
 
-                     CurrntRowStatusAsSave = 4;
 
-                 }
 
-             }
 
-             else if (EditingFifthRow() === true) {
 
-                 if (enabledDateRange(5, "save")) {
 
-                     initDate_asSave = new Array(new Date(initialDate), new Date(initialDate), new Date(initialDate), new Date(initialDate), new Date(initialDate));
 
-                     finalDate_asSave = new Array(new Date(finalDate), new Date(finalDate), new Date(finalDate), new Date(finalDate), new Date(finalDate));
 
-                     operationMode_asSave = new Array(null, null, null, null, null);
 
-                     ref1Status_asSave = new Array(null, null, null, null, null);
 
-                     ref2Status_asSave = new Array(null, null, null, null, null);
 
-                     DataExtract(1);
 
-                     DataExtract(2);
 
-                     DataExtract(3);
 
-                     DataExtract(4);
 
-                     DataExtract(5);
 
-                     $("#LoadPanel").dxLoadPanel('instance').option('visible', true);
 
-                     visibleHourGlassPopup(true);        // 모래시계 팝업 활성화
 
-                     // Python에서 데이터 처리하고 DB에서 데이터 불러오는 시간 고려
 
-                     setTimeout(function () {
 
-                         $("#LoadPanel").dxLoadPanel('instance').option('visible', false);
 
-                         visibleHourGlassPopup(false);
 
-                         handleSearchInSearchView();
 
-                     }, 12000);
 
-                     CurrntRowStatusAsSave = 5;
 
-                 }
 
-             }
 
-         }
 
-         visibleHourGlassPopup(false);        // 모래시계 팝업 비활성화
 
-     }
 
-     // 데이터 범위 및 필수 입력사항 체크 함수
 
-     function enabledDateRange(row_num, mode) {
 
-         var now_ = new Date();
 
-         var finalDate_ = new Date(now_.getFullYear(), now_.getMonth(), now_.getDate(), 20, 45, 0);
 
-         if (now_.getHours() >= 21) {
 
-             finalDate_ = moment(finalDate_).add(1, 'days').toDate();
 
-         }
 
-         var BoxInitDate_tmp = $("#InitialDate" + (row_num).toString()).dxDateBox('instance').option('value');
 
-         var BoxInitTime_tmp = $("#InitialTime" + (row_num).toString()).dxDateBox('instance').option('value');
 
-         var BoxFinalDate_tmp = $("#FinalDate" + (row_num).toString()).dxDateBox('instance').option('value');
 
-         var BoxFinalTime_tmp = $("#FinalTime" + (row_num).toString()).dxDateBox('instance').option('value');
 
-         var input_inialDateTime = new Date(BoxInitDate_tmp.getFullYear(), BoxInitDate_tmp.getMonth(), BoxInitDate_tmp.getDate(), BoxInitTime_tmp.getHours(), BoxInitTime_tmp.getMinutes(), 0);
 
-         var input_finalDateTime = new Date(BoxFinalDate_tmp.getFullYear(), BoxFinalDate_tmp.getMonth(), BoxFinalDate_tmp.getDate(), BoxFinalTime_tmp.getHours(), BoxFinalTime_tmp.getMinutes(), 0);
 
-         var comparedDate = new Date(now_.getFullYear(), now_.getMonth(), now_.getDate(), 20, 45, 0);
 
-         if (now_.getHours() >= 21) {
 
-             comparedDate = moment(comparedDate).add(1, 'days').toDate();
 
-         }
 
-         var BoxDate_tmp = $("#FinalTime" + (row_num).toString()).dxDateBox('instance').option('value');
 
-         var BoxDate = new Date(BoxDate_tmp.getFullYear(), BoxDate_tmp.getMonth(), BoxDate_tmp.getDate(), BoxDate_tmp.getHours(), BoxDate_tmp.getMinutes(), 0);
 
-         if ($("#OperationMode" + (row_num).toString()).dxSelectBox('instance').option('value') == null) {
 
-             utils.toast.show('항목이 모두 입력되지 않았습니다.', 'error');
 
-             return false;
 
-         }
 
-         else if (BoxDate.getTime() == finalDate_.getTime() && mode == "edit") {
 
-             utils.toast.show('마지막 종료시점이 시뮬레이션 허용 마지막 시간(당일 21시 혹은 익일 21시)이므로 행 추가가 불가합니다.', 'error');
 
-             return false;
 
-         }
 
-         else if (BoxDate.getTime() != finalDate_.getTime() && mode == "save") {
 
-             utils.toast.show('마지막 행의 종료 시점이 시뮬레이션 마지막 시간(21시)과 일치하지 않습니다.', 'error');
 
-             return false;
 
-         }
 
-         else if (input_finalDateTime.getTime() > comparedDate.getTime()) {
 
-             utils.toast.show("입력 최대 기간(당일 21시 혹은 익일 21시)을 초과하였습니다.", 'error');
 
-             $("#FinalTime" + (row_num).toString()).dxDateBox("instance").option('value', comparedDate);
 
-             return false;
 
-         }
 
-         else if (input_finalDateTime.getTime() < input_inialDateTime.getTime()) {
 
-             utils.toast.show("마지막 행의 종료 시간이 시작 시간보다 빠릅니다.", 'error');
 
-             $("#FinalTime" + (row_num).toString()).dxDateBox("instance").option('value', comparedDate);
 
-             return false;
 
-         }
 
-         else {
 
-             return true;
 
-         }
 
-     }
 
-     function handlePopupButtonAdd() {
 
-         // 행추가시 기존 제어 변수 입력 열에 미입력 사항이 있는지 확인하는 기능
 
-         var now_ = new Date();
 
-         var finalDate_ = new Date(now_.getFullYear(), now_.getMonth(), now_.getDate(), 20, 45, 0);
 
-         if (now_.getHours() >= 21) {
 
-             finalDate_ = moment(finalDate_).add(1, 'days').toDate();
 
-         }
 
-         if (EditingFirstRow() === true) {
 
-             if (enabledDateRange(1, "edit")) {
 
-                 var InitDate_tmp = $("#InitialTime1").dxDateBox('instance').option('value');
 
-                 var BoxDate_tmp = $("#FinalTime1").dxDateBox('instance').option('value');
 
-                 var BoxDate = new Date(BoxDate_tmp.getFullYear(), BoxDate_tmp.getMonth(), BoxDate_tmp.getDate(), BoxDate_tmp.getHours(), BoxDate_tmp.getMinutes(), 0);
 
-                 initDate_prev[0] = new Date(InitDate_tmp.getFullYear(), InitDate_tmp.getMonth(), InitDate_tmp.getDate(), InitDate_tmp.getHours(), InitDate_tmp.getMinutes(), 0);
 
-                 finalDate_prev[0] = new Date(BoxDate_tmp.getFullYear(), BoxDate_tmp.getMonth(), BoxDate_tmp.getDate(), BoxDate_tmp.getHours(), BoxDate_tmp.getMinutes(), 0);
 
-                 operationMode_prev[0] = $("#OperationMode1").dxSelectBox('instance').option('value');;
 
-                 ref1Status_prev[0] = $("#Ref1_Status1").dxSwitch("instance").option('value');
 
-                 ref2Status_prev[0] = $("#Ref2_Status1").dxSwitch("instance").option('value');
 
-                 EnableDisableRow(1, true);
 
-                 EnableDisableRow(2, false);
 
-                 EditingFirstRow(false);
 
-                 EditingSecondRow(true);
 
-                 isSecondRow(true);
 
-                 BoxDate.setMinutes(BoxDate.getMinutes() + 15);
 
-                 $("#InitialDate2").dxDateBox('instance').option('value', BoxDate);
 
-                 $("#InitialTime2").dxDateBox('instance').option('value', BoxDate);
 
-                 $("#FinalDate2").dxDateBox('instance').option('value', finalDate_);
 
-                 $("#FinalTime2").dxDateBox('instance').option('value', finalDate_);
 
-             }
 
-             else {
 
-                 return;
 
-             }
 
-         }
 
-         else if (EditingSecondRow() === true) {
 
-             if (enabledDateRange(2, "edit")) {
 
-                 var InitDate_tmp = $("#InitialTime2").dxDateBox('instance').option('value');
 
-                 var BoxDate_tmp = $("#FinalTime2").dxDateBox('instance').option('value');
 
-                 var BoxDate = new Date(BoxDate_tmp.getFullYear(), BoxDate_tmp.getMonth(), BoxDate_tmp.getDate(), BoxDate_tmp.getHours(), BoxDate_tmp.getMinutes(), 0);
 
-                 initDate_prev[1] = new Date(InitDate_tmp.getFullYear(), InitDate_tmp.getMonth(), InitDate_tmp.getDate(), InitDate_tmp.getHours(), InitDate_tmp.getMinutes(), 0);
 
-                 finalDate_prev[1] = new Date(BoxDate_tmp.getFullYear(), BoxDate_tmp.getMonth(), BoxDate_tmp.getDate(), BoxDate_tmp.getHours(), BoxDate_tmp.getMinutes(), 0);
 
-                 operationMode_prev[1] = $("#OperationMode2").dxSelectBox('instance').option('value');;
 
-                 ref1Status_prev[1] = $("#Ref1_Status2").dxSwitch("instance").option('value');
 
-                 ref2Status_prev[1] = $("#Ref2_Status2").dxSwitch("instance").option('value');
 
-                 EnableDisableRow(2, true);
 
-                 EnableDisableRow(3, false);
 
-                 EditingSecondRow(false);
 
-                 EditingThirdRow(true);
 
-                 isThirdRow(true);
 
-                 BoxDate.setMinutes(BoxDate.getMinutes() + 15);
 
-                 $("#InitialDate3").dxDateBox('instance').option('value', BoxDate);
 
-                 $("#InitialTime3").dxDateBox('instance').option('value', BoxDate);
 
-                 $("#FinalDate3").dxDateBox('instance').option('value', finalDate_);
 
-                 $("#FinalTime3").dxDateBox('instance').option('value', finalDate_);
 
-             }
 
-         }
 
-         else if (EditingThirdRow() === true) {
 
-             if (enabledDateRange(3, "edit")) {
 
-                 var InitDate_tmp = $("#InitialTime3").dxDateBox('instance').option('value');
 
-                 var BoxDate_tmp = $("#FinalTime3").dxDateBox('instance').option('value');
 
-                 var BoxDate = new Date(BoxDate_tmp.getFullYear(), BoxDate_tmp.getMonth(), BoxDate_tmp.getDate(), BoxDate_tmp.getHours(), BoxDate_tmp.getMinutes(), 0);
 
-                 initDate_prev[2] = new Date(InitDate_tmp.getFullYear(), InitDate_tmp.getMonth(), InitDate_tmp.getDate(), InitDate_tmp.getHours(), InitDate_tmp.getMinutes(), 0);
 
-                 finalDate_prev[2] = new Date(BoxDate_tmp.getFullYear(), BoxDate_tmp.getMonth(), BoxDate_tmp.getDate(), BoxDate_tmp.getHours(), BoxDate_tmp.getMinutes(), 0);
 
-                 operationMode_prev[2] = $("#OperationMode3").dxSelectBox('instance').option('value');;
 
-                 ref1Status_prev[2] = $("#Ref1_Status3").dxSwitch("instance").option('value');
 
-                 ref2Status_prev[2] = $("#Ref2_Status3").dxSwitch("instance").option('value');
 
-                 EnableDisableRow(3, true);
 
-                 EnableDisableRow(4, false);
 
-                 EditingThirdRow(false);
 
-                 EditingFourthRow(true);
 
-                 isFourthRow(true);
 
-                 BoxDate.setMinutes(BoxDate.getMinutes() + 15);
 
-                 $("#InitialDate4").dxDateBox('instance').option('value', BoxDate);
 
-                 $("#InitialTime4").dxDateBox('instance').option('value', BoxDate);
 
-                 $("#FinalDate4").dxDateBox('instance').option('value', finalDate_);
 
-                 $("#FinalTime4").dxDateBox('instance').option('value', finalDate_);
 
-             }
 
-         }
 
-         else if (EditingFourthRow() === true) {
 
-             if (enabledDateRange(4, "edit")) {
 
-                 var InitDate_tmp = $("#InitialTime4").dxDateBox('instance').option('value');
 
-                 var BoxDate_tmp = $("#FinalTime4").dxDateBox('instance').option('value');
 
-                 var BoxDate = new Date(BoxDate_tmp.getFullYear(), BoxDate_tmp.getMonth(), BoxDate_tmp.getDate(), BoxDate_tmp.getHours(), BoxDate_tmp.getMinutes(), 0);
 
-                 initDate_prev[3] = new Date(InitDate_tmp.getFullYear(), InitDate_tmp.getMonth(), InitDate_tmp.getDate(), InitDate_tmp.getHours(), InitDate_tmp.getMinutes(), 0);
 
-                 finalDate_prev[3] = new Date(BoxDate_tmp.getFullYear(), BoxDate_tmp.getMonth(), BoxDate_tmp.getDate(), BoxDate_tmp.getHours(), BoxDate_tmp.getMinutes(), 0);
 
-                 operationMode_prev[3] = $("#OperationMode4").dxSelectBox('instance').option('value');;
 
-                 ref1Status_prev[3] = $("#Ref1_Status4").dxSwitch("instance").option('value');
 
-                 ref2Status_prev[3] = $("#Ref2_Status4").dxSwitch("instance").option('value');
 
-                 EnableDisableRow(4, true);
 
-                 EnableDisableRow(5, false);
 
-                 EditingFourthRow(false);
 
-                 EditingFifthRow(true);
 
-                 isFifthRow(true);
 
-                 BoxDate.setMinutes(BoxDate.getMinutes() + 15);
 
-                 $("#InitialDate5").dxDateBox('instance').option('value', BoxDate);
 
-                 $("#InitialTime5").dxDateBox('instance').option('value', BoxDate);
 
-                 $("#FinalDate5").dxDateBox('instance').option('value', finalDate_);
 
-                 $("#FinalTime5").dxDateBox('instance').option('value', finalDate_);
 
-             }
 
-         }
 
-         else if (EditingFifthRow() === true) {
 
-             utils.toast.show('최대 행 추가 수는 5개입니다.', 'error');
 
-             return;
 
-         }
 
-     }
 
-     // 열 삭제
 
-     function handlePopupButtonDelete() {
 
-         if (EditingFirstRow() === true) {
 
-             utils.toast.show('최소 1개 이상 행을 입력해야합니다.', 'error');
 
-         }
 
-         else {
 
-             DeleteRow();        // 현재 열 삭제
 
-         }
 
-         return;
 
-     }
 
-     function EnableDisableRow(row_num, disabled) {
 
-         // 모든 행의 시작일은 고정
 
-         $("#InitialDate" + (row_num).toString()).dxDateBox("instance").option('disabled', true);
 
-         $("#InitialTime" + (row_num).toString()).dxDateBox("instance").option('disabled', true);
 
-         $("#FinalDate" + (row_num).toString()).dxDateBox("instance").option('disabled', disabled);
 
-         $("#FinalTime" + (row_num).toString()).dxDateBox("instance").option('disabled', disabled);
 
-         $("#OperationMode" + (row_num).toString()).dxSelectBox("instance").option('disabled', disabled);
 
-         if ($("#OperationMode" + (row_num).toString()).dxSelectBox('instance').option('value') == 0
 
-             || $("#OperationMode" + (row_num).toString()).dxSelectBox('instance').option('value') == 2) {
 
-             $("#Ref1_Status" + (row_num).toString()).dxSwitch("instance").option('disabled', true);
 
-             $("#Ref2_Status" + (row_num).toString()).dxSwitch("instance").option('disabled', true);
 
-         }
 
-         else {
 
-             $("#Ref1_Status" + (row_num).toString()).dxSwitch("instance").option('disabled', disabled);
 
-             $("#Ref2_Status" + (row_num).toString()).dxSwitch("instance").option('disabled', disabled);
 
-         }
 
-     }
 
-     // 닫기버튼
 
-     function PopupButtonClose() {
 
-         visibleConfigPopup(false);
 
-         // 전체 열에 대해서 모두 삭제하고 저장된 열들만 다시 채워준다
 
-         for (var i = 0; i < 5; i++) {
 
-             DeleteRow();
 
-         }
 
-         for (var i = 0; i < 5; i++) {
 
-             if (operationMode_asSave[i] != null) {
 
-                 FilledRow(i + 1);
 
-             }
 
-         }
 
-         visibleEditButton(true);
 
-         hasnotModificationPermission(false);
 
-         isEditModeInPopup(false);
 
-         isNotModifyMode(true);
 
-         visibleCancelButton(false);
 
-         if (EditingFirstRow() == true) {
 
-             EnableDisableRow(1, false);
 
-         }
 
-         else if (EditingSecondRow() == true) {
 
-             EnableDisableRow(2, false);
 
-         }
 
-         else if (EditingThirdRow() == true) {
 
-             EnableDisableRow(3, false);
 
-         }
 
-         else if (EditingFourthRow() == true) {
 
-             EnableDisableRow(4, false);
 
-         }
 
-         else if (EditingFifthRow() == true) {
 
-             EnableDisableRow(5, false);
 
-         }
 
-     }
 
-     function SetPointer() {
 
-         var now = new Date();
 
-         var target_date;
 
-         var isRecentData = ko.observable(false);
 
-         if (now.getHours() < 21) {
 
-             target_date = now
 
-         }
 
-         else {
 
-             target_date = now.setDate(now.getDate() - 1);
 
-         }
 
-         var dataSource = new DevExpress.data.DataSource({
 
-             store: {
 
-                 type: "odata",
 
-                 url: endpointSelector + "/BemsMonitoringPointWeatherForecasted",
 
-             },
 
-             requireTotalCount: true,
 
-             pageSize: 99,
 
-         });
 
-         dataSource.filter([
 
-                 ["SiteId", "=", BWA.UserInfo.SiteId()],
 
-                 "and",
 
-                 ["nx", "=", 89],
 
-                 "and",
 
-                 ["ny", "=", 91]
 
-         ]);
 
-         dataSource.sort({ getter: "ForecastedDateTime", desc: true });
 
-         dataSource.load()
 
-        .done(function (WeatherForecasted) {
 
-            if (WeatherForecasted.length != 0) {
 
-                var WFTemperature_tmp = new Array();
 
-                var WFHumidity_tmp = new Array();
 
-                for (var i = 0; i < 16; i++) {       // 예보데이터는 3시간 단위로 8포인트씩 2세트(기온, 습도)이므로
 
-                    if (WeatherForecasted[i].ForecastedDateTime.getFullYear() == target_date.getFullYear()
 
-                        && WeatherForecasted[i].ForecastedDateTime.getMonth() == target_date.getMonth()
 
-                        && WeatherForecasted[i].ForecastedDateTime.getDate() == target_date.getDate()
 
-                        && WeatherForecasted[i].Category == 'Temperature') {
 
-                        WFTemperature_tmp.push(WeatherForecasted[i].ForecastedValue);
 
-                    }
 
-                    if (WeatherForecasted[i].ForecastedDateTime.getFullYear() == target_date.getFullYear()
 
-                        && WeatherForecasted[i].ForecastedDateTime.getMonth() == target_date.getMonth()
 
-                        && WeatherForecasted[i].ForecastedDateTime.getDate() == target_date.getDate()
 
-                        && WeatherForecasted[i].Category == 'Humidity') {
 
-                        WFHumidity_tmp.push(WeatherForecasted[i].ForecastedValue);
 
-                    }
 
-                }
 
-                if (WFTemperature_tmp.length != 0) {
 
-                    $('#pointerText1').text("익일 예상 최고 기온 : " + Math.max.apply(null, WFTemperature_tmp).toFixed(2).toString() + " °C, ");
 
-                    $('#pointerText2').text("익일 예상 최저 기온 : " + Math.min.apply(null, WFTemperature_tmp).toFixed(2).toString() + " °C, ");
 
-                }
 
-                else {
 
-                    $('#pointerText1').text("익일 예상 최고 기온 : ? °C, ");
 
-                    $('#pointerText2').text("익일 예상 최저 기온 : ? °C, ");
 
-                    utils.toast.show("데이터가 없습니다. (익일 기상 예보 데이터 - 기온)", 'error');
 
-                }
 
-                if (WFHumidity_tmp.length != 0) {
 
-                    $('#pointerText3').text("익일 예상 최고 습도 : " + Math.max.apply(null, WFHumidity_tmp).toFixed(2).toString() + " %, ");
 
-                    $('#pointerText4').text("익일 예상 최저 습도 : " + Math.min.apply(null, WFHumidity_tmp).toFixed(2).toString() + " %, ");
 
-                }
 
-                else {
 
-                    $('#pointerText3').text("익일 예상 최고 습도 : ? %, ");
 
-                    $('#pointerText4').text("익일 예상 최저 습도 : ? %, ");
 
-                    utils.toast.show("데이터가 없습니다. (익일 기상 예보 데이터 - 습도)", 'error');
 
-                }
 
-            }
 
-            else {
 
-                $('#pointerText1').text("익일 예상 최고 기온 : ? °C, ");
 
-                $('#pointerText2').text("익일 예상 최저 기온 : ? °C, ");
 
-                $('#pointerText3').text("익일 예상 최고 습도 : ? %, ");
 
-                $('#pointerText4').text("익일 예상 최저 습도 : ? %, ");
 
-                utils.toast.show("데이터가 없습니다. (익일 기상 예보 데이터 - 기온, 습도)", 'error');
 
-            }
 
-        })
 
-         .fail(function (error) {
 
-             utils.toast.show(error);
 
-         });
 
-         var dataSource = new DevExpress.data.DataSource({
 
-             store: {
 
-                 type: "odata",
 
-                 url: endpointSelector + "/BemsMonitoringPointForecastingDayAhead",
 
-             },
 
-             requireTotalCount: true,
 
-             pageSize: 99,
 
-         });
 
-         dataSource.filter([
 
-                 ["SiteId", "=", BWA.UserInfo.SiteId()],
 
-                 "and",
 
-                 ["PropertyId", "=", 0]
 
-         ]);
 
-         dataSource.sort({ getter: "TargetDateTime", desc: true });
 
-         dataSource.load()
 
-        .done(function (PredictedDeicing) {
 
-            if (PredictedDeicing.length != 0 
 
-                 && PredictedDeicing[0].TargetDateTime.getFullYear() == target_date.getFullYear()
 
-                 && PredictedDeicing[0].TargetDateTime.getMonth() == target_date.getMonth()
 
-                 && PredictedDeicing[0].TargetDateTime.getDate() == target_date.getDate()) {
 
-                $('#pointerText5').text("익일 예상 방냉량 : " + PredictedDeicing[0].ForecastedValue.toFixed(2).toString() + "%");
 
-            }
 
-            else {
 
-                $('#pointerText5').text("익일 예상 방냉량 : 0%");
 
-                utils.toast.show("데이터가 없습니다. (익일 예상 방냉량)", 'error');
 
-            }
 
-        })
 
-         .fail(function (error) {
 
-             utils.toast.show(error);
 
-         });
 
-         var now_15min = new Date();
 
-         now_15min.setMinutes(parseInt(now_15min.getMinutes() / 15) * 15); // 15분 단위 맞춰주기 위함
 
-         var now_15min_ = new Date(now_15min.getFullYear(), now_15min.getMonth(), now_15min.getDate(), now_15min.getHours(), now_15min.getMinutes(), 0);
 
-         var finalDate_ = new Date(now_15min_.getFullYear(), now_15min_.getMonth(), now_15min_.getDate(), 20, 45, 0);
 
-         if (now_15min.getHours() >= 21) {
 
-             finalDate_ = moment(finalDate_).add(1, 'days').toDate();
 
-         }
 
-         // 추천 가동 시간 로드
 
-         var dataSource = new DevExpress.data.DataSource({
 
-             store: {
 
-                 type: "odata",
 
-                 url: endpointSelector + "/BemsIceThermalStorageSimulation",
 
-             },
 
-             requireTotalCount: true,
 
-             pageSize: 99,
 
-         });
 
-         dataSource.sort({ getter: "TargetDateTime", desc: true });
 
-         dataSource.filter([
 
-                 ["SiteId", "=", BWA.UserInfo.SiteId()],
 
-                 "and",
 
-                 ["FacilityTypeId", "=", 3],
 
-                 "and",
 
-                 ["PropertyId", "=", 16],
 
-                 "and",
 
-                 ["SimulationCase", "=", 0],      // recommend
 
-                 "and",
 
-                 ["TargetDateTime", ">=", now_15min_],
 
-                 "and",
 
-                 ["TargetDateTime", "<=", finalDate_],
 
-         ]);
 
-         dataSource.load()
 
-        .done(function (Recommended) {
 
-            if (Recommended.length != 0) {
 
-                var isRecommended = false;
 
-                var RecommendedTime = new Date(now_15min.getFullYear(), now_15min.getMonth(), now_15min.getDate(), 0, 0, 0);     // 추천 축열조 운영 모드 (제빙 모드)
 
-                for (var i = 0; i < Recommended.length; i++) {
 
-                    if (Recommended[i].SimulationValue == 10) {
 
-                        RecommendedTime.settMinutes(RecommendedTime.getMinutes() + 15);
 
-                        isRecommended = true;
 
-                    }
 
-                }
 
-                if (isRecommended == true) {
 
-                    $('#RecommendedTime').text("추천 가동 시간(제빙모드) : " + RecommendedTime.getHours().toString() + "시간 " + RecommendedTime.getMinutes().toString() + "분,");
 
-                }
 
-                else {
 
-                    $('#RecommendedTime').text("추천 가동 시간 : 현재 익일 예상 방냉량 초과 저장,");
 
-                }
 
-            }
 
-            else {
 
-                $('#RecommendedTime').text("추천 가동 시간 : ?,");
 
-                utils.toast.show("데이터가 없습니다. (추천 가동 시간)", 'error');
 
-            }
 
-        })
 
-         .fail(function (error) {
 
-             utils.toast.show(error);
 
-         });
 
-         // 냉동기1,2 전력량 로드
 
-         var dataSource = new DevExpress.data.DataSource({
 
-             store: {
 
-                 type: "odata",
 
-                 url: endpointSelector + "/BemsIceThermalStorageSimulation",
 
-             },
 
-             requireTotalCount: true,
 
-             pageSize: 99,
 
-         });
 
-         dataSource.sort({ getter: "TargetDateTime", desc: true });
 
-         dataSource.filter([
 
-                 ["SiteId", "=", BWA.UserInfo.SiteId()],
 
-                 "and",
 
-                 ["FacilityTypeId", "=", 2],
 
-                 "and",
 
-                 ["PropertyId", "=", 11],
 
-                 "and",
 
-                 ["SimulationCase", "=", 1],      // simulation
 
-                 "and",
 
-                 ["TargetDateTime", ">=", now_15min_],
 
-                 "and",
 
-                 ["TargetDateTime", "<=", finalDate_],
 
-         ]);
 
-         dataSource.load()
 
-        .done(function (RefPowerConsume) {
 
-            if (RefPowerConsume.length != 0) {
 
-                var RefPowerConsumeSum = 0;     // 냉동기 전력량 합계 (시뮬레이션 모드)
 
-                for (var i = 0; i < RefPowerConsume.length; i++) {
 
-                    RefPowerConsumeSum += RefPowerConsume[i].SimulationValue;
 
-                }
 
-                if (RefPowerConsumeSum == 0) {
 
-                    $('#RefPowerConsume').text("냉동기 계산 전력량(시뮬레이션 모드) : 0 kWh");
 
-                }
 
-                else {
 
-                    $('#RefPowerConsume').text("냉동기 계산 전력량(시뮬레이션 모드) : " + RefPowerConsumeSum.toFixed(2).toString() + " kWh");
 
-                }
 
-            }
 
-            else {
 
-                $('#RefPowerConsume').text("냉동기 계산 전력량(시뮬레이션 모드) : ?");
 
-                utils.toast.show("데이터가 없습니다. (냉동기 계산 전력량)", 'error');
 
-            }
 
-        })
 
-         .fail(function (error) {
 
-             utils.toast.show(error);
 
-         });
 
-     }
 
-     function handleViewShown() {
 
-         $("#LoadPanel").dxLoadPanel({
 
-             message: '로딩 중...',
 
-             showIndicator: true,
 
-             visible: false
 
-         });
 
-         $("#LoadPanel").dxLoadPanel('instance').option('visible', true);
 
-         visibleHourGlassPopup(true);
 
-         // 초기 화면에서 기존 사용자 제어변수 삭제 
 
-         RemoveData(3, 4478, 16, 1);        // 운전모드
 
-         RemoveData(2, 4479, 15, 1);        // 냉동기1 상태
 
-         RemoveData(2, 4480, 15, 1);        // 냉동기2 상태
 
-         RemoveData(2, 4479, 11, 1);        // 냉동기1 전력량
 
-         RemoveData(2, 4480, 11, 1);        // 냉동기2 전력량
 
-         RemoveData(3, 4478, 2, 1);         // 축열량
 
-         if (initialized === false) {
 
-             setTimeout(function () {
 
-                 chart = chart(BWA.ChartOptions.SimulatorIceStorage.getChartOptions());
 
-                 initialized = true;
 
-                 // 날짜 초기화 (오늘)
 
-                 timeBoxForSearch.setDefaultDateToday();
 
-                 handleSearchInSearchView();
 
-             }, 4000);
 
-         }
 
-         else {
 
-             setTimeout(function () {
 
-                 // 날짜 초기화 (오늘)
 
-                 timeBoxForSearch.setDefaultDateToday();
 
-                 handleSearchInSearchView();
 
-                 // 저장 변수 초기화
 
-                 initDate_asSave = new Array(new Date(initialDate), new Date(initialDate), new Date(initialDate), new Date(initialDate), new Date(initialDate));
 
-                 finalDate_asSave = new Array(new Date(finalDate), new Date(finalDate), new Date(finalDate), new Date(finalDate), new Date(finalDate));
 
-                 operationMode_asSave = new Array(null, null, null, null, null);
 
-                 ref1Status_asSave = new Array(null, null, null, null, null);
 
-                 ref2Status_asSave = new Array(null, null, null, null, null);
 
-             }, 4000);
 
-         }
 
-         timer = setInterval(function () {
 
-             //alert('timer');   // For Debugging
 
-             var now = new Date();
 
-             //if ((now.getMinutes() == 1 && now.getSeconds() == 30) || (now.getMinutes() == 5 && now.getSeconds() == 30)) {
 
-             if (now.getMinutes() % 15 == 2 && now.getSeconds() == 30) {
 
-                 handleSearchInSearchView();
 
-             }
 
-         }, 1000);
 
-         $("#UserCfgBtn").dxButton({
 
-             text: "시뮬레이터 변수 설정",
 
-             onClick: function () {
 
-                 visibleConfigPopup(true);
 
-             }
 
-         });
 
-     }
 
-     function handleViewHidden() {
 
-         $SearchView.visibleObservable(false); // hcLee 2015 03 23
 
-         visibleConfigPopup(false);
 
-         clearInterval(timer); // hcLee 2015 06 12
 
-     }
 
-     function RemoveData(facilityTypeId, facilityCode, propertyId, simulationCase) {
 
-         var now_15min = new Date();
 
-         now_15min.setMinutes(parseInt(now_15min.getMinutes() / 15) * 15); // 15분 단위 맞춰주기 위함
 
-         var targetDate_ = new Date(now_15min.getFullYear(), now_15min.getMonth(), now_15min.getDate(), now_15min.getHours(), now_15min.getMinutes(), 0);
 
-         var finalDate_ = new Date(now_15min.getFullYear(), now_15min.getMonth(), now_15min.getDate(), 20, 45, 0);
 
-         if (now_15min.getHours() >= 21) {
 
-             finalDate_ = moment(finalDate_).add(1, 'days').toDate();
 
-         }
 
-         BemsIceThermalStorageDataSource.filter([
 
-                 ["SiteId", "=", BWA.UserInfo.SiteId()],
 
-                 "and",
 
-                 ["FacilityCode", "=", facilityCode],
 
-                 "and",
 
-                 ["PropertyId", "=", propertyId],
 
-                 "and",
 
-                 ["SimulationCase", "=", simulationCase],
 
-                 "and",
 
-                 ["TargetDateTime", ">=", targetDate_],
 
-                 "and",
 
-                 ["TargetDateTime", "<=", finalDate_]
 
-         ]);
 
-         BemsIceThermalStorageDataSource.load()
 
-         .done(function (result) {
 
-             var store = new DevExpress.data.ODataStore({
 
-                 url: endpointSelector + "/BemsIceThermalStorageSimulation",
 
-                 key: ["SiteId", "FacilityCode", "PropertyId", "CreatedDateTime", "TargetDateTime", "SimulationCase"],
 
-                 keyType: {
 
-                     SiteId: "Int32", FacilityCode: "Int32", PropertyId: "Int32", CreatedDateTime: "DateTime", TargetDateTime: "DateTime", SimulationCase: "Int32"
 
-                 }
 
-             });
 
-             if (result.length != 0) {
 
-                 for (var i = 0; i < result.length; i++) {
 
-                     var removeData = {
 
-                         SiteId: result[i].SiteId(),
 
-                         FacilityTypeId: result[i].FacilityTypeId(),
 
-                         FacilityCode: result[i].FacilityCode(),
 
-                         PropertyId: result[i].PropertyId(),
 
-                         CreatedDateTime: new Date(result[i].CreatedDateTime()),
 
-                         TargetDateTime: new Date(result[i].TargetDateTime()),
 
-                         SimulationValue: result[i].SimulationValue(),
 
-                         SimulationCase: result[i].SimulationCase()
 
-                     };
 
-                     store.remove(removeData).done(function (values, key) {
 
-                     })
 
-                     .fail(function (error) {
 
-                         utils.toast.show(error, 'error');
 
-                     });
 
-                 }
 
-             }
 
-         });
 
-     }
 
-     // 다른 페이지 갔다 들어오면 시뮬레이션 데이터 및 팝업 초기화
 
-     function handleViewShowing() {
 
-         SetPointer();
 
-         initializedforPopUp = false;
 
-         CurrntRowStatusAsSave = 1;
 
-     }
 
-     function refreshList() {
 
-     }
 
-     var searchViewOptions = {
 
-         searchViewItems: [
 
-             //{ id: 'TimeTypeId', defaultValue: 0, value: timeTypeIdForSearch, dataSource: timeTypesForSearch },
 
-             //{ id: 'DateForHour', type: 'dateRange', isOnlyDate: true },
 
-         ],
 
-     };
 
-     function handleSearchInSearchView() {
 
-         $("#LoadPanel").dxLoadPanel('instance').option('visible', true);
 
-         visibleHourGlassPopup(true);
 
-         var dataArray = [];
 
-         dataArrayforPopup = [];
 
-         var date = timeBoxForSearch.getDate();
 
-         var start_date = moment(date.startDate).add(-3, 'hours').toDate();
 
-         var end_date = moment(date.endDate).add(-3, 'hours').toDate();
 
-         SetPointer();
 
-         var commonParameters = {
 
-             TimeIntervalType: $Code.TimeIntervalType.QUARTERMIN,
 
-             StartDate: start_date,
 
-             EndDate: end_date
 
-         };
 
-         var IceThermalStorageParameters_obs = {
 
-             FacilityTypeId: 3,
 
-             FacilityCode: 4478,
 
-             PropertyId: 2,
 
-             SimulationCase: 0       // observed and recommended schedule
 
-         };
 
-         var IceThermalStorageParameters_sim = {
 
-             FacilityTypeId: 3,
 
-             FacilityCode: 4478,
 
-             PropertyId: 2,
 
-             SimulationCase: 1       // simulated schedule
 
-         };
 
-         var now_sub = new Date();
 
-         now_sub.setMinutes(now_sub.getMinutes() - 15);  // 15분까지 데이터 확인 가능
 
-         $.when(
 
-             iceThermalStorage_SimulationValueGet.apiGet(_.extend(IceThermalStorageParameters_obs, commonParameters)),
 
-             iceThermalStorage_SimulationValueGet.apiGet(_.extend(IceThermalStorageParameters_sim, commonParameters))
 
-         ).done(function (Candidate_obs, Candidate_sim) {
 
-             if (Candidate_obs.length == 0) {
 
-                 utils.toast.show("[BemsIceThermalStorageSimulation] 데이터가 없습니다.", 'error');
 
-                 $("#LoadPanel").dxLoadPanel('instance').option('visible', false);
 
-             }
 
-             else {
 
-                 if (Candidate_obs.length != 0) {
 
-                     _.each(Candidate_obs[0][0], function (x) {
 
-                         if (moment(x.DateTime).toDate() < now_sub) {
 
-                             dataArray.push({
 
-                                 DateTime: moment(x.DateTime).toDate(),
 
-                                 ObservedValue: x.Value
 
-                             });
 
-                         }
 
-                     });
 
-                     //  2017.09.08 : 그리드 도표 작업 : 팝업창 추가
 
-                     _.each(Candidate_obs[0][0], function (x) {
 
-                         if (moment(x.DateTime).toDate() < now_sub) {
 
-                             dataArrayforPopup.push({
 
-                                 DateTime: BWA.Chart.getCustermTimeArgumentAxisString($Code.TimeType.QUARTERMIN, moment(x.DateTime).toDate()),
 
-                                 Value: x.Value,
 
-                                 Case: 'Obs'
 
-                             });
 
-                         }
 
-                     });
 
-                 }
 
-                 if (Candidate_sim.length != 0) {
 
-                     _.each(Candidate_sim[0][0], function (x) {
 
-                         if (moment(x.DateTime).toDate() >= now_sub) {
 
-                             dataArray.push({
 
-                                 DateTime: moment(x.DateTime).toDate(),
 
-                                 SimulationValue: x.Value
 
-                             });
 
-                         }
 
-                     });
 
-                     //  2017.09.08 : 그리드 도표 작업 : 팝업창 추가
 
-                     _.each(Candidate_sim[0][0], function (x) {
 
-                         if (moment(x.DateTime).toDate() >= now_sub) {
 
-                             dataArrayforPopup.push({
 
-                                 DateTime: BWA.Chart.getCustermTimeArgumentAxisString($Code.TimeType.QUARTERMIN, moment(x.DateTime).toDate()),
 
-                                 Value: x.Value,
 
-                                 Case: 'Sim'
 
-                             });
 
-                         }
 
-                     });
 
-                 }
 
-                 //  2017.09.08 : 그리드 도표 작업 : 팝업창 추가
 
-                 var options = BWA.ChartOptions.SimulatorIceStorage.getSeriesOptions();
 
-                 if (!_.isNull(start_date) && !_.isNull(end_date)) {
 
-                     options.argumentAxis.min = start_date;
 
-                     options.argumentAxis.max = end_date;
 
-                 }
 
-                 chart().option('argumentAxis', null); // 2015 05 21 결국 이 코드가 필요 함 (시간 축 에러 해결)
 
-                 options.dataSource = dataArray;
 
-                 chart().option(options);
 
-             }
 
-             $("#LoadPanel").dxLoadPanel('instance').option('visible', false);
 
-             visibleHourGlassPopup(false);
 
-         })
 
-         .fail(function (error) {
 
-             utils.toast.show("데이터를 불러오는데 실패 하였습니다.", 'error');
 
-             $("#LoadPanel").dxLoadPanel('instance').option('visible', false);
 
-             visibleConfigPopup(false);
 
-             $("#LoadPanel").dxLoadPanel('instance').option('visible', false);
 
-             visibleHourGlassPopup(false);
 
-         });
 
-     }
 
-     //  2017.09.08 : 그리드 도표 작업 : 팝업창 추가
 
-     function DataGridPopup_ButtonClick() {
 
-         DataGridPopup_Visible(true);
 
-     }
 
-     function handlePopupShown() {
 
-         // 도표 컬럼명 업데이트
 
-         viewModel.SimulatorIceStorageDataGridOptions.columns[0].caption = "날짜";
 
-         viewModel.SimulatorIceStorageDataGridOptions.columns[1].caption = "실/계산 축열량";
 
-         // 도표 데이터소스 업데이트
 
-         $("#SimulatorIceStorageDataGrid_Container").dxDataGrid("instance").option("dataSource", dataArrayforPopup);
 
-         // 도표 팝업창 갱신
 
-         //DataGridPopup_Visible(true);
 
-     }
 
-     // Box Initialize
 
-     function BoxInitialize(row_num, initial_Date, final_Date) {
 
-         $("#InitialDate" + (row_num).toString()).dxDateBox({
 
-             value: initial_Date,
 
-             maxZoomLevel: 'month',
 
-             formatString: "yyyy-MM-dd",
 
-             onValueChanged: function (data) {
 
-                 initial_Date.setFullYear(data.value.getFullYear());
 
-                 initial_Date.setMonth(data.value.getMonth());
 
-                 initial_Date.setDate(data.value.getDate());
 
-                 $("#InitialDate" + (row_num).toString()).dxDateBox('instance').option('value', initial_Date);
 
-                 $("#InitialTime" + (row_num).toString()).dxDateBox('instance').option('value', initial_Date);
 
-             }
 
-         });
 
-         $("#InitialTime" + (row_num).toString()).dxDateBox({
 
-             value: initial_Date,
 
-             format: "time",
 
-             formatString: "HH:mm",
 
-             onValueChanged: function (data) {
 
-                 initial_Date.setHours(data.value.getHours());
 
-                 initial_Date.setMinutes(data.value.getMinutes());
 
-                 $("#InitialDate" + (row_num).toString()).dxDateBox('instance').option('value', initial_Date);
 
-                 $("#InitialTime" + (row_num).toString()).dxDateBox('instance').option('value', initial_Date);
 
-             }
 
-         });
 
-         $("#FinalDate" + (row_num).toString()).dxDateBox({
 
-             value: final_Date,
 
-             maxZoomLevel: 'month',
 
-             formatString: "yyyy-MM-dd",
 
-             min: new Date(moment().add(-1, 'd')),
 
-             max: new Date(moment().add(1, 'd')),
 
-             onValueChanged: function (data) {
 
-                 final_Date.setFullYear(data.value.getFullYear());
 
-                 final_Date.setMonth(data.value.getMonth());
 
-                 final_Date.setDate(data.value.getDate());
 
-                 $("#InitialDate" + (row_num).toString()).dxDateBox('instance').option('value', initial_Date);
 
-                 $("#InitialTime" + (row_num).toString()).dxDateBox('instance').option('value', initial_Date);
 
-                 $("#FinalDate" + (row_num).toString()).dxDateBox('instance').option('value', final_Date);
 
-                 $("#FinalTime" + (row_num).toString()).dxDateBox('instance').option('value', final_Date);
 
-             }
 
-         });
 
-         $("#FinalTime" + (row_num).toString()).dxDateBox({
 
-             value: final_Date,
 
-             format: "time",
 
-             formatString: "HH:mm",
 
-             onValueChanged: function (data) {
 
-                 final_Date.setHours(data.value.getHours());
 
-                 final_Date.setMinutes(data.value.getMinutes());
 
-                 $("#InitialDate" + (row_num).toString()).dxDateBox('instance').option('value', initial_Date);
 
-                 $("#InitialTime" + (row_num).toString()).dxDateBox('instance').option('value', initial_Date);
 
-                 $("#FinalDate" + (row_num).toString()).dxDateBox('instance').option('value', final_Date);
 
-                 $("#FinalTime" + (row_num).toString()).dxDateBox('instance').option('value', final_Date);
 
-             }
 
-         });
 
-         $("#OperationMode" + (row_num).toString()).dxSelectBox({
 
-             placeholder: "운전 모드",
 
-             dataSource: treeOperationMode,
 
-             displayExpr: "text",
 
-             valueExpr: "id",
 
-             onValueChanged: function (data) {
 
-                 $("#OperationMode" + (row_num).toString()).dxSelectBox('instance').option('value', data.value);
 
-                 // OFF, 축단운전시 냉동기 모두 OFF
 
-                 if (data.value == 0 || data.value == 2) {
 
-                     $("#Ref1_Status" + (row_num).toString()).dxSwitch('instance').option('value', false);
 
-                     $("#Ref2_Status" + (row_num).toString()).dxSwitch('instance').option('value', false);
 
-                     $("#Ref1_Status" + (row_num).toString()).dxSwitch("instance").option('disabled', true);
 
-                     $("#Ref2_Status" + (row_num).toString()).dxSwitch("instance").option('disabled', true);
 
-                 }
 
-                 else {
 
-                     $("#Ref1_Status" + (row_num).toString()).dxSwitch("instance").option('disabled', false);
 
-                     $("#Ref2_Status" + (row_num).toString()).dxSwitch("instance").option('disabled', false);
 
-                 }
 
-             }
 
-         });
 
-         $("#Ref1_Status" + (row_num).toString()).dxSwitch({
 
-             onText: $G('use'),
 
-             offText: $G('nonUse'),
 
-             onValueChanged: function (data) {
 
-                 $("#Ref1_Status" + (row_num).toString()).dxSwitch('instance').option('value', data.value);
 
-             }
 
-         });
 
-         $("#Ref2_Status" + (row_num).toString()).dxSwitch({
 
-             onText: $G('use'),
 
-             offText: $G('nonUse'),
 
-             onValueChanged: function (data) {
 
-                 $("#Ref2_Status" + (row_num).toString()).dxSwitch('instance').option('value', data.value);
 
-             }
 
-         });
 
-         // 초기 시작 시점은 고정
 
-         $("#InitialDate" + (row_num).toString()).dxDateBox("instance").option('disabled', true);
 
-         $("#InitialTime" + (row_num).toString()).dxDateBox("instance").option('disabled', true);
 
-         $("#OperationMode" + (row_num).toString()).dxSelectBox('instance').option('value', null);// 운전 모드 클리어
 
-         $("#Ref1_Status" + (row_num).toString()).dxSwitch('instance').option('value', false);// 냉동기1 운전 모드 클리어
 
-         $("#Ref2_Status" + (row_num).toString()).dxSwitch('instance').option('value', false);// 냉동기2 운전 모드 클리어
 
-         initDate_prev[row_num - 1] = new Date(initial_Date);
 
-         finalDate_prev[row_num - 1] = new Date(final_Date);
 
-         operationMode_prev[row_num - 1] = null;
 
-         ref1Status_prev[row_num - 1] = false;
 
-         ref2Status_prev[row_num - 1] = false;
 
-         return 0;
 
-     }
 
-     var viewModel = $.extend(BWA.CommonView.create(
 
-             params, viewInfo, searchViewOptions, ko.observable(null), handleViewShown, null,
 
-             handleSearchInSearchView), {
 
-                 refreshList: refreshList,
 
-                 viewShowing: handleViewShowing,
 
-                 viewHidden: handleViewHidden, // hcLee 2015 03 23
 
-                 //viewDisposing: handleViewHidden, // hcLee 2015 03 23
 
-                 //locationEnableForSearch: locationEnableForSearch,
 
-                 //  그리드 도표 작업 : 팝업창 추가
 
-                 SimulatorIceStorageDataGridPopup_ButtonClicked: DataGridPopup_ButtonClick
 
-                 //  그리드 도표 작업 : 팝업창 추가
 
-             });
 
-     viewModel.SimulatorIceStoragePopupOptions = {
 
-         width: 1500,//1250,
 
-         height: 350,
 
-         visible: visibleConfigPopup,
 
-         dragEnabled: true,
 
-         shading: true,
 
-         closeOnOutsideClick: false,
 
-         shadingColor: 'transparent',
 
-         showTitle: true,
 
-         //title: "사용자 시뮬레이터 변수 설정",
 
-         showCloseButton: true,
 
-         onShowing: function () {
 
-             if (initializedforPopUp === false) {
 
-                 setTimeout(function () {
 
-                     var initialDate_ = new Date();
 
-                     initialDate_.setMinutes((parseInt(initialDate_.getMinutes() / 15)) * 15); // 15분 단위 맞춰주기 위함
 
-                     initialDate_.setSeconds(0);
 
-                     var finalDate_ = new Date(finalDate);
 
-                     for (var i = 0; i < 5; i++) {
 
-                         BoxInitialize(i + 1, initialDate_, finalDate_);
 
-                     }
 
-                     InitializedTemplate();
 
-                     InitializedData();
 
-                     initializedforPopUp = true;
 
-                 }, 100);
 
-             }
 
-             else {
 
-                 InitializedTemplate();
 
-             }
 
-         },
 
-         onShown: function () {
 
-         },
 
-         onHidden: function () {
 
-         }
 
-     }
 
-     //  2020.08.03 : 그리드 도표 작업 : 팝업창 추가
 
-     // 그래프 도표 팝업창 
 
-     viewModel.SimulatorIceStorageDataGridPopupOptions = {
 
-         width: '480px',
 
-         height: '830px', // cyim 2017.05.30 : 테스트 결과 Devextreme 버그임. px 로 지정하면 초기 출력시 정확하게 가운데에 있지만, auto 설정시 화면아래에 위치하게 됨
 
-         contentTemplate: "content",
 
-         showTitle: true,
 
-         title: "도표",
 
-         visible: DataGridPopup_Visible,
 
-         dragEnabled: true,
 
-         closeOnOutsideClick: true,
 
-         shownAction: handlePopupShown,
 
-         animation: window.utils.popup.createAnimation(),
 
-         shading: false
 
-     };
 
-     //  2020.08.03 : 그리드 도표 작업 : 팝업창 추가
 
-     //  2020.08.03 : 그리드 도표 작업 : 팝업창 추가
 
-     viewModel.SimulatorIceStorageDataGridOptions = {
 
-         dataSource: dataArrayforPopup,
 
-         columns: [
 
-             { dataField: 'DateTime', width: '40%', alignment: 'center' },// dataType: 'date', format: 'yyyy-MM-dd HH:mm' },    
 
-             { dataField: 'Value', width: '60%', alignment: 'center', format: 'fixedPoint', precision: 2 }
 
-             //{ dataField: 'ObservedValue', width: '30%', alignment: 'center', format: 'fixedPoint', precision: 2 },
 
-             //{ dataField: 'SimulationValue', width: '30%', alignment: 'center', format: 'fixedPoint', precision: 2 }
 
-         ],
 
-         rowPrepared: function (rowElement, rowInfo) {
 
-             if (rowInfo.rowType == 'data') {
 
-                 var data = rowInfo.data;
 
-                 if (data['Case'] == 'Sim') {
 
-                     //rowElement.css('background-color', 'rgba(255,0,0,0.1)');
 
-                     rowElement.css('background-color', 'rgba(153,102,255,0.1)');
 
-                 }
 
-             }
 
-         },
 
-         // 엑셀 출력
 
-         "export": {
 
-             enabled: true,
 
-             fileName: '축열량 시뮬레이션 결과'
 
-         }
 
-     };
 
-     ///  2020.08.03 : 그리드 도표 작업 : 팝업창 추가
 
-     viewModel.simulatoricestoragePopupToolbarItems = simulatoricestoragePopupToolbarItems;
 
-     viewModel.timeBoxForSearch = timeBoxForSearch;
 
-     viewModel.handlePopupButtonAdd = handlePopupButtonAdd;
 
-     viewModel.handlePopupButtonDelete = handlePopupButtonDelete;
 
-     viewModel.isSecondRow = isSecondRow;
 
-     viewModel.isThirdRow = isThirdRow;
 
-     viewModel.isFourthRow = isFourthRow;
 
-     viewModel.isFifthRow = isFifthRow;
 
-     viewModel.visibleHourGlassPopup = visibleHourGlassPopup;
 
-     viewModel.isEditModeInPopup = isEditModeInPopup;
 
-     return viewModel;
 
- };
 
 
  |