Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Node.js to v16.20.2 #528

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions backend/auto_operation/ATO.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
16 changes: 12 additions & 4 deletions backend/auto_operation/ATS.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand All @@ -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} !")
Expand Down
12 changes: 9 additions & 3 deletions backend/auto_operation/Components.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down Expand Up @@ -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]:
Expand Down
8 changes: 6 additions & 2 deletions backend/auto_operation/PointSwitcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
4 changes: 3 additions & 1 deletion backend/auto_operation/SignalSystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
20 changes: 15 additions & 5 deletions backend/auto_operation/State.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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に列車が存在しない、または存在しても引数で指定された地点より進んだ位置にいる(=遠ざかっている)場合、探索セクションをひとつ前へ
Expand All @@ -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:
Expand All @@ -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()

Expand Down
4 changes: 3 additions & 1 deletion backend/auto_operation/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion frontend/site/.nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
16.20.0
16.20.2
2 changes: 1 addition & 1 deletion frontend/site/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Expand Down