Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
bd2f928a94
@ -6,7 +6,6 @@ import (
|
||||
"time"
|
||||
|
||||
"joylink.club/rtsssimulation/repository/model/proto"
|
||||
ecsSimulation "joylink.club/rtsssimulation/simulation"
|
||||
|
||||
"fmt"
|
||||
"net/http"
|
||||
@ -112,7 +111,8 @@ func DestroySimulation(simulationId string) {
|
||||
simulationInfo := s.(*memory.VerifySimulation)
|
||||
simulationMap.Delete(simulationId)
|
||||
// 停止ecs world
|
||||
ecsSimulation.DestroySimulation(simulationInfo.WorldId)
|
||||
simulationInfo.World.Close()
|
||||
//ecsSimulation.DestroySimulation(simulationInfo.WorldId)
|
||||
//移除道岔状态发送
|
||||
dynamics.Stop()
|
||||
//通知动力学
|
||||
|
@ -140,6 +140,7 @@ func turnoutMapToEcsLink(repo *repository.Repository, id string, port string, of
|
||||
}
|
||||
// 岔心公里标
|
||||
crossKm = turnout.GetTurnoutKm(proto2.Port_None)
|
||||
portKm = repo.ConvertKilometer(portKm, crossKm.CoordinateSystem)
|
||||
// 关联link
|
||||
link := portPosition.Link()
|
||||
isStart := link.ARelation().Device().Id() == id
|
||||
@ -173,7 +174,7 @@ func QueryDeviceByCalcLink(repo *repository.Repository, id string, offset int64,
|
||||
// 判断是否在道岔上
|
||||
onTurnout, isA := isOnLinkTurnout(link, offset)
|
||||
if onTurnout {
|
||||
return ecsLinkMapToTurnout(isA, offset, up, link)
|
||||
return ecsLinkMapToTurnout(repo, isA, offset, up, link)
|
||||
} else {
|
||||
return ecsLinkMapToSection(offset, up, link)
|
||||
}
|
||||
@ -198,7 +199,7 @@ func isOnLinkTurnout(link *repository.Link, offset int64) (bool, bool) {
|
||||
}
|
||||
|
||||
// 处理在道岔上link映射
|
||||
func ecsLinkMapToTurnout(isA bool, offset int64, up bool, link *repository.Link) (
|
||||
func ecsLinkMapToTurnout(repo *repository.Repository, isA bool, offset int64, up bool, link *repository.Link) (
|
||||
deviceId, port string, deviceOffset int64, runDirection, pointTo bool, km int64) {
|
||||
tp := link.ARelation()
|
||||
if !isA {
|
||||
@ -206,7 +207,9 @@ func ecsLinkMapToTurnout(isA bool, offset int64, up bool, link *repository.Link)
|
||||
}
|
||||
deviceId = tp.Turnout().Id()
|
||||
tpOffset := tp.Turnout().FindLinkPositionByPort(tp.Port()).Offset()
|
||||
crossKm, portKm := tp.Turnout().GetTurnoutKm(proto2.Port_None).Value, tp.Turnout().GetTurnoutKm(tp.Port()).Value
|
||||
crossKmInfo, portKmInfo := tp.Turnout().GetTurnoutKm(proto2.Port_None), tp.Turnout().GetTurnoutKm(tp.Port())
|
||||
portKmInfo = repo.ConvertKilometer(portKmInfo, crossKmInfo.CoordinateSystem)
|
||||
crossKm, portKm := crossKmInfo.Value, portKmInfo.Value
|
||||
if isA {
|
||||
deviceOffset = tpOffset - (tpOffset - offset)
|
||||
pointTo = !up
|
||||
@ -217,10 +220,17 @@ func ecsLinkMapToTurnout(isA bool, offset int64, up bool, link *repository.Link)
|
||||
// 查询公里标大于端口公里标
|
||||
if crossKm > portKm {
|
||||
km = crossKm - deviceOffset
|
||||
runDirection = pointTo
|
||||
} else {
|
||||
km = crossKm + deviceOffset
|
||||
runDirection = !pointTo
|
||||
}
|
||||
if up && isA { // link offset 趋大,A端岔心 ---> 边界
|
||||
runDirection = crossKm < portKm
|
||||
} else if up && !isA { // link offset 趋大,B端边界 ---> 岔心
|
||||
runDirection = crossKm > portKm
|
||||
} else if !up && isA { // link offset 趋小,A端边界 ---> 岔心
|
||||
runDirection = crossKm > portKm
|
||||
} else { // link offset 趋小,B端岔心 ---> 边界
|
||||
runDirection = crossKm < portKm
|
||||
}
|
||||
switch tp.Port() {
|
||||
case proto2.Port_A:
|
||||
|
@ -3,7 +3,8 @@ package memory
|
||||
import (
|
||||
"joylink.club/bj-rtsts-server/ats/verify/protos/graphicData"
|
||||
"joylink.club/bj-rtsts-server/ats/verify/protos/state"
|
||||
"joylink.club/rtsssimulation/entities"
|
||||
"joylink.club/rtsssimulation/component"
|
||||
"joylink.club/rtsssimulation/entity"
|
||||
)
|
||||
|
||||
// 获取仿真地图的继电器状态,前端推送
|
||||
@ -12,11 +13,13 @@ func GetMapAllRelayState(sim *VerifySimulation, mapId int32) []*state.ReplyState
|
||||
uidMap := QueryMapUidMapByType(mapId, &graphicData.Relay{})
|
||||
var replyStateArr []*state.ReplyState
|
||||
for _, u := range uidMap {
|
||||
p := entities.GetRelayState(sim.WorldId, u.Uid)
|
||||
if p == nil {
|
||||
continue
|
||||
}
|
||||
replyStateArr = append(replyStateArr, &state.ReplyState{Id: u.CommonId, Xh: p.Xh})
|
||||
entry, _ := entity.GetEntityByUid(sim.World, u.Uid)
|
||||
bit := component.BitStateType.Get(entry)
|
||||
// p := entities.GetRelayState(sim.WorldId, u.Uid)
|
||||
// if p == nil {
|
||||
// continue
|
||||
// }
|
||||
replyStateArr = append(replyStateArr, &state.ReplyState{Id: u.CommonId, Xh: bit.Val})
|
||||
}
|
||||
return replyStateArr
|
||||
}
|
||||
|
@ -1,7 +1,9 @@
|
||||
package memory
|
||||
|
||||
import (
|
||||
"joylink.club/rtsssimulation/entities"
|
||||
"joylink.club/rtsssimulation/component"
|
||||
"joylink.club/rtsssimulation/entity"
|
||||
"joylink.club/rtsssimulation/fi"
|
||||
|
||||
"joylink.club/bj-rtsts-server/ats/verify/protos/graphicData"
|
||||
"joylink.club/bj-rtsts-server/ats/verify/protos/state"
|
||||
@ -11,9 +13,11 @@ import (
|
||||
func ChangeTurnoutState(simulation *VerifySimulation, status *state.SwitchState, mapId int32) {
|
||||
uid := QueryUidByMidAndComId(mapId, status.Id, &graphicData.Turnout{})
|
||||
if status.Normal {
|
||||
entities.TurnToNormal(simulation.WorldId, uid)
|
||||
fi.DriveTurnoutDCOn(simulation.World, uid)
|
||||
// entities.TurnToNormal(simulation.WorldId, uid)
|
||||
} else if status.Reverse {
|
||||
entities.TurnToReverse(simulation.WorldId, uid)
|
||||
fi.DriveTurnoutFCOn(simulation.World, uid)
|
||||
// entities.TurnToReverse(simulation.WorldId, uid)
|
||||
}
|
||||
}
|
||||
|
||||
@ -22,15 +26,19 @@ func GetAllTurnoutState(sim *VerifySimulation) []*state.SwitchState {
|
||||
var switchArr []*state.SwitchState
|
||||
turnoutList := sim.Repo.TurnoutList()
|
||||
for _, o := range turnoutList {
|
||||
p := entities.GetTurnoutState(sim.WorldId, o.Id())
|
||||
if p == nil {
|
||||
continue
|
||||
}
|
||||
entry, _ := entity.GetEntityByUid(sim.World, o.Id())
|
||||
tp := component.TurnoutPositionType.Get(entry)
|
||||
// p := entities.GetTurnoutState(sim.WorldId, o.Id())
|
||||
// if p == nil {
|
||||
// continue
|
||||
// }
|
||||
switchArr = append(switchArr, &state.SwitchState{
|
||||
Id: sim.GetComIdByUid(o.Id()),
|
||||
Normal: p.Normal,
|
||||
Reverse: p.Reverse,
|
||||
Turning: p.Turning,
|
||||
Id: sim.GetComIdByUid(o.Id()),
|
||||
// Normal: p.Normal,
|
||||
// Reverse: p.Reverse,
|
||||
// Turning: p.Turning,
|
||||
Normal: tp.Dw,
|
||||
Reverse: tp.Fw,
|
||||
})
|
||||
}
|
||||
return switchArr
|
||||
@ -42,15 +50,19 @@ func GetMapAllTurnoutState(sim *VerifySimulation, mapId int32) []*state.SwitchSt
|
||||
uidMap := QueryMapUidMapByType(mapId, &graphicData.Turnout{})
|
||||
var switchArr []*state.SwitchState
|
||||
for _, u := range uidMap {
|
||||
p := entities.GetTurnoutState(sim.WorldId, u.Uid)
|
||||
if p == nil {
|
||||
continue
|
||||
}
|
||||
entry, _ := entity.GetEntityByUid(sim.World, u.Uid)
|
||||
tp := component.TurnoutPositionType.Get(entry)
|
||||
// p := entities.GetTurnoutState(sim.WorldId, o.Id())
|
||||
// if p == nil {
|
||||
// continue
|
||||
// }
|
||||
switchArr = append(switchArr, &state.SwitchState{
|
||||
Id: u.CommonId,
|
||||
Normal: p.Normal,
|
||||
Reverse: p.Reverse,
|
||||
Turning: p.Turning,
|
||||
Id: u.CommonId,
|
||||
// Normal: p.Normal,
|
||||
// Reverse: p.Reverse,
|
||||
// Turning: p.Turning,
|
||||
Normal: tp.Dw,
|
||||
Reverse: tp.Fw,
|
||||
})
|
||||
}
|
||||
return switchArr
|
||||
|
@ -7,7 +7,7 @@ import (
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"joylink.club/rtsssimulation/simulation/world"
|
||||
rtss_simulation "joylink.club/rtsssimulation"
|
||||
|
||||
"joylink.club/bj-rtsts-server/ats/verify/protos/graphicData"
|
||||
"joylink.club/bj-rtsts-server/ats/verify/protos/state"
|
||||
@ -32,6 +32,7 @@ type VerifySimulation struct {
|
||||
Repo *repository.Repository
|
||||
//Rtss仿真世界的id
|
||||
WorldId ecs.WorldId
|
||||
World ecs.World
|
||||
//设备UID映射
|
||||
uidMap map[string]*elementIdStructure
|
||||
}
|
||||
@ -110,13 +111,15 @@ func CreateSimulation(projectId int32, mapIds []int32) (*VerifySimulation, error
|
||||
// 构建所有UID映射关系,
|
||||
allUidMap := buildRepositoryAllUidsMap(mapIds, repo)
|
||||
//创建仿真
|
||||
worldId := world.CreateSimulation(repo)
|
||||
// worldId := world.CreateSimulation(repo)
|
||||
w := rtss_simulation.NewSimulation(repo)
|
||||
verifySimulation := &VerifySimulation{
|
||||
MapIds: mapIds,
|
||||
ProjectId: projectId,
|
||||
Memory: worldMemory,
|
||||
Repo: repo,
|
||||
WorldId: worldId,
|
||||
World: w,
|
||||
WorldId: w.Id(),
|
||||
uidMap: allUidMap,
|
||||
}
|
||||
return verifySimulation, nil
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit d36ba6fc7dfe5235ace72be522566e55aadd34e1
|
||||
Subproject commit 33aca5ef48b372ac67c21272ec07267cb025dc2c
|
Loading…
Reference in New Issue
Block a user