From 5421a2d5e0d8b9159ad78daa230dd0723b4bf1d2 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sun, 8 Dec 2024 18:47:12 +0000 Subject: [PATCH 1/2] Update Node.js to v16.20.2 --- frontend/site/.nvmrc | 2 +- frontend/site/Dockerfile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/site/.nvmrc b/frontend/site/.nvmrc index 3b3a53bf..1b497a7b 100644 --- a/frontend/site/.nvmrc +++ b/frontend/site/.nvmrc @@ -1 +1 @@ -16.20.0 \ No newline at end of file +16.20.2 \ No newline at end of file diff --git a/frontend/site/Dockerfile b/frontend/site/Dockerfile index cd6d1b36..ec8ff681 100644 --- a/frontend/site/Dockerfile +++ b/frontend/site/Dockerfile @@ -1,5 +1,5 @@ # Build the source code -FROM node:16.20.0-buster-slim AS builder +FROM node:16.20.2-buster-slim AS builder WORKDIR /app COPY package.json yarn.lock ./ RUN yarn install --frozen-lockfile --immutable From 3d7a13b14372f88dd83e4f0bae881f6e57c0b87d Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 8 Dec 2024 18:47:50 +0000 Subject: [PATCH 2/2] format by black --- backend/auto_operation/ATO.py | 8 ++++++-- backend/auto_operation/ATS.py | 16 ++++++++++++---- backend/auto_operation/Components.py | 12 +++++++++--- backend/auto_operation/PointSwitcher.py | 8 ++++++-- backend/auto_operation/SignalSystem.py | 4 +++- backend/auto_operation/State.py | 20 +++++++++++++++----- backend/auto_operation/main.py | 4 +++- 7 files changed, 54 insertions(+), 18 deletions(-) diff --git a/backend/auto_operation/ATO.py b/backend/auto_operation/ATO.py index 77469643..ccae92b2 100644 --- a/backend/auto_operation/ATO.py +++ b/backend/auto_operation/ATO.py @@ -25,7 +25,9 @@ def __init__( self.__diaPlanner = diaPlanner self.__prevUpdate = 0.0 self.__enabled = {} # 各列車の、ATO有効,無効が入る辞書. key=trainId, valued=enabled - self.__arriveTime = {} # 各列車が、直近に駅に到着した時刻を記録する辞書. key=trainId, value=float + self.__arriveTime = ( + {} + ) # 各列車が、直近に駅に到着した時刻を記録する辞書. key=trainId, value=float self.__MAXSPEED = MAXSPEED self.__MERGIN = MERGIN for train in state.trainList: @@ -74,7 +76,9 @@ def getATOStopPoint(self, train: Train) -> StopPoint: while True: # 現在のセクションに駅がある if testSection.station is not None: - diaOfThisStation = self.__diaPlanner.getDia(train.id, testSection.station.id) # ダイヤ + diaOfThisStation = self.__diaPlanner.getDia( + train.id, testSection.station.id + ) # ダイヤ # 当該駅に列車がすでに到着/通過済みの場合 if ( train.currentSection.id == testSection.id diff --git a/backend/auto_operation/ATS.py b/backend/auto_operation/ATS.py index 72ca78b2..ecd5df92 100644 --- a/backend/auto_operation/ATS.py +++ b/backend/auto_operation/ATS.py @@ -24,8 +24,12 @@ def __init__( self.__MAXSPEED = MAXSPEED self.__MERGIN = MERGIN self.__BREAKING_DISTANCE = BREAKING_DISTANCE - self.__enabled: dict[int, bool] = {} # 各列車の、ATS有効,無効が入る辞書. key=trainId, value=enabled - self.__activated: dict[int, bool] = {} # ATSが作動したときにTrueが入る. key=trainId, value=activated + self.__enabled: dict[int, bool] = ( + {} + ) # 各列車の、ATS有効,無効が入る辞書. key=trainId, value=enabled + self.__activated: dict[int, bool] = ( + {} + ) # ATSが作動したときにTrueが入る. key=trainId, value=activated for train in state.trainList: self.__enabled[train.id] = True self.__activated[train.id] = False @@ -41,7 +45,9 @@ def setSpeedCommand(self, trainId: int, speedCommand: float): distance = self.__state.getDistance( train.currentSection, train.mileage, atsStopPoint.section, atsStopPoint.mileage ) # 絶対停止点までの距離を計算 - if train.stopPoint is None: # 停止点が代入されていない場合、ATSで計算した停止点を代入する + if ( + train.stopPoint is None + ): # 停止点が代入されていない場合、ATSで計算した停止点を代入する train.stopPoint = atsStopPoint if distance > self.__BREAKING_DISTANCE: @@ -51,7 +57,9 @@ def setSpeedCommand(self, trainId: int, speedCommand: float): else: speedLimit = 0 - if speedLimit < speedCommand: # 非常停止できる速度を超えた速度が指示された場合、速度を強制的にspeedLimitに落とす + if ( + speedLimit < speedCommand + ): # 非常停止できる速度を超えた速度が指示された場合、速度を強制的にspeedLimitに落とす train.targetSpeed = speedLimit if not self.__activated[train.id]: # ATS作動フラグ(activated)を立てる print(f"[ATS.setSpeedCommand] ATS activated on train {train.id} !") diff --git a/backend/auto_operation/Components.py b/backend/auto_operation/Components.py index 92dcff18..31d99858 100644 --- a/backend/auto_operation/Components.py +++ b/backend/auto_operation/Components.py @@ -120,7 +120,9 @@ def invert(input: "Junction.ServoState") -> "Junction.ServoState": ] id: JunctionId - pointId: Optional[Point.PointId] # junctionにサーボモータがついている場合のみ対応するPointIdを代入 + pointId: Optional[ + Point.PointId + ] # junctionにサーボモータがついている場合のみ対応するPointIdを代入 inSectionStraight: Optional["Section"] inSectionCurve: Optional["Section"] outSectionStraight: Optional["Section"] @@ -171,9 +173,13 @@ def toggle(self) -> None: self.toggleRequested = True def setServoState(self, servoState: ServoState) -> None: - if self.inSectionStraight and self.inSectionCurve: # IN側に2本入ってくる分岐点の場合inServoStateをセット + if ( + self.inSectionStraight and self.inSectionCurve + ): # IN側に2本入ってくる分岐点の場合inServoStateをセット self.inServoState = servoState - if self.outSectionStraight and self.outSectionCurve: # OUT側に2本入ってくる分岐点の場合outServoStateをセット + if ( + self.outSectionStraight and self.outSectionCurve + ): # OUT側に2本入ってくる分岐点の場合outServoStateをセット self.outServoState = servoState def getOutSection(self) -> Optional[Section]: diff --git a/backend/auto_operation/PointSwitcher.py b/backend/auto_operation/PointSwitcher.py index acd0f9fc..e5ea3638 100644 --- a/backend/auto_operation/PointSwitcher.py +++ b/backend/auto_operation/PointSwitcher.py @@ -122,9 +122,13 @@ def __getNearestTrain( trains, ) ) # 駅で退避するつもりのないtrainをfilter - if len(trainsWantToGo) == 0: # 全列車が退避したい場合、どれを先に出すか決めようがないので、とりあえず0番を返す + if ( + len(trainsWantToGo) == 0 + ): # 全列車が退避したい場合、どれを先に出すか決めようがないので、とりあえず0番を返す return trains[0] - elif len(trainsWantToGo) == 1: # 退避するつもりのない(追い抜きたい)列車が1つのとき、それを先に行かせる + elif ( + len(trainsWantToGo) == 1 + ): # 退避するつもりのない(追い抜きたい)列車が1つのとき、それを先に行かせる return trainsWantToGo[0] else: # 退避するつもりのない列車が2つ以上のとき、最もjunctionに近いものを返す trainsWantToGo.sort( diff --git a/backend/auto_operation/SignalSystem.py b/backend/auto_operation/SignalSystem.py index f45f8b41..96c1359f 100644 --- a/backend/auto_operation/SignalSystem.py +++ b/backend/auto_operation/SignalSystem.py @@ -32,7 +32,9 @@ def getSignal( return None # 信号判定 if junction.getInSection().id == sourceSectionId: # 分岐器が開通している - train = self.__state.getTrainInSection(junction.getOutSection()) # 前方セクションにいる列車を取得 + train = self.__state.getTrainInSection( + junction.getOutSection() + ) # 前方セクションにいる列車を取得 if train is None: # 前方セクションに在線なし return Signal(sourceSectionId, targetSectionId, "G") return Signal(sourceSectionId, targetSectionId, "R") diff --git a/backend/auto_operation/State.py b/backend/auto_operation/State.py index 125253c8..1ec09543 100644 --- a/backend/auto_operation/State.py +++ b/backend/auto_operation/State.py @@ -424,7 +424,9 @@ def update(self): approachingTrain = self.getApproachingTrain(sensor.belongSection, sensor.position) if approachingTrain is not None: approachingTrain.currentSection = sensor.belongSection - approachingTrain.mileage = sensor.position + 1.0 # センサより僅かに先に進める(センサを通過したことを示すため) + approachingTrain.mileage = ( + sensor.position + 1.0 + ) # センサより僅かに先に進める(センサを通過したことを示すため) print(f"[State.update] sensor {sensor.id}: train{train.id} position updated") else: print(f"[State.update] sensor {sensor.id}: train is not detected") @@ -464,7 +466,9 @@ def getTrainInSection(self, section: Section) -> Train: # 指定された地点に近づいてくる列車で一番近いものを取得 def getApproachingTrain(self, section: Section, mileage: float) -> Train: testSection = section - testedSectionId = [] # 一度確認したセクションIDを記録しておき、2回通ったら抜けられないとみてNoneを返す + testedSectionId = ( + [] + ) # 一度確認したセクションIDを記録しておき、2回通ったら抜けられないとみてNoneを返す while True: approachingTrain = self.getTrainInSection(testSection) # testSectionに列車が存在しない、または存在しても引数で指定された地点より進んだ位置にいる(=遠ざかっている)場合、探索セクションをひとつ前へ @@ -473,8 +477,12 @@ def getApproachingTrain(self, section: Section, mileage: float) -> Train: and approachingTrain.mileage > mileage ): testedSectionId.append(testSection.id) # 一度確認したセクションIDを記録しておく - testSection = testSection.sourceJunction.getInSection() # ひとつ前のセクションに検索範囲を移す - if testSection.id in testedSectionId: # すでに確認済みの場合、一周して戻ってしまったので、列車はいない。Noneを返す + testSection = ( + testSection.sourceJunction.getInSection() + ) # ひとつ前のセクションに検索範囲を移す + if ( + testSection.id in testedSectionId + ): # すでに確認済みの場合、一周して戻ってしまったので、列車はいない。Noneを返す return None # 存在すればその列車を返す else: @@ -493,7 +501,9 @@ def getDistance(self, s1: Section, mileage1: float, s2: Section, mileage2: float if testSection.targetJunction.id in passedJunctionId: return float("nan") else: - passedJunctionId.append(testSection.targetJunction.id) # 一度通過したjunctionのidを記録 + passedJunctionId.append( + testSection.targetJunction.id + ) # 一度通過したjunctionのidを記録 distance += testSection.length testSection = testSection.targetJunction.getOutSection() diff --git a/backend/auto_operation/main.py b/backend/auto_operation/main.py index 755ab8f3..cb9b87c6 100644 --- a/backend/auto_operation/main.py +++ b/backend/auto_operation/main.py @@ -81,7 +81,9 @@ def send_signal_to_browser(): stopId = operation.state.sectionIdToStopId[section.id] stops[stopId] = False for train in operation.state.trainList: - if train.stopPoint: # 列車には停止すべき点が存在しない場合もある(ATSを無効化した場合など)。停止点を持っている場合はsectionIDを送る + if ( + train.stopPoint + ): # 列車には停止すべき点が存在しない場合もある(ATSを無効化した場合など)。停止点を持っている場合はsectionIDを送る sectionId = train.stopPoint.section.id stopId = operation.state.sectionIdToStopId[sectionId] stops[stopId] = True