Merge branch 'master' of https://git.code.tencent.com/jl-framework/rtss_simulation
This commit is contained in:
commit
4bcc1c0b16
@ -20,6 +20,55 @@ const (
|
|||||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type Psd_Fault int32
|
||||||
|
|
||||||
|
const (
|
||||||
|
Psd_Undefined Psd_Fault = 0
|
||||||
|
Psd_AsdCannotClose Psd_Fault = 1
|
||||||
|
Psd_AsdCannotOpen Psd_Fault = 2
|
||||||
|
)
|
||||||
|
|
||||||
|
// Enum value maps for Psd_Fault.
|
||||||
|
var (
|
||||||
|
Psd_Fault_name = map[int32]string{
|
||||||
|
0: "Undefined",
|
||||||
|
1: "AsdCannotClose",
|
||||||
|
2: "AsdCannotOpen",
|
||||||
|
}
|
||||||
|
Psd_Fault_value = map[string]int32{
|
||||||
|
"Undefined": 0,
|
||||||
|
"AsdCannotClose": 1,
|
||||||
|
"AsdCannotOpen": 2,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
func (x Psd_Fault) Enum() *Psd_Fault {
|
||||||
|
p := new(Psd_Fault)
|
||||||
|
*p = x
|
||||||
|
return p
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x Psd_Fault) String() string {
|
||||||
|
return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (Psd_Fault) Descriptor() protoreflect.EnumDescriptor {
|
||||||
|
return file_component_psd_proto_enumTypes[0].Descriptor()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (Psd_Fault) Type() protoreflect.EnumType {
|
||||||
|
return &file_component_psd_proto_enumTypes[0]
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x Psd_Fault) Number() protoreflect.EnumNumber {
|
||||||
|
return protoreflect.EnumNumber(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Deprecated: Use Psd_Fault.Descriptor instead.
|
||||||
|
func (Psd_Fault) EnumDescriptor() ([]byte, []int) {
|
||||||
|
return file_component_psd_proto_rawDescGZIP(), []int{1, 0}
|
||||||
|
}
|
||||||
|
|
||||||
type PsdState struct {
|
type PsdState struct {
|
||||||
state protoimpl.MessageState
|
state protoimpl.MessageState
|
||||||
sizeCache protoimpl.SizeCache
|
sizeCache protoimpl.SizeCache
|
||||||
@ -67,6 +116,107 @@ func (x *PsdState) GetClose() bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type Psd struct {
|
||||||
|
state protoimpl.MessageState
|
||||||
|
sizeCache protoimpl.SizeCache
|
||||||
|
unknownFields protoimpl.UnknownFields
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *Psd) Reset() {
|
||||||
|
*x = Psd{}
|
||||||
|
if protoimpl.UnsafeEnabled {
|
||||||
|
mi := &file_component_psd_proto_msgTypes[1]
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *Psd) String() string {
|
||||||
|
return protoimpl.X.MessageStringOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*Psd) ProtoMessage() {}
|
||||||
|
|
||||||
|
func (x *Psd) ProtoReflect() protoreflect.Message {
|
||||||
|
mi := &file_component_psd_proto_msgTypes[1]
|
||||||
|
if protoimpl.UnsafeEnabled && x != nil {
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
if ms.LoadMessageInfo() == nil {
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
return ms
|
||||||
|
}
|
||||||
|
return mi.MessageOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Deprecated: Use Psd.ProtoReflect.Descriptor instead.
|
||||||
|
func (*Psd) Descriptor() ([]byte, []int) {
|
||||||
|
return file_component_psd_proto_rawDescGZIP(), []int{1}
|
||||||
|
}
|
||||||
|
|
||||||
|
type AsdState struct {
|
||||||
|
state protoimpl.MessageState
|
||||||
|
sizeCache protoimpl.SizeCache
|
||||||
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
|
Gmdw bool `protobuf:"varint,1,opt,name=gmdw,proto3" json:"gmdw,omitempty"` //关门到位(实际位置)
|
||||||
|
Kmdw bool `protobuf:"varint,2,opt,name=kmdw,proto3" json:"kmdw,omitempty"` //开门到位(实际位置)
|
||||||
|
Mgj bool `protobuf:"varint,3,opt,name=mgj,proto3" json:"mgj,omitempty"` //门关继电器
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *AsdState) Reset() {
|
||||||
|
*x = AsdState{}
|
||||||
|
if protoimpl.UnsafeEnabled {
|
||||||
|
mi := &file_component_psd_proto_msgTypes[2]
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *AsdState) String() string {
|
||||||
|
return protoimpl.X.MessageStringOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*AsdState) ProtoMessage() {}
|
||||||
|
|
||||||
|
func (x *AsdState) ProtoReflect() protoreflect.Message {
|
||||||
|
mi := &file_component_psd_proto_msgTypes[2]
|
||||||
|
if protoimpl.UnsafeEnabled && x != nil {
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
if ms.LoadMessageInfo() == nil {
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
return ms
|
||||||
|
}
|
||||||
|
return mi.MessageOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Deprecated: Use AsdState.ProtoReflect.Descriptor instead.
|
||||||
|
func (*AsdState) Descriptor() ([]byte, []int) {
|
||||||
|
return file_component_psd_proto_rawDescGZIP(), []int{2}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *AsdState) GetGmdw() bool {
|
||||||
|
if x != nil {
|
||||||
|
return x.Gmdw
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *AsdState) GetKmdw() bool {
|
||||||
|
if x != nil {
|
||||||
|
return x.Kmdw
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *AsdState) GetMgj() bool {
|
||||||
|
if x != nil {
|
||||||
|
return x.Mgj
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
var File_component_psd_proto protoreflect.FileDescriptor
|
var File_component_psd_proto protoreflect.FileDescriptor
|
||||||
|
|
||||||
var file_component_psd_proto_rawDesc = []byte{
|
var file_component_psd_proto_rawDesc = []byte{
|
||||||
@ -74,9 +224,18 @@ var file_component_psd_proto_rawDesc = []byte{
|
|||||||
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x09, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74,
|
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x09, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74,
|
||||||
0x22, 0x20, 0x0a, 0x08, 0x50, 0x73, 0x64, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x14, 0x0a, 0x05,
|
0x22, 0x20, 0x0a, 0x08, 0x50, 0x73, 0x64, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x14, 0x0a, 0x05,
|
||||||
0x63, 0x6c, 0x6f, 0x73, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x63, 0x6c, 0x6f,
|
0x63, 0x6c, 0x6f, 0x73, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x63, 0x6c, 0x6f,
|
||||||
0x73, 0x65, 0x42, 0x1d, 0x5a, 0x1b, 0x2e, 0x2f, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e,
|
0x73, 0x65, 0x22, 0x44, 0x0a, 0x03, 0x50, 0x73, 0x64, 0x22, 0x3d, 0x0a, 0x05, 0x46, 0x61, 0x75,
|
||||||
0x74, 0x2f, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x5f, 0x70, 0x72, 0x6f, 0x74,
|
0x6c, 0x74, 0x12, 0x0d, 0x0a, 0x09, 0x55, 0x6e, 0x64, 0x65, 0x66, 0x69, 0x6e, 0x65, 0x64, 0x10,
|
||||||
0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
0x00, 0x12, 0x12, 0x0a, 0x0e, 0x41, 0x73, 0x64, 0x43, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x43, 0x6c,
|
||||||
|
0x6f, 0x73, 0x65, 0x10, 0x01, 0x12, 0x11, 0x0a, 0x0d, 0x41, 0x73, 0x64, 0x43, 0x61, 0x6e, 0x6e,
|
||||||
|
0x6f, 0x74, 0x4f, 0x70, 0x65, 0x6e, 0x10, 0x02, 0x22, 0x44, 0x0a, 0x08, 0x41, 0x73, 0x64, 0x53,
|
||||||
|
0x74, 0x61, 0x74, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x67, 0x6d, 0x64, 0x77, 0x18, 0x01, 0x20, 0x01,
|
||||||
|
0x28, 0x08, 0x52, 0x04, 0x67, 0x6d, 0x64, 0x77, 0x12, 0x12, 0x0a, 0x04, 0x6b, 0x6d, 0x64, 0x77,
|
||||||
|
0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x04, 0x6b, 0x6d, 0x64, 0x77, 0x12, 0x10, 0x0a, 0x03,
|
||||||
|
0x6d, 0x67, 0x6a, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x03, 0x6d, 0x67, 0x6a, 0x42, 0x1d,
|
||||||
|
0x5a, 0x1b, 0x2e, 0x2f, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x2f, 0x63, 0x6f,
|
||||||
|
0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70,
|
||||||
|
0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -91,9 +250,13 @@ func file_component_psd_proto_rawDescGZIP() []byte {
|
|||||||
return file_component_psd_proto_rawDescData
|
return file_component_psd_proto_rawDescData
|
||||||
}
|
}
|
||||||
|
|
||||||
var file_component_psd_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
|
var file_component_psd_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
|
||||||
|
var file_component_psd_proto_msgTypes = make([]protoimpl.MessageInfo, 3)
|
||||||
var file_component_psd_proto_goTypes = []interface{}{
|
var file_component_psd_proto_goTypes = []interface{}{
|
||||||
(*PsdState)(nil), // 0: component.PsdState
|
(Psd_Fault)(0), // 0: component.Psd.Fault
|
||||||
|
(*PsdState)(nil), // 1: component.PsdState
|
||||||
|
(*Psd)(nil), // 2: component.Psd
|
||||||
|
(*AsdState)(nil), // 3: component.AsdState
|
||||||
}
|
}
|
||||||
var file_component_psd_proto_depIdxs = []int32{
|
var file_component_psd_proto_depIdxs = []int32{
|
||||||
0, // [0:0] is the sub-list for method output_type
|
0, // [0:0] is the sub-list for method output_type
|
||||||
@ -121,19 +284,44 @@ func file_component_psd_proto_init() {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
file_component_psd_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
||||||
|
switch v := v.(*Psd); i {
|
||||||
|
case 0:
|
||||||
|
return &v.state
|
||||||
|
case 1:
|
||||||
|
return &v.sizeCache
|
||||||
|
case 2:
|
||||||
|
return &v.unknownFields
|
||||||
|
default:
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
file_component_psd_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
|
||||||
|
switch v := v.(*AsdState); i {
|
||||||
|
case 0:
|
||||||
|
return &v.state
|
||||||
|
case 1:
|
||||||
|
return &v.sizeCache
|
||||||
|
case 2:
|
||||||
|
return &v.unknownFields
|
||||||
|
default:
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
type x struct{}
|
type x struct{}
|
||||||
out := protoimpl.TypeBuilder{
|
out := protoimpl.TypeBuilder{
|
||||||
File: protoimpl.DescBuilder{
|
File: protoimpl.DescBuilder{
|
||||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||||
RawDescriptor: file_component_psd_proto_rawDesc,
|
RawDescriptor: file_component_psd_proto_rawDesc,
|
||||||
NumEnums: 0,
|
NumEnums: 1,
|
||||||
NumMessages: 1,
|
NumMessages: 3,
|
||||||
NumExtensions: 0,
|
NumExtensions: 0,
|
||||||
NumServices: 0,
|
NumServices: 0,
|
||||||
},
|
},
|
||||||
GoTypes: file_component_psd_proto_goTypes,
|
GoTypes: file_component_psd_proto_goTypes,
|
||||||
DependencyIndexes: file_component_psd_proto_depIdxs,
|
DependencyIndexes: file_component_psd_proto_depIdxs,
|
||||||
|
EnumInfos: file_component_psd_proto_enumTypes,
|
||||||
MessageInfos: file_component_psd_proto_msgTypes,
|
MessageInfos: file_component_psd_proto_msgTypes,
|
||||||
}.Build()
|
}.Build()
|
||||||
File_component_psd_proto = out.File
|
File_component_psd_proto = out.File
|
||||||
|
@ -47,6 +47,8 @@ type AsdMotorState struct {
|
|||||||
MG bool //门是否关闭(继电器状态)
|
MG bool //门是否关闭(继电器状态)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var AsdStateType = ecs.NewComponentType[component_proto.AsdState]()
|
||||||
|
|
||||||
var PlatformMkxCircuitType = ecs.NewComponentType[PlatformMkxCircuit]()
|
var PlatformMkxCircuitType = ecs.NewComponentType[PlatformMkxCircuit]()
|
||||||
|
|
||||||
// PlatformMkxCircuit 站台门控箱电路
|
// PlatformMkxCircuit 站台门控箱电路
|
||||||
|
@ -9,6 +9,8 @@ import (
|
|||||||
|
|
||||||
var PsdBaseComponentTypeArr = []ecs.IComponentType{component.PsdTag, component.UidType,
|
var PsdBaseComponentTypeArr = []ecs.IComponentType{component.PsdTag, component.UidType,
|
||||||
component.PsdStateType, component.AsdListType, component.PscType}
|
component.PsdStateType, component.AsdListType, component.PscType}
|
||||||
|
var AsdBaseComponentTypeArr = []ecs.IComponentType{component.AsdTag, component.UidType,
|
||||||
|
component.AsdMotorStateType, component.TwoPositionTransformType, component.AsdStateType}
|
||||||
|
|
||||||
func LoadPsd(w ecs.World) error {
|
func LoadPsd(w ecs.World) error {
|
||||||
data := GetWorldData(w)
|
data := GetWorldData(w)
|
||||||
@ -71,9 +73,9 @@ func NewPsdEntry(world ecs.World, psd *repository.Psd, worldData *component.Worl
|
|||||||
entry = world.Entry(world.Create(PsdBaseComponentTypeArr...))
|
entry = world.Entry(world.Create(PsdBaseComponentTypeArr...))
|
||||||
component.UidType.SetValue(entry, component.Uid{Id: psd.Id()})
|
component.UidType.SetValue(entry, component.Uid{Id: psd.Id()})
|
||||||
worldData.EntityMap[psd.Id()] = entry
|
worldData.EntityMap[psd.Id()] = entry
|
||||||
asdList := &component.AsdList{}
|
asdList := &component.AsdList{List: make([]*ecs.Entry, psd.AsdAmount(), psd.AsdAmount())}
|
||||||
for i := int32(0); i <= psd.AsdAmount(); i++ {
|
for i := int32(0); i < psd.AsdAmount(); i++ {
|
||||||
asdList.List = append(asdList.List, NewAsdEntry(world, worldData, psd.Id(), int(i)))
|
asdList.List[i] = NewAsdEntry(world, worldData, psd.Id(), int(i))
|
||||||
}
|
}
|
||||||
component.AsdListType.Set(entry, asdList)
|
component.AsdListType.Set(entry, asdList)
|
||||||
}
|
}
|
||||||
@ -81,8 +83,7 @@ func NewPsdEntry(world ecs.World, psd *repository.Psd, worldData *component.Worl
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewAsdEntry(world ecs.World, worldData *component.WorldData, psdId string, asdIndex int) *ecs.Entry {
|
func NewAsdEntry(world ecs.World, worldData *component.WorldData, psdId string, asdIndex int) *ecs.Entry {
|
||||||
entry := world.Entry(world.Create(component.AsdTag, component.UidType,
|
entry := world.Entry(world.Create(AsdBaseComponentTypeArr...))
|
||||||
component.AsdMotorStateType, component.TwoPositionTransformType))
|
|
||||||
uid := psdId + "_" + strconv.Itoa(asdIndex)
|
uid := psdId + "_" + strconv.Itoa(asdIndex)
|
||||||
worldData.EntityMap[uid] = entry
|
worldData.EntityMap[uid] = entry
|
||||||
component.UidType.SetValue(entry, component.Uid{Id: uid})
|
component.UidType.SetValue(entry, component.Uid{Id: uid})
|
||||||
|
@ -7,3 +7,18 @@ option go_package = "./component/component_proto";
|
|||||||
message PsdState {
|
message PsdState {
|
||||||
bool close = 1;
|
bool close = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message Psd {
|
||||||
|
enum Fault {
|
||||||
|
Undefined = 0;
|
||||||
|
AsdCannotClose = 1;
|
||||||
|
AsdCannotOpen = 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
message AsdState {
|
||||||
|
bool gmdw = 1; //关门到位(实际位置)
|
||||||
|
bool kmdw = 2; //开门到位(实际位置)
|
||||||
|
|
||||||
|
bool mgj = 3; //门关继电器
|
||||||
|
}
|
@ -23,20 +23,34 @@ func (s *AsdSys) Update(world ecs.World) {
|
|||||||
//设置两位置转换速度
|
//设置两位置转换速度
|
||||||
psdMotorState := component.AsdMotorStateType.Get(entry)
|
psdMotorState := component.AsdMotorStateType.Get(entry)
|
||||||
twoPosition := component.TwoPositionTransformType.Get(entry)
|
twoPosition := component.TwoPositionTransformType.Get(entry)
|
||||||
|
asdState := component.AsdStateType.Get(entry)
|
||||||
|
pos := twoPosition.Pos
|
||||||
if psdMotorState.TD {
|
if psdMotorState.TD {
|
||||||
if psdMotorState.KM {
|
if psdMotorState.KM {
|
||||||
twoPosition.Speed = speed
|
twoPosition.Speed = speed
|
||||||
if twoPosition.Pos == consts.TwoPosMax { //开门到位后断电
|
if pos == consts.TwoPosMax { //开门到位后断电
|
||||||
psdMotorState.TD = false
|
psdMotorState.TD = false
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
twoPosition.Speed = -speed
|
twoPosition.Speed = -speed
|
||||||
if twoPosition.Pos == consts.TwoPosMin { //关门到位后断电
|
if pos == consts.TwoPosMin { //关门到位后断电
|
||||||
psdMotorState.TD = false
|
psdMotorState.TD = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//门关继电器状态
|
//门关继电器状态
|
||||||
psdMotorState.MG = twoPosition.Pos == consts.TwoPosMin
|
psdMotorState.MG = pos == consts.TwoPosMin
|
||||||
|
asdState.Mgj = psdMotorState.MG
|
||||||
|
//滑动门状态
|
||||||
|
if pos == consts.TwoPosMax {
|
||||||
|
asdState.Kmdw = true
|
||||||
|
asdState.Gmdw = false
|
||||||
|
} else if pos == consts.TwoPosMin {
|
||||||
|
asdState.Kmdw = false
|
||||||
|
asdState.Gmdw = true
|
||||||
|
} else {
|
||||||
|
asdState.Kmdw = false
|
||||||
|
asdState.Gmdw = false
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user