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