From ef2744a9ffe68852e05ee9bdca30c71613fc1666 Mon Sep 17 00:00:00 2001 From: Koichi Hirachi Date: Wed, 22 Nov 2023 14:59:52 +0900 Subject: [PATCH 1/9] update proto --- proto/spec/state/v1/train.proto | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/proto/spec/state/v1/train.proto b/proto/spec/state/v1/train.proto index 88ca077f..7562bbfe 100644 --- a/proto/spec/state/v1/train.proto +++ b/proto/spec/state/v1/train.proto @@ -18,12 +18,13 @@ enum Priority { } message Train { - string train_id = 1; // 列車ID(NFCのUUIDと一意に対応している) - string station_id = 2; // 駅のID + string train_id = 1; // 列車ID(NFCのUUIDと一意に対応している) + string position_id = 2; // 駅 or 閉塞のID + Priority priority = 3; // 列車の優先度 } /* - GetTrains : 列車の状態を取得するAPI + GetTrains : 列車の状態を取得するAPI */ message GetTrainsRequest {} @@ -32,11 +33,11 @@ message GetTrainsResponse { } /* - UpdateTrainUUID : NFCのUUID紐付けを更新するAPI + UpdateTrainUUID : NFCのUUID紐付けを更新するAPI */ message UpdateTrainUUIDRequest { - string train_id = 1; // 列車ID - string uuid = 2; // NFCのUUID + string train_id = 1; // 列車ID + string uuid = 2; // NFCのUUID } -message UpdateTrainUUIDResponse{} \ No newline at end of file +message UpdateTrainUUIDResponse {} From 670ed258dcf683daff76e80d0f7383ba4b715bff Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 22 Nov 2023 06:00:58 +0000 Subject: [PATCH 2/9] Commit from GitHub Actions (compile_PB) --- backend/spec/state/v1/train.pb.go | 92 +++++++++++-------- .../dashboard/proto/state/v1/train_pb.d.ts | 13 ++- frontend/dashboard/proto/state/v1/train_pb.js | 3 +- 3 files changed, 64 insertions(+), 44 deletions(-) diff --git a/backend/spec/state/v1/train.pb.go b/backend/spec/state/v1/train.pb.go index 6205fe7b..0ef80d7e 100644 --- a/backend/spec/state/v1/train.pb.go +++ b/backend/spec/state/v1/train.pb.go @@ -79,8 +79,9 @@ type Train struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - TrainId string `protobuf:"bytes,1,opt,name=train_id,json=trainId,proto3" json:"train_id,omitempty"` // 列車ID(NFCのUUIDと一意に対応している) - StationId string `protobuf:"bytes,2,opt,name=station_id,json=stationId,proto3" json:"station_id,omitempty"` // 駅のID + TrainId string `protobuf:"bytes,1,opt,name=train_id,json=trainId,proto3" json:"train_id,omitempty"` // 列車ID(NFCのUUIDと一意に対応している) + PositionId string `protobuf:"bytes,2,opt,name=position_id,json=positionId,proto3" json:"position_id,omitempty"` // 駅 or 閉塞のID + Priority Priority `protobuf:"varint,3,opt,name=priority,proto3,enum=state.v1.Priority" json:"priority,omitempty"` // 列車の優先度 } func (x *Train) Reset() { @@ -122,13 +123,20 @@ func (x *Train) GetTrainId() string { return "" } -func (x *Train) GetStationId() string { +func (x *Train) GetPositionId() string { if x != nil { - return x.StationId + return x.PositionId } return "" } +func (x *Train) GetPriority() Priority { + if x != nil { + return x.Priority + } + return Priority_PRIORITY_UNSPECIFIED +} + // GetTrains : 列車の状態を取得するAPI type GetTrainsRequest struct { state protoimpl.MessageState @@ -316,37 +324,40 @@ var file_state_v1_train_proto_rawDesc = []byte{ 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x08, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x76, 0x31, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x22, 0x41, 0x0a, 0x05, 0x54, 0x72, 0x61, 0x69, 0x6e, 0x12, 0x19, 0x0a, 0x08, 0x74, 0x72, + 0x6f, 0x22, 0x73, 0x0a, 0x05, 0x54, 0x72, 0x61, 0x69, 0x6e, 0x12, 0x19, 0x0a, 0x08, 0x74, 0x72, 0x61, 0x69, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x74, 0x72, - 0x61, 0x69, 0x6e, 0x49, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, - 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x74, 0x61, 0x74, 0x69, - 0x6f, 0x6e, 0x49, 0x64, 0x22, 0x12, 0x0a, 0x10, 0x47, 0x65, 0x74, 0x54, 0x72, 0x61, 0x69, 0x6e, - 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x3c, 0x0a, 0x11, 0x47, 0x65, 0x74, 0x54, - 0x72, 0x61, 0x69, 0x6e, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x27, 0x0a, - 0x06, 0x74, 0x72, 0x61, 0x69, 0x6e, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0f, 0x2e, - 0x73, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x72, 0x61, 0x69, 0x6e, 0x52, 0x06, - 0x74, 0x72, 0x61, 0x69, 0x6e, 0x73, 0x22, 0x47, 0x0a, 0x16, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, - 0x54, 0x72, 0x61, 0x69, 0x6e, 0x55, 0x55, 0x49, 0x44, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x12, 0x19, 0x0a, 0x08, 0x74, 0x72, 0x61, 0x69, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x07, 0x74, 0x72, 0x61, 0x69, 0x6e, 0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x75, - 0x75, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x75, 0x75, 0x69, 0x64, 0x22, - 0x19, 0x0a, 0x17, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x54, 0x72, 0x61, 0x69, 0x6e, 0x55, 0x55, - 0x49, 0x44, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2a, 0x49, 0x0a, 0x08, 0x50, 0x72, - 0x69, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x12, 0x18, 0x0a, 0x14, 0x50, 0x52, 0x49, 0x4f, 0x52, 0x49, - 0x54, 0x59, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, - 0x12, 0x10, 0x0a, 0x0c, 0x50, 0x52, 0x49, 0x4f, 0x52, 0x49, 0x54, 0x59, 0x5f, 0x4c, 0x4f, 0x57, - 0x10, 0x01, 0x12, 0x11, 0x0a, 0x0d, 0x50, 0x52, 0x49, 0x4f, 0x52, 0x49, 0x54, 0x59, 0x5f, 0x48, - 0x49, 0x47, 0x48, 0x10, 0x02, 0x42, 0x9a, 0x01, 0x0a, 0x0c, 0x63, 0x6f, 0x6d, 0x2e, 0x73, 0x74, - 0x61, 0x74, 0x65, 0x2e, 0x76, 0x31, 0x42, 0x0a, 0x54, 0x72, 0x61, 0x69, 0x6e, 0x50, 0x72, 0x6f, - 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x3d, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, - 0x2f, 0x75, 0x65, 0x63, 0x6b, 0x6f, 0x6b, 0x65, 0x6e, 0x2f, 0x70, 0x6c, 0x61, 0x72, 0x61, 0x69, - 0x6c, 0x32, 0x30, 0x32, 0x33, 0x2f, 0x62, 0x61, 0x63, 0x6b, 0x65, 0x6e, 0x64, 0x2f, 0x73, 0x70, - 0x65, 0x63, 0x2f, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2f, 0x76, 0x31, 0x3b, 0x73, 0x74, 0x61, 0x74, - 0x65, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x53, 0x58, 0x58, 0xaa, 0x02, 0x08, 0x53, 0x74, 0x61, 0x74, - 0x65, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x08, 0x53, 0x74, 0x61, 0x74, 0x65, 0x5c, 0x56, 0x31, 0xe2, - 0x02, 0x14, 0x53, 0x74, 0x61, 0x74, 0x65, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, - 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x09, 0x53, 0x74, 0x61, 0x74, 0x65, 0x3a, 0x3a, - 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x61, 0x69, 0x6e, 0x49, 0x64, 0x12, 0x1f, 0x0a, 0x0b, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, + 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x70, 0x6f, 0x73, 0x69, + 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x2e, 0x0a, 0x08, 0x70, 0x72, 0x69, 0x6f, 0x72, 0x69, + 0x74, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x12, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x65, + 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x72, 0x69, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x52, 0x08, 0x70, 0x72, + 0x69, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x22, 0x12, 0x0a, 0x10, 0x47, 0x65, 0x74, 0x54, 0x72, 0x61, + 0x69, 0x6e, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x3c, 0x0a, 0x11, 0x47, 0x65, + 0x74, 0x54, 0x72, 0x61, 0x69, 0x6e, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, + 0x27, 0x0a, 0x06, 0x74, 0x72, 0x61, 0x69, 0x6e, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, + 0x0f, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x72, 0x61, 0x69, 0x6e, + 0x52, 0x06, 0x74, 0x72, 0x61, 0x69, 0x6e, 0x73, 0x22, 0x47, 0x0a, 0x16, 0x55, 0x70, 0x64, 0x61, + 0x74, 0x65, 0x54, 0x72, 0x61, 0x69, 0x6e, 0x55, 0x55, 0x49, 0x44, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x12, 0x19, 0x0a, 0x08, 0x74, 0x72, 0x61, 0x69, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x74, 0x72, 0x61, 0x69, 0x6e, 0x49, 0x64, 0x12, 0x12, 0x0a, + 0x04, 0x75, 0x75, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x75, 0x75, 0x69, + 0x64, 0x22, 0x19, 0x0a, 0x17, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x54, 0x72, 0x61, 0x69, 0x6e, + 0x55, 0x55, 0x49, 0x44, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2a, 0x49, 0x0a, 0x08, + 0x50, 0x72, 0x69, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x12, 0x18, 0x0a, 0x14, 0x50, 0x52, 0x49, 0x4f, + 0x52, 0x49, 0x54, 0x59, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, + 0x10, 0x00, 0x12, 0x10, 0x0a, 0x0c, 0x50, 0x52, 0x49, 0x4f, 0x52, 0x49, 0x54, 0x59, 0x5f, 0x4c, + 0x4f, 0x57, 0x10, 0x01, 0x12, 0x11, 0x0a, 0x0d, 0x50, 0x52, 0x49, 0x4f, 0x52, 0x49, 0x54, 0x59, + 0x5f, 0x48, 0x49, 0x47, 0x48, 0x10, 0x02, 0x42, 0x9a, 0x01, 0x0a, 0x0c, 0x63, 0x6f, 0x6d, 0x2e, + 0x73, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x76, 0x31, 0x42, 0x0a, 0x54, 0x72, 0x61, 0x69, 0x6e, 0x50, + 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x3d, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, + 0x6f, 0x6d, 0x2f, 0x75, 0x65, 0x63, 0x6b, 0x6f, 0x6b, 0x65, 0x6e, 0x2f, 0x70, 0x6c, 0x61, 0x72, + 0x61, 0x69, 0x6c, 0x32, 0x30, 0x32, 0x33, 0x2f, 0x62, 0x61, 0x63, 0x6b, 0x65, 0x6e, 0x64, 0x2f, + 0x73, 0x70, 0x65, 0x63, 0x2f, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2f, 0x76, 0x31, 0x3b, 0x73, 0x74, + 0x61, 0x74, 0x65, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x53, 0x58, 0x58, 0xaa, 0x02, 0x08, 0x53, 0x74, + 0x61, 0x74, 0x65, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x08, 0x53, 0x74, 0x61, 0x74, 0x65, 0x5c, 0x56, + 0x31, 0xe2, 0x02, 0x14, 0x53, 0x74, 0x61, 0x74, 0x65, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, + 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x09, 0x53, 0x74, 0x61, 0x74, 0x65, + 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -372,12 +383,13 @@ var file_state_v1_train_proto_goTypes = []interface{}{ (*UpdateTrainUUIDResponse)(nil), // 5: state.v1.UpdateTrainUUIDResponse } var file_state_v1_train_proto_depIdxs = []int32{ - 1, // 0: state.v1.GetTrainsResponse.trains:type_name -> state.v1.Train - 1, // [1:1] is the sub-list for method output_type - 1, // [1:1] is the sub-list for method input_type - 1, // [1:1] is the sub-list for extension type_name - 1, // [1:1] is the sub-list for extension extendee - 0, // [0:1] is the sub-list for field type_name + 0, // 0: state.v1.Train.priority:type_name -> state.v1.Priority + 1, // 1: state.v1.GetTrainsResponse.trains:type_name -> state.v1.Train + 2, // [2:2] is the sub-list for method output_type + 2, // [2:2] is the sub-list for method input_type + 2, // [2:2] is the sub-list for extension type_name + 2, // [2:2] is the sub-list for extension extendee + 0, // [0:2] is the sub-list for field type_name } func init() { file_state_v1_train_proto_init() } diff --git a/frontend/dashboard/proto/state/v1/train_pb.d.ts b/frontend/dashboard/proto/state/v1/train_pb.d.ts index 19040853..67cf89ea 100644 --- a/frontend/dashboard/proto/state/v1/train_pb.d.ts +++ b/frontend/dashboard/proto/state/v1/train_pb.d.ts @@ -42,11 +42,18 @@ export declare class Train extends Message { trainId: string; /** - * 駅のID + * 駅 or 閉塞のID * - * @generated from field: string station_id = 2; + * @generated from field: string position_id = 2; */ - stationId: string; + positionId: string; + + /** + * 列車の優先度 + * + * @generated from field: state.v1.Priority priority = 3; + */ + priority: Priority; constructor(data?: PartialMessage); diff --git a/frontend/dashboard/proto/state/v1/train_pb.js b/frontend/dashboard/proto/state/v1/train_pb.js index d284bf40..76a6be31 100644 --- a/frontend/dashboard/proto/state/v1/train_pb.js +++ b/frontend/dashboard/proto/state/v1/train_pb.js @@ -28,7 +28,8 @@ export const Train = proto3.makeMessageType( "state.v1.Train", () => [ { no: 1, name: "train_id", kind: "scalar", T: 9 /* ScalarType.STRING */ }, - { no: 2, name: "station_id", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 2, name: "position_id", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 3, name: "priority", kind: "enum", T: proto3.getEnumType(Priority) }, ], ); From b129ed932ba24d3386331ff01788e1dcdcbd3c98 Mon Sep 17 00:00:00 2001 From: Koichi Hirachi Date: Wed, 22 Nov 2023 21:21:10 +0900 Subject: [PATCH 3/9] update proto --- proto/spec/state/v1/state.proto | 9 +++++---- proto/spec/state/v1/train.proto | 28 ++++++++++++++++++++++++---- 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/proto/spec/state/v1/state.proto b/proto/spec/state/v1/state.proto index 1bdb07fe..e7fbe9f7 100644 --- a/proto/spec/state/v1/state.proto +++ b/proto/spec/state/v1/state.proto @@ -8,8 +8,8 @@ import "state/v1/stop.proto"; import "state/v1/train.proto"; /* - StateManagerが提供するサービス - AutoOperationとフロントエンド間の通信に利用される + StateManagerが提供するサービス + AutoOperationとフロントエンド間の通信に利用される */ service StateManagerService { /* Block */ @@ -23,5 +23,6 @@ service StateManagerService { rpc GetStopStates(GetStopStatesRequest) returns (GetStopStatesResponse); /* Train */ rpc GetTrains(GetTrainsRequest) returns (GetTrainsResponse); - rpc UpdateTrainUUID(UpdateTrainUUIDRequest) returns (UpdateTrainUUIDResponse); -} \ No newline at end of file + rpc AddTrain(AddTrainRequest) returns (AddTrainResponse); + rpc UpdateTrain(UpdateTrainRequest) returns (UpdateTrainResponse); +} diff --git a/proto/spec/state/v1/train.proto b/proto/spec/state/v1/train.proto index 7562bbfe..11c79919 100644 --- a/proto/spec/state/v1/train.proto +++ b/proto/spec/state/v1/train.proto @@ -21,6 +21,7 @@ message Train { string train_id = 1; // 列車ID(NFCのUUIDと一意に対応している) string position_id = 2; // 駅 or 閉塞のID Priority priority = 3; // 列車の優先度 + string uuid = 4; // NFCのUUID } /* @@ -33,11 +34,30 @@ message GetTrainsResponse { } /* - UpdateTrainUUID : NFCのUUID紐付けを更新するAPI + Add Train : 列車を追加するAPI */ -message UpdateTrainUUIDRequest { +message AddTrainRequest { string train_id = 1; // 列車ID - string uuid = 2; // NFCのUUID + string position_id = 2; // 駅 or 閉塞のID + Priority priority = 3; // 列車の優先度 + string uuid = 4; // NFCのUUID +} + +message AddTrainResponse { + Train train = 1; } -message UpdateTrainUUIDResponse {} +/* + Update Train: 列車の情報を更新するAPI +*/ + +message UpdateTrainRequest { + string train_id = 1; // 列車ID + string position_id = 2; // 駅 or 閉塞のID + Priority priority = 3; // 列車の優先度 + string uuid = 4; // NFCのUUID +} + +message UpdateTrainResponse { + Train train = 1; +} From 58cd0d88e39309bd6292a5c555e9eb0356edd403 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 22 Nov 2023 12:22:09 +0000 Subject: [PATCH 4/9] Commit from GitHub Actions (compile_PB) --- backend/spec/state/v1/state.pb.go | 82 +++-- .../state/v1/statev1connect/state.connect.go | 63 +++- backend/spec/state/v1/train.pb.go | 343 ++++++++++++++---- .../proto/state/v1/state_connectweb.d.ts | 21 +- .../proto/state/v1/state_connectweb.js | 21 +- .../dashboard/proto/state/v1/train_pb.d.ts | 133 ++++++- frontend/dashboard/proto/state/v1/train_pb.js | 46 ++- 7 files changed, 545 insertions(+), 164 deletions(-) diff --git a/backend/spec/state/v1/state.pb.go b/backend/spec/state/v1/state.pb.go index 08ceb37e..ab887c4d 100644 --- a/backend/spec/state/v1/state.pb.go +++ b/backend/spec/state/v1/state.pb.go @@ -29,7 +29,7 @@ var file_state_v1_state_proto_rawDesc = []byte{ 0x2f, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x13, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2f, 0x76, 0x31, 0x2f, 0x73, 0x74, 0x6f, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x14, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2f, 0x76, 0x31, 0x2f, 0x74, 0x72, 0x61, 0x69, - 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x32, 0xbd, 0x05, 0x0a, 0x13, 0x53, 0x74, 0x61, 0x74, + 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x32, 0xf4, 0x05, 0x0a, 0x13, 0x53, 0x74, 0x61, 0x74, 0x65, 0x4d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x53, 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x53, 0x74, 0x61, 0x74, 0x65, 0x73, 0x12, 0x1f, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, @@ -68,22 +68,26 @@ var file_state_v1_state_proto_rawDesc = []byte{ 0x31, 0x2e, 0x47, 0x65, 0x74, 0x54, 0x72, 0x61, 0x69, 0x6e, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1b, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x54, 0x72, 0x61, 0x69, 0x6e, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, - 0x56, 0x0a, 0x0f, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x54, 0x72, 0x61, 0x69, 0x6e, 0x55, 0x55, - 0x49, 0x44, 0x12, 0x20, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x70, - 0x64, 0x61, 0x74, 0x65, 0x54, 0x72, 0x61, 0x69, 0x6e, 0x55, 0x55, 0x49, 0x44, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x1a, 0x21, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x76, 0x31, 0x2e, - 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x54, 0x72, 0x61, 0x69, 0x6e, 0x55, 0x55, 0x49, 0x44, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x9a, 0x01, 0x0a, 0x0c, 0x63, 0x6f, 0x6d, 0x2e, - 0x73, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x76, 0x31, 0x42, 0x0a, 0x53, 0x74, 0x61, 0x74, 0x65, 0x50, - 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x3d, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, - 0x6f, 0x6d, 0x2f, 0x75, 0x65, 0x63, 0x6b, 0x6f, 0x6b, 0x65, 0x6e, 0x2f, 0x70, 0x6c, 0x61, 0x72, - 0x61, 0x69, 0x6c, 0x32, 0x30, 0x32, 0x33, 0x2f, 0x62, 0x61, 0x63, 0x6b, 0x65, 0x6e, 0x64, 0x2f, - 0x73, 0x70, 0x65, 0x63, 0x2f, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2f, 0x76, 0x31, 0x3b, 0x73, 0x74, - 0x61, 0x74, 0x65, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x53, 0x58, 0x58, 0xaa, 0x02, 0x08, 0x53, 0x74, - 0x61, 0x74, 0x65, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x08, 0x53, 0x74, 0x61, 0x74, 0x65, 0x5c, 0x56, - 0x31, 0xe2, 0x02, 0x14, 0x53, 0x74, 0x61, 0x74, 0x65, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, - 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x09, 0x53, 0x74, 0x61, 0x74, 0x65, - 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x41, 0x0a, 0x08, 0x41, 0x64, 0x64, 0x54, 0x72, 0x61, 0x69, 0x6e, 0x12, 0x19, 0x2e, 0x73, 0x74, + 0x61, 0x74, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x41, 0x64, 0x64, 0x54, 0x72, 0x61, 0x69, 0x6e, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x76, + 0x31, 0x2e, 0x41, 0x64, 0x64, 0x54, 0x72, 0x61, 0x69, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x12, 0x4a, 0x0a, 0x0b, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x54, 0x72, 0x61, 0x69, + 0x6e, 0x12, 0x1c, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x70, 0x64, + 0x61, 0x74, 0x65, 0x54, 0x72, 0x61, 0x69, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, + 0x1d, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, + 0x65, 0x54, 0x72, 0x61, 0x69, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x9a, + 0x01, 0x0a, 0x0c, 0x63, 0x6f, 0x6d, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x76, 0x31, 0x42, + 0x0a, 0x53, 0x74, 0x61, 0x74, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x3d, 0x67, + 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x75, 0x65, 0x63, 0x6b, 0x6f, 0x6b, + 0x65, 0x6e, 0x2f, 0x70, 0x6c, 0x61, 0x72, 0x61, 0x69, 0x6c, 0x32, 0x30, 0x32, 0x33, 0x2f, 0x62, + 0x61, 0x63, 0x6b, 0x65, 0x6e, 0x64, 0x2f, 0x73, 0x70, 0x65, 0x63, 0x2f, 0x73, 0x74, 0x61, 0x74, + 0x65, 0x2f, 0x76, 0x31, 0x3b, 0x73, 0x74, 0x61, 0x74, 0x65, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x53, + 0x58, 0x58, 0xaa, 0x02, 0x08, 0x53, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x08, + 0x53, 0x74, 0x61, 0x74, 0x65, 0x5c, 0x56, 0x31, 0xe2, 0x02, 0x14, 0x53, 0x74, 0x61, 0x74, 0x65, + 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, + 0x02, 0x09, 0x53, 0x74, 0x61, 0x74, 0x65, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x33, } var file_state_v1_state_proto_goTypes = []interface{}{ @@ -94,15 +98,17 @@ var file_state_v1_state_proto_goTypes = []interface{}{ (*UpdateStopStateRequest)(nil), // 4: state.v1.UpdateStopStateRequest (*GetStopStatesRequest)(nil), // 5: state.v1.GetStopStatesRequest (*GetTrainsRequest)(nil), // 6: state.v1.GetTrainsRequest - (*UpdateTrainUUIDRequest)(nil), // 7: state.v1.UpdateTrainUUIDRequest - (*GetBlockStatesResponse)(nil), // 8: state.v1.GetBlockStatesResponse - (*UpdateBlockStateResponse)(nil), // 9: state.v1.UpdateBlockStateResponse - (*UpdatePointStateResponse)(nil), // 10: state.v1.UpdatePointStateResponse - (*GetPointStatesResponse)(nil), // 11: state.v1.GetPointStatesResponse - (*UpdateStopStateResponse)(nil), // 12: state.v1.UpdateStopStateResponse - (*GetStopStatesResponse)(nil), // 13: state.v1.GetStopStatesResponse - (*GetTrainsResponse)(nil), // 14: state.v1.GetTrainsResponse - (*UpdateTrainUUIDResponse)(nil), // 15: state.v1.UpdateTrainUUIDResponse + (*AddTrainRequest)(nil), // 7: state.v1.AddTrainRequest + (*UpdateTrainRequest)(nil), // 8: state.v1.UpdateTrainRequest + (*GetBlockStatesResponse)(nil), // 9: state.v1.GetBlockStatesResponse + (*UpdateBlockStateResponse)(nil), // 10: state.v1.UpdateBlockStateResponse + (*UpdatePointStateResponse)(nil), // 11: state.v1.UpdatePointStateResponse + (*GetPointStatesResponse)(nil), // 12: state.v1.GetPointStatesResponse + (*UpdateStopStateResponse)(nil), // 13: state.v1.UpdateStopStateResponse + (*GetStopStatesResponse)(nil), // 14: state.v1.GetStopStatesResponse + (*GetTrainsResponse)(nil), // 15: state.v1.GetTrainsResponse + (*AddTrainResponse)(nil), // 16: state.v1.AddTrainResponse + (*UpdateTrainResponse)(nil), // 17: state.v1.UpdateTrainResponse } var file_state_v1_state_proto_depIdxs = []int32{ 0, // 0: state.v1.StateManagerService.GetBlockStates:input_type -> state.v1.GetBlockStatesRequest @@ -112,17 +118,19 @@ var file_state_v1_state_proto_depIdxs = []int32{ 4, // 4: state.v1.StateManagerService.UpdateStopState:input_type -> state.v1.UpdateStopStateRequest 5, // 5: state.v1.StateManagerService.GetStopStates:input_type -> state.v1.GetStopStatesRequest 6, // 6: state.v1.StateManagerService.GetTrains:input_type -> state.v1.GetTrainsRequest - 7, // 7: state.v1.StateManagerService.UpdateTrainUUID:input_type -> state.v1.UpdateTrainUUIDRequest - 8, // 8: state.v1.StateManagerService.GetBlockStates:output_type -> state.v1.GetBlockStatesResponse - 9, // 9: state.v1.StateManagerService.UpdateBlockState:output_type -> state.v1.UpdateBlockStateResponse - 10, // 10: state.v1.StateManagerService.UpdatePointState:output_type -> state.v1.UpdatePointStateResponse - 11, // 11: state.v1.StateManagerService.GetPointStates:output_type -> state.v1.GetPointStatesResponse - 12, // 12: state.v1.StateManagerService.UpdateStopState:output_type -> state.v1.UpdateStopStateResponse - 13, // 13: state.v1.StateManagerService.GetStopStates:output_type -> state.v1.GetStopStatesResponse - 14, // 14: state.v1.StateManagerService.GetTrains:output_type -> state.v1.GetTrainsResponse - 15, // 15: state.v1.StateManagerService.UpdateTrainUUID:output_type -> state.v1.UpdateTrainUUIDResponse - 8, // [8:16] is the sub-list for method output_type - 0, // [0:8] is the sub-list for method input_type + 7, // 7: state.v1.StateManagerService.AddTrain:input_type -> state.v1.AddTrainRequest + 8, // 8: state.v1.StateManagerService.UpdateTrain:input_type -> state.v1.UpdateTrainRequest + 9, // 9: state.v1.StateManagerService.GetBlockStates:output_type -> state.v1.GetBlockStatesResponse + 10, // 10: state.v1.StateManagerService.UpdateBlockState:output_type -> state.v1.UpdateBlockStateResponse + 11, // 11: state.v1.StateManagerService.UpdatePointState:output_type -> state.v1.UpdatePointStateResponse + 12, // 12: state.v1.StateManagerService.GetPointStates:output_type -> state.v1.GetPointStatesResponse + 13, // 13: state.v1.StateManagerService.UpdateStopState:output_type -> state.v1.UpdateStopStateResponse + 14, // 14: state.v1.StateManagerService.GetStopStates:output_type -> state.v1.GetStopStatesResponse + 15, // 15: state.v1.StateManagerService.GetTrains:output_type -> state.v1.GetTrainsResponse + 16, // 16: state.v1.StateManagerService.AddTrain:output_type -> state.v1.AddTrainResponse + 17, // 17: state.v1.StateManagerService.UpdateTrain:output_type -> state.v1.UpdateTrainResponse + 9, // [9:18] is the sub-list for method output_type + 0, // [0:9] is the sub-list for method input_type 0, // [0:0] is the sub-list for extension type_name 0, // [0:0] is the sub-list for extension extendee 0, // [0:0] is the sub-list for field type_name diff --git a/backend/spec/state/v1/statev1connect/state.connect.go b/backend/spec/state/v1/statev1connect/state.connect.go index 9f93f21b..fba2f969 100644 --- a/backend/spec/state/v1/statev1connect/state.connect.go +++ b/backend/spec/state/v1/statev1connect/state.connect.go @@ -54,9 +54,12 @@ const ( // StateManagerServiceGetTrainsProcedure is the fully-qualified name of the StateManagerService's // GetTrains RPC. StateManagerServiceGetTrainsProcedure = "/state.v1.StateManagerService/GetTrains" - // StateManagerServiceUpdateTrainUUIDProcedure is the fully-qualified name of the - // StateManagerService's UpdateTrainUUID RPC. - StateManagerServiceUpdateTrainUUIDProcedure = "/state.v1.StateManagerService/UpdateTrainUUID" + // StateManagerServiceAddTrainProcedure is the fully-qualified name of the StateManagerService's + // AddTrain RPC. + StateManagerServiceAddTrainProcedure = "/state.v1.StateManagerService/AddTrain" + // StateManagerServiceUpdateTrainProcedure is the fully-qualified name of the StateManagerService's + // UpdateTrain RPC. + StateManagerServiceUpdateTrainProcedure = "/state.v1.StateManagerService/UpdateTrain" ) // StateManagerServiceClient is a client for the state.v1.StateManagerService service. @@ -72,7 +75,8 @@ type StateManagerServiceClient interface { GetStopStates(context.Context, *connect.Request[v1.GetStopStatesRequest]) (*connect.Response[v1.GetStopStatesResponse], error) // Train GetTrains(context.Context, *connect.Request[v1.GetTrainsRequest]) (*connect.Response[v1.GetTrainsResponse], error) - UpdateTrainUUID(context.Context, *connect.Request[v1.UpdateTrainUUIDRequest]) (*connect.Response[v1.UpdateTrainUUIDResponse], error) + AddTrain(context.Context, *connect.Request[v1.AddTrainRequest]) (*connect.Response[v1.AddTrainResponse], error) + UpdateTrain(context.Context, *connect.Request[v1.UpdateTrainRequest]) (*connect.Response[v1.UpdateTrainResponse], error) } // NewStateManagerServiceClient constructs a client for the state.v1.StateManagerService service. By @@ -120,9 +124,14 @@ func NewStateManagerServiceClient(httpClient connect.HTTPClient, baseURL string, baseURL+StateManagerServiceGetTrainsProcedure, opts..., ), - updateTrainUUID: connect.NewClient[v1.UpdateTrainUUIDRequest, v1.UpdateTrainUUIDResponse]( + addTrain: connect.NewClient[v1.AddTrainRequest, v1.AddTrainResponse]( httpClient, - baseURL+StateManagerServiceUpdateTrainUUIDProcedure, + baseURL+StateManagerServiceAddTrainProcedure, + opts..., + ), + updateTrain: connect.NewClient[v1.UpdateTrainRequest, v1.UpdateTrainResponse]( + httpClient, + baseURL+StateManagerServiceUpdateTrainProcedure, opts..., ), } @@ -137,7 +146,8 @@ type stateManagerServiceClient struct { updateStopState *connect.Client[v1.UpdateStopStateRequest, v1.UpdateStopStateResponse] getStopStates *connect.Client[v1.GetStopStatesRequest, v1.GetStopStatesResponse] getTrains *connect.Client[v1.GetTrainsRequest, v1.GetTrainsResponse] - updateTrainUUID *connect.Client[v1.UpdateTrainUUIDRequest, v1.UpdateTrainUUIDResponse] + addTrain *connect.Client[v1.AddTrainRequest, v1.AddTrainResponse] + updateTrain *connect.Client[v1.UpdateTrainRequest, v1.UpdateTrainResponse] } // GetBlockStates calls state.v1.StateManagerService.GetBlockStates. @@ -175,9 +185,14 @@ func (c *stateManagerServiceClient) GetTrains(ctx context.Context, req *connect. return c.getTrains.CallUnary(ctx, req) } -// UpdateTrainUUID calls state.v1.StateManagerService.UpdateTrainUUID. -func (c *stateManagerServiceClient) UpdateTrainUUID(ctx context.Context, req *connect.Request[v1.UpdateTrainUUIDRequest]) (*connect.Response[v1.UpdateTrainUUIDResponse], error) { - return c.updateTrainUUID.CallUnary(ctx, req) +// AddTrain calls state.v1.StateManagerService.AddTrain. +func (c *stateManagerServiceClient) AddTrain(ctx context.Context, req *connect.Request[v1.AddTrainRequest]) (*connect.Response[v1.AddTrainResponse], error) { + return c.addTrain.CallUnary(ctx, req) +} + +// UpdateTrain calls state.v1.StateManagerService.UpdateTrain. +func (c *stateManagerServiceClient) UpdateTrain(ctx context.Context, req *connect.Request[v1.UpdateTrainRequest]) (*connect.Response[v1.UpdateTrainResponse], error) { + return c.updateTrain.CallUnary(ctx, req) } // StateManagerServiceHandler is an implementation of the state.v1.StateManagerService service. @@ -193,7 +208,8 @@ type StateManagerServiceHandler interface { GetStopStates(context.Context, *connect.Request[v1.GetStopStatesRequest]) (*connect.Response[v1.GetStopStatesResponse], error) // Train GetTrains(context.Context, *connect.Request[v1.GetTrainsRequest]) (*connect.Response[v1.GetTrainsResponse], error) - UpdateTrainUUID(context.Context, *connect.Request[v1.UpdateTrainUUIDRequest]) (*connect.Response[v1.UpdateTrainUUIDResponse], error) + AddTrain(context.Context, *connect.Request[v1.AddTrainRequest]) (*connect.Response[v1.AddTrainResponse], error) + UpdateTrain(context.Context, *connect.Request[v1.UpdateTrainRequest]) (*connect.Response[v1.UpdateTrainResponse], error) } // NewStateManagerServiceHandler builds an HTTP handler from the service implementation. It returns @@ -237,9 +253,14 @@ func NewStateManagerServiceHandler(svc StateManagerServiceHandler, opts ...conne svc.GetTrains, opts..., ) - stateManagerServiceUpdateTrainUUIDHandler := connect.NewUnaryHandler( - StateManagerServiceUpdateTrainUUIDProcedure, - svc.UpdateTrainUUID, + stateManagerServiceAddTrainHandler := connect.NewUnaryHandler( + StateManagerServiceAddTrainProcedure, + svc.AddTrain, + opts..., + ) + stateManagerServiceUpdateTrainHandler := connect.NewUnaryHandler( + StateManagerServiceUpdateTrainProcedure, + svc.UpdateTrain, opts..., ) return "/state.v1.StateManagerService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { @@ -258,8 +279,10 @@ func NewStateManagerServiceHandler(svc StateManagerServiceHandler, opts ...conne stateManagerServiceGetStopStatesHandler.ServeHTTP(w, r) case StateManagerServiceGetTrainsProcedure: stateManagerServiceGetTrainsHandler.ServeHTTP(w, r) - case StateManagerServiceUpdateTrainUUIDProcedure: - stateManagerServiceUpdateTrainUUIDHandler.ServeHTTP(w, r) + case StateManagerServiceAddTrainProcedure: + stateManagerServiceAddTrainHandler.ServeHTTP(w, r) + case StateManagerServiceUpdateTrainProcedure: + stateManagerServiceUpdateTrainHandler.ServeHTTP(w, r) default: http.NotFound(w, r) } @@ -297,6 +320,10 @@ func (UnimplementedStateManagerServiceHandler) GetTrains(context.Context, *conne return nil, connect.NewError(connect.CodeUnimplemented, errors.New("state.v1.StateManagerService.GetTrains is not implemented")) } -func (UnimplementedStateManagerServiceHandler) UpdateTrainUUID(context.Context, *connect.Request[v1.UpdateTrainUUIDRequest]) (*connect.Response[v1.UpdateTrainUUIDResponse], error) { - return nil, connect.NewError(connect.CodeUnimplemented, errors.New("state.v1.StateManagerService.UpdateTrainUUID is not implemented")) +func (UnimplementedStateManagerServiceHandler) AddTrain(context.Context, *connect.Request[v1.AddTrainRequest]) (*connect.Response[v1.AddTrainResponse], error) { + return nil, connect.NewError(connect.CodeUnimplemented, errors.New("state.v1.StateManagerService.AddTrain is not implemented")) +} + +func (UnimplementedStateManagerServiceHandler) UpdateTrain(context.Context, *connect.Request[v1.UpdateTrainRequest]) (*connect.Response[v1.UpdateTrainResponse], error) { + return nil, connect.NewError(connect.CodeUnimplemented, errors.New("state.v1.StateManagerService.UpdateTrain is not implemented")) } diff --git a/backend/spec/state/v1/train.pb.go b/backend/spec/state/v1/train.pb.go index 0ef80d7e..aade3ed7 100644 --- a/backend/spec/state/v1/train.pb.go +++ b/backend/spec/state/v1/train.pb.go @@ -82,6 +82,7 @@ type Train struct { TrainId string `protobuf:"bytes,1,opt,name=train_id,json=trainId,proto3" json:"train_id,omitempty"` // 列車ID(NFCのUUIDと一意に対応している) PositionId string `protobuf:"bytes,2,opt,name=position_id,json=positionId,proto3" json:"position_id,omitempty"` // 駅 or 閉塞のID Priority Priority `protobuf:"varint,3,opt,name=priority,proto3,enum=state.v1.Priority" json:"priority,omitempty"` // 列車の優先度 + Uuid string `protobuf:"bytes,4,opt,name=uuid,proto3" json:"uuid,omitempty"` // NFCのUUID } func (x *Train) Reset() { @@ -137,6 +138,13 @@ func (x *Train) GetPriority() Priority { return Priority_PRIORITY_UNSPECIFIED } +func (x *Train) GetUuid() string { + if x != nil { + return x.Uuid + } + return "" +} + // GetTrains : 列車の状態を取得するAPI type GetTrainsRequest struct { state protoimpl.MessageState @@ -223,18 +231,20 @@ func (x *GetTrainsResponse) GetTrains() []*Train { return nil } -// UpdateTrainUUID : NFCのUUID紐付けを更新するAPI -type UpdateTrainUUIDRequest struct { +// Add Train : 列車を追加するAPI +type AddTrainRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - TrainId string `protobuf:"bytes,1,opt,name=train_id,json=trainId,proto3" json:"train_id,omitempty"` // 列車ID - Uuid string `protobuf:"bytes,2,opt,name=uuid,proto3" json:"uuid,omitempty"` // NFCのUUID + TrainId string `protobuf:"bytes,1,opt,name=train_id,json=trainId,proto3" json:"train_id,omitempty"` // 列車ID + PositionId string `protobuf:"bytes,2,opt,name=position_id,json=positionId,proto3" json:"position_id,omitempty"` // 駅 or 閉塞のID + Priority Priority `protobuf:"varint,3,opt,name=priority,proto3,enum=state.v1.Priority" json:"priority,omitempty"` // 列車の優先度 + Uuid string `protobuf:"bytes,4,opt,name=uuid,proto3" json:"uuid,omitempty"` // NFCのUUID } -func (x *UpdateTrainUUIDRequest) Reset() { - *x = UpdateTrainUUIDRequest{} +func (x *AddTrainRequest) Reset() { + *x = AddTrainRequest{} if protoimpl.UnsafeEnabled { mi := &file_state_v1_train_proto_msgTypes[3] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -242,13 +252,13 @@ func (x *UpdateTrainUUIDRequest) Reset() { } } -func (x *UpdateTrainUUIDRequest) String() string { +func (x *AddTrainRequest) String() string { return protoimpl.X.MessageStringOf(x) } -func (*UpdateTrainUUIDRequest) ProtoMessage() {} +func (*AddTrainRequest) ProtoMessage() {} -func (x *UpdateTrainUUIDRequest) ProtoReflect() protoreflect.Message { +func (x *AddTrainRequest) ProtoReflect() protoreflect.Message { mi := &file_state_v1_train_proto_msgTypes[3] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -260,33 +270,49 @@ func (x *UpdateTrainUUIDRequest) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use UpdateTrainUUIDRequest.ProtoReflect.Descriptor instead. -func (*UpdateTrainUUIDRequest) Descriptor() ([]byte, []int) { +// Deprecated: Use AddTrainRequest.ProtoReflect.Descriptor instead. +func (*AddTrainRequest) Descriptor() ([]byte, []int) { return file_state_v1_train_proto_rawDescGZIP(), []int{3} } -func (x *UpdateTrainUUIDRequest) GetTrainId() string { +func (x *AddTrainRequest) GetTrainId() string { if x != nil { return x.TrainId } return "" } -func (x *UpdateTrainUUIDRequest) GetUuid() string { +func (x *AddTrainRequest) GetPositionId() string { + if x != nil { + return x.PositionId + } + return "" +} + +func (x *AddTrainRequest) GetPriority() Priority { + if x != nil { + return x.Priority + } + return Priority_PRIORITY_UNSPECIFIED +} + +func (x *AddTrainRequest) GetUuid() string { if x != nil { return x.Uuid } return "" } -type UpdateTrainUUIDResponse struct { +type AddTrainResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields + + Train *Train `protobuf:"bytes,1,opt,name=train,proto3" json:"train,omitempty"` } -func (x *UpdateTrainUUIDResponse) Reset() { - *x = UpdateTrainUUIDResponse{} +func (x *AddTrainResponse) Reset() { + *x = AddTrainResponse{} if protoimpl.UnsafeEnabled { mi := &file_state_v1_train_proto_msgTypes[4] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -294,13 +320,13 @@ func (x *UpdateTrainUUIDResponse) Reset() { } } -func (x *UpdateTrainUUIDResponse) String() string { +func (x *AddTrainResponse) String() string { return protoimpl.X.MessageStringOf(x) } -func (*UpdateTrainUUIDResponse) ProtoMessage() {} +func (*AddTrainResponse) ProtoMessage() {} -func (x *UpdateTrainUUIDResponse) ProtoReflect() protoreflect.Message { +func (x *AddTrainResponse) ProtoReflect() protoreflect.Message { mi := &file_state_v1_train_proto_msgTypes[4] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -312,11 +338,136 @@ func (x *UpdateTrainUUIDResponse) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use UpdateTrainUUIDResponse.ProtoReflect.Descriptor instead. -func (*UpdateTrainUUIDResponse) Descriptor() ([]byte, []int) { +// Deprecated: Use AddTrainResponse.ProtoReflect.Descriptor instead. +func (*AddTrainResponse) Descriptor() ([]byte, []int) { return file_state_v1_train_proto_rawDescGZIP(), []int{4} } +func (x *AddTrainResponse) GetTrain() *Train { + if x != nil { + return x.Train + } + return nil +} + +type UpdateTrainRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + TrainId string `protobuf:"bytes,1,opt,name=train_id,json=trainId,proto3" json:"train_id,omitempty"` // 列車ID + PositionId string `protobuf:"bytes,2,opt,name=position_id,json=positionId,proto3" json:"position_id,omitempty"` // 駅 or 閉塞のID + Priority Priority `protobuf:"varint,3,opt,name=priority,proto3,enum=state.v1.Priority" json:"priority,omitempty"` // 列車の優先度 + Uuid string `protobuf:"bytes,4,opt,name=uuid,proto3" json:"uuid,omitempty"` // NFCのUUID +} + +func (x *UpdateTrainRequest) Reset() { + *x = UpdateTrainRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_state_v1_train_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *UpdateTrainRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdateTrainRequest) ProtoMessage() {} + +func (x *UpdateTrainRequest) ProtoReflect() protoreflect.Message { + mi := &file_state_v1_train_proto_msgTypes[5] + 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 UpdateTrainRequest.ProtoReflect.Descriptor instead. +func (*UpdateTrainRequest) Descriptor() ([]byte, []int) { + return file_state_v1_train_proto_rawDescGZIP(), []int{5} +} + +func (x *UpdateTrainRequest) GetTrainId() string { + if x != nil { + return x.TrainId + } + return "" +} + +func (x *UpdateTrainRequest) GetPositionId() string { + if x != nil { + return x.PositionId + } + return "" +} + +func (x *UpdateTrainRequest) GetPriority() Priority { + if x != nil { + return x.Priority + } + return Priority_PRIORITY_UNSPECIFIED +} + +func (x *UpdateTrainRequest) GetUuid() string { + if x != nil { + return x.Uuid + } + return "" +} + +type UpdateTrainResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Train *Train `protobuf:"bytes,1,opt,name=train,proto3" json:"train,omitempty"` +} + +func (x *UpdateTrainResponse) Reset() { + *x = UpdateTrainResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_state_v1_train_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *UpdateTrainResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdateTrainResponse) ProtoMessage() {} + +func (x *UpdateTrainResponse) ProtoReflect() protoreflect.Message { + mi := &file_state_v1_train_proto_msgTypes[6] + 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 UpdateTrainResponse.ProtoReflect.Descriptor instead. +func (*UpdateTrainResponse) Descriptor() ([]byte, []int) { + return file_state_v1_train_proto_rawDescGZIP(), []int{6} +} + +func (x *UpdateTrainResponse) GetTrain() *Train { + if x != nil { + return x.Train + } + return nil +} + var File_state_v1_train_proto protoreflect.FileDescriptor var file_state_v1_train_proto_rawDesc = []byte{ @@ -324,40 +475,62 @@ var file_state_v1_train_proto_rawDesc = []byte{ 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x08, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x76, 0x31, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x22, 0x73, 0x0a, 0x05, 0x54, 0x72, 0x61, 0x69, 0x6e, 0x12, 0x19, 0x0a, 0x08, 0x74, 0x72, - 0x61, 0x69, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x74, 0x72, - 0x61, 0x69, 0x6e, 0x49, 0x64, 0x12, 0x1f, 0x0a, 0x0b, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, - 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x70, 0x6f, 0x73, 0x69, - 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x2e, 0x0a, 0x08, 0x70, 0x72, 0x69, 0x6f, 0x72, 0x69, - 0x74, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x12, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x65, - 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x72, 0x69, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x52, 0x08, 0x70, 0x72, - 0x69, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x22, 0x12, 0x0a, 0x10, 0x47, 0x65, 0x74, 0x54, 0x72, 0x61, - 0x69, 0x6e, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x3c, 0x0a, 0x11, 0x47, 0x65, - 0x74, 0x54, 0x72, 0x61, 0x69, 0x6e, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, - 0x27, 0x0a, 0x06, 0x74, 0x72, 0x61, 0x69, 0x6e, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, - 0x0f, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x72, 0x61, 0x69, 0x6e, - 0x52, 0x06, 0x74, 0x72, 0x61, 0x69, 0x6e, 0x73, 0x22, 0x47, 0x0a, 0x16, 0x55, 0x70, 0x64, 0x61, - 0x74, 0x65, 0x54, 0x72, 0x61, 0x69, 0x6e, 0x55, 0x55, 0x49, 0x44, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x12, 0x19, 0x0a, 0x08, 0x74, 0x72, 0x61, 0x69, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x74, 0x72, 0x61, 0x69, 0x6e, 0x49, 0x64, 0x12, 0x12, 0x0a, - 0x04, 0x75, 0x75, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x75, 0x75, 0x69, - 0x64, 0x22, 0x19, 0x0a, 0x17, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x54, 0x72, 0x61, 0x69, 0x6e, - 0x55, 0x55, 0x49, 0x44, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2a, 0x49, 0x0a, 0x08, - 0x50, 0x72, 0x69, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x12, 0x18, 0x0a, 0x14, 0x50, 0x52, 0x49, 0x4f, - 0x52, 0x49, 0x54, 0x59, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, - 0x10, 0x00, 0x12, 0x10, 0x0a, 0x0c, 0x50, 0x52, 0x49, 0x4f, 0x52, 0x49, 0x54, 0x59, 0x5f, 0x4c, - 0x4f, 0x57, 0x10, 0x01, 0x12, 0x11, 0x0a, 0x0d, 0x50, 0x52, 0x49, 0x4f, 0x52, 0x49, 0x54, 0x59, - 0x5f, 0x48, 0x49, 0x47, 0x48, 0x10, 0x02, 0x42, 0x9a, 0x01, 0x0a, 0x0c, 0x63, 0x6f, 0x6d, 0x2e, - 0x73, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x76, 0x31, 0x42, 0x0a, 0x54, 0x72, 0x61, 0x69, 0x6e, 0x50, - 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x3d, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, - 0x6f, 0x6d, 0x2f, 0x75, 0x65, 0x63, 0x6b, 0x6f, 0x6b, 0x65, 0x6e, 0x2f, 0x70, 0x6c, 0x61, 0x72, - 0x61, 0x69, 0x6c, 0x32, 0x30, 0x32, 0x33, 0x2f, 0x62, 0x61, 0x63, 0x6b, 0x65, 0x6e, 0x64, 0x2f, - 0x73, 0x70, 0x65, 0x63, 0x2f, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2f, 0x76, 0x31, 0x3b, 0x73, 0x74, - 0x61, 0x74, 0x65, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x53, 0x58, 0x58, 0xaa, 0x02, 0x08, 0x53, 0x74, - 0x61, 0x74, 0x65, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x08, 0x53, 0x74, 0x61, 0x74, 0x65, 0x5c, 0x56, - 0x31, 0xe2, 0x02, 0x14, 0x53, 0x74, 0x61, 0x74, 0x65, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, - 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x09, 0x53, 0x74, 0x61, 0x74, 0x65, - 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x6f, 0x22, 0x87, 0x01, 0x0a, 0x05, 0x54, 0x72, 0x61, 0x69, 0x6e, 0x12, 0x19, 0x0a, 0x08, 0x74, + 0x72, 0x61, 0x69, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x74, + 0x72, 0x61, 0x69, 0x6e, 0x49, 0x64, 0x12, 0x1f, 0x0a, 0x0b, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, + 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x70, 0x6f, 0x73, + 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x2e, 0x0a, 0x08, 0x70, 0x72, 0x69, 0x6f, 0x72, + 0x69, 0x74, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x12, 0x2e, 0x73, 0x74, 0x61, 0x74, + 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x72, 0x69, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x52, 0x08, 0x70, + 0x72, 0x69, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x12, 0x12, 0x0a, 0x04, 0x75, 0x75, 0x69, 0x64, 0x18, + 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x75, 0x75, 0x69, 0x64, 0x22, 0x12, 0x0a, 0x10, 0x47, + 0x65, 0x74, 0x54, 0x72, 0x61, 0x69, 0x6e, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, + 0x3c, 0x0a, 0x11, 0x47, 0x65, 0x74, 0x54, 0x72, 0x61, 0x69, 0x6e, 0x73, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x27, 0x0a, 0x06, 0x74, 0x72, 0x61, 0x69, 0x6e, 0x73, 0x18, 0x01, + 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x76, 0x31, 0x2e, + 0x54, 0x72, 0x61, 0x69, 0x6e, 0x52, 0x06, 0x74, 0x72, 0x61, 0x69, 0x6e, 0x73, 0x22, 0x91, 0x01, + 0x0a, 0x0f, 0x41, 0x64, 0x64, 0x54, 0x72, 0x61, 0x69, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x12, 0x19, 0x0a, 0x08, 0x74, 0x72, 0x61, 0x69, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x07, 0x74, 0x72, 0x61, 0x69, 0x6e, 0x49, 0x64, 0x12, 0x1f, 0x0a, 0x0b, + 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x0a, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x2e, 0x0a, + 0x08, 0x70, 0x72, 0x69, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, + 0x12, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x72, 0x69, 0x6f, 0x72, + 0x69, 0x74, 0x79, 0x52, 0x08, 0x70, 0x72, 0x69, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x12, 0x12, 0x0a, + 0x04, 0x75, 0x75, 0x69, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x75, 0x75, 0x69, + 0x64, 0x22, 0x39, 0x0a, 0x10, 0x41, 0x64, 0x64, 0x54, 0x72, 0x61, 0x69, 0x6e, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x25, 0x0a, 0x05, 0x74, 0x72, 0x61, 0x69, 0x6e, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x76, 0x31, 0x2e, + 0x54, 0x72, 0x61, 0x69, 0x6e, 0x52, 0x05, 0x74, 0x72, 0x61, 0x69, 0x6e, 0x22, 0x94, 0x01, 0x0a, + 0x12, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x54, 0x72, 0x61, 0x69, 0x6e, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x12, 0x19, 0x0a, 0x08, 0x74, 0x72, 0x61, 0x69, 0x6e, 0x5f, 0x69, 0x64, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x74, 0x72, 0x61, 0x69, 0x6e, 0x49, 0x64, 0x12, 0x1f, + 0x0a, 0x0b, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x0a, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, + 0x2e, 0x0a, 0x08, 0x70, 0x72, 0x69, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, + 0x0e, 0x32, 0x12, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x72, 0x69, + 0x6f, 0x72, 0x69, 0x74, 0x79, 0x52, 0x08, 0x70, 0x72, 0x69, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x12, + 0x12, 0x0a, 0x04, 0x75, 0x75, 0x69, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x75, + 0x75, 0x69, 0x64, 0x22, 0x3c, 0x0a, 0x13, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x54, 0x72, 0x61, + 0x69, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x25, 0x0a, 0x05, 0x74, 0x72, + 0x61, 0x69, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x73, 0x74, 0x61, 0x74, + 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x72, 0x61, 0x69, 0x6e, 0x52, 0x05, 0x74, 0x72, 0x61, 0x69, + 0x6e, 0x2a, 0x49, 0x0a, 0x08, 0x50, 0x72, 0x69, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x12, 0x18, 0x0a, + 0x14, 0x50, 0x52, 0x49, 0x4f, 0x52, 0x49, 0x54, 0x59, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, + 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x10, 0x0a, 0x0c, 0x50, 0x52, 0x49, 0x4f, 0x52, + 0x49, 0x54, 0x59, 0x5f, 0x4c, 0x4f, 0x57, 0x10, 0x01, 0x12, 0x11, 0x0a, 0x0d, 0x50, 0x52, 0x49, + 0x4f, 0x52, 0x49, 0x54, 0x59, 0x5f, 0x48, 0x49, 0x47, 0x48, 0x10, 0x02, 0x42, 0x9a, 0x01, 0x0a, + 0x0c, 0x63, 0x6f, 0x6d, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x76, 0x31, 0x42, 0x0a, 0x54, + 0x72, 0x61, 0x69, 0x6e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x3d, 0x67, 0x69, 0x74, + 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x75, 0x65, 0x63, 0x6b, 0x6f, 0x6b, 0x65, 0x6e, + 0x2f, 0x70, 0x6c, 0x61, 0x72, 0x61, 0x69, 0x6c, 0x32, 0x30, 0x32, 0x33, 0x2f, 0x62, 0x61, 0x63, + 0x6b, 0x65, 0x6e, 0x64, 0x2f, 0x73, 0x70, 0x65, 0x63, 0x2f, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2f, + 0x76, 0x31, 0x3b, 0x73, 0x74, 0x61, 0x74, 0x65, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x53, 0x58, 0x58, + 0xaa, 0x02, 0x08, 0x53, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x08, 0x53, 0x74, + 0x61, 0x74, 0x65, 0x5c, 0x56, 0x31, 0xe2, 0x02, 0x14, 0x53, 0x74, 0x61, 0x74, 0x65, 0x5c, 0x56, + 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x09, + 0x53, 0x74, 0x61, 0x74, 0x65, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x33, } var ( @@ -373,23 +546,29 @@ func file_state_v1_train_proto_rawDescGZIP() []byte { } var file_state_v1_train_proto_enumTypes = make([]protoimpl.EnumInfo, 1) -var file_state_v1_train_proto_msgTypes = make([]protoimpl.MessageInfo, 5) +var file_state_v1_train_proto_msgTypes = make([]protoimpl.MessageInfo, 7) var file_state_v1_train_proto_goTypes = []interface{}{ - (Priority)(0), // 0: state.v1.Priority - (*Train)(nil), // 1: state.v1.Train - (*GetTrainsRequest)(nil), // 2: state.v1.GetTrainsRequest - (*GetTrainsResponse)(nil), // 3: state.v1.GetTrainsResponse - (*UpdateTrainUUIDRequest)(nil), // 4: state.v1.UpdateTrainUUIDRequest - (*UpdateTrainUUIDResponse)(nil), // 5: state.v1.UpdateTrainUUIDResponse + (Priority)(0), // 0: state.v1.Priority + (*Train)(nil), // 1: state.v1.Train + (*GetTrainsRequest)(nil), // 2: state.v1.GetTrainsRequest + (*GetTrainsResponse)(nil), // 3: state.v1.GetTrainsResponse + (*AddTrainRequest)(nil), // 4: state.v1.AddTrainRequest + (*AddTrainResponse)(nil), // 5: state.v1.AddTrainResponse + (*UpdateTrainRequest)(nil), // 6: state.v1.UpdateTrainRequest + (*UpdateTrainResponse)(nil), // 7: state.v1.UpdateTrainResponse } var file_state_v1_train_proto_depIdxs = []int32{ 0, // 0: state.v1.Train.priority:type_name -> state.v1.Priority 1, // 1: state.v1.GetTrainsResponse.trains:type_name -> state.v1.Train - 2, // [2:2] is the sub-list for method output_type - 2, // [2:2] is the sub-list for method input_type - 2, // [2:2] is the sub-list for extension type_name - 2, // [2:2] is the sub-list for extension extendee - 0, // [0:2] is the sub-list for field type_name + 0, // 2: state.v1.AddTrainRequest.priority:type_name -> state.v1.Priority + 1, // 3: state.v1.AddTrainResponse.train:type_name -> state.v1.Train + 0, // 4: state.v1.UpdateTrainRequest.priority:type_name -> state.v1.Priority + 1, // 5: state.v1.UpdateTrainResponse.train:type_name -> state.v1.Train + 6, // [6:6] is the sub-list for method output_type + 6, // [6:6] is the sub-list for method input_type + 6, // [6:6] is the sub-list for extension type_name + 6, // [6:6] is the sub-list for extension extendee + 0, // [0:6] is the sub-list for field type_name } func init() { file_state_v1_train_proto_init() } @@ -435,7 +614,7 @@ func file_state_v1_train_proto_init() { } } file_state_v1_train_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*UpdateTrainUUIDRequest); i { + switch v := v.(*AddTrainRequest); i { case 0: return &v.state case 1: @@ -447,7 +626,31 @@ func file_state_v1_train_proto_init() { } } file_state_v1_train_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*UpdateTrainUUIDResponse); i { + switch v := v.(*AddTrainResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_state_v1_train_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*UpdateTrainRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_state_v1_train_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*UpdateTrainResponse); i { case 0: return &v.state case 1: @@ -465,7 +668,7 @@ func file_state_v1_train_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_state_v1_train_proto_rawDesc, NumEnums: 1, - NumMessages: 5, + NumMessages: 7, NumExtensions: 0, NumServices: 0, }, diff --git a/frontend/dashboard/proto/state/v1/state_connectweb.d.ts b/frontend/dashboard/proto/state/v1/state_connectweb.d.ts index 2e087925..ce3b0613 100644 --- a/frontend/dashboard/proto/state/v1/state_connectweb.d.ts +++ b/frontend/dashboard/proto/state/v1/state_connectweb.d.ts @@ -7,7 +7,7 @@ import { GetBlockStatesRequest, GetBlockStatesResponse, UpdateBlockStateRequest, import { MethodKind } from "@bufbuild/protobuf"; import { GetPointStatesRequest, GetPointStatesResponse, UpdatePointStateRequest, UpdatePointStateResponse } from "./point_pb.js"; import { GetStopStatesRequest, GetStopStatesResponse, UpdateStopStateRequest, UpdateStopStateResponse } from "./stop_pb.js"; -import { GetTrainsRequest, GetTrainsResponse, UpdateTrainUUIDRequest, UpdateTrainUUIDResponse } from "./train_pb.js"; +import { AddTrainRequest, AddTrainResponse, GetTrainsRequest, GetTrainsResponse, UpdateTrainRequest, UpdateTrainResponse } from "./train_pb.js"; /** * @@ -91,12 +91,21 @@ export declare const StateManagerService: { readonly kind: MethodKind.Unary, }, /** - * @generated from rpc state.v1.StateManagerService.UpdateTrainUUID + * @generated from rpc state.v1.StateManagerService.AddTrain */ - readonly updateTrainUUID: { - readonly name: "UpdateTrainUUID", - readonly I: typeof UpdateTrainUUIDRequest, - readonly O: typeof UpdateTrainUUIDResponse, + readonly addTrain: { + readonly name: "AddTrain", + readonly I: typeof AddTrainRequest, + readonly O: typeof AddTrainResponse, + readonly kind: MethodKind.Unary, + }, + /** + * @generated from rpc state.v1.StateManagerService.UpdateTrain + */ + readonly updateTrain: { + readonly name: "UpdateTrain", + readonly I: typeof UpdateTrainRequest, + readonly O: typeof UpdateTrainResponse, readonly kind: MethodKind.Unary, }, } diff --git a/frontend/dashboard/proto/state/v1/state_connectweb.js b/frontend/dashboard/proto/state/v1/state_connectweb.js index 637fee8c..1f4e198d 100644 --- a/frontend/dashboard/proto/state/v1/state_connectweb.js +++ b/frontend/dashboard/proto/state/v1/state_connectweb.js @@ -7,7 +7,7 @@ import { GetBlockStatesRequest, GetBlockStatesResponse, UpdateBlockStateRequest, import { MethodKind } from "@bufbuild/protobuf"; import { GetPointStatesRequest, GetPointStatesResponse, UpdatePointStateRequest, UpdatePointStateResponse } from "./point_pb.js"; import { GetStopStatesRequest, GetStopStatesResponse, UpdateStopStateRequest, UpdateStopStateResponse } from "./stop_pb.js"; -import { GetTrainsRequest, GetTrainsResponse, UpdateTrainUUIDRequest, UpdateTrainUUIDResponse } from "./train_pb.js"; +import { AddTrainRequest, AddTrainResponse, GetTrainsRequest, GetTrainsResponse, UpdateTrainRequest, UpdateTrainResponse } from "./train_pb.js"; /** * @@ -91,12 +91,21 @@ export const StateManagerService = { kind: MethodKind.Unary, }, /** - * @generated from rpc state.v1.StateManagerService.UpdateTrainUUID + * @generated from rpc state.v1.StateManagerService.AddTrain */ - updateTrainUUID: { - name: "UpdateTrainUUID", - I: UpdateTrainUUIDRequest, - O: UpdateTrainUUIDResponse, + addTrain: { + name: "AddTrain", + I: AddTrainRequest, + O: AddTrainResponse, + kind: MethodKind.Unary, + }, + /** + * @generated from rpc state.v1.StateManagerService.UpdateTrain + */ + updateTrain: { + name: "UpdateTrain", + I: UpdateTrainRequest, + O: UpdateTrainResponse, kind: MethodKind.Unary, }, } diff --git a/frontend/dashboard/proto/state/v1/train_pb.d.ts b/frontend/dashboard/proto/state/v1/train_pb.d.ts index 67cf89ea..6a716ec2 100644 --- a/frontend/dashboard/proto/state/v1/train_pb.d.ts +++ b/frontend/dashboard/proto/state/v1/train_pb.d.ts @@ -55,6 +55,13 @@ export declare class Train extends Message { */ priority: Priority; + /** + * NFCのUUID + * + * @generated from field: string uuid = 4; + */ + uuid: string; + constructor(data?: PartialMessage); static readonly runtime: typeof proto3; @@ -118,11 +125,11 @@ export declare class GetTrainsResponse extends Message { /** * - * UpdateTrainUUID : NFCのUUID紐付けを更新するAPI + * Add Train : 列車を追加するAPI * - * @generated from message state.v1.UpdateTrainUUIDRequest + * @generated from message state.v1.AddTrainRequest */ -export declare class UpdateTrainUUIDRequest extends Message { +export declare class AddTrainRequest extends Message { /** * 列車ID * @@ -130,44 +137,134 @@ export declare class UpdateTrainUUIDRequest extends Message); + constructor(data?: PartialMessage); static readonly runtime: typeof proto3; - static readonly typeName = "state.v1.UpdateTrainUUIDRequest"; + static readonly typeName = "state.v1.AddTrainRequest"; static readonly fields: FieldList; - static fromBinary(bytes: Uint8Array, options?: Partial): UpdateTrainUUIDRequest; + static fromBinary(bytes: Uint8Array, options?: Partial): AddTrainRequest; - static fromJson(jsonValue: JsonValue, options?: Partial): UpdateTrainUUIDRequest; + static fromJson(jsonValue: JsonValue, options?: Partial): AddTrainRequest; - static fromJsonString(jsonString: string, options?: Partial): UpdateTrainUUIDRequest; + static fromJsonString(jsonString: string, options?: Partial): AddTrainRequest; - static equals(a: UpdateTrainUUIDRequest | PlainMessage | undefined, b: UpdateTrainUUIDRequest | PlainMessage | undefined): boolean; + static equals(a: AddTrainRequest | PlainMessage | undefined, b: AddTrainRequest | PlainMessage | undefined): boolean; } /** - * @generated from message state.v1.UpdateTrainUUIDResponse + * @generated from message state.v1.AddTrainResponse */ -export declare class UpdateTrainUUIDResponse extends Message { - constructor(data?: PartialMessage); +export declare class AddTrainResponse extends Message { + /** + * @generated from field: state.v1.Train train = 1; + */ + train?: Train; + + constructor(data?: PartialMessage); + + static readonly runtime: typeof proto3; + static readonly typeName = "state.v1.AddTrainResponse"; + static readonly fields: FieldList; + + static fromBinary(bytes: Uint8Array, options?: Partial): AddTrainResponse; + + static fromJson(jsonValue: JsonValue, options?: Partial): AddTrainResponse; + + static fromJsonString(jsonString: string, options?: Partial): AddTrainResponse; + + static equals(a: AddTrainResponse | PlainMessage | undefined, b: AddTrainResponse | PlainMessage | undefined): boolean; +} + +/** + * @generated from message state.v1.UpdateTrainRequest + */ +export declare class UpdateTrainRequest extends Message { + /** + * 列車ID + * + * @generated from field: string train_id = 1; + */ + trainId: string; + + /** + * 駅 or 閉塞のID + * + * @generated from field: string position_id = 2; + */ + positionId: string; + + /** + * 列車の優先度 + * + * @generated from field: state.v1.Priority priority = 3; + */ + priority: Priority; + + /** + * NFCのUUID + * + * @generated from field: string uuid = 4; + */ + uuid: string; + + constructor(data?: PartialMessage); + + static readonly runtime: typeof proto3; + static readonly typeName = "state.v1.UpdateTrainRequest"; + static readonly fields: FieldList; + + static fromBinary(bytes: Uint8Array, options?: Partial): UpdateTrainRequest; + + static fromJson(jsonValue: JsonValue, options?: Partial): UpdateTrainRequest; + + static fromJsonString(jsonString: string, options?: Partial): UpdateTrainRequest; + + static equals(a: UpdateTrainRequest | PlainMessage | undefined, b: UpdateTrainRequest | PlainMessage | undefined): boolean; +} + +/** + * @generated from message state.v1.UpdateTrainResponse + */ +export declare class UpdateTrainResponse extends Message { + /** + * @generated from field: state.v1.Train train = 1; + */ + train?: Train; + + constructor(data?: PartialMessage); static readonly runtime: typeof proto3; - static readonly typeName = "state.v1.UpdateTrainUUIDResponse"; + static readonly typeName = "state.v1.UpdateTrainResponse"; static readonly fields: FieldList; - static fromBinary(bytes: Uint8Array, options?: Partial): UpdateTrainUUIDResponse; + static fromBinary(bytes: Uint8Array, options?: Partial): UpdateTrainResponse; - static fromJson(jsonValue: JsonValue, options?: Partial): UpdateTrainUUIDResponse; + static fromJson(jsonValue: JsonValue, options?: Partial): UpdateTrainResponse; - static fromJsonString(jsonString: string, options?: Partial): UpdateTrainUUIDResponse; + static fromJsonString(jsonString: string, options?: Partial): UpdateTrainResponse; - static equals(a: UpdateTrainUUIDResponse | PlainMessage | undefined, b: UpdateTrainUUIDResponse | PlainMessage | undefined): boolean; + static equals(a: UpdateTrainResponse | PlainMessage | undefined, b: UpdateTrainResponse | PlainMessage | undefined): boolean; } diff --git a/frontend/dashboard/proto/state/v1/train_pb.js b/frontend/dashboard/proto/state/v1/train_pb.js index 76a6be31..a2c92073 100644 --- a/frontend/dashboard/proto/state/v1/train_pb.js +++ b/frontend/dashboard/proto/state/v1/train_pb.js @@ -30,6 +30,7 @@ export const Train = proto3.makeMessageType( { no: 1, name: "train_id", kind: "scalar", T: 9 /* ScalarType.STRING */ }, { no: 2, name: "position_id", kind: "scalar", T: 9 /* ScalarType.STRING */ }, { no: 3, name: "priority", kind: "enum", T: proto3.getEnumType(Priority) }, + { no: 4, name: "uuid", kind: "scalar", T: 9 /* ScalarType.STRING */ }, ], ); @@ -56,23 +57,50 @@ export const GetTrainsResponse = proto3.makeMessageType( /** * - * UpdateTrainUUID : NFCのUUID紐付けを更新するAPI + * Add Train : 列車を追加するAPI * - * @generated from message state.v1.UpdateTrainUUIDRequest + * @generated from message state.v1.AddTrainRequest */ -export const UpdateTrainUUIDRequest = proto3.makeMessageType( - "state.v1.UpdateTrainUUIDRequest", +export const AddTrainRequest = proto3.makeMessageType( + "state.v1.AddTrainRequest", () => [ { no: 1, name: "train_id", kind: "scalar", T: 9 /* ScalarType.STRING */ }, - { no: 2, name: "uuid", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 2, name: "position_id", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 3, name: "priority", kind: "enum", T: proto3.getEnumType(Priority) }, + { no: 4, name: "uuid", kind: "scalar", T: 9 /* ScalarType.STRING */ }, ], ); /** - * @generated from message state.v1.UpdateTrainUUIDResponse + * @generated from message state.v1.AddTrainResponse */ -export const UpdateTrainUUIDResponse = proto3.makeMessageType( - "state.v1.UpdateTrainUUIDResponse", - [], +export const AddTrainResponse = proto3.makeMessageType( + "state.v1.AddTrainResponse", + () => [ + { no: 1, name: "train", kind: "message", T: Train }, + ], +); + +/** + * @generated from message state.v1.UpdateTrainRequest + */ +export const UpdateTrainRequest = proto3.makeMessageType( + "state.v1.UpdateTrainRequest", + () => [ + { no: 1, name: "train_id", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 2, name: "position_id", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 3, name: "priority", kind: "enum", T: proto3.getEnumType(Priority) }, + { no: 4, name: "uuid", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + ], +); + +/** + * @generated from message state.v1.UpdateTrainResponse + */ +export const UpdateTrainResponse = proto3.makeMessageType( + "state.v1.UpdateTrainResponse", + () => [ + { no: 1, name: "train", kind: "message", T: Train }, + ], ); From f7ea4e008f8d8d6bd6717963ee3cf2b91fac5ab0 Mon Sep 17 00:00:00 2001 From: Koichi Hirachi Date: Wed, 22 Nov 2023 22:43:43 +0900 Subject: [PATCH 5/9] update proto --- proto/spec/state/v1/train.proto | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/proto/spec/state/v1/train.proto b/proto/spec/state/v1/train.proto index 11c79919..be0a9cb3 100644 --- a/proto/spec/state/v1/train.proto +++ b/proto/spec/state/v1/train.proto @@ -52,10 +52,7 @@ message AddTrainResponse { */ message UpdateTrainRequest { - string train_id = 1; // 列車ID - string position_id = 2; // 駅 or 閉塞のID - Priority priority = 3; // 列車の優先度 - string uuid = 4; // NFCのUUID + Train train = 1; } message UpdateTrainResponse { From 746393b518334ddd3e3bd4b665e1b314b39f67bc Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 22 Nov 2023 13:44:42 +0000 Subject: [PATCH 6/9] Commit from GitHub Actions (compile_PB) --- backend/spec/state/v1/train.pb.go | 88 ++++++------------- .../dashboard/proto/state/v1/train_pb.d.ts | 27 +----- frontend/dashboard/proto/state/v1/train_pb.js | 5 +- 3 files changed, 32 insertions(+), 88 deletions(-) diff --git a/backend/spec/state/v1/train.pb.go b/backend/spec/state/v1/train.pb.go index aade3ed7..b8664ed4 100644 --- a/backend/spec/state/v1/train.pb.go +++ b/backend/spec/state/v1/train.pb.go @@ -355,10 +355,7 @@ type UpdateTrainRequest struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - TrainId string `protobuf:"bytes,1,opt,name=train_id,json=trainId,proto3" json:"train_id,omitempty"` // 列車ID - PositionId string `protobuf:"bytes,2,opt,name=position_id,json=positionId,proto3" json:"position_id,omitempty"` // 駅 or 閉塞のID - Priority Priority `protobuf:"varint,3,opt,name=priority,proto3,enum=state.v1.Priority" json:"priority,omitempty"` // 列車の優先度 - Uuid string `protobuf:"bytes,4,opt,name=uuid,proto3" json:"uuid,omitempty"` // NFCのUUID + Train *Train `protobuf:"bytes,1,opt,name=train,proto3" json:"train,omitempty"` } func (x *UpdateTrainRequest) Reset() { @@ -393,32 +390,11 @@ func (*UpdateTrainRequest) Descriptor() ([]byte, []int) { return file_state_v1_train_proto_rawDescGZIP(), []int{5} } -func (x *UpdateTrainRequest) GetTrainId() string { - if x != nil { - return x.TrainId - } - return "" -} - -func (x *UpdateTrainRequest) GetPositionId() string { +func (x *UpdateTrainRequest) GetTrain() *Train { if x != nil { - return x.PositionId - } - return "" -} - -func (x *UpdateTrainRequest) GetPriority() Priority { - if x != nil { - return x.Priority - } - return Priority_PRIORITY_UNSPECIFIED -} - -func (x *UpdateTrainRequest) GetUuid() string { - if x != nil { - return x.Uuid + return x.Train } - return "" + return nil } type UpdateTrainResponse struct { @@ -501,36 +477,30 @@ var file_state_v1_train_proto_rawDesc = []byte{ 0x64, 0x22, 0x39, 0x0a, 0x10, 0x41, 0x64, 0x64, 0x54, 0x72, 0x61, 0x69, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x25, 0x0a, 0x05, 0x74, 0x72, 0x61, 0x69, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x76, 0x31, 0x2e, - 0x54, 0x72, 0x61, 0x69, 0x6e, 0x52, 0x05, 0x74, 0x72, 0x61, 0x69, 0x6e, 0x22, 0x94, 0x01, 0x0a, - 0x12, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x54, 0x72, 0x61, 0x69, 0x6e, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x12, 0x19, 0x0a, 0x08, 0x74, 0x72, 0x61, 0x69, 0x6e, 0x5f, 0x69, 0x64, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x74, 0x72, 0x61, 0x69, 0x6e, 0x49, 0x64, 0x12, 0x1f, - 0x0a, 0x0b, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x0a, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, - 0x2e, 0x0a, 0x08, 0x70, 0x72, 0x69, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, - 0x0e, 0x32, 0x12, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x72, 0x69, - 0x6f, 0x72, 0x69, 0x74, 0x79, 0x52, 0x08, 0x70, 0x72, 0x69, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x12, - 0x12, 0x0a, 0x04, 0x75, 0x75, 0x69, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x75, - 0x75, 0x69, 0x64, 0x22, 0x3c, 0x0a, 0x13, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x54, 0x72, 0x61, - 0x69, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x25, 0x0a, 0x05, 0x74, 0x72, - 0x61, 0x69, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x73, 0x74, 0x61, 0x74, - 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x72, 0x61, 0x69, 0x6e, 0x52, 0x05, 0x74, 0x72, 0x61, 0x69, - 0x6e, 0x2a, 0x49, 0x0a, 0x08, 0x50, 0x72, 0x69, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x12, 0x18, 0x0a, - 0x14, 0x50, 0x52, 0x49, 0x4f, 0x52, 0x49, 0x54, 0x59, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, - 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x10, 0x0a, 0x0c, 0x50, 0x52, 0x49, 0x4f, 0x52, - 0x49, 0x54, 0x59, 0x5f, 0x4c, 0x4f, 0x57, 0x10, 0x01, 0x12, 0x11, 0x0a, 0x0d, 0x50, 0x52, 0x49, - 0x4f, 0x52, 0x49, 0x54, 0x59, 0x5f, 0x48, 0x49, 0x47, 0x48, 0x10, 0x02, 0x42, 0x9a, 0x01, 0x0a, - 0x0c, 0x63, 0x6f, 0x6d, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x76, 0x31, 0x42, 0x0a, 0x54, - 0x72, 0x61, 0x69, 0x6e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x3d, 0x67, 0x69, 0x74, - 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x75, 0x65, 0x63, 0x6b, 0x6f, 0x6b, 0x65, 0x6e, - 0x2f, 0x70, 0x6c, 0x61, 0x72, 0x61, 0x69, 0x6c, 0x32, 0x30, 0x32, 0x33, 0x2f, 0x62, 0x61, 0x63, - 0x6b, 0x65, 0x6e, 0x64, 0x2f, 0x73, 0x70, 0x65, 0x63, 0x2f, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2f, - 0x76, 0x31, 0x3b, 0x73, 0x74, 0x61, 0x74, 0x65, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x53, 0x58, 0x58, - 0xaa, 0x02, 0x08, 0x53, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x08, 0x53, 0x74, - 0x61, 0x74, 0x65, 0x5c, 0x56, 0x31, 0xe2, 0x02, 0x14, 0x53, 0x74, 0x61, 0x74, 0x65, 0x5c, 0x56, - 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x09, - 0x53, 0x74, 0x61, 0x74, 0x65, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x33, + 0x54, 0x72, 0x61, 0x69, 0x6e, 0x52, 0x05, 0x74, 0x72, 0x61, 0x69, 0x6e, 0x22, 0x3b, 0x0a, 0x12, + 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x54, 0x72, 0x61, 0x69, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x12, 0x25, 0x0a, 0x05, 0x74, 0x72, 0x61, 0x69, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x0f, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x72, 0x61, + 0x69, 0x6e, 0x52, 0x05, 0x74, 0x72, 0x61, 0x69, 0x6e, 0x22, 0x3c, 0x0a, 0x13, 0x55, 0x70, 0x64, + 0x61, 0x74, 0x65, 0x54, 0x72, 0x61, 0x69, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x12, 0x25, 0x0a, 0x05, 0x74, 0x72, 0x61, 0x69, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x0f, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x72, 0x61, 0x69, 0x6e, + 0x52, 0x05, 0x74, 0x72, 0x61, 0x69, 0x6e, 0x2a, 0x49, 0x0a, 0x08, 0x50, 0x72, 0x69, 0x6f, 0x72, + 0x69, 0x74, 0x79, 0x12, 0x18, 0x0a, 0x14, 0x50, 0x52, 0x49, 0x4f, 0x52, 0x49, 0x54, 0x59, 0x5f, + 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x10, 0x0a, + 0x0c, 0x50, 0x52, 0x49, 0x4f, 0x52, 0x49, 0x54, 0x59, 0x5f, 0x4c, 0x4f, 0x57, 0x10, 0x01, 0x12, + 0x11, 0x0a, 0x0d, 0x50, 0x52, 0x49, 0x4f, 0x52, 0x49, 0x54, 0x59, 0x5f, 0x48, 0x49, 0x47, 0x48, + 0x10, 0x02, 0x42, 0x9a, 0x01, 0x0a, 0x0c, 0x63, 0x6f, 0x6d, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x65, + 0x2e, 0x76, 0x31, 0x42, 0x0a, 0x54, 0x72, 0x61, 0x69, 0x6e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, + 0x01, 0x5a, 0x3d, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x75, 0x65, + 0x63, 0x6b, 0x6f, 0x6b, 0x65, 0x6e, 0x2f, 0x70, 0x6c, 0x61, 0x72, 0x61, 0x69, 0x6c, 0x32, 0x30, + 0x32, 0x33, 0x2f, 0x62, 0x61, 0x63, 0x6b, 0x65, 0x6e, 0x64, 0x2f, 0x73, 0x70, 0x65, 0x63, 0x2f, + 0x73, 0x74, 0x61, 0x74, 0x65, 0x2f, 0x76, 0x31, 0x3b, 0x73, 0x74, 0x61, 0x74, 0x65, 0x76, 0x31, + 0xa2, 0x02, 0x03, 0x53, 0x58, 0x58, 0xaa, 0x02, 0x08, 0x53, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x56, + 0x31, 0xca, 0x02, 0x08, 0x53, 0x74, 0x61, 0x74, 0x65, 0x5c, 0x56, 0x31, 0xe2, 0x02, 0x14, 0x53, + 0x74, 0x61, 0x74, 0x65, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, + 0x61, 0x74, 0x61, 0xea, 0x02, 0x09, 0x53, 0x74, 0x61, 0x74, 0x65, 0x3a, 0x3a, 0x56, 0x31, 0x62, + 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -562,7 +532,7 @@ var file_state_v1_train_proto_depIdxs = []int32{ 1, // 1: state.v1.GetTrainsResponse.trains:type_name -> state.v1.Train 0, // 2: state.v1.AddTrainRequest.priority:type_name -> state.v1.Priority 1, // 3: state.v1.AddTrainResponse.train:type_name -> state.v1.Train - 0, // 4: state.v1.UpdateTrainRequest.priority:type_name -> state.v1.Priority + 1, // 4: state.v1.UpdateTrainRequest.train:type_name -> state.v1.Train 1, // 5: state.v1.UpdateTrainResponse.train:type_name -> state.v1.Train 6, // [6:6] is the sub-list for method output_type 6, // [6:6] is the sub-list for method input_type diff --git a/frontend/dashboard/proto/state/v1/train_pb.d.ts b/frontend/dashboard/proto/state/v1/train_pb.d.ts index 6a716ec2..b6c95e38 100644 --- a/frontend/dashboard/proto/state/v1/train_pb.d.ts +++ b/frontend/dashboard/proto/state/v1/train_pb.d.ts @@ -202,32 +202,9 @@ export declare class AddTrainResponse extends Message { */ export declare class UpdateTrainRequest extends Message { /** - * 列車ID - * - * @generated from field: string train_id = 1; - */ - trainId: string; - - /** - * 駅 or 閉塞のID - * - * @generated from field: string position_id = 2; - */ - positionId: string; - - /** - * 列車の優先度 - * - * @generated from field: state.v1.Priority priority = 3; - */ - priority: Priority; - - /** - * NFCのUUID - * - * @generated from field: string uuid = 4; + * @generated from field: state.v1.Train train = 1; */ - uuid: string; + train?: Train; constructor(data?: PartialMessage); diff --git a/frontend/dashboard/proto/state/v1/train_pb.js b/frontend/dashboard/proto/state/v1/train_pb.js index a2c92073..f4c88d93 100644 --- a/frontend/dashboard/proto/state/v1/train_pb.js +++ b/frontend/dashboard/proto/state/v1/train_pb.js @@ -87,10 +87,7 @@ export const AddTrainResponse = proto3.makeMessageType( export const UpdateTrainRequest = proto3.makeMessageType( "state.v1.UpdateTrainRequest", () => [ - { no: 1, name: "train_id", kind: "scalar", T: 9 /* ScalarType.STRING */ }, - { no: 2, name: "position_id", kind: "scalar", T: 9 /* ScalarType.STRING */ }, - { no: 3, name: "priority", kind: "enum", T: proto3.getEnumType(Priority) }, - { no: 4, name: "uuid", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 1, name: "train", kind: "message", T: Train }, ], ); From 6b205ef7eb09db7d217baacf3fbe6693172eea9c Mon Sep 17 00:00:00 2001 From: Koichi Hirachi Date: Wed, 22 Nov 2023 22:46:50 +0900 Subject: [PATCH 7/9] fix proto --- proto/spec/state/v1/train.proto | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/proto/spec/state/v1/train.proto b/proto/spec/state/v1/train.proto index be0a9cb3..f1460b7c 100644 --- a/proto/spec/state/v1/train.proto +++ b/proto/spec/state/v1/train.proto @@ -37,10 +37,7 @@ message GetTrainsResponse { Add Train : 列車を追加するAPI */ message AddTrainRequest { - string train_id = 1; // 列車ID - string position_id = 2; // 駅 or 閉塞のID - Priority priority = 3; // 列車の優先度 - string uuid = 4; // NFCのUUID + Train train = 1; } message AddTrainResponse { From 53838548c2d1ee738c02de2c8d826aeb904fc1d1 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 22 Nov 2023 13:47:44 +0000 Subject: [PATCH 8/9] Commit from GitHub Actions (compile_PB) --- backend/spec/state/v1/train.pb.go | 98 +++++++------------ .../dashboard/proto/state/v1/train_pb.d.ts | 27 +---- frontend/dashboard/proto/state/v1/train_pb.js | 5 +- 3 files changed, 37 insertions(+), 93 deletions(-) diff --git a/backend/spec/state/v1/train.pb.go b/backend/spec/state/v1/train.pb.go index b8664ed4..2d1c2ff4 100644 --- a/backend/spec/state/v1/train.pb.go +++ b/backend/spec/state/v1/train.pb.go @@ -237,10 +237,7 @@ type AddTrainRequest struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - TrainId string `protobuf:"bytes,1,opt,name=train_id,json=trainId,proto3" json:"train_id,omitempty"` // 列車ID - PositionId string `protobuf:"bytes,2,opt,name=position_id,json=positionId,proto3" json:"position_id,omitempty"` // 駅 or 閉塞のID - Priority Priority `protobuf:"varint,3,opt,name=priority,proto3,enum=state.v1.Priority" json:"priority,omitempty"` // 列車の優先度 - Uuid string `protobuf:"bytes,4,opt,name=uuid,proto3" json:"uuid,omitempty"` // NFCのUUID + Train *Train `protobuf:"bytes,1,opt,name=train,proto3" json:"train,omitempty"` } func (x *AddTrainRequest) Reset() { @@ -275,32 +272,11 @@ func (*AddTrainRequest) Descriptor() ([]byte, []int) { return file_state_v1_train_proto_rawDescGZIP(), []int{3} } -func (x *AddTrainRequest) GetTrainId() string { - if x != nil { - return x.TrainId - } - return "" -} - -func (x *AddTrainRequest) GetPositionId() string { - if x != nil { - return x.PositionId - } - return "" -} - -func (x *AddTrainRequest) GetPriority() Priority { +func (x *AddTrainRequest) GetTrain() *Train { if x != nil { - return x.Priority - } - return Priority_PRIORITY_UNSPECIFIED -} - -func (x *AddTrainRequest) GetUuid() string { - if x != nil { - return x.Uuid + return x.Train } - return "" + return nil } type AddTrainResponse struct { @@ -464,43 +440,37 @@ var file_state_v1_train_proto_rawDesc = []byte{ 0x3c, 0x0a, 0x11, 0x47, 0x65, 0x74, 0x54, 0x72, 0x61, 0x69, 0x6e, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x27, 0x0a, 0x06, 0x74, 0x72, 0x61, 0x69, 0x6e, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x76, 0x31, 0x2e, - 0x54, 0x72, 0x61, 0x69, 0x6e, 0x52, 0x06, 0x74, 0x72, 0x61, 0x69, 0x6e, 0x73, 0x22, 0x91, 0x01, - 0x0a, 0x0f, 0x41, 0x64, 0x64, 0x54, 0x72, 0x61, 0x69, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x12, 0x19, 0x0a, 0x08, 0x74, 0x72, 0x61, 0x69, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x07, 0x74, 0x72, 0x61, 0x69, 0x6e, 0x49, 0x64, 0x12, 0x1f, 0x0a, 0x0b, - 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x0a, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x2e, 0x0a, - 0x08, 0x70, 0x72, 0x69, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, - 0x12, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x72, 0x69, 0x6f, 0x72, - 0x69, 0x74, 0x79, 0x52, 0x08, 0x70, 0x72, 0x69, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x12, 0x12, 0x0a, - 0x04, 0x75, 0x75, 0x69, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x75, 0x75, 0x69, - 0x64, 0x22, 0x39, 0x0a, 0x10, 0x41, 0x64, 0x64, 0x54, 0x72, 0x61, 0x69, 0x6e, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x25, 0x0a, 0x05, 0x74, 0x72, 0x61, 0x69, 0x6e, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x76, 0x31, 0x2e, - 0x54, 0x72, 0x61, 0x69, 0x6e, 0x52, 0x05, 0x74, 0x72, 0x61, 0x69, 0x6e, 0x22, 0x3b, 0x0a, 0x12, - 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x54, 0x72, 0x61, 0x69, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x12, 0x25, 0x0a, 0x05, 0x74, 0x72, 0x61, 0x69, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x0f, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x72, 0x61, - 0x69, 0x6e, 0x52, 0x05, 0x74, 0x72, 0x61, 0x69, 0x6e, 0x22, 0x3c, 0x0a, 0x13, 0x55, 0x70, 0x64, - 0x61, 0x74, 0x65, 0x54, 0x72, 0x61, 0x69, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x54, 0x72, 0x61, 0x69, 0x6e, 0x52, 0x06, 0x74, 0x72, 0x61, 0x69, 0x6e, 0x73, 0x22, 0x38, 0x0a, + 0x0f, 0x41, 0x64, 0x64, 0x54, 0x72, 0x61, 0x69, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x25, 0x0a, 0x05, 0x74, 0x72, 0x61, 0x69, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x72, 0x61, 0x69, 0x6e, - 0x52, 0x05, 0x74, 0x72, 0x61, 0x69, 0x6e, 0x2a, 0x49, 0x0a, 0x08, 0x50, 0x72, 0x69, 0x6f, 0x72, - 0x69, 0x74, 0x79, 0x12, 0x18, 0x0a, 0x14, 0x50, 0x52, 0x49, 0x4f, 0x52, 0x49, 0x54, 0x59, 0x5f, - 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x10, 0x0a, - 0x0c, 0x50, 0x52, 0x49, 0x4f, 0x52, 0x49, 0x54, 0x59, 0x5f, 0x4c, 0x4f, 0x57, 0x10, 0x01, 0x12, - 0x11, 0x0a, 0x0d, 0x50, 0x52, 0x49, 0x4f, 0x52, 0x49, 0x54, 0x59, 0x5f, 0x48, 0x49, 0x47, 0x48, - 0x10, 0x02, 0x42, 0x9a, 0x01, 0x0a, 0x0c, 0x63, 0x6f, 0x6d, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x65, - 0x2e, 0x76, 0x31, 0x42, 0x0a, 0x54, 0x72, 0x61, 0x69, 0x6e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, - 0x01, 0x5a, 0x3d, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x75, 0x65, - 0x63, 0x6b, 0x6f, 0x6b, 0x65, 0x6e, 0x2f, 0x70, 0x6c, 0x61, 0x72, 0x61, 0x69, 0x6c, 0x32, 0x30, - 0x32, 0x33, 0x2f, 0x62, 0x61, 0x63, 0x6b, 0x65, 0x6e, 0x64, 0x2f, 0x73, 0x70, 0x65, 0x63, 0x2f, - 0x73, 0x74, 0x61, 0x74, 0x65, 0x2f, 0x76, 0x31, 0x3b, 0x73, 0x74, 0x61, 0x74, 0x65, 0x76, 0x31, - 0xa2, 0x02, 0x03, 0x53, 0x58, 0x58, 0xaa, 0x02, 0x08, 0x53, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x56, - 0x31, 0xca, 0x02, 0x08, 0x53, 0x74, 0x61, 0x74, 0x65, 0x5c, 0x56, 0x31, 0xe2, 0x02, 0x14, 0x53, - 0x74, 0x61, 0x74, 0x65, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, - 0x61, 0x74, 0x61, 0xea, 0x02, 0x09, 0x53, 0x74, 0x61, 0x74, 0x65, 0x3a, 0x3a, 0x56, 0x31, 0x62, - 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x52, 0x05, 0x74, 0x72, 0x61, 0x69, 0x6e, 0x22, 0x39, 0x0a, 0x10, 0x41, 0x64, 0x64, 0x54, 0x72, + 0x61, 0x69, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x25, 0x0a, 0x05, 0x74, + 0x72, 0x61, 0x69, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x73, 0x74, 0x61, + 0x74, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x72, 0x61, 0x69, 0x6e, 0x52, 0x05, 0x74, 0x72, 0x61, + 0x69, 0x6e, 0x22, 0x3b, 0x0a, 0x12, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x54, 0x72, 0x61, 0x69, + 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x25, 0x0a, 0x05, 0x74, 0x72, 0x61, 0x69, + 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2e, + 0x76, 0x31, 0x2e, 0x54, 0x72, 0x61, 0x69, 0x6e, 0x52, 0x05, 0x74, 0x72, 0x61, 0x69, 0x6e, 0x22, + 0x3c, 0x0a, 0x13, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x54, 0x72, 0x61, 0x69, 0x6e, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x25, 0x0a, 0x05, 0x74, 0x72, 0x61, 0x69, 0x6e, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x76, 0x31, + 0x2e, 0x54, 0x72, 0x61, 0x69, 0x6e, 0x52, 0x05, 0x74, 0x72, 0x61, 0x69, 0x6e, 0x2a, 0x49, 0x0a, + 0x08, 0x50, 0x72, 0x69, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x12, 0x18, 0x0a, 0x14, 0x50, 0x52, 0x49, + 0x4f, 0x52, 0x49, 0x54, 0x59, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, + 0x44, 0x10, 0x00, 0x12, 0x10, 0x0a, 0x0c, 0x50, 0x52, 0x49, 0x4f, 0x52, 0x49, 0x54, 0x59, 0x5f, + 0x4c, 0x4f, 0x57, 0x10, 0x01, 0x12, 0x11, 0x0a, 0x0d, 0x50, 0x52, 0x49, 0x4f, 0x52, 0x49, 0x54, + 0x59, 0x5f, 0x48, 0x49, 0x47, 0x48, 0x10, 0x02, 0x42, 0x9a, 0x01, 0x0a, 0x0c, 0x63, 0x6f, 0x6d, + 0x2e, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x76, 0x31, 0x42, 0x0a, 0x54, 0x72, 0x61, 0x69, 0x6e, + 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x3d, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, + 0x63, 0x6f, 0x6d, 0x2f, 0x75, 0x65, 0x63, 0x6b, 0x6f, 0x6b, 0x65, 0x6e, 0x2f, 0x70, 0x6c, 0x61, + 0x72, 0x61, 0x69, 0x6c, 0x32, 0x30, 0x32, 0x33, 0x2f, 0x62, 0x61, 0x63, 0x6b, 0x65, 0x6e, 0x64, + 0x2f, 0x73, 0x70, 0x65, 0x63, 0x2f, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2f, 0x76, 0x31, 0x3b, 0x73, + 0x74, 0x61, 0x74, 0x65, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x53, 0x58, 0x58, 0xaa, 0x02, 0x08, 0x53, + 0x74, 0x61, 0x74, 0x65, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x08, 0x53, 0x74, 0x61, 0x74, 0x65, 0x5c, + 0x56, 0x31, 0xe2, 0x02, 0x14, 0x53, 0x74, 0x61, 0x74, 0x65, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, + 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x09, 0x53, 0x74, 0x61, 0x74, + 0x65, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -530,7 +500,7 @@ var file_state_v1_train_proto_goTypes = []interface{}{ var file_state_v1_train_proto_depIdxs = []int32{ 0, // 0: state.v1.Train.priority:type_name -> state.v1.Priority 1, // 1: state.v1.GetTrainsResponse.trains:type_name -> state.v1.Train - 0, // 2: state.v1.AddTrainRequest.priority:type_name -> state.v1.Priority + 1, // 2: state.v1.AddTrainRequest.train:type_name -> state.v1.Train 1, // 3: state.v1.AddTrainResponse.train:type_name -> state.v1.Train 1, // 4: state.v1.UpdateTrainRequest.train:type_name -> state.v1.Train 1, // 5: state.v1.UpdateTrainResponse.train:type_name -> state.v1.Train diff --git a/frontend/dashboard/proto/state/v1/train_pb.d.ts b/frontend/dashboard/proto/state/v1/train_pb.d.ts index b6c95e38..25927e47 100644 --- a/frontend/dashboard/proto/state/v1/train_pb.d.ts +++ b/frontend/dashboard/proto/state/v1/train_pb.d.ts @@ -131,32 +131,9 @@ export declare class GetTrainsResponse extends Message { */ export declare class AddTrainRequest extends Message { /** - * 列車ID - * - * @generated from field: string train_id = 1; - */ - trainId: string; - - /** - * 駅 or 閉塞のID - * - * @generated from field: string position_id = 2; - */ - positionId: string; - - /** - * 列車の優先度 - * - * @generated from field: state.v1.Priority priority = 3; - */ - priority: Priority; - - /** - * NFCのUUID - * - * @generated from field: string uuid = 4; + * @generated from field: state.v1.Train train = 1; */ - uuid: string; + train?: Train; constructor(data?: PartialMessage); diff --git a/frontend/dashboard/proto/state/v1/train_pb.js b/frontend/dashboard/proto/state/v1/train_pb.js index f4c88d93..a70e7d4a 100644 --- a/frontend/dashboard/proto/state/v1/train_pb.js +++ b/frontend/dashboard/proto/state/v1/train_pb.js @@ -64,10 +64,7 @@ export const GetTrainsResponse = proto3.makeMessageType( export const AddTrainRequest = proto3.makeMessageType( "state.v1.AddTrainRequest", () => [ - { no: 1, name: "train_id", kind: "scalar", T: 9 /* ScalarType.STRING */ }, - { no: 2, name: "position_id", kind: "scalar", T: 9 /* ScalarType.STRING */ }, - { no: 3, name: "priority", kind: "enum", T: proto3.getEnumType(Priority) }, - { no: 4, name: "uuid", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 1, name: "train", kind: "message", T: Train }, ], ); From 20dff9e4013e06073437516d16f3c164386bee33 Mon Sep 17 00:00:00 2001 From: Koichi Hirachi Date: Wed, 22 Nov 2023 22:48:56 +0900 Subject: [PATCH 9/9] Update Handlers --- .../pkg/connect/connect_handler.go | 120 ++++++++++++++---- backend/state-manager/pkg/db/db.go | 65 ++++++++-- 2 files changed, 154 insertions(+), 31 deletions(-) diff --git a/backend/state-manager/pkg/connect/connect_handler.go b/backend/state-manager/pkg/connect/connect_handler.go index 1100e736..ff705297 100644 --- a/backend/state-manager/pkg/connect/connect_handler.go +++ b/backend/state-manager/pkg/connect/connect_handler.go @@ -94,11 +94,29 @@ func (s *StateManagerServer) GetPointStates( ctx context.Context, req *connect.Request[statev1.GetPointStatesRequest], ) (*connect.Response[statev1.GetPointStatesResponse], error) { - err := connect.NewError( - connect.CodeUnknown, - errors.New("not implemented"), - ) - return nil, err + blockStates, err := s.DBHandler.GetPoints() + if err != nil { + err = connect.NewError( + connect.CodeUnknown, + errors.New("db error"), + ) + return nil, err + } + + var response []*statev1.PointAndState + + for _, pointState := range blockStates { + response = append(response, &statev1.PointAndState{ + Id: pointState.Id, + State: pointState.State, + }) + } + + res := connect.NewResponse(&statev1.GetPointStatesResponse{ + States: response, + }) + + return res, nil } /* @@ -126,11 +144,30 @@ func (s *StateManagerServer) GetStopStates( ctx context.Context, req *connect.Request[statev1.GetStopStatesRequest], ) (*connect.Response[statev1.GetStopStatesResponse], error) { - err := connect.NewError( - connect.CodeUnknown, - errors.New("not implemented"), - ) - return nil, err + stopStates, err := s.DBHandler.GetStops() + if err != nil { + err = connect.NewError( + connect.CodeUnknown, + errors.New("db error"), + ) + slog.Default().Error("db connection error", err) + return nil, err + } + + var response []*statev1.StopAndState + + for _, stopState := range stopStates { + response = append(response, &statev1.StopAndState{ + Id: stopState.Id, + State: stopState.State, + }) + } + + res := connect.NewResponse(&statev1.GetStopStatesResponse{ + States: response, + }) + + return res, nil } /* @@ -141,20 +178,57 @@ func (s *StateManagerServer) GetTrains( ctx context.Context, req *connect.Request[statev1.GetTrainsRequest], ) (*connect.Response[statev1.GetTrainsResponse], error) { - err := connect.NewError( - connect.CodeUnknown, - errors.New("not implemented"), - ) - return nil, err + trains, err := s.DBHandler.GetTrains() + if err != nil { + err = connect.NewError( + connect.CodeUnknown, + errors.New("db error"), + ) + slog.Default().Error("db connection error", err) + } + var response []*statev1.Train + + for _, train := range trains { + response = append(response, &statev1.Train{ + TrainId: train.TrainId, + PositionId: train.PositionId, + Priority: train.Priority, + }) + } + + res := connect.NewResponse(&statev1.GetTrainsResponse{ + Trains: response, + }) + + return res, err } -func (s *StateManagerServer) UpdateTrainUUID( +func (s *StateManagerServer) AddTrain( ctx context.Context, - req *connect.Request[statev1.UpdateTrainUUIDRequest], -) (*connect.Response[statev1.UpdateTrainUUIDResponse], error) { - err := connect.NewError( - connect.CodeUnknown, - errors.New("not implemented"), - ) - return nil, err + req *connect.Request[statev1.AddTrainRequest], +) (*connect.Response[statev1.AddTrainResponse], error) { + err := s.DBHandler.AddTrain(req.Msg.Train) + if err != nil { + err = connect.NewError( + connect.CodeUnknown, + errors.New("db error"), + ) + slog.Default().Error("db connection error", err) + } + return connect.NewResponse(&statev1.AddTrainResponse{}), err +} + +func (s *StateManagerServer) UpdateTrain( + ctx context.Context, + req *connect.Request[statev1.UpdateTrainRequest], +) (*connect.Response[statev1.UpdateTrainResponse], error) { + err := s.DBHandler.UpdateTrain(req.Msg.Train) + if err != nil { + err = connect.NewError( + connect.CodeUnknown, + errors.New("db error"), + ) + slog.Default().Error("db connection error", err) + } + return connect.NewResponse(&statev1.UpdateTrainResponse{}), err } diff --git a/backend/state-manager/pkg/db/db.go b/backend/state-manager/pkg/db/db.go index 80903aab..16e2db5c 100644 --- a/backend/state-manager/pkg/db/db.go +++ b/backend/state-manager/pkg/db/db.go @@ -86,18 +86,18 @@ func (db *DBHandler) GetPoint(pointId string) (*statev1.PointAndState, error) { return result, nil } -func (db *DBHandler) GetPoints() []*statev1.PointAndState { +func (db *DBHandler) GetPoints() ([]*statev1.PointAndState, error) { collection := db.stateManagerDB.Collection("points") cursor, err := collection.Find(context.Background(), bson.M{}) if err != nil { slog.Default().Warn("Get Points failed", slog.Any("err", err)) - panic(err) + return nil, err } var result []*statev1.PointAndState if err = cursor.All(context.Background(), &result); err != nil { - panic(err) + return nil, err } - return result + return result, nil } /* @@ -138,17 +138,17 @@ func (db *DBHandler) GetStop(stopId string) (*statev1.StopAndState, error) { return result, nil } -func (db *DBHandler) GetStops() []*statev1.StopAndState { +func (db *DBHandler) GetStops() ([]*statev1.StopAndState, error) { collection := db.stateManagerDB.Collection("stops") cursor, err := collection.Find(context.Background(), bson.M{}) if err != nil { - panic(err) + return nil, err } var result []*statev1.StopAndState if err = cursor.All(context.Background(), &result); err != nil { - panic(err) + return nil, err } - return result + return result, nil } /* @@ -199,3 +199,52 @@ func (db *DBHandler) GetBlocks() ([]*statev1.BlockState, error) { } return result, nil } + +/* +Train +*/ + +func (db *DBHandler) AddTrain(train *statev1.Train) error { + collection := db.stateManagerDB.Collection("trains") + _, err := collection.InsertOne(context.Background(), train) + if err != nil { + return err + } + return nil +} + +func (db *DBHandler) UpdateTrain(train *statev1.Train) error { + collection := db.stateManagerDB.Collection("trains") + _, err := collection.UpdateOne( + context.Background(), + bson.M{"trainid": train.TrainId}, + bson.M{"$set": bson.M{"state": train}}, + ) + if err != nil { + return err + } + return nil +} + +func (db *DBHandler) GetTrain(trainId string) (*statev1.Train, error) { + collection := db.stateManagerDB.Collection("trains") + var result *statev1.Train + err := collection.FindOne(context.Background(), bson.M{"trainid": trainId}).Decode(&result) + if err != nil { + return nil, err + } + return result, nil +} + +func (db *DBHandler) GetTrains() ([]*statev1.Train, error) { + collection := db.stateManagerDB.Collection("trains") + cursor, err := collection.Find(context.Background(), bson.M{}) + if err != nil { + return nil, err + } + var result []*statev1.Train + if err = cursor.All(context.Background(), &result); err != nil { + return nil, err + } + return result, nil +}