Browse Source

New alarm handlers

Avetisyan Karen 7 years ago
parent
commit
7b8e5610c2

BIN
modules/HTTP_Server/fs/main.js


BIN
modules/HTTP_Server/fs/role.js


File diff suppressed because it is too large
+ 620 - 607
modules/HTTP_Server/fsdata.c


+ 3 - 3
web_interface/src/wui/bat_test.cgi

@@ -10,9 +10,9 @@ print ""
 if data["func"] == "stop":
   print "Тест остановлен"
 elif data["func"] == "time" and data["time"]:
-  print "Тест зпущен на " + str(data["time"]) + " минут"
+  print "Тест запущен на " + str(data["time"]) + " минут"
 elif data["func"] == "discharge":
-  print "Тест зпущен до разряда"
+  print "Тест запущен до разряда"
 # elif data["func"] == "run" and !data["time"]:
-#   print "Тест зпущен до разрядки АКБ"
+#   print "Тест запущен до разрядки АКБ"
 

+ 2 - 1
web_interface/src/wui/getJson.cgi

@@ -31,7 +31,8 @@ JSON = {
   "ro2": "1",
   "batsym": "Норма",
   "mode": "Профилактика сульфатации",
-  "alarm": "5",
+  "u_alarm": "5",
+  "m_alarm": "13",
   "utc": "3.0",
   "netsettings_changed": "false"
 }

+ 48 - 20
web_interface/src/wui/main.js

@@ -169,7 +169,6 @@ function submitForms() {
     }
     if (formValidation()) {
       $('form1').submit();
-      netsettings_changedCheck();
     }
     else{
       $('validation-box').style.display = 'block';
@@ -422,46 +421,69 @@ function setIcons(containerID, icnName) {
 
 function paramsRefresh() {
   getJSON('getJson.cgi'+'?'+Math.random(), function (data) {
-    var alrm = +data.alarm;
+    var alrm   = +data.u_alarm;
+    var ma     = +data.m_alarm;
     var pstate = [];
     var bstate = [];
-    var ups_bypass =   Alarm(alrm, 5),
-      ups_alarm =    Alarm(alrm, 4) || Alarm(alrm, 7),
-      ups_standby =  Alarm(alrm, 3),
+    var ups_bypass = Alarm(alrm, 5),
+      ups_alarm    = Alarm(alrm, 4) || Alarm(alrm, 7),
+      ups_standby  = Alarm(alrm, 3),
       ups_shutdown = Alarm(alrm, 1),
-
-      bat_low =      Alarm(alrm, 6),
-      bat_test =     Alarm(alrm, 2);
+      bat_low      = Alarm(alrm, 6),
+      bat_test     = Alarm(alrm, 2);
     // PPS
-    $('AC').innerHTML            = parseFloat(data.AC) + ' В';
-    $('DC').innerHTML            = parseFloat(data.DC) + ' В';
-    $('in_freq').innerHTML       = parseFloat(data.in_freq) + ' Гц';
-    $('out_freq').innerHTML      = parseFloat(data.out_freq) + ' Гц';
-    $('pwr').innerHTML           = parseFloat(data.pwr) + ' %';
-    $('pmode').innerHTML         = ups_bypass ? 'Bypass' : 'Boost or Buck';
+    $('AC').innerHTML         = parseFloat(data.AC) + ' В';
+    $('AC').style.color       = Alarm(alrm, 7) ? ALARM_RED : ALARM_GREEN;
+
+    $('DC').innerHTML         = parseFloat(data.DC) + ' В';
+    $('DC').style.color       = Alarm(alrm, 7) ? ALARM_RED : ALARM_GREEN;
+
+    $('in_freq').innerHTML    = parseFloat(data.in_freq) + ' Гц';
+    $('in_freq').style.color  = Alarm(alrm, 7) ? ALARM_RED : ALARM_GREEN;
+
+    $('out_freq').innerHTML   = parseFloat(data.out_freq) + ' Гц';
+    $('out_freq').style.color = Alarm(alrm, 7) ? ALARM_RED : ALARM_GREEN;
+
+    $('pwr').innerHTML        = parseFloat(data.pwr) + ' %';
+    $('pwr').style.color      = Alarm(ma, 0) ? ALARM_RED : ALARM_GREEN;
+
+    $('pmode').innerHTML      = ups_bypass ? 'Bypass' : 'Boost or Buck';
 
     // State
     ups_alarm ? pstate.push('exclamination') : pstate.push('normal');
     ups_standby ? pstate.push('clock') : null;
     ups_shutdown ? pstate.push('shutdown') : null;
 
-    bat_low ? bstate.push('batteryLow') : bstate.push('normal');
+    !Alarm(ma, 3) && !bat_low ? bstate.push('normal') : null;
+    Alarm(ma, 3) ? bstate.push('exclamination') : null;
+    bat_low ? bstate.push('batteryLow') : null;
     bat_test ? bstate.push('batTest') : null;
 
     setIcons('pstate_icons', pstate);
     setIcons('bstate_icons', bstate);
 
     // ACB
-    $('bat_cap').innerHTML       = parseFloat(data.bat_cap) + ' %';
-    $('inner_temp').innerHTML    = parseFloat(data.inner_temp) + ' °C';
+    $('bat_cap').innerHTML      = parseFloat(data.bat_cap) + ' %';
+    $('bat_cap').style.color    = bat_low ? ALARM_RED : ALARM_GREEN;
+
+    $('inner_temp').innerHTML   = parseFloat(data.inner_temp) + ' °C';
+    $('inner_temp').style.color = Alarm(ma, 1) ? ALARM_RED : ALARM_GREEN;
+
     $('bat_time_left').innerHTML = parseFloat(data.bat_time_left) + ' мин';
+    $('bat_time_left').style.color    = bat_low ? ALARM_RED : ALARM_GREEN;
 
     // Inputs
-    $('di1').innerHTML = +data.di1 ? 'Разомкнут' : 'Замкнут';
-    $('ro1').innerHTML = +data.ro1 ? 'Замкнут' : 'Разомкнут';
-    $('ro2').innerHTML = +data.ro2 ? 'Замкнут' : 'Разомкнут';
+    $('di1').innerHTML   = +data.di1 ? 'Разомкнут' : 'Замкнут';
+    $('di1').style.color = +data.di1 ? ALARM_GREEN : ALARM_RED;
+
+    $('ro1').innerHTML   = +data.ro1 ? 'Замкнут' : 'Разомкнут';
+    $('ro1').style.color = +data.ro1 ? ALARM_RED : ALARM_GREEN;
+
+    $('ro2').innerHTML   = +data.ro2 ? 'Замкнут' : 'Разомкнут';
+    $('ro2').style.color = +data.ro2 ? ALARM_RED : ALARM_GREEN;
     // checkState();
     window.setCookie('netsettings_changed', data.netsettings_changed);
+    window.setCookie('device-error', Alarm(ma, 2));
     checkNotify();
     setTimeout(paramsRefresh, 1000);
   }, function (status) {
@@ -731,6 +753,12 @@ var apply_settings = new NotificationBox('apply-settings',
     'url': 'confirm.cgi',
     'show': window.getCookie('role') < 2
   });
+var device_error = new NotificationBox('apply-settings',
+  {
+    'message': 'Внимание, связь с UPS не установлена!',
+    'bgcolor':'#ec0035',
+    'textcolor': '#fff'
+  });
 
 // ################################################################################
 

+ 10 - 7
web_interface/src/wui/role.js

@@ -180,7 +180,8 @@ function getJSON(url, successHandler, errorHandler) {
 }
 
 function checkNotify() {
-  ( getCookie('netsettings_changed')  == 'true' ) ? apply_settings.init()           : apply_settings.close();
+  ( getCookie('netsettings_changed')  == 'true' ) ? apply_settings.init() : apply_settings.close();
+  ( getCookie('device-error') == '1' )            ? device_error.init()   : device_error.close();
 }
 function getParam(e,x) {
   switch (x) {
@@ -221,7 +222,7 @@ function NotificationBox (id, options) {
   if(! ('bgcolor' in this.options)) this.options.bgcolor = '#009966';
   if(! ('textcolor' in this.options)) this.options.textcolor = '#fff';
   if(! ('show' in this.options)) this.options.show = true;
-  if(! ('url' in this.options)) console.log('NotificationBox: Please add confirm URL in options');
+  if(! ('url' in this.options)) this.options.url = false;
 }
 
 NotificationBox.prototype.init = function(){
@@ -235,11 +236,13 @@ NotificationBox.prototype.init = function(){
       var string  = document.createElement('p');
       string.textContent = this.options.message;
       maindiv.appendChild(string);
-      var confirm = document.createElement('button');
-      confirm.className = 'btn btn-danger-inverted';
-      confirm.textContent = 'Подтвердить';
-      confirm.setAttribute('onclick', 'loadXMLDoc(\''+ this.options.url +'\',\'GET\', updatepage)');
-      maindiv.appendChild(confirm);
+      if (this.options.url) {
+        var confirm = document.createElement('button');
+        confirm.className = 'btn btn-danger-inverted';
+        confirm.textContent = 'Подтвердить';
+        confirm.setAttribute('onclick', 'loadXMLDoc(\''+ this.options.url +'\',\'GET\', updatepage)');
+        maindiv.appendChild(confirm);
+      }
       if (this.options.cancelButton) {
         var cancel = document.createElement('button');
         cancel.className = 'btn btn-warning-inverted';

+ 1 - 1
web_interface/src/wui/ups_power.cgi

@@ -8,7 +8,7 @@ print "Content-Type: application/json"
 print ""
 
 if data["func"] == "cancel":
-  print "Выключенеие остановлено"
+  print "Выключение остановлено"
 elif data["func"] == "off":
   print "ИБП выключится через " + str(data["after"]) + " секунд на " + str(data["to"]) + " секунд"
 # elif data["func"] == "run" and !data["time"]:

Some files were not shown because too many files changed in this diff