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

add platform edge message to approaching announcement #891

Merged
merged 1 commit into from
Feb 28, 2025
Merged
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
22 changes: 15 additions & 7 deletions lib/content/audio/approaching.ex
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ defmodule Content.Audio.Approaching do
@with_all_new_red_line_cars "893"
# audio: "It is a shorter 4-car train. Move toward the front of the train to board, and stand back from the platform edge.", visual: "Please move to front of the train to board."
@four_car_train_message "922"
# "Please stand back from the platform edge."
@stand_back_message "925"
@comma "21012"
@period "21014"

Expand All @@ -68,15 +70,15 @@ defmodule Content.Audio.Approaching do
approaching = if audio.four_cars?, do: [@now_approaching], else: [@is_now_approaching]
platform = if audio.platform, do: [platform_var(audio.platform)], else: []
new_cars = if audio.new_cars?, do: [@comma, @with_all_new_red_line_cars], else: []
four_cars = if audio.four_cars?, do: [@four_car_train_message], else: []
followup = if audio.four_cars?, do: [@four_car_train_message], else: [@stand_back_message]

crowding =
if audio.crowding_description,
do: [Content.Utilities.crowding_description_var(audio.crowding_description)],
else: []

(prefix ++
train ++ approaching ++ platform ++ new_cars ++ [@period] ++ four_cars ++ crowding)
train ++ approaching ++ platform ++ new_cars ++ [@period] ++ followup ++ crowding)
|> Utilities.take_message(:audio_visual)
end

Expand All @@ -88,12 +90,14 @@ defmodule Content.Audio.Approaching do
platform = platform_string(audio.platform)
new_cars = new_cars_string(audio.new_cars?)

four_cars =
if audio.four_cars?, do: " Please move to front of the train to board.", else: ""
followup =
if audio.four_cars?,
do: " Please move to front of the train to board.",
else: " Please stand back from the platform edge."

{tts_text(audio),
PaEss.Utilities.paginate_text(
"#{prefix}#{train} #{approaching}#{platform}#{new_cars}.#{four_cars}#{crowding}"
"#{prefix}#{train} #{approaching}#{platform}#{new_cars}.#{followup}#{crowding}"
)}
end

Expand All @@ -106,9 +110,13 @@ defmodule Content.Audio.Approaching do
crowding = PaEss.Utilities.crowding_text(audio.crowding_description)
platform = platform_string(audio.platform)
new_cars = new_cars_string(audio.new_cars?)
four_cars = if audio.four_cars?, do: PaEss.Utilities.four_cars_text(), else: ""

"Attention passengers: The next #{train} is now approaching#{platform}#{new_cars}.#{four_cars}#{crowding}"
followup =
if audio.four_cars?,
do: PaEss.Utilities.four_cars_text(),
else: " Please stand back from the platform edge."

"Attention passengers: The next #{train} is now approaching#{platform}#{new_cars}.#{followup}#{crowding}"
end

defp destination_var(:alewife), do: "892"
Expand Down
14 changes: 8 additions & 6 deletions test/content/audio/approaching_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -9,30 +9,33 @@ defmodule Content.Audio.ApproachingTest do

assert Content.Audio.to_params(audio) ==
{:canned,
{"112", spaced(["896", "892", "920", "910", "901", "21014"]), :audio_visual}}
{"114", spaced(["896", "892", "920", "910", "901", "21014", "925"]),
:audio_visual}}
end

test "Returns params when platform is not present" do
audio = %Approaching{destination: :oak_grove, route_id: "Orange"}

assert Content.Audio.to_params(audio) ==
{:canned, {"110", spaced(["896", "915", "920", "910", "21014"]), :audio_visual}}
{:canned,
{"112", spaced(["896", "915", "920", "910", "21014", "925"]), :audio_visual}}
end

test "Returns params for Green Line trips" do
audio = %Approaching{destination: :riverside, route_id: "Green-D"}

assert Content.Audio.to_params(audio) ==
{:canned,
{"112", spaced(["896", "905", "919", "918", "910", "21014"]), :audio_visual}}
{"114", spaced(["896", "905", "919", "918", "910", "21014", "925"]),
:audio_visual}}
end

test "Returns params for new Red Line cars" do
audio = %Approaching{destination: :alewife, route_id: "Red", new_cars?: true}

assert Content.Audio.to_params(audio) ==
{:canned,
{"113", spaced(["896", "892", "920", "910", "21012", "893", "21014"]),
{"115", spaced(["896", "892", "920", "910", "21012", "893", "21014", "925"]),
:audio_visual}}
end

Expand All @@ -45,8 +48,7 @@ defmodule Content.Audio.ApproachingTest do

assert Content.Audio.to_params(audio) ==
{:canned,
{"112",
["896", "21000", "907", "21000", "920", "21000", "910", "21014", "21000", "876"],
{"114", spaced(["896", "907", "920", "910", "21014", "925", "876"]),
:audio_visual}}
end
end
Expand Down
80 changes: 56 additions & 24 deletions test/signs/realtime_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -600,10 +600,16 @@ defmodule Signs.RealtimeTest do
expect_messages({"Clvlnd Cir ARR", "Riverside ARR"})

expect_audios(
[{:canned, {"112", spaced(["896", "903", "919", "904", "910", "21014"]), :audio_visual}}],
[
{"Attention passengers: The next C train to Cleveland Circle is now approaching.",
[{"C train to Clvlnd Cir is", "now approaching.", 3}]}
{:canned,
{"114", spaced(["896", "903", "919", "904", "910", "21014", "925"]), :audio_visual}}
],
[
{"Attention passengers: The next C train to Cleveland Circle is now approaching. Please stand back from the platform edge.",
[
{"C train to Clvlnd Cir is", "now approaching. Please", 3},
{"stand back from the", "platform edge.", 3}
]}
]
)

Expand Down Expand Up @@ -717,10 +723,13 @@ defmodule Signs.RealtimeTest do
expect_messages({"Ashmont 1 min", ""})

expect_audios(
[{:canned, {"110", spaced(["896", "895", "920", "910", "21014"]), :audio_visual}}],
[{:canned, {"112", spaced(["896", "895", "920", "910", "21014", "925"]), :audio_visual}}],
[
{"Attention passengers: The next Ashmont train is now approaching.",
[{"Ashmont train is now", "approaching.", 3}]}
{"Attention passengers: The next Ashmont train is now approaching. Please stand back from the platform edge.",
[
{"Ashmont train is now", "approaching. Please", 3},
{"stand back from the", "platform edge.", 3}
]}
]
)

Expand All @@ -744,10 +753,16 @@ defmodule Signs.RealtimeTest do
expect_messages({"Clvlnd Cir 1 min", ""})

expect_audios(
[{:canned, {"112", spaced(["896", "903", "919", "904", "910", "21014"]), :audio_visual}}],
[
{"Attention passengers: The next C train to Cleveland Circle is now approaching.",
[{"C train to Clvlnd Cir is", "now approaching.", 3}]}
{:canned,
{"114", spaced(["896", "903", "919", "904", "910", "21014", "925"]), :audio_visual}}
],
[
{"Attention passengers: The next C train to Cleveland Circle is now approaching. Please stand back from the platform edge.",
[
{"C train to Clvlnd Cir is", "now approaching. Please", 3},
{"stand back from the", "platform edge.", 3}
]}
]
)

Expand Down Expand Up @@ -789,10 +804,13 @@ defmodule Signs.RealtimeTest do
expect_messages({"Ashmont 1 min", ""})

expect_audios(
[{:canned, {"110", spaced(["896", "895", "920", "910", "21014"]), :audio_visual}}],
[{:canned, {"112", spaced(["896", "895", "920", "910", "21014", "925"]), :audio_visual}}],
[
{"Attention passengers: The next Ashmont train is now approaching.",
[{"Ashmont train is now", "approaching.", 3}]}
{"Attention passengers: The next Ashmont train is now approaching. Please stand back from the platform edge.",
[
{"Ashmont train is now", "approaching. Please", 3},
{"stand back from the", "platform edge.", 3}
]}
]
)

Expand All @@ -812,10 +830,13 @@ defmodule Signs.RealtimeTest do
expect_messages({"Frst Hills 1 min", ""})

expect_audios(
[{:canned, {"110", spaced(["896", "907", "920", "910", "21014"]), :audio_visual}}],
[{:canned, {"112", spaced(["896", "907", "920", "910", "21014", "925"]), :audio_visual}}],
[
{"Attention passengers: The next Forest Hills train is now approaching.",
[{"Frst Hills train is now", "approaching.", 3}]}
{"Attention passengers: The next Forest Hills train is now approaching. Please stand back from the platform edge.",
[
{"Frst Hills train is now", "approaching. Please", 3},
{"stand back from the", "platform edge.", 3}
]}
]
)

Expand All @@ -836,10 +857,13 @@ defmodule Signs.RealtimeTest do
expect_messages({"Frst Hills 1 min", ""})

expect_audios(
[{:canned, {"110", spaced(["896", "907", "920", "910", "21014"]), :audio_visual}}],
[{:canned, {"112", spaced(["896", "907", "920", "910", "21014", "925"]), :audio_visual}}],
[
{"Attention passengers: The next Forest Hills train is now approaching.",
[{"Frst Hills train is now", "approaching.", 3}]}
{"Attention passengers: The next Forest Hills train is now approaching. Please stand back from the platform edge.",
[
{"Frst Hills train is now", "approaching. Please", 3},
{"stand back from the", "platform edge.", 3}
]}
]
)

Expand Down Expand Up @@ -1463,11 +1487,16 @@ defmodule Signs.RealtimeTest do
expect_audios(
[
{:canned,
{"113", spaced(["896", "895", "920", "910", "21012", "893", "21014"]), :audio_visual}}
{"115", spaced(["896", "895", "920", "910", "21012", "893", "21014", "925"]),
:audio_visual}}
],
[
{"Attention passengers: The next Ashmont train is now approaching, with all new Red Line cars.",
[{"Ashmont train is now", "approaching, with all", 3}, {"new Red Line cars.", "", 3}]}
{"Attention passengers: The next Ashmont train is now approaching, with all new Red Line cars. Please stand back from the platform edge.",
[
{"Ashmont train is now", "approaching, with all", 3},
{"new Red Line cars.", "Please stand back from", 3},
{"the platform edge.", "", 3}
]}
]
)

Expand Down Expand Up @@ -1497,10 +1526,13 @@ defmodule Signs.RealtimeTest do
expect_messages({"Ashmont 1 min", ""})

expect_audios(
[{:canned, {"110", spaced(["896", "895", "920", "910", "21014"]), :audio_visual}}],
[{:canned, {"112", spaced(["896", "895", "920", "910", "21014", "925"]), :audio_visual}}],
[
{"Attention passengers: The next Ashmont train is now approaching.",
[{"Ashmont train is now", "approaching.", 3}]}
{"Attention passengers: The next Ashmont train is now approaching. Please stand back from the platform edge.",
[
{"Ashmont train is now", "approaching. Please", 3},
{"stand back from the", "platform edge.", 3}
]}
]
)

Expand Down
Loading