Skip to content

Commit

Permalink
Merge branch 'main' into #302-only_local_train
Browse files Browse the repository at this point in the history
  • Loading branch information
thgcMtdh committed Nov 18, 2022
2 parents 4bbf22b + a327490 commit 4c19c35
Show file tree
Hide file tree
Showing 75 changed files with 1,611 additions and 966 deletions.
2 changes: 1 addition & 1 deletion backend/ats/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"ts-jest": "^29.0.3",
"ts-node": "^10.9.1",
"ts-protoc-gen": "0.15.0",
"typescript": "4.9.3"
"typescript": "4.8.4"
},
"dependencies": {
"@grpc/grpc-js": "^1.7.2",
Expand Down
2 changes: 1 addition & 1 deletion backend/ats/spec/block_pb.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ export interface BlockIdMap {
HASHIMOTO_B1: 31;
HASHIMOTO_B2: 32;
HACHIOJI_B1: 41;
HASHIOJI_B2: 42;
HACHIOJI_B2: 42;
}

export const BlockId: BlockIdMap;
Expand Down
2 changes: 1 addition & 1 deletion backend/ats/spec/block_pb.js
Original file line number Diff line number Diff line change
Expand Up @@ -821,7 +821,7 @@ proto.BlockId = {
HASHIMOTO_B1: 31,
HASHIMOTO_B2: 32,
HACHIOJI_B1: 41,
HASHIOJI_B2: 42
HACHIOJI_B2: 42
};

goog.object.extend(exports, proto);
8 changes: 4 additions & 4 deletions backend/ats/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2509,10 +2509,10 @@ type-fest@^0.21.3:
resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.21.3.tgz#d260a24b0198436e133fa26a524a6d65fa3b2e37"
integrity sha512-t0rzBq87m3fVcduHDUFhKmyyX+9eo6WQjZvf51Ea/M0Q7+T374Jp1aUiyUl0GKxp8M/OETVHSDvmkyPgvX+X2w==

typescript@4.9.3:
version "4.9.3"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.9.3.tgz#3aea307c1746b8c384435d8ac36b8a2e580d85db"
integrity sha512-CIfGzTelbKNEnLpLdGFgdyKhG23CKdKgQPOBc+OUNrkJ2vr+KSzsSV5kq5iWhEQbok+quxgGzrAtGWCyU7tHnA==
typescript@4.8.4:
version "4.8.4"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.8.4.tgz#c464abca159669597be5f96b8943500b238e60e6"
integrity sha512-QCh+85mCy+h0IGff8r5XWzOVSbBO+KfeYrMQh7NJ58QujwcE22u+NUSmUxqF+un70P9GXKxa2HCNiTTMJknyjQ==

update-browserslist-db@^1.0.9:
version "1.0.10"
Expand Down
4 changes: 2 additions & 2 deletions backend/auto_operation/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
bidict==0.22.0
click==8.1.3
dnspython==2.2.1
eventlet==0.33.1
eventlet==0.33.2
Flask==2.2.2
Flask-Cors==3.0.10
Flask-SocketIO==5.3.1
Expand All @@ -22,5 +22,5 @@ types-protobuf==3.20.4.5
types-Flask-Cors
Werkzeug==2.2.2
zope.event==4.5.0
zope.interface==5.5.1
zope.interface==5.5.2
grpcio-tools==1.50.0
2 changes: 1 addition & 1 deletion backend/auto_operation/spec/block_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion backend/auto_operation/spec/block_pb2.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ chofu_b3: BlockId
chofu_b4: BlockId
chofu_b5: BlockId
hachioji_b1: BlockId
hachioji_b2: BlockId
hashimoto_b1: BlockId
hashimoto_b2: BlockId
hashioji_b2: BlockId
sakurajosui_b1: BlockId
sakurajosui_b2: BlockId
sakurajosui_b3: BlockId
Expand Down
78 changes: 39 additions & 39 deletions backend/external/internal/embed/stationInit.yml
Original file line number Diff line number Diff line change
@@ -1,86 +1,86 @@
stations:
- name: motoyawata_s1
state: ON
state: POINTSTATE_ON
- name: motoyawata_s2
state: ON
state: POINTSTATE_ON

- name: iwamotocho_s1
state: ON
state: POINTSTATE_ON
- name: iwamotocho_s2
state: ON
state: POINTSTATE_ON
- name: iwamotocho_s4
state: ON
state: POINTSTATE_ON
- name: iwamotocho_b1
state: ON
state: POINTSTATE_ON
- name: iwamotocho_b4
state: ON
state: POINTSTATE_ON

- name: kudanshita_s5
state: ON
state: POINTSTATE_ON
- name: kudanshita_s6
state: ON
state: POINTSTATE_ON

- name: sasazuka_b1
state: ON
state: POINTSTATE_ON
- name: sasazuka_b2
state: ON
state: POINTSTATE_ON
- name: sasazuka_s1
state: ON
state: POINTSTATE_ON
- name: sasazuka_s2
state: ON
state: POINTSTATE_ON
- name: sasazuka_s3
state: ON
state: POINTSTATE_ON
- name: sasazuka_s4
state: ON
state: POINTSTATE_ON
- name: sasazuka_s5
state: ON
state: POINTSTATE_ON

- name: meidaimae_s1
state: ON
state: POINTSTATE_ON
- name: meidaimae_s2
state: ON
state: POINTSTATE_ON

- name: chofu_s1
state: ON
state: POINTSTATE_ON
- name: chofu_s2
state: OFF
state: POINTSTATE_OFF
- name: chofu_s3
state: ON
state: POINTSTATE_ON
- name: chofu_s4
state: ON
state: POINTSTATE_ON
- name: chofu_s5
state: ON
state: POINTSTATE_ON
- name: chofu_s6
state: ON
state: POINTSTATE_ON
- name: chofu_b1
state: ON
state: POINTSTATE_ON
- name: chofu_b2
state: OFF
state: POINTSTATE_OFF
- name: chofu_b3
state: ON
state: POINTSTATE_ON
- name: chofu_b4
state: ON
state: POINTSTATE_ON
- name: chofu_b5
state: ON
state: POINTSTATE_ON

- name: kitano_b1
state: ON
state: POINTSTATE_ON
- name: kitano_b2
state: ON
state: POINTSTATE_ON
- name: kitano_s1
state: ON
state: POINTSTATE_ON
- name: kitano_s2
state: ON
state: POINTSTATE_ON
- name: kitano_s3
state: ON
state: POINTSTATE_ON
- name: kitano_s4
state: ON
state: POINTSTATE_ON
- name: kitano_s5
state: ON
state: POINTSTATE_ON
- name: kitano_s6
state: ON
state: POINTSTATE_ON

- name: takao_s1
state: ON
state: POINTSTATE_ON
- name: takao_s2
state: ON
state: POINTSTATE_ON
39 changes: 39 additions & 0 deletions backend/external/internal/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,42 @@ func GRPCListenAndServe(ctx context.Context, logger *zap.Logger, port uint, hand
logger.Panic("failed to server", zap.Error(err))
}
}

// GrpcStateHandler is a handler for gRPC.
type GrpcStateHandlerForInternal struct {
logger *zap.Logger
env *envStore.Env
stateInput <-chan synccontroller.KV[spec.StationId, spec.PointStateEnum]
}

// / handleInput transmits changes received in channel to ATS.
func (g GrpcStateHandlerForInternal) handleInput(ctx context.Context) {
con, err := grpc.DialContext(ctx, g.env.InternalServer.Addr.String(),
grpc.WithTransportCredentials(insecure.NewCredentials()),
)
if err != nil {
g.logger.Error("failed to connect ATS", zap.Error(err))
}
defer con.Close()
for d := range g.stateInput {
client := spec.NewPointStateNotificationClient(con)
req := &spec.NotifyPointStateRequest{
State: &spec.PointAndState{
Station: &spec.Station{StationId: d.Key},
State: d.Value,
},
}
_, err := client.NotifyPointState(ctx, req)
if err != nil {
g.logger.Error("failed to send data to ATS", zap.Any("payload", req), zap.Error(err))
}
}
}

func NewGrpcHandlerForInternal(logger *zap.Logger, env *envStore.Env, stateInput <-chan synccontroller.KV[spec.StationId, spec.PointStateEnum]) *GrpcStateHandlerForInternal {
return &GrpcStateHandlerForInternal{logger, env, stateInput}
}

func (g GrpcStateHandlerForInternal) Run(ctx context.Context) {
g.handleInput(ctx)
}
Loading

0 comments on commit 4c19c35

Please sign in to comment.