修改bug以及循环引用
This commit is contained in:
parent
f323aa9465
commit
bf36d8204c
@ -6,7 +6,6 @@ import (
|
||||
"math"
|
||||
"time"
|
||||
|
||||
"joylink.club/ecs"
|
||||
"joylink.club/rtsssimulation/repository/model/proto"
|
||||
ecsSimulation "joylink.club/rtsssimulation/simulation"
|
||||
|
||||
@ -118,7 +117,7 @@ func DestroySimulation(simulationId string) {
|
||||
simulationInfo := s.(*memory.VerifySimulation)
|
||||
simulationMap.Delete(simulationId)
|
||||
// 停止ecs world
|
||||
ecsSimulation.DestroySimulation(ecs.WorldId(simulationInfo.WorldId))
|
||||
ecsSimulation.DestroySimulation(simulationInfo.WorldId)
|
||||
//移除道岔状态发送
|
||||
dynamics.Stop()
|
||||
//通知动力学
|
||||
|
@ -1,14 +1,12 @@
|
||||
package memory
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"joylink.club/bj-rtsts-server/dto"
|
||||
"joylink.club/rtsssimulation/entities"
|
||||
"strconv"
|
||||
|
||||
"google.golang.org/protobuf/proto"
|
||||
"joylink.club/bj-rtsts-server/ats/verify/protos/graphicData"
|
||||
"joylink.club/bj-rtsts-server/ats/verify/protos/state"
|
||||
"joylink.club/bj-rtsts-server/dto"
|
||||
)
|
||||
|
||||
// 道岔相关道岔操作方法
|
||||
@ -18,21 +16,22 @@ func ChangeTurnoutState(simulation *VerifySimulation, status *state.SwitchState,
|
||||
panic(&dto.ErrorDto{Code: dto.ArgumentParseError, Message: "参数转换出错"})
|
||||
}
|
||||
uid := QueryUidByMidAndIndex(mapId, int32(index), &graphicData.Turnout{})
|
||||
log.Default().Printf("修改道岔【UID:%s】\n", uid)
|
||||
allSwitchMap := &simulation.Memory.Status.SwitchStateMap
|
||||
d, ok := allSwitchMap.Load(uid)
|
||||
if !ok {
|
||||
panic(fmt.Sprintf("道岔【UID:%s】不存在", uid))
|
||||
}
|
||||
status.Id = uid
|
||||
cur := d.(*state.SwitchState)
|
||||
if !proto.Equal(cur, status) { // 如果信息发送了变化
|
||||
// 将信息合并到当前设备状态中
|
||||
cur.Normal = status.Normal
|
||||
cur.Reverse = status.Reverse
|
||||
// 将变更信息放入变更状态队列中
|
||||
simulation.Memory.ChangeStatus.SwitchStateMap.Store(status.Id, proto.Clone(cur))
|
||||
}
|
||||
entities.TurnToNormal(simulation.WorldId, uid)
|
||||
//log.Default().Printf("修改道岔【UID:%s】\n", uid)
|
||||
//allSwitchMap := &simulation.Memory.Status.SwitchStateMap
|
||||
//d, ok := allSwitchMap.Load(uid)
|
||||
//if !ok {
|
||||
// panic(fmt.Sprintf("道岔【UID:%s】不存在", uid))
|
||||
//}
|
||||
//status.Id = uid
|
||||
//cur := d.(*state.SwitchState)
|
||||
//if !proto.Equal(cur, status) { // 如果信息发送了变化
|
||||
// // 将信息合并到当前设备状态中
|
||||
// cur.Normal = status.Normal
|
||||
// cur.Reverse = status.Reverse
|
||||
// // 将变更信息放入变更状态队列中
|
||||
// simulation.Memory.ChangeStatus.SwitchStateMap.Store(status.Id, proto.Clone(cur))
|
||||
//}
|
||||
}
|
||||
|
||||
// 获取全部的道岔状态,动力学使用
|
||||
|
@ -2,6 +2,7 @@ package memory
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"joylink.club/rtsssimulation/simulation/world"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
@ -14,7 +15,6 @@ import (
|
||||
"joylink.club/rtsssimulation/repository"
|
||||
"joylink.club/rtsssimulation/repository/model/proto"
|
||||
"joylink.club/rtsssimulation/simulation"
|
||||
"joylink.club/rtsssimulation/system"
|
||||
)
|
||||
|
||||
// 轨旁仿真定义
|
||||
@ -30,7 +30,7 @@ type VerifySimulation struct {
|
||||
//模型仓库
|
||||
Repo *repository.Repository
|
||||
//Rtss仿真世界的id
|
||||
WorldId int
|
||||
WorldId ecs.WorldId
|
||||
//设备UID映射
|
||||
uidMap map[string]*elementIdStructure
|
||||
}
|
||||
@ -109,7 +109,7 @@ func CreateSimulation(projectId int32, mapIds []int32) (*VerifySimulation, error
|
||||
// 构建所有UID映射关系,
|
||||
allUidMap := buildRepositoryAllUidsMap(mapIds, repo)
|
||||
//创建仿真
|
||||
worldId := simulation.CreateSimulation(repo, system.SWITCH_ZDJ9_2, system.RELAY)
|
||||
worldId := world.CreateSimulation(repo)
|
||||
verifySimulation := &VerifySimulation{
|
||||
MapIds: mapIds,
|
||||
ProjectId: projectId,
|
||||
@ -142,7 +142,7 @@ func (s *VerifySimulation) GetSimulationWorld() ecs.World {
|
||||
if ecsSimulation == nil {
|
||||
panic(&dto.ErrorDto{Code: dto.DataNotExist, Message: "ecs 仿真不存在"})
|
||||
}
|
||||
return ecsSimulation.GetWorld()
|
||||
return ecsSimulation.World()
|
||||
}
|
||||
|
||||
// 获取仿真世界信息
|
||||
@ -205,6 +205,9 @@ func relateRelay(repo *proto.Repository, relayGi *graphicData.RelayCabinetGraphi
|
||||
switch relationship.DeviceType {
|
||||
case graphicData.RelatedRef_Turnout:
|
||||
turnout := turnoutMap[GenerateElementUid(city, lineId, []string{station}, relationship.Code)]
|
||||
if turnout == nil {
|
||||
continue
|
||||
}
|
||||
for _, group := range relationship.Combinationtypes {
|
||||
turnout.RelayGroups = append(turnout.RelayGroups, &proto.RelayGroup{
|
||||
Code: group.Code,
|
||||
@ -213,6 +216,9 @@ func relateRelay(repo *proto.Repository, relayGi *graphicData.RelayCabinetGraphi
|
||||
}
|
||||
case graphicData.RelatedRef_signal:
|
||||
signal := signalMap[GenerateElementUid(city, lineId, []string{station}, relationship.Code)]
|
||||
if signal == nil {
|
||||
continue
|
||||
}
|
||||
for _, group := range relationship.Combinationtypes {
|
||||
signal.RelayGroups = append(signal.RelayGroups, &proto.RelayGroup{
|
||||
Code: group.Code,
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 0dfee803453857329f121f37e5a2e88cebd1ea67
|
||||
Subproject commit 842a37077aadb855720640dec191ebc1cd2849f3
|
Loading…
Reference in New Issue
Block a user