he wei
2024-09-21 70edda3b00f2528a473c28ec5a50b739ed160f0f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
<template>
  <content-box :title="fullStationName" class="mgl8">
    <flex-layout>
      <div class="flex-page-content">
        <el-tabs
          type="border-card"
          class="flex-layout noborder top-border"
          v-model="acTabs"
          @tab-click="tabsChange">
          <el-tab-pane label="模拟量" name="analog">
            <analog-data ref="analogData" :list="list" :list1="list1"></analog-data>
          </el-tab-pane>
          <el-tab-pane label="信号量" name="signal">
            <sinal-data :list="signalData" :cols="8"></sinal-data>
          </el-tab-pane>
          <el-tab-pane label="资产管理" name="asset">
            <div class="center-box">
              <power-asset-info :info="powerInfo"></power-asset-info>
            </div>
          </el-tab-pane>
        </el-tabs>
      </div>
    </flex-layout>
  </content-box>
</template>
 
<script>
 
import ContentBox from "@/components/ContentBox.vue";
import {getInfoById} from "@/views/dataMager/js/power";
import PowerAssetInfo from "@/views/dataMager/components/powerAssetInfo.vue";
import AnalogData from "@/views/dataTest/components/ups/analogData.vue";
import createWs from "@/assets/js/websocket";
import SinalData from "@/views/dataTest/components/ups/sinalData.vue";
import {getBit} from "@/assets/js/const/const_storage";
const WSMixin = createWs("ups");
 
export default {
  components: {SinalData, AnalogData, PowerAssetInfo, ContentBox},
  mixins: [WSMixin],
  data() {
    return {
      acTabs: "analog",
      isFirst: true,
      powerInfo: {
        num: 0,
        powerDeviceId: 0,
        stationId: 0,
        stationName: "",
        stationName1: "",
        stationName2: "",
        stationName3: "",
        stationName4: " ",
        stationName5: "",
        exceptionCause: "",
        exceptionCauseAnalysis: "",
        powerDeviceName: ""
      },
      list: [
        {
          label: "A相输入功率因数:",
          key: "inPowerfactorA",
          value: 0,
        },
        {
          label: "B相输入功率因数:",
          key: "inPowerfactorB",
          value: 0,
        },
        {
          label: "C相输入功率因数:",
          key: "inPowerfactorC",
          value: 0,
        },
        {
          label: "A相输出功率因数:",
          key: "outPowerfactorA",
          value: 0,
        },
        {
          label: "B相输出功率因数:",
          key: "outPowerfactorB",
          value: 0,
        },
        {
          label: "C相输出功率因数:",
          key: "outPowerfactorC",
          value: 0,
        },
        {
          label: "A相输出峰值比:",
          key: "outPeakratioA",
          value: 0,
        },
        {
          label: "B相输出峰值比:",
          key: "outPeakratioB",
          value: 0,
        },
        {
          label: "C相输出峰值比:",
          key: "outPeakratioC",
          value: 0,
        },
        {
          label: "A相输出有功功率:",
          key: "outActpowerA",
          value: 0
        },
        {
          label: "B相输出有功功率:",
          key: "outActpowerB",
          value: 0
        },
        {
          label: "C相输出有功功率:",
          key: "outActpowerC",
          value: 0
        },
        {
          label: "A相输出无功功率:",
          key: "outReapowerA",
          value: 0
        },
        {
          label: "B相输出无功功率:",
          key: "outReapowerB",
          value: 0
        },
        {
          label: "C相输出无功功率:",
          key: "outReapowerC",
          value: 0
        },
        {
          label: "A相输出视在功率:",
          key: "outApppowerA",
          value: 0
        },
        {
          label: "B相输出视在功率:",
          key: "outApppowerB",
          value: 0
        },
        {
          label: "C相输出视在功率:",
          key: "outApppowerC",
          value: 0
        },
        {
          label: "A相输出负载百分比:",
          key: "outLoadpercentA",
          value: 0
        },
        {
          label: "B相输出负载百分比:",
          key: "outLoadpercentB",
          value: 0
        },
        {
          label: "C相输出负载百分比:",
          key: "outLoadpercentC",
          value: 0
        },
        {
          label: "系统A相输出有功功率:",
          key: "sysoutActpowerA",
          value: 0
        },
        {
          label: "系统B相输出有功功率:",
          key: "sysoutActpowerB",
          value: 0
        },
        {
          label: "系统C相输出有功功率:",
          key: "sysoutActpowerC",
          value: 0
        },
        {
          label: "系统A相输出视在功率:",
          key: "sysoutApppowerA",
          value: 0
        },
        {
          label: "系统B相输出视在功率:",
          key: "sysoutApppowerB",
          value: 0
        },
        {
          label: "系统C相输出视在功率:",
          key: "sysoutApppowerC",
          value: 0
        },
        {
          label: "系统A相输出无功功率:",
          key: "sysoutReapowerA",
          value: 0
        },
        {
          label: "系统B相输出无功功率:",
          key: "sysoutReapowerB",
          value: 0
        },
        {
          label: "系统C相输出无功功率:",
          key: "sysoutReapowerC",
          value: 0
        },
      ],
      list1: [
        {
          label: "直流输入电压(V):",
          key: "dcinVol",
          value: 0,
        },
        {
          label: "输出频率(HZ):",
          key: "outFreq",
          value: 0,
        },
        {
          label: "输入频率(HZ):",
          key: "inFreq",
          value: 0,
        },
        {
          label: "旁路频率(HZ):",
          key: "passFreq",
          value: 0,
        },
        {
          label: "整机环境温度(℃):",
          key: "devEnvirTemp",
          value: 0
        },
        {
          label: "电池后备时间:",
          key: "battBackupTime",
          value: 0
        },
        {
          label: "正电池电压(V):",
          key: "battPosivol",
          value: 0
        },
        {
          label: "正电池电流(A):",
          key: "battPosicurr",
          value: 0
        },
        {
          label: "负电池电压(V):",
          key: "battNegavol",
          value: 0
        },
        {
          label: "负电池电流(A):",
          key: "battNegacurr",
          value: 0
        },
        {
          label: "电池老化系数:",
          key: "battAgecoefficient",
          value: 0
        },
        {
          label: "电池温度(℃):",
          key: "battTemp",
          value: 0
        },
        {
          label: "环境温度(℃):",
          key: "envirTemp",
          value: 0
        },
      ],
      signalData: [
        {
          key: "modelOnline",
          labels: [
            "模块1在线", "模块2在线","模块3在线", "模块4在线",
            "模块5在线", "模块6在线", "模块7在线", "模块8在线",
            "模块9在线", "模块10在线", "模块11在线", "模块12在线"
          ],
          list: []
        },
        {
          key: "dynamoAccess",
          labels: ["发电机接入"],
          list: []
        },
        {
          key: "battState",
          labels: ["电池自检中", "电池浮充", "电池均充"],
          list: []
        },
        {
          key: "inverterOn",
          labels: ["逆变器开机"],
          list: []
        },
        {
          key: "rectifierPowerSupply",
          labels: ["主逆变供电", '电池逆变供电'],
          list: []
        },
        {
          key: "inputSwitchState",
          labels: ["输入空开断开", "输入空开不支持"],
          list: []
        },
        {
          key: "repireSwitchState",
          labels: ["空开断开", "空开不支持"],
          list: []
        },
        {
          key: "passSwitchState",
          labels: ["旁路空开断开", "旁路空开不支持"],
          list: []
        },
        {
          key: "outputSwitchState",
          labels: ["输出空开断开", "输出空开不支持"],
          list: []
        },
        {
          key: "machineWorkMode",
          labels: ["正常模式", "变频器模式", "智能并机模式", "智能并机演示模式", "ECO模式", "智能ECO模式", "智能ECO演示模式"],
          list: []
        },
        {
          key: "parallelsysPowerstate",
          labels: ["旁路供电", "主路逆变供电", "电池逆变供电"],
          list: []
        },
        {
          key: "bcb1State",
          labels: ["BCB1未接入", "BCB1:闭合"],
          list: []
        },
        {
          key: "bcb2State",
          labels: ["BCB2未接入", "BCB2:闭合"],
          list: []
        },
        {
          key: "bcb3State",
          labels: ["BCB3未接入", "BCB3:闭合"],
          list: []
        },
        {
          key: "bcb3State",
          labels: ["BCB3未接入", "BCB3:闭合"],
          list: []
        },
        {
          key: "powerSupplyState",
          labels: ["逆变供电", "旁路供电"],
          list: []
        },
        {
          key: "upsAlm1",
          labels: [
            "逆变器不同步", "主路电压异常", "整流器异常", "逆变器异常", "旁路异常","电池电压低于下限", "电池电压过高", "电池未接入",
            "电池电压低预告警", "电池接反", "ParaMonCAN通讯异常", "PowerCAN通讯异常", "整流DSP程序错误","整流FPGA程序错误",
            "逆变DSP程序错误", "逆变FPGA程序错误", "旁路DSP程序错误", "旁路FPGA程序错误", "机架内离散总线通讯异常",
            "机架间离散总线通讯异常", "主控模块设置不匹配", "LBS异常", "紧急关机", "旁路晶闸管故障", "旁路相序反"
          ],
          isWarn: true,
          list: []
        },
        {
          key: "upsAlm2",
          labels: [
            "旁路过流", "旁路异常关机","切换次数限制", "ECO切换次数限制", "ParaPowerCan通讯异常", "电池放电限流", "放电器故障",
            "充电器故障", "LBS连接线异常", "电池需维护", "电池过温", "电池接地故障", "主路频率异常", "模块过温",
            "从控模块设置不匹配", "接口模块设置不匹配","均充超时", "辅助电源掉电", "主路相序反", "整流器软启动失败",
            "用户操作错误", "输出熔丝断", "输出过载", "系统过载", "输出过载超时"
          ],
          isWarn: true,
          start: 0,
          list: []
        },
        {
          key: "upsAlm3",
          labels: [
            "负载冲击转旁路", "并机均流异常", "母线异常关机", "临机请求转旁路", "直流母线过压",
            "MonCAN通讯异常", "输入缺零故障", "逆变继电器故障", "主路反灌", "输入电流异常", "输出电压异常", "输入电流超限",
            "旁路过温", "邻机旁路晶闸管故障", "并机连接线异常", "充电器过温", "电池端口短路", "电池房环境异常",
            "风扇异常", "旁路缺零故障", "旁路接管", "BCB1状态异常", "BCB2状态异常", "BCB3状态异常", "BCB4状态异常"
          ],
          isWarn: true,
          start: 0,
          list: []
        },
        {
          key: "upsAlm4",
          labels: [
            "旁路SCR风扇异常", "平衡电路故障", "平衡电路过流", "平衡电路过温", "失去冗余", "容量过载", "功率板设置不匹配",
            "旁路设置不匹配", "上抽风风扇异常", "系统A相输出熔丝断", "系统B相输出熔丝断", "系统C相输出熔丝断", "旁路无效", "整流器过流",
            "旁路过流超时", "输出零地过压", "输入熔丝断", "旁路熔丝断"
          ],
          isWarn: true,
          start: 0,
          list: []
        },
        {
          key: "upsConnErr",
          labels: [
            "协转/UPS通信故障"
          ],
          isWarn: true,
          start: 0,
          list: []
        },
      ],
    }
  },
  methods: {
    searchPowerInfo() {
      // 获取电源信息
      let powerDeviceId = this.$route.params.powerDeviceId;
      if (powerDeviceId) {
        this.getPowerInfo(powerDeviceId);
      }
    },
    getPowerInfo(powerDeviceId) {
      this.powerInfo.powerDeviceId = powerDeviceId;
      getInfoById({
        powerDeviceId: powerDeviceId,
      }).then((res) => {
          res = res.data;
          if (res.code && res.data.list.length) {
            this.powerInfo = res.data.list[0];
          } else {
            this.powerInfo = {
              num: 0,
              powerDeviceId: 0,
              stationId: 0,
              stationName: "",
              stationName1: "",
              stationName2: "",
              stationName3: "",
              stationName4: " ",
              stationName5: "",
              exceptionCause: "",
              exceptionCauseAnalysis: ""
            };
          }
          // 启动查询
          this.sendMessage();
        }).catch((error) => {
          console.log(error);
        });
    },
    tabsChange() {
      if(this.acTabs === "analog") {
        this.$refs.analogData.resize();
      }
    },
    onWSOpen() {
      //this.sendMessage();
      this.searchPowerInfo();
    },
    sendMessage() {
      let powerInfo = this.powerInfo;
      // console.log(powerInfo, '=====powerInfo');
      if (!powerInfo.powerDeviceId || !this.isWSOpen) {
        return false;
      }
      // console.log("====", params, JSON.stringify(params));
      this.SOCKET.send(powerInfo.powerDeviceId);
    },
    onWSMessage(res) {
      res = JSON.parse(res.data);
      // console.log(res);
      if(res.code === 1) {
        const data = res.data;
        this.setSimulateData(data.UpspowerSimulate);
        this.setSignalData(data.UpspowerSinal);
 
        // 设置不是首次加载
        this.isFirst = false;
      }
    },
    setSimulateData(data) {
      if(data.code === 1 && data.data && this.acTabs==="analog") {
        let data2 =data.data2;
        // 设置list
        for(let i=0; i<this.list.length; i++) {
          let item = this.list[i];
          Object.keys(data2).forEach(key=>{
            if(key === item.key) {
              item.value = data2[key];
            }
          });
        }
 
        // 设置list1
        for(let i=0; i<this.list1.length; i++) {
          let item = this.list1[i];
          Object.keys(data2).forEach(key=>{
            if(key === item.key) {
              item.value = data2[key];
            }
          });
        }
 
        // 相电压
        const phaseVol = {
          unit: "V",
          yData: ["A相", "B相", "C相"],
          series: [
            {
              name: "输入电压",
              key: ["acinVola", "acinVolb", "acinVolc"],
              data: [0, 0, 0]
            },
            {
              name: "输出电压",
              key: ["acoutVola", "acoutVolb", "acoutVolc"],
              data: [0, 0, 0]
            },
            {
              name: "旁路电压",
              key: ["passVola", "passVolb", "passVolc"],
              data: [0, 0, 0]
            },
          ],
        };
        // 设置相电压
        for(let i=0; i<phaseVol.series.length; i++) {
          let itemVol = phaseVol.series[i];
          itemVol.data = itemVol.key.map(itemKey=>{
            return data2[itemKey];
          })
        }
 
        // 电流
        const currents = {
          unit: "A",
          yData: ["A相", "B相", "C相"],
          series: [
            {
              name: "输出电流",
              key: ["acoutCurra", "acoutCurrb", "acoutCurrc"],
              data: [0, 0, 0]
            },
            {
              name: "输入电流",
              key: ["acinCurra", "acinCurrb", "acinCurrc"],
              data: [0, 0, 0]
            },
          ],
        };
        // 设置电流
        for(let i=0; i<currents.series.length; i++) {
          let itemCurr = currents.series[i];
          itemCurr.data = itemCurr.key.map(itemKey=>{
            return data2[itemKey];
          })
        }
 
        // 线电压
        const lineVol = {
          unit: "V",
          yData: ["AB线", "BC线", "CA线"],
          series: [
            {
              name: "输入电压",
              key: ["abinVol", "bcinVol", "cainVol"],
              data: [0, 0, 0]
            },
            {
              name: "输出电压",
              key: ["aboutVol", "bcoutVol", "caoutVol"],
              data: [0, 0, 0]
            },
            {
              name: "旁路电压",
              key: ["abpassVol", "bcpassVol", "capassVol"],
              data: [0, 0, 0]
            },
          ],
        };
        // 设置电流
        for(let i=0; i<lineVol.series.length; i++) {
          let itemVol = lineVol.series[i];
          itemVol.data = itemVol.key.map(itemKey=>{
            return data2[itemKey];
          })
        }
        this.$refs.analogData.setBarOption(phaseVol, currents, lineVol);
      }
    },
    setSignalData(data) {
      // 选择信号量或者首次加载数据
      if((data.code === 1 && data.data && this.acTabs==="signal") || this.isFirst) {
        let data2 = data.data2;
        this.signalData.map(itemData=>{
          let num = data2[itemData.key];
          let start = itemData.start?itemData.start:0;
          itemData.list = itemData.labels.map((item, key)=>{
            const value = getBit(num, key+start);
            return {
              label: item,
              value: itemData.isWarn?(value?1:-1):(value?0:-1)
            }
          });
        });
      }
    },
  },
  computed: {
    fullStationName() {
      let powerInfo = this.powerInfo;
      if (powerInfo.powerDeviceId) {
        return (
          powerInfo.stationName1 +
          "-" +
          powerInfo.stationName2 +
          "-" +
          powerInfo.stationName5 +
          "-" +
          powerInfo.stationName3 +
          "-" +
          powerInfo.powerDeviceName
        );
      } else {
        return "未知站点名称";
      }
    },
  },
  mounted() {
 
  }
}
</script>
 
<style scoped>
.mgl8 {
  margin-left: 8px;
}
.flex-page-content {
  padding: 4px 4px 0 4px;
  box-sizing: border-box;
}
.center-box {
  display: flex;
  height: 100%;
  align-items: center;
  justify-content: center;
}
</style>