Skip to content

Commit

Permalink
feat: add request stop functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
davwheat committed Oct 28, 2023
1 parent 911aaad commit 540f885
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
22 changes: 22 additions & 0 deletions src/announcement-data/systems/stations/KeTechPhil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,26 @@ export default class KeTechPhil extends StationAnnouncementSystem {
return files
}

private async getRequestStops(callingPoints: CallingAtPoint[]): Promise<AudioItem[]> {
const files: AudioItem[] = []

const reqStops = callingPoints.filter(s => s.requestStop)
if (reqStops.length === 0) return []

files.push(
...this.pluraliseAudio(
reqStops.map((s, i) => ({ id: s.crsCode, opts: { delayStart: i === 0 ? 400 : 100 } })),
100,
{ prefix: 'station.m.', finalPrefix: 'station.m.', andId: 'm.and' },
),
reqStops.length === 1 ? 'm.is a request stop and customers for this station' : 'm.are request stops and customers for these stations',
'm.should ask the conductor on the train to arrange for the train to stop',
'e.to allow them to alight',
)

return files
}

private async playNextTrainAnnouncement(options: INextTrainAnnouncementOptions, download: boolean = false): Promise<void> {
const files: AudioItem[] = []

Expand Down Expand Up @@ -496,6 +516,7 @@ export default class KeTechPhil extends StationAnnouncementSystem {
}

files.push(...(await this.getShortPlatforms(options.callingAt)))
files.push(...(await this.getRequestStops(options.callingAt)))

const coaches = options.coaches.split(' ')[0]

Expand Down Expand Up @@ -3174,6 +3195,7 @@ export default class KeTechPhil extends StationAnnouncementSystem {
props: {
availableStations: this.stations,
enableShortPlatforms: this.shortPlatforms,
enableRequestStops: true,
},
default: [],
},
Expand Down
6 changes: 3 additions & 3 deletions src/components/CallingAtSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ interface ICallingAtSelectorProps {
/**
* Whether request stops are enabled.
*/
requestStops?: boolean
enableRequestStops?: boolean
}

function CallingAtSelector({
Expand All @@ -98,7 +98,7 @@ function CallingAtSelector({
placeholder = 'Add a calling point...',
heading = 'Calling at... (excluding terminating station)',
enableShortPlatforms = false,
requestStops = false,
enableRequestStops = false,
}: ICallingAtSelectorProps): JSX.Element {
const classes = useStyles()

Expand Down Expand Up @@ -191,7 +191,7 @@ function CallingAtSelector({
},
)}

{requestStops &&
{enableRequestStops &&
createOptionField(
{
default: false,
Expand Down

0 comments on commit 540f885

Please sign in to comment.