liling преди 1 година
родител
ревизия
c82a4c6e5b
променени са 2 файла, в които са добавени 38 реда и са изтрити 26 реда
  1. 2 3
      global.js
  2. 36 23
      main.html

+ 2 - 3
global.js

@@ -1,10 +1,9 @@
 var AutoPlayer = false; //开启自动漫游
-var SERVER_URL = "http://192.168.188.8/api"; //服务接口地址
+var SERVER_URL = "http://192.168.188.8/demo"; //服务接口地址
 var PLAYER3D_URL = "ws://192.168.188.8:8082"; //
 var DEV_ALAR_COLOR = "ff6c00"; //全局设备告警颜色
 var DEV_HINT_COLOR = "d69d85"; //设备盘头剩余20-50之间的提示颜色
 var DEV_OFFLINE_COLOR = "666666"; //设备未接入的颜色
 var ONLIME_TIMEOUT = 1000 * 60 * 5; //在线设备定时任务时间
 var INDEX_TIMEOUT = 5 * 60 * 1000; //首页统计数据定时任务时间
-var ALARM_TIMEOUT = 30 * 1000; //告警数据定时任务时间
-
+var ALARM_TIMEOUT = 30 * 1000; //告警数据定时任务时间

+ 36 - 23
main.html

@@ -1279,6 +1279,7 @@
             "stop6": "落布米数达到停机",
             "stop7": "盘头剩余圈数达到停机",
         },
+        LastAlarmDevs:{},
         //告警设备列表数据
         AlarmTable: function (data) {
             this.AlarmData = data;
@@ -1287,7 +1288,8 @@
                 $("#dev_alarm .content").hide();
                 $("#dev_alarm .title").html("当前无告警");
                 for(var devcode in modelsMap){
-                    if(this.PanAlarm[devcode]==null){
+                    this.LastAlarmDevs[devcode] = null;               
+                    if(this.PanAlarm[devcode]==null){                        
                         //还原设备状态
                         ChangeModelColor(devcode);
                     }
@@ -1306,23 +1308,31 @@
             for(var devcode in modelsMap){
                 if(OFFLINE_DEVS[devcode]==1) continue;
                 var alarmInfo = alarmDev[devcode];
+                //上一次没有告警,本次有告警,需要设置成告警状态
                 if(alarmInfo!=null){
-                    var color = "rgb(206,161,94)" //默认告警文本颜色
-                    var typeName = this.AlarmType[alarmInfo];
-                    if (typeName.indexOf("故障") > -1) color = "rgb(195,70,76)" //红色提醒
-                    lst.push(tpl.replace(/\{1\}/gi, devcode.replace(/C_/g, "")).replace(/\{2\}/g, typeName).replace('{COLOR}', color))
-                    if (MODEL_LOADED == 1) {
-                        //机器告警提示
-                        ChangeModelColor(devcode, DEV_ALAR_COLOR, typeName)
-                    } else {
-                        //记录下来,等待模型加载完成时处理
-                        ALARM_DEVS.push(devcode + ">" + typeName)
+                    if(this.LastAlarmDevs[devcode]==null){
+                        var color = "rgb(206,161,94)" //默认告警文本颜色
+                        var typeName = this.AlarmType[alarmInfo];
+                        if (typeName.indexOf("故障") > -1) color = "rgb(195,70,76)" //红色提醒
+                        lst.push(tpl.replace(/\{1\}/gi, devcode.replace(/C_/g, "")).replace(/\{2\}/g, typeName).replace('{COLOR}', color))
+                        if (MODEL_LOADED == 1) {
+                            //机器告警提示
+                            ChangeModelColor(devcode, DEV_ALAR_COLOR, typeName)
+                        } else {
+                            //记录下来,等待模型加载完成时处理
+                            ALARM_DEVS.push(devcode + ">" + typeName)
+                        }
                     }
+                    this.LastAlarmDevs[devcode]=1;
                 }else{
-                    if(this.PanAlarm[devcode]==null) noAlarmDevs.push(devcode);
+                    //上一次有告警,并且没有盘头告警时,本次未告警,需要恢复成未告警状态
+                    if(this.LastAlarmDevs[devcode]==1 && this.PanAlarm[devcode]==null){
+                        noAlarmDevs.push(devcode);
+                    }
+                    this.LastAlarmDevs[devcode]=null;
                 }
             }
-            if(noAlarmDevs.length>0){
+            if(noAlarmDevs.length>0){                
                 for (var i = 0; i < noAlarmDevs.length; i++) {
                     ChangeModelColor(noAlarmDevs[i]) //还原设备的无告警状态
                 }
@@ -1947,6 +1957,7 @@
                             //该设备进行告警
                             if (MODEL_LOADED == 1) {
                                 //机器告警提示
+                                console.log('设备',devCode,'盘头小于20%')
                                 ChangeModelColor(devCode, DEV_ALAR_COLOR, this.AlarmType["1000"])
                             } else {
                                 //记录下来,等待模型加载完成时处理
@@ -1970,6 +1981,7 @@
                             //该设备进行提醒
                             if (MODEL_LOADED == 1) {
                                 //机器提醒提示
+                                console.log('设备',devCode,'盘头小于50%大于20%')
                                 ChangeModelColor(devCode, DEV_HINT_COLOR, this.AlarmType["1001"])
                             } else {
                                 //记录下来,等待模型加载完成时处理
@@ -1984,8 +1996,8 @@
                 if(is50){
                     continue
                 }
-                if (MODEL_LOADED == 1) {
-                    this.PanAlarm[devCode]=null;
+                this.PanAlarm[devCode]=null;
+                if (MODEL_LOADED == 1) {                    
                     //盘头剩余比例正常,隐藏提示标签
                     ChangeModelColor(devCode)
                 }
@@ -2227,6 +2239,7 @@
         playerConnState = false
         //4.[推荐]尝试重新连接
         reconntimer=setTimeout(function () {
+            console.log('尝试自动重连:',playerConnState)
             if (playerConnState) return
             player.reconnect();
         }, 10000)
@@ -2293,8 +2306,8 @@
             // 添加关键帧
             player.Native.CameraAnimation.addKeyFrames([ANIMATION_DATA[i]]);
         }
-        document.getElementById("loading").remove(true) //加载完成,移除Loading
-        document.getElementById("loading_a1").remove(true)
+        if(document.getElementById("loading")!=null)document.getElementById("loading").remove(true) //加载完成,移除Loading
+        if(document.getElementById("loading_a1")!=null)document.getElementById("loading_a1").remove(true)
         //调整视角,使其达到最佳初始效果
         backMasterView();
         //player.Native.Camera.moveToItem(lastPtr,1);
@@ -2383,12 +2396,12 @@
         if (color == null || color == "") {
             if(OFFLINE_DEVS[name]==1) return; //离线设备无需处理
             //还原
-            player.Native.ModelTree.restoreItemColor(iteminfo.item)
+            await player.Native.ModelTree.restoreItemColor(iteminfo.item)
             //隐藏已有标签
-            player.Native.GisMarker.update(MarkerMap[name],{"visible":false});
+            await player.Native.GisMarker.update(MarkerMap[name],{"visible":false});
             MarkerMap[name]=null;
         } else {
-            player.Native.ModelTree.setItemColor(iteminfo.item, parseInt("0x" + color + "ff"), true)
+            await player.Native.ModelTree.setItemColor(iteminfo.item, parseInt("0x" + color + "ff"), true)
             if (hinttxt != null && hinttxt != "") {
                 var srcPosition = iteminfo.xyz // await player.Native.NodeProxy.getNodePosition(temp.item);
                 //console.log("posio",srcPosition)
@@ -2414,14 +2427,14 @@
                     options.text = hinttxt;
                 }
                 if(MarkerMap[name]!=null){
-                    player.Native.GisMarker.update(MarkerMap[name],options);
+                    await player.Native.GisMarker.update(MarkerMap[name],options);
                 }else{
                     var markPtr = await player.Native.GisMarker.create(options);
-                    player.Native.GisMarker.update(markPtr, options);
+                    await player.Native.GisMarker.update(markPtr, options);
                     MarkerMap[name] = markPtr;                    
                 }
             }else{
-                player.Native.GisMarker.update(MarkerMap[name],{"visible":false});
+                await player.Native.GisMarker.update(MarkerMap[name],{"visible":false});
             }
         }
     }