$(function () {
    "use strict";
    BWA.Chart = BWA.Chart || {};

    // 실시간 에너지 사용량 화면에서 사용하고 있으며 빌딩ID를 0으로 주면 해당 사이트의 모든 빌딩의 합산을 주는 코드 내가 추가했다. 2015 03 30 hcLee
    function PointHistoryGet(siteId) {
        this.siteId = siteId;
        this.apiUri = 'BemsMonitoringPointHistory/Location';
    }

    function FormulaGet(siteId) {
        this.siteId = siteId;
        this.apiUri = 'BemsFormula/Calculation';
    }

    // 제어를 위한 API 2015 08 05 hcLee
    /*
    function ControlPoint(siteId) {
        this.siteId = siteId;
        this.apiUri = 'BemsFormula/ControlPoint';
    }*/

    //hcLee 2015 03 26
    function PointHistoryServiceTypeGet(siteId) {
        this.siteId = siteId;
        //this.apiUri = 'BemsFormula/ServiceType';
        //this.apiUri = 'BemsFormula/Calculation';
        this.apiUri = 'BemsMonitoringPointHistory/ServiceType';
    }

    //실내환경분석용
    function PointHistory_ZoneTempHumiGet(siteId) {
        this.siteId = siteId;
        this.apiUri = 'BemsMonitoringPointHistory/Location_ZoneTempHumi';
    }

    function PointHistory_RunTimeGet(siteId) {
        this.siteId = siteId;
        this.apiUri = 'BemsMonitoringPointHistory/FacilityRunTime';
    }

    //냉동기 가동시간 분석용
    function PointHistory_RuntimeREFRIGERATORGet(siteId) {
        this.siteId = siteId;
        this.apiUri = 'BemsMonitoringPointHistory/RuntimeREFRIGERATOR';
    }

    //보일러 가동시간 분석용
    function PointHistory_RuntimeBOILERGet(siteId) {
        this.siteId = siteId;
        this.apiUri = 'BemsMonitoringPointHistory/RuntimeBOILER';
    }

    //월별에너지사용금액
    function PointHistory_MonthMoneyGet(siteId) {
        this.siteId = siteId;
        this.apiUri = 'BemsMonitoringPointHistory/MonthMoney';
    }

    //월별에너지사용금액//
    function PointHistory_CurrentValueGet(siteId) {
        this.siteId = siteId;
        this.apiUri = 'BemsMonitoringPointHistory/CurrentValueFrom15min';
    }

    //가상설비, 일반설비 데이터 2019.05.****************
    function VirtualNormalPointHistory_CurrentValueGet(siteId) {
        this.siteId = siteId;
        this.apiUri = 'BemsMonitoringPointHistory/VirtualNormalFacilityData';
    }

    //예측 데이터 2020.05.****************
    function ForecastingPointHistory_DayAheadValueGet(siteId) {
        this.siteId = siteId;
        this.apiUri = 'BemsMonitoringPointHistory/ForecastingDayAheadData';
    }
    function ForecastingPointHistory_HourAheadValueGet(siteId) {
        this.siteId = siteId;
        this.apiUri = 'BemsMonitoringPointHistory/ForecastingHourAheadData';
    }
    //예측 데이터 2020.05.****************

    //축열조 시뮬레이터 관련 데이터 2020.08.****************
    function IceThermalStorage_SimulationValueGet(siteId) {
        this.siteId = siteId;
        this.apiUri = 'BemsMonitoringPointHistory/IceThermalStorageSimulation';
    }
    //축열조 시뮬레이터 관련 데이터 2020.08.****************

    function PointHistory_LCCViewGet(siteId) {
        this.siteId = siteId;
        this.apiUri = 'BemsMonitoringPointHistory/LCCView';
    }

    function PointHistory_LCCViewPreSumGet(siteId) {
        this.siteId = siteId;
        this.apiUri = 'BemsMonitoringPointHistory/LCCViewPreSum';
    }

    function FmsHouseStockGet(siteId) {
        this.siteId = siteId;
        this.apiUri = 'BemsMonitoringPointHistory/FmsHouseStock';
    }

    function apiGet(parameters) {

        if (parameters == undefined) return;

        if (_.has(parameters, 'SiteId') === false) {
            parameters.SiteId = this.siteId;
        }

        if (_.has(parameters, 'EndDate') === false) {
            parameters.EndDate = this.StartDate;
        }

        parameters.StartDate = $G.dateTime(parameters.StartDate);
        parameters.EndDate = $G.dateTime(parameters.EndDate);

        return BemsWebApplication.api.get(this.apiUri, parameters);
    };

    BWA.Chart.FormulaGet = FormulaGet;
    BWA.Chart.PointHistoryGet = PointHistoryGet;
    BWA.Chart.PointHistory_ZoneTempHumiGet = PointHistory_ZoneTempHumiGet;
    BWA.Chart.PointHistory_RunTimeGet = PointHistory_RunTimeGet;
    BWA.Chart.PointHistory_RuntimeREFRIGERATORGet = PointHistory_RuntimeREFRIGERATORGet;
    BWA.Chart.PointHistory_RuntimeBOILERGet = PointHistory_RuntimeBOILERGet;
    //hcLee 2015 03 26
    BWA.Chart.PointHistoryServiceTypeGet = PointHistoryServiceTypeGet;
    //hcLee 2015 08 05
    //BWA.Chart.ControlPoint = ControlPoint; // Post만 하는 경우는 필요없다// promises.push(BWA.api.post('BemsFormula/ControlPoint', null, param));
    BWA.Chart.FmsHouseStockGet = FmsHouseStockGet;
    BWA.Chart.PointHistory_LCCViewPreSumGet = PointHistory_LCCViewPreSumGet;
    BWA.Chart.PointHistory_LCCViewGet = PointHistory_LCCViewGet;
    BWA.Chart.PointHistory_MonthMoneyGet = PointHistory_MonthMoneyGet;
    BWA.Chart.PointHistory_CurrentValueGet = PointHistory_CurrentValueGet;
    BWA.Chart.VirtualNormalPointHistory_CurrentValueGet = VirtualNormalPointHistory_CurrentValueGet;
    BWA.Chart.ForecastingPointHistory_DayAheadValueGet = ForecastingPointHistory_DayAheadValueGet;
    BWA.Chart.ForecastingPointHistory_HourAheadValueGet = ForecastingPointHistory_HourAheadValueGet;
    BWA.Chart.IceThermalStorage_SimulationValueGet = IceThermalStorage_SimulationValueGet;

    //ControlPoint.prototype.apiGet = // promises.push(BWA.api.post('BemsFormula/ControlPoint', null, param));
    FmsHouseStockGet.prototype.apiGet =
    PointHistory_LCCViewPreSumGet.prototype.apiGet =
    PointHistory_LCCViewGet.prototype.apiGet =
    PointHistory_CurrentValueGet.prototype.apiGet =
    VirtualNormalPointHistory_CurrentValueGet.prototype.apiGet =
    PointHistory_MonthMoneyGet.prototype.apiGet =
    PointHistory_RuntimeBOILERGet.prototype.apiGet = //2015 06 08
    PointHistory_RuntimeREFRIGERATORGet.prototype.apiGet = //2015 06 08
    PointHistory_ZoneTempHumiGet.prototype.apiGet = PointHistoryServiceTypeGet.prototype.apiGet =
    PointHistory_RunTimeGet.prototype.apiGet =

    PointHistoryGet.prototype.apiGet = FormulaGet.prototype.apiGet = apiGet;
    ForecastingPointHistory_DayAheadValueGet.prototype.apiGet = ForecastingPointHistory_HourAheadValueGet.prototype.apiGet = apiGet;
    IceThermalStorage_SimulationValueGet.prototype.apiGet = apiGet;
    VirtualNormalPointHistory_CurrentValueGet.prototype.apiGet = apiGet;
    ////hcLee 2015 03 26
});