openatc-components 0.4.19 → 0.4.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -309,6 +309,7 @@ export default {
309
309
  crossStatusData: {
310
310
  handler: function (val, oldVal) {
311
311
  // 路口状态数据
312
+ this.compareIsChangedPhase(val, oldVal) // 比较相位状态决定是否更新相位图标(解决虚相位显示问题,虚相位图标不显示)
312
313
  this.statusData = JSON.parse(JSON.stringify(val))
313
314
  // 默认显示相位数据(包括黄闪、全红、关灯状态下,或者匝道,均不做比对跟随相位的处理)
314
315
  this.drawDefaultPhaseIcon()
@@ -389,10 +390,26 @@ export default {
389
390
  top: '1px'
390
391
  },
391
392
  isHasCountdown: false,
392
- contrloType: 'ring'
393
+ contrloType: 'ring',
394
+ isMphaseStatusDataReturnMap: new Map() // 每个跟随相位的母相位是否返回了相位状态数据
393
395
  }
394
396
  },
395
397
  methods: {
398
+ compareIsChangedPhase (newCrossStatus, oldCrossStatus) {
399
+ // 返回的相位状态改变后,按照返回的相位状态更新路口相位显示(下个周期生效)
400
+ let newPhaseIds = newCrossStatus.phase.map(item => item.id)
401
+ let oldPhaseIds = oldCrossStatus.phase.map(item => item.id)
402
+ if (!this.isArraysEqual(newPhaseIds, oldPhaseIds)) { // 通过比较相位id是否完全一致
403
+ this.getIntersectionInfo()
404
+ }
405
+ },
406
+ isArraysEqual (arr1, arr2) {
407
+ if (arr1.length !== arr2.length) return false
408
+ for (let i = 0; i < arr1.length; i++) {
409
+ if (arr1[i] !== arr2[i]) return false
410
+ }
411
+ return true
412
+ },
396
413
  handleTempCrossStatus (val) {
397
414
  // 模版路口图状态数据
398
415
  this.phaseStatusList = val.phase
@@ -423,6 +440,7 @@ export default {
423
440
  this.curStage = val.current_stage
424
441
  this.isHasPhase = true
425
442
  this.createPhaseStatusMap()
443
+ this.createOverlapPhaseStatusMap()
426
444
  // 正常情况下,获取车道相位、车道跟随相位、相位倒计时、行人相位、行人跟随相位 的状态
427
445
  this.getPhaseStatus()
428
446
  this.getOverlapPhaseStatus()
@@ -558,6 +576,7 @@ export default {
558
576
  },
559
577
  createPhaseStatusMap () {
560
578
  // 生成相位id和相位状态对应数据结构
579
+ this.phaseStatusMap = new Map()
561
580
  this.phaseStatusList.map(phase => {
562
581
  let phaseId = phase.id
563
582
  let phaseInfo = {
@@ -638,20 +657,38 @@ export default {
638
657
  // 如果有相同direction,处理后会改变原数组长度,导致第二次无法正确比较状态,因此需要中间变量存储
639
658
  this.comdirePhaseData = JSON.parse(JSON.stringify(this.CrossDiagramMgr.compareRepeatDirection(this.LanePhaseData, 'type', 'phase')))
640
659
  },
660
+ createOverlapPhaseStatusMap () {
661
+ // 处理跟随相位的母相位设置为忽略相位后的情况(如果跟随相位的母相位包含忽略相位,过滤掉跟随相位的状态数据,参照相位状态数据处理)
662
+ let isMphaseStatusDataReturn = false
663
+ let reset = false
664
+ this.overlapStatusList = this.overlapStatusList.filter(ele => {
665
+ let phaseids = this.phaseStatusList.map(item => item.id)
666
+ let mphase = ele.mphase
667
+ const phaseidsSet = new Set(phaseids)
668
+ isMphaseStatusDataReturn = mphase.every(value => phaseidsSet.has(value))
669
+ console.log(`跟随相位${ele.id}的母相位状态数据是否均返回?`, isMphaseStatusDataReturn)
670
+ if (isMphaseStatusDataReturn !== this.isMphaseStatusDataReturnMap.get(ele.id) && !reset) {
671
+ this.getIntersectionInfo()
672
+ reset = true
673
+ }
674
+ this.isMphaseStatusDataReturnMap = this.isMphaseStatusDataReturnMap.set(ele.id, isMphaseStatusDataReturn)
675
+ return isMphaseStatusDataReturn
676
+ })
677
+ // 得到跟随相位状态Map数据
678
+ this.overlapPhaseStatusMap = new Map()
679
+ this.overlapStatusList.map(phase => {
680
+ let phaseId = phase.id
681
+ let phaseInfo = {
682
+ type: phase.type,
683
+ phaseCountdown: phase.countdown,
684
+ pedtype: phase.pedtype
685
+ }
686
+ this.overlapPhaseStatusMap.set(phaseId, phaseInfo)
687
+ })
688
+ },
641
689
  getOverlapPhaseStatus () {
642
690
  // 得到车道跟随相位状态(颜色)
643
691
  this.comdireOverlapPhaseData = []
644
- if (this.overlapStatusList) {
645
- this.overlapStatusList.map(phase => {
646
- let phaseId = phase.id
647
- let phaseInfo = {
648
- type: phase.type,
649
- phaseCountdown: phase.countdown,
650
- pedtype: phase.pedtype
651
- }
652
- this.overlapPhaseStatusMap.set(phaseId, phaseInfo)
653
- })
654
- }
655
692
  let curLanePhaseData = []
656
693
  for (let i = 0; i < this.overlapLanePhaseData.length; i++) {
657
694
  let curPhaseStatus = this.overlapPhaseStatusMap.get(this.overlapLanePhaseData[i].phaseid)
@@ -704,13 +741,23 @@ export default {
704
741
  countdownObj.phaseCountdownColor = this.ColorMap.get(phaseInfo.type)
705
742
  let curphasedir = this.phaseDirMap.get(phaseInfo.id)
706
743
  if (curphasedir !== undefined) {
707
- countdownObj.showlist = curphasedir.direction.map(dir => {
744
+ if (curphasedir.direction && curphasedir.direction.length > 0) {
745
+ countdownObj.showlist = curphasedir.direction.map(dir => {
708
746
  return {
709
747
  id: dir,
710
748
  peddirection: this.getshowped(curphasedir.peddirection),
711
749
  color: '#fff'
712
750
  }
713
751
  })
752
+ } else {
753
+ countdownObj.showlist = [
754
+ {
755
+ id: '',
756
+ peddirection: this.getshowped(curphasedir.peddirection),
757
+ color: '#fff'
758
+ }
759
+ ]
760
+ }
714
761
  } else {
715
762
  countdownObj.showlist = []
716
763
  }
@@ -1084,11 +1131,11 @@ export default {
1084
1131
  let curPhaseStatus = this.overlapPhaseStatusMap.get(this.overlapsidewalkPhaseData[i].phaseid)
1085
1132
  if (!curPhaseStatus) {
1086
1133
  // 无状态的行人道,也显示出来
1087
- const data = {
1088
- ...this.overlapsidewalkPhaseData[i],
1089
- pedtype: undefined
1090
- }
1091
- curPedStatus.push(data)
1134
+ // const data = {
1135
+ // ...this.overlapsidewalkPhaseData[i],
1136
+ // pedtype: undefined
1137
+ // }
1138
+ // curPedStatus.push(data)
1092
1139
  continue
1093
1140
  }
1094
1141
  const data = {