Merge branch 'master' of https://git.code.tencent.com/jl-framework/rtss_simulation
# Conflicts: # proto/src/status.proto # state/status.pb.go
This commit is contained in:
commit
b0b63b7df6
15
components/button.go
Normal file
15
components/button.go
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
package components
|
||||||
|
|
||||||
|
import (
|
||||||
|
"joylink.club/ecs"
|
||||||
|
"joylink.club/rtsssimulation/state"
|
||||||
|
)
|
||||||
|
|
||||||
|
// 按钮状态组件
|
||||||
|
var ButtonState = ecs.NewComponentType[state.ButtonState]()
|
||||||
|
|
||||||
|
// 按钮操作组件
|
||||||
|
var ButtonPressOperating = ecs.NewComponentType[state.ButtonPressOperating]()
|
||||||
|
|
||||||
|
// 按钮确认组件
|
||||||
|
var ButtonConfirmOperating = ecs.NewComponentType[state.ButtonConfirmOperating]()
|
@ -180,3 +180,31 @@ message TrainState{
|
|||||||
repeated OccupiedLinkPosition occupiedLinks = 7;
|
repeated OccupiedLinkPosition occupiedLinks = 7;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// 按钮状态
|
||||||
|
message ButtonState {
|
||||||
|
// 是否按下
|
||||||
|
bool pressDown = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 按钮按下、抬起操作
|
||||||
|
message ButtonPressOperating {
|
||||||
|
// 开始操作
|
||||||
|
bool start = 1;
|
||||||
|
// 是否按下(true)、抬起(false)
|
||||||
|
bool down = 2;
|
||||||
|
// 倒计时
|
||||||
|
int64 operateTime = 3;
|
||||||
|
// 需确认
|
||||||
|
bool needConfirm = 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 按钮确认操作
|
||||||
|
message ButtonConfirmOperating {
|
||||||
|
// 确认操作
|
||||||
|
bool confirm = 1;
|
||||||
|
// 取消
|
||||||
|
bool cancel = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -121,6 +121,59 @@ func (SignalAspect) EnumDescriptor() ([]byte, []int) {
|
|||||||
return file_status_proto_rawDescGZIP(), []int{0}
|
return file_status_proto_rawDescGZIP(), []int{0}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 列车激活的枚举
|
||||||
|
type TrainActiveEnum int32
|
||||||
|
|
||||||
|
const (
|
||||||
|
// 列车两端均未激活
|
||||||
|
TrainActiveEnum_HEAD_N TrainActiveEnum = 0
|
||||||
|
// 列车A端激活
|
||||||
|
TrainActiveEnum_HEAD_A TrainActiveEnum = 1
|
||||||
|
// 列车B端激活
|
||||||
|
TrainActiveEnum_HEAD_B TrainActiveEnum = 2
|
||||||
|
)
|
||||||
|
|
||||||
|
// Enum value maps for TrainActiveEnum.
|
||||||
|
var (
|
||||||
|
TrainActiveEnum_name = map[int32]string{
|
||||||
|
0: "HEAD_N",
|
||||||
|
1: "HEAD_A",
|
||||||
|
2: "HEAD_B",
|
||||||
|
}
|
||||||
|
TrainActiveEnum_value = map[string]int32{
|
||||||
|
"HEAD_N": 0,
|
||||||
|
"HEAD_A": 1,
|
||||||
|
"HEAD_B": 2,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
func (x TrainActiveEnum) Enum() *TrainActiveEnum {
|
||||||
|
p := new(TrainActiveEnum)
|
||||||
|
*p = x
|
||||||
|
return p
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x TrainActiveEnum) String() string {
|
||||||
|
return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (TrainActiveEnum) Descriptor() protoreflect.EnumDescriptor {
|
||||||
|
return file_status_proto_enumTypes[1].Descriptor()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (TrainActiveEnum) Type() protoreflect.EnumType {
|
||||||
|
return &file_status_proto_enumTypes[1]
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x TrainActiveEnum) Number() protoreflect.EnumNumber {
|
||||||
|
return protoreflect.EnumNumber(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Deprecated: Use TrainActiveEnum.Descriptor instead.
|
||||||
|
func (TrainActiveEnum) EnumDescriptor() ([]byte, []int) {
|
||||||
|
return file_status_proto_rawDescGZIP(), []int{1}
|
||||||
|
}
|
||||||
|
|
||||||
// 设备身份信息
|
// 设备身份信息
|
||||||
type DeviceIdentity struct {
|
type DeviceIdentity struct {
|
||||||
state protoimpl.MessageState
|
state protoimpl.MessageState
|
||||||
@ -950,8 +1003,10 @@ type TrainState struct {
|
|||||||
sizeCache protoimpl.SizeCache
|
sizeCache protoimpl.SizeCache
|
||||||
unknownFields protoimpl.UnknownFields
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
|
// 列车激活端
|
||||||
|
ActiveHead TrainActiveEnum `protobuf:"varint,1,opt,name=activeHead,proto3,enum=state.TrainActiveEnum" json:"activeHead,omitempty"`
|
||||||
// 列车所占的轨道位置列表
|
// 列车所占的轨道位置列表
|
||||||
OccupiedLinks []*OccupiedLinkPosition `protobuf:"bytes,1,rep,name=occupiedLinks,proto3" json:"occupiedLinks,omitempty"`
|
OccupiedLinks []*OccupiedLinkPosition `protobuf:"bytes,7,rep,name=occupiedLinks,proto3" json:"occupiedLinks,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *TrainState) Reset() {
|
func (x *TrainState) Reset() {
|
||||||
@ -986,6 +1041,13 @@ func (*TrainState) Descriptor() ([]byte, []int) {
|
|||||||
return file_status_proto_rawDescGZIP(), []int{13}
|
return file_status_proto_rawDescGZIP(), []int{13}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (x *TrainState) GetActiveHead() TrainActiveEnum {
|
||||||
|
if x != nil {
|
||||||
|
return x.ActiveHead
|
||||||
|
}
|
||||||
|
return TrainActiveEnum_HEAD_N
|
||||||
|
}
|
||||||
|
|
||||||
func (x *TrainState) GetOccupiedLinks() []*OccupiedLinkPosition {
|
func (x *TrainState) GetOccupiedLinks() []*OccupiedLinkPosition {
|
||||||
if x != nil {
|
if x != nil {
|
||||||
return x.OccupiedLinks
|
return x.OccupiedLinks
|
||||||
@ -993,6 +1055,189 @@ func (x *TrainState) GetOccupiedLinks() []*OccupiedLinkPosition {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 按钮状态
|
||||||
|
type ButtonState struct {
|
||||||
|
state protoimpl.MessageState
|
||||||
|
sizeCache protoimpl.SizeCache
|
||||||
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
|
// 是否按下
|
||||||
|
PressDown bool `protobuf:"varint,1,opt,name=pressDown,proto3" json:"pressDown,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *ButtonState) Reset() {
|
||||||
|
*x = ButtonState{}
|
||||||
|
if protoimpl.UnsafeEnabled {
|
||||||
|
mi := &file_status_proto_msgTypes[14]
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *ButtonState) String() string {
|
||||||
|
return protoimpl.X.MessageStringOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*ButtonState) ProtoMessage() {}
|
||||||
|
|
||||||
|
func (x *ButtonState) ProtoReflect() protoreflect.Message {
|
||||||
|
mi := &file_status_proto_msgTypes[14]
|
||||||
|
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 ButtonState.ProtoReflect.Descriptor instead.
|
||||||
|
func (*ButtonState) Descriptor() ([]byte, []int) {
|
||||||
|
return file_status_proto_rawDescGZIP(), []int{14}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *ButtonState) GetPressDown() bool {
|
||||||
|
if x != nil {
|
||||||
|
return x.PressDown
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
// 按钮按下、抬起操作
|
||||||
|
type ButtonPressOperating struct {
|
||||||
|
state protoimpl.MessageState
|
||||||
|
sizeCache protoimpl.SizeCache
|
||||||
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
|
// 开始操作
|
||||||
|
Start bool `protobuf:"varint,1,opt,name=start,proto3" json:"start,omitempty"`
|
||||||
|
// 是否按下(true)、抬起(false)
|
||||||
|
Down bool `protobuf:"varint,2,opt,name=down,proto3" json:"down,omitempty"`
|
||||||
|
// 倒计时
|
||||||
|
OperateTime int64 `protobuf:"varint,3,opt,name=operateTime,proto3" json:"operateTime,omitempty"`
|
||||||
|
// 需确认
|
||||||
|
NeedConfirm bool `protobuf:"varint,4,opt,name=needConfirm,proto3" json:"needConfirm,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *ButtonPressOperating) Reset() {
|
||||||
|
*x = ButtonPressOperating{}
|
||||||
|
if protoimpl.UnsafeEnabled {
|
||||||
|
mi := &file_status_proto_msgTypes[15]
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *ButtonPressOperating) String() string {
|
||||||
|
return protoimpl.X.MessageStringOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*ButtonPressOperating) ProtoMessage() {}
|
||||||
|
|
||||||
|
func (x *ButtonPressOperating) ProtoReflect() protoreflect.Message {
|
||||||
|
mi := &file_status_proto_msgTypes[15]
|
||||||
|
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 ButtonPressOperating.ProtoReflect.Descriptor instead.
|
||||||
|
func (*ButtonPressOperating) Descriptor() ([]byte, []int) {
|
||||||
|
return file_status_proto_rawDescGZIP(), []int{15}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *ButtonPressOperating) GetStart() bool {
|
||||||
|
if x != nil {
|
||||||
|
return x.Start
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *ButtonPressOperating) GetDown() bool {
|
||||||
|
if x != nil {
|
||||||
|
return x.Down
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *ButtonPressOperating) GetOperateTime() int64 {
|
||||||
|
if x != nil {
|
||||||
|
return x.OperateTime
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *ButtonPressOperating) GetNeedConfirm() bool {
|
||||||
|
if x != nil {
|
||||||
|
return x.NeedConfirm
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
// 按钮确认操作
|
||||||
|
type ButtonConfirmOperating struct {
|
||||||
|
state protoimpl.MessageState
|
||||||
|
sizeCache protoimpl.SizeCache
|
||||||
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
|
// 确认操作
|
||||||
|
Confirm bool `protobuf:"varint,1,opt,name=confirm,proto3" json:"confirm,omitempty"`
|
||||||
|
// 取消
|
||||||
|
Cancel bool `protobuf:"varint,2,opt,name=cancel,proto3" json:"cancel,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *ButtonConfirmOperating) Reset() {
|
||||||
|
*x = ButtonConfirmOperating{}
|
||||||
|
if protoimpl.UnsafeEnabled {
|
||||||
|
mi := &file_status_proto_msgTypes[16]
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *ButtonConfirmOperating) String() string {
|
||||||
|
return protoimpl.X.MessageStringOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*ButtonConfirmOperating) ProtoMessage() {}
|
||||||
|
|
||||||
|
func (x *ButtonConfirmOperating) ProtoReflect() protoreflect.Message {
|
||||||
|
mi := &file_status_proto_msgTypes[16]
|
||||||
|
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 ButtonConfirmOperating.ProtoReflect.Descriptor instead.
|
||||||
|
func (*ButtonConfirmOperating) Descriptor() ([]byte, []int) {
|
||||||
|
return file_status_proto_rawDescGZIP(), []int{16}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *ButtonConfirmOperating) GetConfirm() bool {
|
||||||
|
if x != nil {
|
||||||
|
return x.Confirm
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *ButtonConfirmOperating) GetCancel() bool {
|
||||||
|
if x != nil {
|
||||||
|
return x.Cancel
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
var File_status_proto protoreflect.FileDescriptor
|
var File_status_proto protoreflect.FileDescriptor
|
||||||
|
|
||||||
var file_status_proto_rawDesc = []byte{
|
var file_status_proto_rawDesc = []byte{
|
||||||
@ -1079,20 +1324,43 @@ var file_status_proto_rawDesc = []byte{
|
|||||||
0x65, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0b, 0x73, 0x74, 0x61, 0x72, 0x74, 0x4f,
|
0x65, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0b, 0x73, 0x74, 0x61, 0x72, 0x74, 0x4f,
|
||||||
0x66, 0x66, 0x73, 0x65, 0x74, 0x12, 0x1c, 0x0a, 0x09, 0x65, 0x6e, 0x64, 0x4f, 0x66, 0x66, 0x73,
|
0x66, 0x66, 0x73, 0x65, 0x74, 0x12, 0x1c, 0x0a, 0x09, 0x65, 0x6e, 0x64, 0x4f, 0x66, 0x66, 0x73,
|
||||||
0x65, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x65, 0x6e, 0x64, 0x4f, 0x66, 0x66,
|
0x65, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x65, 0x6e, 0x64, 0x4f, 0x66, 0x66,
|
||||||
0x73, 0x65, 0x74, 0x22, 0x4f, 0x0a, 0x0a, 0x54, 0x72, 0x61, 0x69, 0x6e, 0x53, 0x74, 0x61, 0x74,
|
0x73, 0x65, 0x74, 0x22, 0x87, 0x01, 0x0a, 0x0a, 0x54, 0x72, 0x61, 0x69, 0x6e, 0x53, 0x74, 0x61,
|
||||||
0x65, 0x12, 0x41, 0x0a, 0x0d, 0x6f, 0x63, 0x63, 0x75, 0x70, 0x69, 0x65, 0x64, 0x4c, 0x69, 0x6e,
|
0x74, 0x65, 0x12, 0x36, 0x0a, 0x0a, 0x61, 0x63, 0x74, 0x69, 0x76, 0x65, 0x48, 0x65, 0x61, 0x64,
|
||||||
0x6b, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x65,
|
0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x16, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x54,
|
||||||
0x2e, 0x4f, 0x63, 0x63, 0x75, 0x70, 0x69, 0x65, 0x64, 0x4c, 0x69, 0x6e, 0x6b, 0x50, 0x6f, 0x73,
|
0x72, 0x61, 0x69, 0x6e, 0x41, 0x63, 0x74, 0x69, 0x76, 0x65, 0x45, 0x6e, 0x75, 0x6d, 0x52, 0x0a,
|
||||||
0x69, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0d, 0x6f, 0x63, 0x63, 0x75, 0x70, 0x69, 0x65, 0x64, 0x4c,
|
0x61, 0x63, 0x74, 0x69, 0x76, 0x65, 0x48, 0x65, 0x61, 0x64, 0x12, 0x41, 0x0a, 0x0d, 0x6f, 0x63,
|
||||||
0x69, 0x6e, 0x6b, 0x73, 0x2a, 0x81, 0x01, 0x0a, 0x0c, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x41,
|
0x63, 0x75, 0x70, 0x69, 0x65, 0x64, 0x4c, 0x69, 0x6e, 0x6b, 0x73, 0x18, 0x07, 0x20, 0x03, 0x28,
|
||||||
0x73, 0x70, 0x65, 0x63, 0x74, 0x12, 0x06, 0x0a, 0x02, 0x4e, 0x6f, 0x10, 0x00, 0x12, 0x05, 0x0a,
|
0x0b, 0x32, 0x1b, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x4f, 0x63, 0x63, 0x75, 0x70, 0x69,
|
||||||
0x01, 0x52, 0x10, 0x01, 0x12, 0x05, 0x0a, 0x01, 0x47, 0x10, 0x02, 0x12, 0x05, 0x0a, 0x01, 0x59,
|
0x65, 0x64, 0x4c, 0x69, 0x6e, 0x6b, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0d,
|
||||||
0x10, 0x03, 0x12, 0x05, 0x0a, 0x01, 0x57, 0x10, 0x04, 0x12, 0x05, 0x0a, 0x01, 0x42, 0x10, 0x05,
|
0x6f, 0x63, 0x63, 0x75, 0x70, 0x69, 0x65, 0x64, 0x4c, 0x69, 0x6e, 0x6b, 0x73, 0x22, 0x2b, 0x0a,
|
||||||
0x12, 0x06, 0x0a, 0x02, 0x52, 0x59, 0x10, 0x06, 0x12, 0x06, 0x0a, 0x02, 0x52, 0x57, 0x10, 0x07,
|
0x0b, 0x42, 0x75, 0x74, 0x74, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x1c, 0x0a, 0x09,
|
||||||
0x12, 0x06, 0x0a, 0x02, 0x47, 0x47, 0x10, 0x08, 0x12, 0x06, 0x0a, 0x02, 0x47, 0x59, 0x10, 0x09,
|
0x70, 0x72, 0x65, 0x73, 0x73, 0x44, 0x6f, 0x77, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52,
|
||||||
0x12, 0x06, 0x0a, 0x02, 0x59, 0x59, 0x10, 0x0a, 0x12, 0x06, 0x0a, 0x02, 0x52, 0x46, 0x10, 0x0b,
|
0x09, 0x70, 0x72, 0x65, 0x73, 0x73, 0x44, 0x6f, 0x77, 0x6e, 0x22, 0x84, 0x01, 0x0a, 0x14, 0x42,
|
||||||
0x12, 0x06, 0x0a, 0x02, 0x59, 0x46, 0x10, 0x0c, 0x12, 0x06, 0x0a, 0x02, 0x47, 0x46, 0x10, 0x0d,
|
0x75, 0x74, 0x74, 0x6f, 0x6e, 0x50, 0x72, 0x65, 0x73, 0x73, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74,
|
||||||
0x12, 0x06, 0x0a, 0x02, 0x57, 0x46, 0x10, 0x0e, 0x42, 0x09, 0x5a, 0x07, 0x2e, 0x2f, 0x73, 0x74,
|
0x69, 0x6e, 0x67, 0x12, 0x14, 0x0a, 0x05, 0x73, 0x74, 0x61, 0x72, 0x74, 0x18, 0x01, 0x20, 0x01,
|
||||||
|
0x28, 0x08, 0x52, 0x05, 0x73, 0x74, 0x61, 0x72, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x6f, 0x77,
|
||||||
|
0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x04, 0x64, 0x6f, 0x77, 0x6e, 0x12, 0x20, 0x0a,
|
||||||
|
0x0b, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01,
|
||||||
|
0x28, 0x03, 0x52, 0x0b, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x12,
|
||||||
|
0x20, 0x0a, 0x0b, 0x6e, 0x65, 0x65, 0x64, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x72, 0x6d, 0x18, 0x04,
|
||||||
|
0x20, 0x01, 0x28, 0x08, 0x52, 0x0b, 0x6e, 0x65, 0x65, 0x64, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x72,
|
||||||
|
0x6d, 0x22, 0x4a, 0x0a, 0x16, 0x42, 0x75, 0x74, 0x74, 0x6f, 0x6e, 0x43, 0x6f, 0x6e, 0x66, 0x69,
|
||||||
|
0x72, 0x6d, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6e, 0x67, 0x12, 0x18, 0x0a, 0x07, 0x63,
|
||||||
|
0x6f, 0x6e, 0x66, 0x69, 0x72, 0x6d, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x63, 0x6f,
|
||||||
|
0x6e, 0x66, 0x69, 0x72, 0x6d, 0x12, 0x16, 0x0a, 0x06, 0x63, 0x61, 0x6e, 0x63, 0x65, 0x6c, 0x18,
|
||||||
|
0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x63, 0x61, 0x6e, 0x63, 0x65, 0x6c, 0x2a, 0x81, 0x01,
|
||||||
|
0x0a, 0x0c, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x41, 0x73, 0x70, 0x65, 0x63, 0x74, 0x12, 0x06,
|
||||||
|
0x0a, 0x02, 0x4e, 0x6f, 0x10, 0x00, 0x12, 0x05, 0x0a, 0x01, 0x52, 0x10, 0x01, 0x12, 0x05, 0x0a,
|
||||||
|
0x01, 0x47, 0x10, 0x02, 0x12, 0x05, 0x0a, 0x01, 0x59, 0x10, 0x03, 0x12, 0x05, 0x0a, 0x01, 0x57,
|
||||||
|
0x10, 0x04, 0x12, 0x05, 0x0a, 0x01, 0x42, 0x10, 0x05, 0x12, 0x06, 0x0a, 0x02, 0x52, 0x59, 0x10,
|
||||||
|
0x06, 0x12, 0x06, 0x0a, 0x02, 0x52, 0x57, 0x10, 0x07, 0x12, 0x06, 0x0a, 0x02, 0x47, 0x47, 0x10,
|
||||||
|
0x08, 0x12, 0x06, 0x0a, 0x02, 0x47, 0x59, 0x10, 0x09, 0x12, 0x06, 0x0a, 0x02, 0x59, 0x59, 0x10,
|
||||||
|
0x0a, 0x12, 0x06, 0x0a, 0x02, 0x52, 0x46, 0x10, 0x0b, 0x12, 0x06, 0x0a, 0x02, 0x59, 0x46, 0x10,
|
||||||
|
0x0c, 0x12, 0x06, 0x0a, 0x02, 0x47, 0x46, 0x10, 0x0d, 0x12, 0x06, 0x0a, 0x02, 0x57, 0x46, 0x10,
|
||||||
|
0x0e, 0x2a, 0x35, 0x0a, 0x0f, 0x54, 0x72, 0x61, 0x69, 0x6e, 0x41, 0x63, 0x74, 0x69, 0x76, 0x65,
|
||||||
|
0x45, 0x6e, 0x75, 0x6d, 0x12, 0x0a, 0x0a, 0x06, 0x48, 0x45, 0x41, 0x44, 0x5f, 0x4e, 0x10, 0x00,
|
||||||
|
0x12, 0x0a, 0x0a, 0x06, 0x48, 0x45, 0x41, 0x44, 0x5f, 0x41, 0x10, 0x01, 0x12, 0x0a, 0x0a, 0x06,
|
||||||
|
0x48, 0x45, 0x41, 0x44, 0x5f, 0x42, 0x10, 0x02, 0x42, 0x09, 0x5a, 0x07, 0x2e, 0x2f, 0x73, 0x74,
|
||||||
0x61, 0x74, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
0x61, 0x74, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1108,35 +1376,40 @@ func file_status_proto_rawDescGZIP() []byte {
|
|||||||
return file_status_proto_rawDescData
|
return file_status_proto_rawDescData
|
||||||
}
|
}
|
||||||
|
|
||||||
var file_status_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
|
var file_status_proto_enumTypes = make([]protoimpl.EnumInfo, 2)
|
||||||
var file_status_proto_msgTypes = make([]protoimpl.MessageInfo, 14)
|
var file_status_proto_msgTypes = make([]protoimpl.MessageInfo, 17)
|
||||||
var file_status_proto_goTypes = []interface{}{
|
var file_status_proto_goTypes = []interface{}{
|
||||||
(SignalAspect)(0), // 0: state.SignalAspect
|
(SignalAspect)(0), // 0: state.SignalAspect
|
||||||
(*DeviceIdentity)(nil), // 1: state.DeviceIdentity
|
(TrainActiveEnum)(0), // 1: state.TrainActiveEnum
|
||||||
(*SwitchState)(nil), // 2: state.SwitchState
|
(*DeviceIdentity)(nil), // 2: state.DeviceIdentity
|
||||||
(*SwitchNRRelayOperating)(nil), // 3: state.SwitchNRRelayOperating
|
(*SwitchState)(nil), // 3: state.SwitchState
|
||||||
(*SwitchTurnOperating)(nil), // 4: state.SwitchTurnOperating
|
(*SwitchNRRelayOperating)(nil), // 4: state.SwitchNRRelayOperating
|
||||||
(*PhysicalSectionState)(nil), // 5: state.PhysicalSectionState
|
(*SwitchTurnOperating)(nil), // 5: state.SwitchTurnOperating
|
||||||
(*SignalState)(nil), // 6: state.SignalState
|
(*PhysicalSectionState)(nil), // 6: state.PhysicalSectionState
|
||||||
(*SignalDisplayOperating)(nil), // 7: state.SignalDisplayOperating
|
(*SignalState)(nil), // 7: state.SignalState
|
||||||
(*PsdCellState)(nil), // 8: state.PsdCellState
|
(*SignalDisplayOperating)(nil), // 8: state.SignalDisplayOperating
|
||||||
(*PsdState)(nil), // 9: state.PsdState
|
(*PsdCellState)(nil), // 9: state.PsdCellState
|
||||||
(*PsdCellOperating)(nil), // 10: state.PsdCellOperating
|
(*PsdState)(nil), // 10: state.PsdState
|
||||||
(*BaliseState)(nil), // 11: state.BaliseState
|
(*PsdCellOperating)(nil), // 11: state.PsdCellOperating
|
||||||
(*BaliseContent)(nil), // 12: state.BaliseContent
|
(*BaliseState)(nil), // 12: state.BaliseState
|
||||||
(*OccupiedLinkPosition)(nil), // 13: state.OccupiedLinkPosition
|
(*BaliseContent)(nil), // 13: state.BaliseContent
|
||||||
(*TrainState)(nil), // 14: state.TrainState
|
(*OccupiedLinkPosition)(nil), // 14: state.OccupiedLinkPosition
|
||||||
|
(*TrainState)(nil), // 15: state.TrainState
|
||||||
|
(*ButtonState)(nil), // 16: state.ButtonState
|
||||||
|
(*ButtonPressOperating)(nil), // 17: state.ButtonPressOperating
|
||||||
|
(*ButtonConfirmOperating)(nil), // 18: state.ButtonConfirmOperating
|
||||||
}
|
}
|
||||||
var file_status_proto_depIdxs = []int32{
|
var file_status_proto_depIdxs = []int32{
|
||||||
0, // 0: state.SignalState.display:type_name -> state.SignalAspect
|
0, // 0: state.SignalState.display:type_name -> state.SignalAspect
|
||||||
0, // 1: state.SignalDisplayOperating.targetAspect:type_name -> state.SignalAspect
|
0, // 1: state.SignalDisplayOperating.targetAspect:type_name -> state.SignalAspect
|
||||||
12, // 2: state.BaliseState.content:type_name -> state.BaliseContent
|
13, // 2: state.BaliseState.content:type_name -> state.BaliseContent
|
||||||
13, // 3: state.TrainState.occupiedLinks:type_name -> state.OccupiedLinkPosition
|
1, // 3: state.TrainState.activeHead:type_name -> state.TrainActiveEnum
|
||||||
4, // [4:4] is the sub-list for method output_type
|
14, // 4: state.TrainState.occupiedLinks:type_name -> state.OccupiedLinkPosition
|
||||||
4, // [4:4] is the sub-list for method input_type
|
5, // [5:5] is the sub-list for method output_type
|
||||||
4, // [4:4] is the sub-list for extension type_name
|
5, // [5:5] is the sub-list for method input_type
|
||||||
4, // [4:4] is the sub-list for extension extendee
|
5, // [5:5] is the sub-list for extension type_name
|
||||||
0, // [0:4] is the sub-list for field type_name
|
5, // [5:5] is the sub-list for extension extendee
|
||||||
|
0, // [0:5] is the sub-list for field type_name
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() { file_status_proto_init() }
|
func init() { file_status_proto_init() }
|
||||||
@ -1313,14 +1586,50 @@ func file_status_proto_init() {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
file_status_proto_msgTypes[14].Exporter = func(v interface{}, i int) interface{} {
|
||||||
|
switch v := v.(*ButtonState); i {
|
||||||
|
case 0:
|
||||||
|
return &v.state
|
||||||
|
case 1:
|
||||||
|
return &v.sizeCache
|
||||||
|
case 2:
|
||||||
|
return &v.unknownFields
|
||||||
|
default:
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
file_status_proto_msgTypes[15].Exporter = func(v interface{}, i int) interface{} {
|
||||||
|
switch v := v.(*ButtonPressOperating); i {
|
||||||
|
case 0:
|
||||||
|
return &v.state
|
||||||
|
case 1:
|
||||||
|
return &v.sizeCache
|
||||||
|
case 2:
|
||||||
|
return &v.unknownFields
|
||||||
|
default:
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
file_status_proto_msgTypes[16].Exporter = func(v interface{}, i int) interface{} {
|
||||||
|
switch v := v.(*ButtonConfirmOperating); 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_status_proto_rawDesc,
|
RawDescriptor: file_status_proto_rawDesc,
|
||||||
NumEnums: 1,
|
NumEnums: 2,
|
||||||
NumMessages: 14,
|
NumMessages: 17,
|
||||||
NumExtensions: 0,
|
NumExtensions: 0,
|
||||||
NumServices: 0,
|
NumServices: 0,
|
||||||
},
|
},
|
||||||
|
91
system/button_system.go
Normal file
91
system/button_system.go
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
package system
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/yohamta/donburi/filter"
|
||||||
|
"joylink.club/ecs"
|
||||||
|
"joylink.club/rtsssimulation/components"
|
||||||
|
)
|
||||||
|
|
||||||
|
// 按钮系统
|
||||||
|
type ButtonSystem struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
// 按钮组件
|
||||||
|
var btnIdCom, btnStaCom, btnPreOperCom, btnConOperCom = components.ComDeviceIdentity, components.ButtonState, components.ButtonPressOperating, components.ButtonConfirmOperating
|
||||||
|
|
||||||
|
var btnIdOperQuery = ecs.NewQuery(filter.Contains(btnIdCom, btnPreOperCom, btnConOperCom))
|
||||||
|
|
||||||
|
var btnUpdateQuery = ecs.NewQuery(filter.Contains(btnStaCom, btnPreOperCom, btnConOperCom))
|
||||||
|
|
||||||
|
func NewButtonSystem() *ButtonSystem {
|
||||||
|
return &ButtonSystem{}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 按钮操作
|
||||||
|
func PressDownAndUpButton(w ecs.World, btnId string, down bool) bool {
|
||||||
|
buttonEntry := queryButton(w, btnId)
|
||||||
|
if buttonEntry == nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
t, b := getButtonBaseInfo(btnId)
|
||||||
|
preOper := btnPreOperCom.Get(buttonEntry)
|
||||||
|
preOper.Start, preOper.Down, preOper.NeedConfirm, preOper.OperateTime = true, down, b, t
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
// 确认操作
|
||||||
|
func ConfirmButton(w ecs.World, btnId string, confirm bool) bool {
|
||||||
|
buttonEntry := queryButton(w, btnId)
|
||||||
|
if buttonEntry == nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
conOper := btnConOperCom.Get(buttonEntry)
|
||||||
|
conOper.Confirm, conOper.Cancel = confirm, !confirm
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
// 更新按钮状态
|
||||||
|
func (bs *ButtonSystem) Update(w ecs.World) {
|
||||||
|
btnUpdateQuery.Each(w, func(e *ecs.Entry) {
|
||||||
|
btnPreOper := btnPreOperCom.Get(e)
|
||||||
|
if btnPreOper.Start { // 按钮开始操作
|
||||||
|
if btnPreOper.OperateTime <= 0 { // 按钮操作时间大于0
|
||||||
|
btnPreOper.Start, btnPreOper.OperateTime = false, 0
|
||||||
|
} else {
|
||||||
|
btnPreOper.OperateTime -= int64(w.Tick())
|
||||||
|
if btnPreOper.NeedConfirm {
|
||||||
|
conOper := btnConOperCom.Get(e)
|
||||||
|
if conOper.Cancel || conOper.Confirm {
|
||||||
|
if conOper.Confirm {
|
||||||
|
btnSta := btnStaCom.Get(e)
|
||||||
|
btnSta.PressDown = btnPreOper.Down
|
||||||
|
}
|
||||||
|
btnPreOper.Start, btnPreOper.OperateTime = false, 0
|
||||||
|
conOper.Cancel, conOper.Confirm = false, false
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
|
||||||
|
btnSta := btnStaCom.Get(e)
|
||||||
|
btnSta.PressDown = btnPreOper.Down
|
||||||
|
btnPreOper.Start, btnPreOper.OperateTime = false, 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查找按钮
|
||||||
|
func queryButton(w ecs.World, btnId string) *ecs.Entry {
|
||||||
|
var buttonEntry *ecs.Entry = nil
|
||||||
|
btnIdOperQuery.Each(w, func(e *ecs.Entry) {
|
||||||
|
if id := btnIdCom.Get(e).Id; id == btnId {
|
||||||
|
buttonEntry = e
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return buttonEntry
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取按钮设置信息
|
||||||
|
func getButtonBaseInfo(btnId string) (int64, bool) {
|
||||||
|
return 15, false
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user