Quellcode durchsuchen

add message window,update simulation methods

xyh vor 1 Jahr
Ursprung
Commit
bbbb5ebd9d
1 geänderte Dateien mit 58 neuen und 16 gelöschten Zeilen
  1. 58 16
      src/views/simulation/index.vue

+ 58 - 16
src/views/simulation/index.vue

@@ -28,6 +28,17 @@
             </el-table-column>
           </el-table>
         </el-tab-pane>
+        <el-tab-pane name="fifth">
+          <el-tooltip placement="right" effect="light" slot="label">
+            <span slot="content" class="item">消息</span>
+            <span><i class="el-icon-chat-line-round"></i></span>
+          </el-tooltip>
+          <el-table :data="messageList">
+            <el-table-column label="序号" prop="order" width="50px"></el-table-column>
+            <el-table-column label="时间" align="center" prop="time"></el-table-column>
+            <el-table-column label="消息" align="center" prop="context"></el-table-column>
+          </el-table>
+        </el-tab-pane>
       </el-tabs>
       <div class="buttons">
         <el-button icon="el-icon-full-screen" circle @click="ismax()"></el-button>
@@ -64,6 +75,7 @@ export default {
   data() {
     return {
       save: false,
+      messageList:[],
       situation: [],
       nameIdList: [],
       satelliteRange: [],
@@ -75,6 +87,7 @@ export default {
       satellite: [],
       center: [],
       move_data: {},
+      order : 1,
       _viewer2D: null,
       _viewer3D: null,
       mousevalue: null,
@@ -136,12 +149,20 @@ export default {
   },
   methods: {
     async getJson(row) {
+      this.order = 1;
+      this.messageList = [];
+      this.nameIdList = [];
+     this.satelliteRange = [];
+      this.missileList = {};
+      this.thaadList = {};
       let redunit = [];
       let blueunit = [];
       let satellite = [];
       let center = [];
       let fileInfoStr = row.xdfile;
       let fileInfoArr = JSON.parse(fileInfoStr);
+      this.$data._viewer2D.entities.removeAll();
+      this.$data._viewer3D.entities.removeAll();
       await axios
         .get("http://127.0.0.1:8084/admin/online/onlineOperation/downloadDatasource/main", {
           params: {
@@ -545,7 +566,7 @@ export default {
         color = 'Blue'
         modelUrl = radarModel
         this.thaadList[name] = {
-          range: 1000000.0,
+          range: 700000.0,
           health: 100.0,
           id: this.id
         }
@@ -560,7 +581,7 @@ export default {
       }
       if (type == 'blue') {
         console.log(' radar!!!');
-        const range = 1000000;
+        const range = 700000;
         this.$data._viewer2D.entities.add({
           id: this.id,
           position: position,
@@ -752,6 +773,11 @@ export default {
       // 循环执行,到达终止时间,重新从起点时间开始
       this.$data._viewer2D.clock.clockRange = this.Cesium.ClockRange.LOOP_STOP;
       this.$data._viewer3D.clock.clockRange = this.Cesium.ClockRange.LOOP_STOP;
+      this.messageList.push({
+        order : this.order++,
+        time : startTime,
+        context: "开始模拟!!!"
+      })
       this.$data._viewer2D.clock.onTick.addEventListener(clock => {
         const currentTime = clock.currentTime; // 获取当前时间轴的时间
         const elapsedTime = this.Cesium.JulianDate.secondsDifference(
@@ -759,7 +785,6 @@ export default {
           this.$data._viewer2D.clock.startTime
         ); // 获取从起始时间到当前时间的秒数
         if (parseInt(elapsedTime) % stepTime === 0 && elapsedTime != 0) {
-          console.log('elapsedTime :>> ', elapsedTime);
           // 当从起始时间到当前时间的秒数是 stepTime 的倍数时,发送请求
           this.requestDataAndUpdateModel2D(startTime, elapsedTime);
         }
@@ -771,7 +796,6 @@ export default {
           this.$data._viewer3D.clock.startTime
         ); // 获取从起始时间到当前时间的秒数
         if (parseInt(elapsedTime) % stepTime === 0 && elapsedTime != 0) {
-          console.log('elapsedTime :>> ', elapsedTime);
           // 当从起始时间到当前时间的秒数是 stepTime 的倍数时,发送请求
           this.requestDataAndUpdateModel3D(startTime, elapsedTime);
         }
@@ -813,8 +837,6 @@ export default {
               let cylinderposition = this.convertWorldToCartographic(position)
               cylinderposition.height = cylinderposition.height / 10.0
               cylinderposition = this.Cesium.Cartesian3.fromDegrees(cylinderposition.longitude, cylinderposition.latitude, cylinderposition.height);
-              console.log('position :>> ', position);
-              console.log('cylinderposition :>> ', cylinderposition);
               this.$data._viewer2D.entities.add({
                 id: this.id,
                 position: position,
@@ -935,12 +957,17 @@ export default {
               }
               if(this.thaadList[this.nameIdList[i].name].health != health){
                 //修改健康值并修改范围
+                let mark = true
+                if(health>this.thaadList[this.nameIdList[i].name].health)
+                {
+                  mark = false
+                }
                 this.thaadList[this.nameIdList[i].name].health = health
-                this.changeRange(this.$data._viewer2D,this.thaadList[this.nameIdList[i].name].id,this.thaadList[this.nameIdList[i].name].range,this.thaadList[this.nameIdList[i].name].health)
+                this.changeRange(this.$data._viewer2D,this.thaadList[this.nameIdList[i].name].id,this.thaadList[this.nameIdList[i].name].range,this.thaadList[this.nameIdList[i].name].health,newTimeString,this.nameIdList[i].name,mark)
               }
             }
           }
-          this.judgeMissile(this.$data._viewer2D);
+          this.judgeMissile(this.$data._viewer2D,newTimeString);
           //更新模型位置
           // this.modelEntityMoveByIDAndLocation(this.$data._viewer2D,"1654426964397658112",res.data[1].data.W1.x,res.data[1].data.W1.y,res.data[1].data.W1.z)
         })
@@ -975,14 +1002,19 @@ export default {
               }
               if(this.thaadList[this.nameIdList[i].name].health != health){
                 //修改健康值并修改范围
+                let mark = true
+                if(health>this.thaadList[this.nameIdList[i].name].health)
+                {
+                  mark = false
+                }
                 this.thaadList[this.nameIdList[i].name].health = health
-                this.changeRange(this.$data._viewer3D,this.thaadList[this.nameIdList[i].name].id,this.thaadList[this.nameIdList[i].name].range,this.thaadList[this.nameIdList[i].name].health)
+                this.changeRange(this.$data._viewer3D,this.thaadList[this.nameIdList[i].name].id,this.thaadList[this.nameIdList[i].name].range,this.thaadList[this.nameIdList[i].name].health,newTimeString,this.nameIdList[i].name,mark)
               }
               
             }
           }
           //判断是否有导弹被拦截
-          this.judgeMissile(this.$data._viewer3D);
+          this.judgeMissile(this.$data._viewer3D,newTimeString);
           //更新模型位置
           //  this.modelEntityMoveByIDAndLocation(this.$data._viewer3D,viewer,"1654426964397658112",res.data[1].data.W1.x,res.data[1].data.W1.y,res.data[1].data.W1.z)  
         })
@@ -1036,17 +1068,19 @@ export default {
       return num;
     },
     //判断导弹是否被拦截
-    judgeMissile(viewer){
+    judgeMissile(viewer,time){
       for(let key in this.missileList){
         let missile = viewer.entities.getById(this.missileList[key].id)
         let missilePos = viewer.entities.getById(this.missileList[key].id).position._value
         for(let item in this.thaadList){
           let radarPos = viewer.entities.getById(this.thaadList[item].id).position._value
-          console.log(key+'和'+item+'的距离:   ', this.Cesium.Cartesian3.distance(radarPos,missilePos));
-          console.log('this.thaadList[item].range*this.thaadList[item].health :>> ', this.thaadList[item].range*this.thaadList[item].health);
           if(this.Cesium.Cartesian3.distance(radarPos,missilePos)<=this.thaadList[item].range*this.thaadList[item].health*0.01){
             // 导弹进入了被干扰后的雷达探测范围,判断被拦截 移除实体,删除信息
-            console.log('导弹'+key+'被雷达'+item+'拦截!!!');
+            this.messageList.push({
+              order : this.order++,
+              time: time,
+              context : '导弹'+key+'被雷达'+item+'拦截!!!'
+            })
             viewer.entities.remove(missile)
             this.nameIdList = this.nameIdList.filter(item => item.id !== this.missileList[key].id);
             delete this.missileList[key]
@@ -1056,8 +1090,16 @@ export default {
       }
     },
     //修改雷达的显示范围
-    changeRange(viewer,id,range,health){
-      console.log('修改雷达'+id+'的范围!!!');
+    changeRange(viewer,id,range,health,time,name,mark){
+      let context = '雷达'+name+'受到干扰!健康值变化为: '+health
+      if(!mark){
+        context = '雷达'+name+'恢复健康值,健康值变化为: '+health
+      }
+      this.messageList.push({
+        order : this.order++,
+        time : time,
+        context: context
+      })
       let radar = viewer.entities.getById(id)
       let newRange = range*health*0.01
       radar.ellipsoid.radii = new this.Cesium.Cartesian3(newRange, newRange, newRange);