This commit is contained in:
walker 2023-11-03 17:26:37 +08:00
commit 4bcc1c0b16
5 changed files with 235 additions and 15 deletions

View File

@ -20,6 +20,55 @@ const (
_ = 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 {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
@ -67,6 +116,107 @@ func (x *PsdState) GetClose() bool {
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_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,
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,
0x73, 0x65, 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,
0x73, 0x65, 0x22, 0x44, 0x0a, 0x03, 0x50, 0x73, 0x64, 0x22, 0x3d, 0x0a, 0x05, 0x46, 0x61, 0x75,
0x6c, 0x74, 0x12, 0x0d, 0x0a, 0x09, 0x55, 0x6e, 0x64, 0x65, 0x66, 0x69, 0x6e, 0x65, 0x64, 0x10,
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 (
@ -91,9 +250,13 @@ func file_component_psd_proto_rawDescGZIP() []byte {
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{}{
(*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{
0, // [0:0] is the sub-list for method output_type
@ -121,19 +284,44 @@ func file_component_psd_proto_init() {
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{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_component_psd_proto_rawDesc,
NumEnums: 0,
NumMessages: 1,
NumEnums: 1,
NumMessages: 3,
NumExtensions: 0,
NumServices: 0,
},
GoTypes: file_component_psd_proto_goTypes,
DependencyIndexes: file_component_psd_proto_depIdxs,
EnumInfos: file_component_psd_proto_enumTypes,
MessageInfos: file_component_psd_proto_msgTypes,
}.Build()
File_component_psd_proto = out.File

View File

@ -47,6 +47,8 @@ type AsdMotorState struct {
MG bool //门是否关闭(继电器状态)
}
var AsdStateType = ecs.NewComponentType[component_proto.AsdState]()
var PlatformMkxCircuitType = ecs.NewComponentType[PlatformMkxCircuit]()
// PlatformMkxCircuit 站台门控箱电路

View File

@ -9,6 +9,8 @@ import (
var PsdBaseComponentTypeArr = []ecs.IComponentType{component.PsdTag, component.UidType,
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 {
data := GetWorldData(w)
@ -71,9 +73,9 @@ func NewPsdEntry(world ecs.World, psd *repository.Psd, worldData *component.Worl
entry = world.Entry(world.Create(PsdBaseComponentTypeArr...))
component.UidType.SetValue(entry, component.Uid{Id: psd.Id()})
worldData.EntityMap[psd.Id()] = entry
asdList := &component.AsdList{}
for i := int32(0); i <= psd.AsdAmount(); i++ {
asdList.List = append(asdList.List, NewAsdEntry(world, worldData, psd.Id(), int(i)))
asdList := &component.AsdList{List: make([]*ecs.Entry, psd.AsdAmount(), psd.AsdAmount())}
for i := int32(0); i < psd.AsdAmount(); i++ {
asdList.List[i] = NewAsdEntry(world, worldData, psd.Id(), int(i))
}
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 {
entry := world.Entry(world.Create(component.AsdTag, component.UidType,
component.AsdMotorStateType, component.TwoPositionTransformType))
entry := world.Entry(world.Create(AsdBaseComponentTypeArr...))
uid := psdId + "_" + strconv.Itoa(asdIndex)
worldData.EntityMap[uid] = entry
component.UidType.SetValue(entry, component.Uid{Id: uid})

View File

@ -6,4 +6,19 @@ option go_package = "./component/component_proto";
message PsdState {
bool close = 1;
}
message Psd {
enum Fault {
Undefined = 0;
AsdCannotClose = 1;
AsdCannotOpen = 2;
}
}
message AsdState {
bool gmdw = 1; //
bool kmdw = 2; //
bool mgj = 3; //
}

View File

@ -23,20 +23,34 @@ func (s *AsdSys) Update(world ecs.World) {
//设置两位置转换速度
psdMotorState := component.AsdMotorStateType.Get(entry)
twoPosition := component.TwoPositionTransformType.Get(entry)
asdState := component.AsdStateType.Get(entry)
pos := twoPosition.Pos
if psdMotorState.TD {
if psdMotorState.KM {
twoPosition.Speed = speed
if twoPosition.Pos == consts.TwoPosMax { //开门到位后断电
if pos == consts.TwoPosMax { //开门到位后断电
psdMotorState.TD = false
}
} else {
twoPosition.Speed = -speed
if twoPosition.Pos == consts.TwoPosMin { //关门到位后断电
if pos == consts.TwoPosMin { //关门到位后断电
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
}
})
}