0a9dabc41f2a9b202f9045695ec49be0ae0168b2.svn-base 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614
  1. BemsWebApplication.EnergySavingControl = function (params, viewInfo) {
  2. "use strict";
  3. var initialized = false,
  4. shouldReload = false,
  5. datagrid = null,
  6. currentTabIndex = ko.observable(0),
  7. facilityViewModel = new BWA.CmFacilityViewModel(),
  8. dataSource;
  9. var m_Facility;
  10. var multiViewItems = [
  11. {
  12. template: 'mainCharts',
  13. },
  14. {
  15. template: 'subCharts'
  16. },
  17. ];
  18. var facilityDataSource = BWA.db.createDataSource('CmFacility'),
  19. facilitiesForSearch = ko.observableArray(),
  20. facilityCodeForSearch = ko.observable(0),
  21. deferredForSearch = new $.Deferred();
  22. var visiblePopup = ko.observable(false);
  23. var dataCalorie = ko.observableArray(),
  24. dataAtfw = ko.observableArray(),
  25. dataTemperatureCalorie = ko.observableArray(),
  26. dataTemperatureElectricity = ko.observableArray()
  27. ;
  28. var formulaGet = new BWA.Chart.FormulaGet(BWA.UserInfo.SiteId());
  29. //var controlPoint = new BWA.Chart.ControlPoint(BWA.UserInfo.SiteId());
  30. var timeBoxForSearch = BWA.SearchView.createDateTimeBox();
  31. var chartEnthalpy = BWA.Chart.Instance('chartEnthalpyES', 'dxChart'),
  32. chartCO2 = BWA.Chart.Instance('chartCO2ES', 'dxChart'),
  33. chartSet = BWA.Chart.Instance('chartSetES', 'dxChart');
  34. var chartLayout = new BWA.ChartLayout({
  35. divs: [{
  36. id: 'EnergySavingControlDetail'
  37. }, {
  38. id: 'Enthalpy',
  39. chartId: 'chartEnthalpyES'
  40. },{
  41. id: 'CO2',
  42. chartId: 'chartCO2ES'
  43. },{
  44. id: 'Set',
  45. chartId: 'chartSetES'
  46. },
  47. ],
  48. multiViewOptions: {
  49. viewIndex: currentTabIndex,
  50. viewCount: 1
  51. }
  52. });
  53. var enthalpyOnOff = ko.observable(false);
  54. var dutyOnOff = ko.observable(false);
  55. var effiOnOff = ko.observable(false);
  56. var co2OnOff = ko.observable(false);
  57. var tempValue = ko.observable(100);
  58. var m = moment();
  59. dataCalorie([
  60. { DateTime: new Date(m.year(), m.month(), 1), Value: 50 },
  61. { DateTime: new Date(m.year(), m.month(), 2), Value: 50 },
  62. { DateTime: new Date(m.year(), m.month(), 3), Value: 60 },
  63. { DateTime: new Date(m.year(), m.month(), 4), Value: 80 },
  64. { DateTime: new Date(m.year(), m.month(), 5), Value: 100 },
  65. { DateTime: new Date(m.year(), m.month(), 6), Value: 40, },
  66. { DateTime: new Date(m.year(), m.month(), 7), Value: 120 },
  67. { DateTime: new Date(m.year(), m.month(), 31), Value: 120 }
  68. ]);
  69. // 추가 2015 04 20 hcLee ->
  70. var CODE = $Code,
  71. FuelType = CODE.FuelType,
  72. FT = CODE.FacilityType,
  73. FC = CODE.FacilityCode,
  74. F = CODE.Formula,
  75. TIT = CODE.TimeIntervalType;
  76. // 추가 2015 04 20 hcLee <-
  77. //dataMonthForBar(dataDayForBar());
  78. //dataDayForPie([
  79. // { FuelTypeName: '전기', Value: 320 },
  80. // { FuelTypeName: '가스', Value: 350 },
  81. // { FuelTypeName: '수도', Value: 360 },
  82. //]);
  83. //dataMonthForPie(dataDayForPie());
  84. function handleViewShown() {
  85. if (initialized === false) {
  86. var chartOption = BWA.ChartOptions.EnergySavingControl;
  87. chartEnthalpy = chartEnthalpy(chartOption.getChartControlEnthalpyOptions(timeBoxForSearch.type()));
  88. chartCO2 = chartCO2(chartOption.getChartControlCO2Options(timeBoxForSearch.type()));
  89. chartSet = chartSet(chartOption.getChartControlSetOptions(timeBoxForSearch.type()));
  90. //chartTemperatureCalorie = chartTemperatureCalorie(chartOption.getChartTemperatureCalorieOptions($Code.TimeType.HOUR));
  91. //chartTemperatureElectricity2 = chartTemperatureElectricity2(chartOption.getTemperatureElectricityOptions(timeBoxForSearch.type()));
  92. initialized = true;
  93. }
  94. var eq = BWA.DataUtil.constructEqualFilter;
  95. facilityDataSource.filter([
  96. eq('SiteId', BWA.UserInfo.SiteId()),
  97. 'and',
  98. eq('FacilityTypeId', $Code.FacilityType.AIR_HANDLING)
  99. ]);
  100. facilityDataSource.load().done(function(facilities) {
  101. facilitiesForSearch(facilities);
  102. if (_.isEmpty(facilities) === false) {
  103. var f = facilities[0];
  104. handleSelectedFacilityInSearchView(f);
  105. handleSearchInSearchView();
  106. var datagrid = $('#EnergySavingControlDataGridViewInSearchView').dxDataGrid('instance');
  107. if (_.has(datagrid, 'selectRows')) {
  108. datagrid.selectRows(f);
  109. }
  110. }
  111. });
  112. }
  113. if (shouldReload) {
  114. //shouldReload = false;
  115. //dataSource.pageIndex(0);
  116. //dataSource.load();
  117. }
  118. function handleViewHidden() {
  119. var paging = BWA.ChartLayout.Paging;
  120. paging.sideOverlayVisible(false);
  121. $SearchView.visibleObservable(false); // hcLee 2015 03 23
  122. visiblePopup(false);
  123. }
  124. function handleViewShowing() {
  125. }
  126. function refreshList() {
  127. //dataSource.pageIndex(0);
  128. //dataSource.load();
  129. }
  130. var searchViewOptions = {
  131. searchViewItems: [
  132. { id: 'FacilityCode', ignoreValue: 0, defaultValue: 0, value: facilityCodeForSearch, dataSource: facilitiesForSearch },
  133. ],
  134. promiseDataInSearchView: deferredForSearch.promise()
  135. };
  136. function handleSelectedFacilityInSearchView(facility) {
  137. m_Facility = facility;
  138. return;
  139. }
  140. function handleSearchInSearchView(filter, searchViewItems) {
  141. //console.log(filter);
  142. //console.log(searchViewItems);
  143. if (m_Facility == null) return;
  144. visiblePopup(true);
  145. var f = m_Facility.toJS();
  146. facilityViewModel.fromJS(f);
  147. //var timeIntervalType = $Code.TimeIntervalType.QUARTERMIN;
  148. var timeIntervalType = timeBoxForSearch.type();
  149. var formula = $Code.Formula[$Code.FacilityType.AIR_HANDLING];
  150. var formulaIds = _.values(formula);
  151. var date = timeBoxForSearch.getDate();
  152. //utils.toast.displayTime=1000000;
  153. //utils.toast.show('공조기 성능분석 중 입니다. 잠시만 기다려 주세요');
  154. // var startDate = moment().
  155. var promises = [];
  156. _.each(formulaIds, function (formulaId) {
  157. var p = formulaGet.apiGet({
  158. FacilityTypeId: f.FacilityTypeId,
  159. FacilityCode: f.FacilityCode,
  160. FormulaId: formulaId,
  161. TimeIntervalType: timeIntervalType,
  162. StartDate: date.startDate,
  163. EndDate: date.endDate
  164. });
  165. promises.push(p);
  166. });
  167. // 외기 온도와 습도를 위해 추가 hcLee 2015 04 20 ->
  168. var commonParameters = {
  169. //TimeIntervalType: $Code.TimeIntervalType.QUARTERMIN,
  170. TimeIntervalType: timeIntervalType,
  171. StartDate: date.startDate,
  172. EndDate: date.endDate
  173. };
  174. var temperatureParameters = {
  175. FacilityTypeId: FT.OUTDOOR,
  176. FacilityCode: FC.OUTDOOR,
  177. FormulaId: F[FT.OUTDOOR].TEMPERATURE,
  178. };
  179. var humidityParameters = _.extend({}, temperatureParameters, {
  180. FormulaId: F[FT.OUTDOOR].HUMIDITY,
  181. });
  182. promises.push(formulaGet.apiGet(_.extend(temperatureParameters, commonParameters)));
  183. promises.push(formulaGet.apiGet(_.extend(humidityParameters, commonParameters)));
  184. // 외기 온도와 습도를 위해 추가 hcLee 2015 04 20 <-
  185. //promises.push(utils.toast.show('공조기 성능분석 중 입니다. 잠시만 기다려 주세요'));
  186. $.when.apply(this, promises)
  187. .done(function (coldWaterCalories, hotWaterCalories, coldWaterAtfws,
  188. hotWaterAtfws, in_temperatures, out_temperatures, cold_electricities, hot_electricities,
  189. cold_vopen, hot_vopen,
  190. cold_in_temperatures, cold_out_temperatures, // 이 2개는 2015 06 15일 추가
  191. f_temp, f_humi, // 2015 07 10 추가
  192. co2, // 2015 07 10 추가
  193. enthalpyOnoff, dutyOnoff, effiOnoff, co2Onoff, tempset,
  194. //2016 03 최종추가
  195. A21,A22,A23,A24,A25,A26,
  196. OUTtemperatures, OUThumidities) {
  197. if (enthalpyOnoff[0].length > 0)
  198. enthalpyOnOff(enthalpyOnoff[0][enthalpyOnoff[0].length - 1].Value == 0 ? false : true);
  199. else
  200. enthalpyOnOff(false);
  201. if (dutyOnoff[0].length > 0)
  202. dutyOnOff(dutyOnoff[0][dutyOnoff[0].length - 1].Value == 0 ? false : true);
  203. else
  204. dutyOnOff(false);
  205. if (effiOnoff[0].length > 0)
  206. effiOnOff(effiOnoff[0][effiOnoff[0].length - 1].Value == 0 ? false : true);
  207. else
  208. effiOnOff(false);
  209. if (co2Onoff[0].length > 0)
  210. co2OnOff(co2Onoff[0][co2Onoff[0].length - 1].Value == 0 ? false : true);
  211. else
  212. co2OnOff(false);
  213. tempValue(tempset[0].length == 0 ? 0 : tempset[0][tempset[0].length - 1].Value);
  214. var dataArray = [];
  215. for (var i = 0; i < OUTtemperatures[0].length; i++) {
  216. dataArray.push({
  217. DateTime: BWA.Chart.getCustermTimeArgumentAxisString(timeBoxForSearch.type(), moment(OUTtemperatures[0][i].DateTime).toDate()),
  218. enthalpy: BWA.Bems.refinegetENTHALPY(OUTtemperatures[0][i].Value, OUThumidities[0][i].Value / 100)
  219. //enthalpy: getENTHALPY(humi[i].Value / 100, temp[i].Value)
  220. });
  221. }
  222. for (var i = 0; i < f_temp[0].length; i++) {
  223. dataArray.push({
  224. DateTime: BWA.Chart.getCustermTimeArgumentAxisString(timeBoxForSearch.type(), moment(f_temp[0][i].DateTime).toDate()),
  225. f_enthalpy: BWA.Bems.refinegetENTHALPY(f_temp[0][i].Value, f_humi[0][i].Value / 100)
  226. //enthalpy: getENTHALPY(humi[i].Value / 100, temp[i].Value)
  227. });
  228. }
  229. var options = BWA.ChartOptions.EnergySavingControl.getChartControlEnthalpyOptions(timeBoxForSearch.type());
  230. options.dataSource = dataArray;
  231. chartEnthalpy().option(options);
  232. var dataCO2 = [];
  233. for (var i = 0; i < co2[0].length; i++) {
  234. dataCO2.push({
  235. DateTime: BWA.Chart.getCustermTimeArgumentAxisString(timeBoxForSearch.type(), moment(co2[0][i].DateTime).toDate()),
  236. co2: co2[0][i].Value
  237. //enthalpy: getENTHALPY(humi[i].Value / 100, temp[i].Value)
  238. });
  239. }
  240. options = BWA.ChartOptions.EnergySavingControl.getChartControlCO2Options(timeBoxForSearch.type());
  241. options.dataSource = dataCO2;
  242. chartCO2().option(options);
  243. var dataTH = [];
  244. for (var i = 0; i < f_temp[0].length; i++) {
  245. dataTH.push({
  246. DateTime: BWA.Chart.getCustermTimeArgumentAxisString(timeBoxForSearch.type(), moment(f_temp[0][i].DateTime).toDate()),
  247. temp: f_temp[0][i].Value
  248. //enthalpy: getENTHALPY(humi[i].Value / 100, temp[i].Value)
  249. });
  250. }
  251. for (var i = 0; i < f_humi[0].length; i++) {
  252. dataTH.push({
  253. DateTime: BWA.Chart.getCustermTimeArgumentAxisString(timeBoxForSearch.type(), moment(f_humi[0][i].DateTime).toDate()),
  254. humi: f_humi[0][i].Value
  255. //enthalpy: getENTHALPY(humi[i].Value / 100, temp[i].Value)
  256. });
  257. }
  258. for (var i = 0; i < OUTtemperatures[0].length; i++) {
  259. dataTH.push({
  260. DateTime: BWA.Chart.getCustermTimeArgumentAxisString(timeBoxForSearch.type(), moment(OUTtemperatures[0][i].DateTime).toDate()),
  261. out_temp : OUTtemperatures[0][i].Value
  262. //enthalpy: getENTHALPY(humi[i].Value / 100, temp[i].Value)
  263. });
  264. }
  265. for (var i = 0; i < OUThumidities[0].length; i++) {
  266. dataTH.push({
  267. DateTime: BWA.Chart.getCustermTimeArgumentAxisString(timeBoxForSearch.type(), moment(OUThumidities[0][i].DateTime).toDate()),
  268. out_humi: OUThumidities[0][i].Value
  269. //enthalpy: getENTHALPY(humi[i].Value / 100, temp[i].Value)
  270. });
  271. }
  272. options = BWA.ChartOptions.EnergySavingControl.getChartControlSetOptions(timeBoxForSearch.type());
  273. options.dataSource = dataTH;
  274. chartSet().option(options);
  275. /*
  276. coldWaterCalories = coldWaterCalories[0];
  277. hotWaterCalories = hotWaterCalories[0];
  278. coldWaterAtfws = coldWaterAtfws[0];
  279. hotWaterAtfws = hotWaterAtfws[0];
  280. in_temperatures = in_temperatures[0];
  281. out_temperatures = out_temperatures[0];
  282. cold_electricities = cold_electricities[0];
  283. hot_electricities = hot_electricities[0];
  284. cold_vopen = cold_vopen[0];
  285. hot_vopen = hot_vopen[0];
  286. cold_in_temperatures = cold_in_temperatures[0];
  287. cold_out_temperatures = cold_out_temperatures[0];
  288. OUTtemperatures = OUTtemperatures[0];
  289. BWA.Chart.mapWithConvertingDateTime(coldWaterCalories, timeBoxForSearch.type());
  290. BWA.Chart.mapWithConvertingDateTime(hotWaterCalories, timeBoxForSearch.type());
  291. //BWA.Chart.mapWithConvertingDateTime(coldWaterAtfws);
  292. //BWA.Chart.mapWithConvertingDateTime(hotWaterAtfws);
  293. BWA.Chart.mapWithConvertingDateTime(OUTtemperatures, timeBoxForSearch.type());
  294. var coldWaterCalorieDataArray = _.map(coldWaterCalories, function (x) {
  295. return {
  296. DateTime: x.DateTime,
  297. //DateTime: BWA.Chart.getCustermTimeArgumentAxisString(timeBoxForSearch.type(), x.DateTime),
  298. CV: x.Value
  299. };
  300. })
  301. _.each(cold_in_temperatures, function (x) {
  302. coldWaterCalorieDataArray.push({
  303. //DateTime: moment(x.DateTime).toDate(),
  304. DateTime: BWA.Chart.getCustermTimeArgumentAxisString(timeBoxForSearch.type(), moment(x.DateTime).toDate()),
  305. cold_in_temp: x.Value
  306. });
  307. });
  308. _.each(cold_out_temperatures, function (x) {
  309. coldWaterCalorieDataArray.push({
  310. //DateTime: moment(x.DateTime).toDate(),
  311. DateTime: BWA.Chart.getCustermTimeArgumentAxisString(timeBoxForSearch.type(), moment(x.DateTime).toDate()),
  312. cold_out_temp: x.Value
  313. });
  314. });
  315. var options = BWA.ChartOptions.WaterCoolingAnalysis.getChartCalorieCOptions(timeBoxForSearch.type());
  316. //chartCalorie().option('argumentAxis', null); // 2015 05 21 결국 이 코드가 필요 함 (시간 축 에러 해결)
  317. options.dataSource = coldWaterCalorieDataArray;
  318. chartCalorieC().option(options);
  319. // chart 2
  320. var hotWaterCalorieDataArray = _.map(hotWaterCalories, function (x) {
  321. return {
  322. DateTime: x.DateTime,
  323. //DateTime: BWA.Chart.getCustermTimeArgumentAxisString(timeBoxForSearch.type(), x.DateTime),
  324. HV: x.Value
  325. };
  326. })
  327. //var calories = coldWaterCalorieDataArray.concat(hotWaterCalorieDataArray);
  328. _.each(in_temperatures, function (x) {
  329. hotWaterCalorieDataArray.push({
  330. //DateTime: moment(x.DateTime).toDate(),
  331. DateTime: BWA.Chart.getCustermTimeArgumentAxisString(timeBoxForSearch.type(), moment(x.DateTime).toDate()),
  332. in_temp: x.Value
  333. });
  334. });
  335. _.each(out_temperatures, function (x) {
  336. hotWaterCalorieDataArray.push({
  337. //DateTime: moment(x.DateTime).toDate(),
  338. DateTime: BWA.Chart.getCustermTimeArgumentAxisString(timeBoxForSearch.type(), moment(x.DateTime).toDate()),
  339. out_temp: x.Value
  340. });
  341. });
  342. //var chartOption = BWA.ChartOptions.WaterCoolingAnalysis;
  343. //chartOption.getChartCalorieOptions(timeBoxForSearch.type());
  344. //chartCalorie().option.getChartCalorieOptions(timeBoxForSearch.type())
  345. var options = BWA.ChartOptions.WaterCoolingAnalysis.getChartCalorieHOptions(timeBoxForSearch.type());
  346. //chartCalorie().option('argumentAxis', null); // 2015 05 21 결국 이 코드가 필요 함 (시간 축 에러 해결)
  347. options.dataSource = hotWaterCalorieDataArray;
  348. chartCalorieH().option(options);
  349. // chart 2
  350. var atfwDataArray = [];
  351. var maxValueCHV = 0;
  352. _.map(coldWaterAtfws, function (x) {
  353. atfwDataArray.push({
  354. //DateTime: moment(x.DateTime).toDate(),
  355. DateTime: BWA.Chart.getCustermTimeArgumentAxisString(timeBoxForSearch.type(), moment(x.DateTime).toDate()),
  356. CV: x.Value
  357. });
  358. if (maxValueCHV < x.Value) maxValueCHV = x.Value;
  359. })
  360. _.map(hotWaterAtfws, function (x) {
  361. atfwDataArray.push({
  362. //DateTime: moment(x.DateTime).toDate(),
  363. DateTime: BWA.Chart.getCustermTimeArgumentAxisString(timeBoxForSearch.type(), moment(x.DateTime).toDate()),
  364. HV: x.Value
  365. });
  366. if (maxValueCHV < x.Value) maxValueCHV = x.Value;
  367. })
  368. options = BWA.ChartOptions.WaterCoolingAnalysis.getChartAtfwOptions(timeBoxForSearch.type());
  369. //chartAtfw().option('argumentAxis', null); // 2015 05 21 결국 이 코드가 필요 함 (시간 축 에러 해결)
  370. //maxValueCHV = 30;
  371. options.valueAxis[0].tickInterval = Math.round(Math.round(maxValueCHV) / 5) + 1;
  372. options.dataSource = atfwDataArray.concat(OUTtemperatures);
  373. chartAtfw().option(options); // 냉난방ATF와 외기온도관계
  374. //chart3
  375. //chartTemperatureCalorie().option('dataSource', calories.concat(OUTtemperatures));
  376. //BWA.Chart.mapWithConvertingDateTime(cold_vopen);
  377. //BWA.Chart.mapWithConvertingDateTime(hot_vopen);
  378. var vopenDataArray = [];
  379. maxValueCHV = 0;
  380. _.map(cold_vopen, function (x) {
  381. vopenDataArray.push({
  382. //DateTime: moment(x.DateTime).toDate(),
  383. DateTime: BWA.Chart.getCustermTimeArgumentAxisString(timeBoxForSearch.type(), moment(x.DateTime).toDate()),
  384. CV: x.Value
  385. });
  386. if (maxValueCHV < x.Value) maxValueCHV = x.Value;
  387. })
  388. _.map(hot_vopen, function (x) {
  389. vopenDataArray.push({
  390. //DateTime: moment(x.DateTime).toDate(),
  391. DateTime: BWA.Chart.getCustermTimeArgumentAxisString(timeBoxForSearch.type(), moment(x.DateTime).toDate()),
  392. HV: x.Value
  393. });
  394. if (maxValueCHV < x.Value) maxValueCHV = x.Value;
  395. })
  396. options = BWA.ChartOptions.WaterCoolingAnalysis.getChartVOpenOptions(timeBoxForSearch.type());
  397. options.valueAxis[0].tickInterval = Math.round(maxValueCHV / 5) + 1;
  398. //chartVOpen().option('argumentAxis', null); // 2015 05 21 결국 이 코드가 필요 함 (시간 축 에러 해결)
  399. options.dataSource = vopenDataArray.concat(OUTtemperatures);
  400. chartVOpen().option(options); // 냉난방ATF와 외기온도관계
  401. */
  402. visiblePopup(false);
  403. })
  404. .fail(function (error) {
  405. //alert(error);
  406. visiblePopup(false);
  407. });
  408. }
  409. var viewModel = $.extend(BWA.CommonView.create(
  410. params, viewInfo, searchViewOptions, ko.observable(null),
  411. handleViewShown, null, handleSearchInSearchView, undefined,
  412. chartLayout), {
  413. // facility: facilityViewModel,
  414. viewHidden: handleViewHidden, // hcLee 2015 06 03
  415. refreshList: refreshList,
  416. viewShowing: handleViewShowing,
  417. scrolling: { mode: 'infinite' },
  418. EnergySavingControlDataGridOptions : {
  419. dataSource: facilitiesForSearch,
  420. columns: [
  421. { dataField: 'Name', caption: $G('facilityName'), width: '100%', alignment: 'left' }
  422. ],
  423. filterRow: {
  424. visible: true,
  425. showOperationChooser: false
  426. },
  427. selection: {
  428. mode: 'single'
  429. },
  430. rowClick: function(clickRow) {
  431. handleSelectedFacilityInSearchView(clickRow.data);
  432. }
  433. },
  434. contentReadyAction: function(e) {
  435. datagrid = e.component;
  436. }
  437. });
  438. viewModel.timeBoxForSearch = timeBoxForSearch;
  439. viewModel.currentTabIndex = currentTabIndex;
  440. viewModel.multiViewItems = [{
  441. facility: facilityViewModel,
  442. template: 'mainCharts',
  443. enthalpyOnOff: enthalpyOnOff,
  444. dutyOnOff: dutyOnOff,
  445. effiOnOff: effiOnOff,
  446. co2OnOff: co2OnOff,
  447. tempValue: tempValue,
  448. setEnthalpyOnOff: function () {
  449. //alert(enthalpyOnOff());
  450. var f = m_Facility.toJS();
  451. var param = {
  452. SiteId: BWA.UserInfo.SiteId(),
  453. FacilityTypeId: f.FacilityTypeId, // 이게 문제다....
  454. FacilityCode: f.FacilityCode,
  455. FormulaId: $Code.Formula[$Code.FacilityType.AIR_HANDLING].ENTHALPY_ONOFF,
  456. ControlValue: enthalpyOnOff() ? 1 : 0,
  457. };
  458. BWA.api.post('BemsFormula/ControlPoint', null, param).done(function () {
  459. utils.toast.show('엔탈피제어 완료');
  460. });
  461. },
  462. setDutyOnOff: function () {
  463. //alert(dutyOnOff());
  464. var f = m_Facility.toJS();
  465. var param = {
  466. SiteId: BWA.UserInfo.SiteId(),
  467. FacilityTypeId: f.FacilityTypeId, // 이게 문제다....
  468. FacilityCode: f.FacilityCode,
  469. FormulaId: $Code.Formula[$Code.FacilityType.AIR_HANDLING].DUTYCYCLE_ONOFF,
  470. ControlValue: dutyOnOff() ? 1 : 0,
  471. };
  472. BWA.api.post('BemsFormula/ControlPoint', null, param).done(function () {
  473. utils.toast.show('절전제어 완료');
  474. });
  475. },
  476. setEffiOnOff: function () {
  477. var f = m_Facility.toJS();
  478. var param = {
  479. SiteId: BWA.UserInfo.SiteId(),
  480. FacilityTypeId: f.FacilityTypeId, // 이게 문제다....
  481. FacilityCode: f.FacilityCode,
  482. FormulaId: $Code.Formula[$Code.FacilityType.AIR_HANDLING].EFFI_ONOFF,
  483. ControlValue: effiOnOff() ? 1 : 0,
  484. };
  485. BWA.api.post('BemsFormula/ControlPoint', null, param).done(function () {
  486. utils.toast.show('효율제어 완료');
  487. });
  488. },
  489. setCO2OnOff: function () {
  490. var f = m_Facility.toJS();
  491. var param = {
  492. SiteId: BWA.UserInfo.SiteId(),
  493. FacilityTypeId: f.FacilityTypeId, // 이게 문제다....
  494. FacilityCode: f.FacilityCode,
  495. FormulaId: $Code.Formula[$Code.FacilityType.AIR_HANDLING].CO2_ONOFF,
  496. ControlValue: co2OnOff() ? 1 : 0,
  497. };
  498. BWA.api.post('BemsFormula/ControlPoint', null, param).done(function () {
  499. utils.toast.show('CO2제어 완료');
  500. });
  501. },
  502. setTempValue: function () {
  503. var f = m_Facility.toJS();
  504. /*
  505. var p = controlPoint.apiGet({
  506. FacilityTypeId: f.FacilityTypeId, // 이게 문제다....
  507. FacilityCode: f.FacilityCode,
  508. //FormulaId: $Code.FacilityType.AIR_HANDLING.TEMP_SET,
  509. FormulaId: $Code.Formula[$Code.FacilityType.AIR_HANDLING].TEMP_SET,
  510. ControlValue: tempValue(),
  511. });
  512. promises.push(p);
  513. $.when.apply(this, promises)
  514. .done(function () {
  515. alert(tempValue());
  516. })
  517. .fail(function (error) {
  518. //visiblePopup(false);
  519. alert('fail');
  520. });*/
  521. var param = {
  522. SiteId:BWA.UserInfo.SiteId(),
  523. FacilityTypeId: f.FacilityTypeId, // 이게 문제다....
  524. FacilityCode: f.FacilityCode,
  525. FormulaId: $Code.Formula[$Code.FacilityType.AIR_HANDLING].TEMP_SET,
  526. ControlValue: tempValue(),
  527. };
  528. BWA.api.post('BemsFormula/ControlPoint', null, param).done(function () {
  529. utils.toast.show('온도제어 완료');
  530. });
  531. }
  532. },
  533. {
  534. template: 'subCharts'
  535. }
  536. ];
  537. $HourGlassPopup(viewModel, visiblePopup);
  538. return viewModel;
  539. };