openatc-components 0.4.19 → 0.4.21

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,42 @@ 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 sum = 0 // 首次加载跳过比较母相位状态数据是否返回
664
+ let reset = false
665
+ this.overlapStatusList = this.overlapStatusList.filter(ele => {
666
+ let phaseids = this.phaseStatusList.map(item => item.id)
667
+ let mphase = ele.mphase
668
+ console.log(phaseids)
669
+ console.log(mphase)
670
+ const phaseidsSet = new Set(phaseids)
671
+ isMphaseStatusDataReturn = mphase.every(value => phaseidsSet.has(value))
672
+ console.log(`跟随相位${ele.id}的母相位状态数据是否均返回?`, isMphaseStatusDataReturn)
673
+ if (isMphaseStatusDataReturn !== this.isMphaseStatusDataReturnMap.get(ele.id) && !reset && sum > 0) {
674
+ this.getIntersectionInfo()
675
+ reset = true
676
+ }
677
+ this.isMphaseStatusDataReturnMap = this.isMphaseStatusDataReturnMap.set(ele.id, isMphaseStatusDataReturn)
678
+ return isMphaseStatusDataReturn
679
+ })
680
+ sum++
681
+ // 得到跟随相位状态Map数据
682
+ this.overlapPhaseStatusMap = new Map()
683
+ this.overlapStatusList.map(phase => {
684
+ let phaseId = phase.id
685
+ let phaseInfo = {
686
+ type: phase.type,
687
+ phaseCountdown: phase.countdown,
688
+ pedtype: phase.pedtype
689
+ }
690
+ this.overlapPhaseStatusMap.set(phaseId, phaseInfo)
691
+ })
692
+ },
641
693
  getOverlapPhaseStatus () {
642
694
  // 得到车道跟随相位状态(颜色)
643
695
  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
696
  let curLanePhaseData = []
656
697
  for (let i = 0; i < this.overlapLanePhaseData.length; i++) {
657
698
  let curPhaseStatus = this.overlapPhaseStatusMap.get(this.overlapLanePhaseData[i].phaseid)
@@ -704,13 +745,23 @@ export default {
704
745
  countdownObj.phaseCountdownColor = this.ColorMap.get(phaseInfo.type)
705
746
  let curphasedir = this.phaseDirMap.get(phaseInfo.id)
706
747
  if (curphasedir !== undefined) {
707
- countdownObj.showlist = curphasedir.direction.map(dir => {
748
+ if (curphasedir.direction && curphasedir.direction.length > 0) {
749
+ countdownObj.showlist = curphasedir.direction.map(dir => {
708
750
  return {
709
751
  id: dir,
710
752
  peddirection: this.getshowped(curphasedir.peddirection),
711
753
  color: '#fff'
712
754
  }
713
755
  })
756
+ } else {
757
+ countdownObj.showlist = [
758
+ {
759
+ id: '',
760
+ peddirection: this.getshowped(curphasedir.peddirection),
761
+ color: '#fff'
762
+ }
763
+ ]
764
+ }
714
765
  } else {
715
766
  countdownObj.showlist = []
716
767
  }
@@ -1084,11 +1135,11 @@ export default {
1084
1135
  let curPhaseStatus = this.overlapPhaseStatusMap.get(this.overlapsidewalkPhaseData[i].phaseid)
1085
1136
  if (!curPhaseStatus) {
1086
1137
  // 无状态的行人道,也显示出来
1087
- const data = {
1088
- ...this.overlapsidewalkPhaseData[i],
1089
- pedtype: undefined
1090
- }
1091
- curPedStatus.push(data)
1138
+ // const data = {
1139
+ // ...this.overlapsidewalkPhaseData[i],
1140
+ // pedtype: undefined
1141
+ // }
1142
+ // curPedStatus.push(data)
1092
1143
  continue
1093
1144
  }
1094
1145
  const data = {