Skip to content

Commit

Permalink
Merge branch 'main' into deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
davwheat committed Dec 7, 2023
2 parents 9c4e25f + 850db44 commit 9150caa
Show file tree
Hide file tree
Showing 33 changed files with 47 additions and 28 deletions.
4 changes: 2 additions & 2 deletions src/announcement-data/AnnouncementSystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -287,8 +287,8 @@ export default abstract class AnnouncementSystem {
_items.splice(_items.length - 1, 0, { id: _options.andId, opts: { delayStart: _options.beforeAndDelay } })

if (_options.afterAndDelay !== undefined || _options.beforeItemDelay !== undefined) {
_items[items.length - 1].opts ??= {}
_items[items.length - 1].opts!!.delayStart = _options.afterAndDelay ?? _options.beforeItemDelay
_items[_items.length - 1].opts ??= {}
_items[_items.length - 1].opts!!.delayStart = _options.afterAndDelay ?? _options.beforeItemDelay
}
}

Expand Down
11 changes: 8 additions & 3 deletions src/announcement-data/systems/stations/AmeyCelia.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,14 @@ export default class AmeyCelia extends AmeyPhil {
readonly FILE_PREFIX = 'station/ketech/celia'
readonly SYSTEM_TYPE = 'station'

protected readonly CALLING_POINT_DELAY = 160
protected readonly CALLING_POINT_AND_DELAY = 80
protected readonly BEFORE_TOC_DELAY: number = 75
protected readonly BEFORE_TOC_DELAY: number = 30
protected readonly BEFORE_SECTION_DELAY: number = 520

protected readonly callingPointsOptions = {
beforeCallingAtDelay: this.BEFORE_SECTION_DELAY,
betweenStopsDelay: 220,
aroundAndDelay: 0,
}

get DEFAULT_CHIME(): ChimeType {
return 'three'
Expand Down
60 changes: 37 additions & 23 deletions src/announcement-data/systems/stations/AmeyPhil.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,18 @@ export default class AmeyPhil extends StationAnnouncementSystem {
readonly FILE_PREFIX: string = 'station/ketech/phil'
readonly SYSTEM_TYPE = 'station'

protected readonly CALLING_POINT_DELAY: number = 200
protected readonly CALLING_POINT_AND_DELAY: number = 100
protected readonly BEFORE_TOC_DELAY: number = 150
protected readonly BEFORE_SECTION_DELAY: number = 870

protected readonly callingPointsOptions = {
beforeCallingAtDelay: this.BEFORE_SECTION_DELAY,
betweenStopsDelay: 320,
aroundAndDelay: 100,
}

protected readonly requestStopOptions = {
andId: 'm.or-2',
}

get DEFAULT_CHIME(): ChimeType {
return 'four'
Expand Down Expand Up @@ -3571,7 +3580,7 @@ export default class AmeyPhil extends StationAnnouncementSystem {
finalPrefix: 'station.m.',
andId: 'm.and',
beforeAndDelay: this.CALLING_POINT_AND_DELAY,
beforeItemDelay: this.CALLING_POINT_DELAY,
beforeItemDelay: this.BETWEEN_CALLING_POINT_DELAY,
afterAndDelay: this.CALLING_POINT_AND_DELAY,
}),
...s.split(','),
Expand All @@ -3588,7 +3597,7 @@ export default class AmeyPhil extends StationAnnouncementSystem {
finalPrefix: 'station.m.',
andId: 'm.and',
beforeAndDelay: this.CALLING_POINT_AND_DELAY,
beforeItemDelay: this.CALLING_POINT_DELAY,
beforeItemDelay: this.BETWEEN_CALLING_POINT_DELAY,
afterAndDelay: this.CALLING_POINT_AND_DELAY,
}),
...s.split(','),
Expand All @@ -3601,10 +3610,6 @@ export default class AmeyPhil extends StationAnnouncementSystem {
return files
}

protected readonly requestStopOptions = {
andId: 'm.or-2',
}

private async getRequestStops(
callingPoints: CallingAtPoint[],
terminatingStation: string,
Expand Down Expand Up @@ -3641,7 +3646,7 @@ export default class AmeyPhil extends StationAnnouncementSystem {
prefix: 'station.m.',
finalPrefix: 'station.m.',
andId: this.requestStopOptions.andId,
beforeItemDelay: this.CALLING_POINT_DELAY,
beforeItemDelay: this.BETWEEN_CALLING_POINT_DELAY,
beforeAndDelay: this.CALLING_POINT_AND_DELAY,
afterAndDelay: this.CALLING_POINT_AND_DELAY,
}),
Expand Down Expand Up @@ -3803,9 +3808,9 @@ export default class AmeyPhil extends StationAnnouncementSystem {
splitData.stopsUpToSplit.map(s => `station.m.${s.crsCode}`),
{
andId: 'm.and',
beforeItemDelay: this.CALLING_POINT_DELAY,
beforeAndDelay: this.CALLING_POINT_AND_DELAY,
afterAndDelay: this.CALLING_POINT_AND_DELAY,
beforeItemDelay: this.callingPointsOptions.betweenStopsDelay,
beforeAndDelay: this.callingPointsOptions.aroundAndDelay,
afterAndDelay: this.callingPointsOptions.aroundAndDelay,
},
),
)
Expand Down Expand Up @@ -3858,9 +3863,9 @@ export default class AmeyPhil extends StationAnnouncementSystem {
stops.map(s => `station.m.${s}`),
{
andId: 'm.and',
beforeAndDelay: this.CALLING_POINT_AND_DELAY,
afterAndDelay: this.CALLING_POINT_AND_DELAY,
beforeItemDelay: this.CALLING_POINT_DELAY,
beforeItemDelay: this.callingPointsOptions.betweenStopsDelay,
beforeAndDelay: this.callingPointsOptions.aroundAndDelay,
afterAndDelay: this.callingPointsOptions.aroundAndDelay,
},
),
]
Expand Down Expand Up @@ -3921,21 +3926,21 @@ export default class AmeyPhil extends StationAnnouncementSystem {
const callingPointsWithSplits = await this.getCallingPointsWithSplits(callingPoints, terminatingStation, overallLength)

if (callingPointsWithSplits.length !== 0) {
files.push({ id: 'm.calling at', opts: { delayStart: 750 } }, ...callingPointsWithSplits)
files.push({ id: 'm.calling at', opts: { delayStart: this.callingPointsOptions.beforeCallingAtDelay } }, ...callingPointsWithSplits)
return files
}

files.push({ id: 'm.calling at', opts: { delayStart: 750 } })
files.push({ id: 'm.calling at', opts: { delayStart: this.callingPointsOptions.beforeCallingAtDelay } })

if (callingPoints.length === 0) {
files.push(`station.m.${terminatingStation}`, 'e.only')
} else {
files.push(
...this.pluraliseAudio([...callingPoints.map(stn => `station.m.${stn.crsCode}`), `station.e.${terminatingStation}`], {
andId: 'm.and',
beforeItemDelay: this.CALLING_POINT_DELAY,
beforeAndDelay: this.CALLING_POINT_AND_DELAY,
afterAndDelay: this.CALLING_POINT_AND_DELAY,
beforeItemDelay: this.callingPointsOptions.betweenStopsDelay,
beforeAndDelay: this.callingPointsOptions.aroundAndDelay,
afterAndDelay: this.callingPointsOptions.aroundAndDelay,
}),
)
}
Expand Down Expand Up @@ -4762,6 +4767,15 @@ function LiveTrainAnnouncements({ nextTrainHandler, disruptedTrainHandler, syste
return true
})

if (train.destination[0].tiploc !== callingPoints[callingPoints.length - 1].tiploc) {
// False destination -- need to trim calling points
const lastRealCallingPoint = callingPoints.findIndex(s => s.tiploc == train.destination[0].tiploc)

console.log(`Fake destination detected. Last real calling point index is ${lastRealCallingPoint}`)

for (let i = lastRealCallingPoint; i < callingPoints.length; i++) delete callingPoints[i]
}

const callingAt = callingPoints
.map((p, i, arr): CallingAtPoint | null => {
console.log(`[${i} of ${arr.length - 1}]: ${p.crs}`)
Expand Down Expand Up @@ -4801,7 +4815,7 @@ function LiveTrainAnnouncements({ nextTrainHandler, disruptedTrainHandler, syste
const options: INextTrainAnnouncementOptions = {
chime: system.DEFAULT_CHIME,
hour: h === '00' ? '00 - midnight' : h,
min: m === '00' ? '00 - hundred' : m,
min: m === '00' ? '00 - hundred-hours' : m,
isDelayed: delayMins > 5,
toc,
coaches: train.length ? `${train.length} coaches` : null,
Expand Down Expand Up @@ -5011,8 +5025,8 @@ function LiveTrainAnnouncements({ nextTrainHandler, disruptedTrainHandler, syste
return false
}
if (s.atdSpecified) {
addLog(`Skipping ${s.trainid} ${s.rid} (${std} to ${s.destination[0].locationName}) as it has already departed`)
console.log(`[Live Trains] Skipping ${s.rid} (${std} to ${s.destination[0].locationName}) as it has already departed`)
addLog(`Skipping ${s.trainid} ${s.rid} (${s.std} to ${s.destination[0].locationName}) as it has already departed`)
console.log(`[Live Trains] Skipping ${s.rid} (${s.std} to ${s.destination[0].locationName}) as it has already departed`)
return false
}
if (!s.isCancelled && calculateDelayMins(new Date(s.std), new Date(s.etd)) < 5 && s.etdSpecified && s.stdSpecified) {
Expand Down
Binary file not shown.
Binary file not shown.
Binary file modified static/audio/station/ketech/celia/station/e/CFR.mp3
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified static/audio/station/ketech/celia/station/e/YVJ.mp3
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified static/audio/station/ketech/celia/station/m/CFR.mp3
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified static/audio/station/ketech/celia/station/m/YVJ.mp3
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified static/audio/station/ketech/phil/e/is being delayed.mp3
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified static/audio/station/ketech/phil/m/is being delayed.mp3
Binary file not shown.
Binary file not shown.
Binary file removed static/audio/station/ketech/phil/station/e/CFR-2.mp3
Binary file not shown.
Binary file modified static/audio/station/ketech/phil/station/e/CFR.mp3
Binary file not shown.
Binary file not shown.
Binary file removed static/audio/station/ketech/phil/station/e/YVJ-2.mp3
Binary file not shown.
Binary file modified static/audio/station/ketech/phil/station/e/YVJ.mp3
Binary file not shown.
Binary file not shown.
Binary file removed static/audio/station/ketech/phil/station/m/CFR-2.mp3
Binary file not shown.
Binary file modified static/audio/station/ketech/phil/station/m/CFR.mp3
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified static/audio/station/ketech/phil/station/m/YVJ.mp3
Binary file not shown.

0 comments on commit 9150caa

Please sign in to comment.