diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index ed2517c..3e6e37d 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -1,14 +1,50 @@ -
-
-

Mecha Mayhem 2024

-

10:00

-

Qualifications 1

+ switch(topic_str){ + case arena_topic: + const arena_obj = JSON.parse(message_str); + teams_red = [arena_obj.red1, arena_obj.red2]; + teams_blue = [arena_obj.blue1, arena_obj.blue2]; + // TODO: fill match name based off metadata + break; + case arena_state_topic: + const state_obj = JSON.parse(message_str); + // Convert seconds to ms *1000 convert ns to ms /1000000 + const start_time = new Date((state_obj.start_s * 1000) + (state_obj.start_ns / 1000000)); + switch(state_obj.state) { + case "SCHEDULED": + timer = "Scheduled"; + timer_running = false; + break; + case "TIMEOUT": + timer = "Timeout"; + timer_running = false; + break; + case "DRIVER": + timer_running = true; + timer_start = start_time; + timer_duration = 105000; + break; + case "DRIVER_DONE": + timer = "Driver Done"; + timer_running = false; + break; + case "AUTONOMOUS": + timer_running = true; + timer_start = start_time; + timer_duration = 15000; + break; + case "AUTONOMOUS_DONE": + timer = "Auton Done"; + timer_running = false; + break; + case "ABANDONED": + timer = "Abandoned"; + timer_running = false; + break; + } + break; + case arena_score_topic: + const score_obj = JSON.parse(message_str); + score_red = score_obj.red.total; + score_blue = score_obj.blue.total; + break; + default: + console.log(`Unhandled topic ${topic_str}`) + } +}); -

40

-

120

+import { onMount } from 'svelte'; +onMount(() => { + const search_params = new URLSearchParams(window.location.search); + arena_id = search_params.get("arena"); + arena_topic = `arena/${arena_id}`; + arena_state_topic = `arena/${arena_id}/state`; + arena_score_topic = `arena/${arena_id}/score`; +}); -

6659A

6659B

-

210Y

210Z

-
-
+
-

Mecha Mayhem 2024

-

10:00

-

Qualifications 1

- -

40

-

120

- -

6659A

6659B

-

210Y

210Z

+

{event_name}

+

{timer}

+

{match_name}

+ +

{score_red}

+

{score_blue}

+ +
+ {#each teams_red as team} +

{team}

+ {/each} +
+
+ {#each teams_blue as team} +

{team}

+ {/each} +
@@ -126,7 +218,7 @@ div.score-grid { justify-items: center; align-items: center; - grid-template: 30% 40% 30% / 35% 30% 35%; + grid-template: 30% 40% 30% / 20% 40% 20%; grid-template-areas: "red-top top blue-top"