import React from 'react'; import styles from './MonitoringPage.module.css'; import useProgramStore from "../../utils/programStore.ts"; import { GestureControls, SpeechPresets, DirectSpeechInput, StatusList, RobotConnected } from './Components'; import { nextPhase, pauseExperiment, playExperiment, resetExperiment, resetPhase } from ".//MonitoringPageAPI.ts" type Goal = { id?: string | number; description?: string; achieved?: boolean }; type Trigger = { id?: string | number; label?: string ; achieved?: boolean }; type Norm = { id?: string | number; norm?: string }; const MonitoringPage: React.FC = () => { const getPhaseIds = useProgramStore((s) => s.getPhaseIds); const getNormsInPhase = useProgramStore((s) => s.getNormsInPhase); const getGoalsInPhase = useProgramStore((s) => s.getGoalsInPhase); const getTriggersInPhase = useProgramStore((s) => s.getTriggersInPhase); // Can be used to block actions until feedback from CB. const [loading, setLoading] = React.useState(false); const [isPlaying, setIsPlaying] = React.useState(false); const phaseIds = getPhaseIds(); const [phaseIndex, _] = React.useState(0); if (phaseIds.length === 0) { return

No program loaded.

; } const phaseId = phaseIds[phaseIndex]; const goals = getGoalsInPhase(phaseId) as Goal[]; const triggers = getTriggersInPhase(phaseId) as Trigger[]; const norms = getNormsInPhase(phaseId) as Norm[]; // Handle logic of 'next' button. const handleButton = async (button: string, _context?: string, _endpoint?: string) => { try { setLoading(true); switch (button) { case "pause": await pauseExperiment(); break; case "play": await playExperiment(); break; case "nextPhase": await nextPhase(); break; case "resetPhase": await resetPhase(); break; case "resetExperiment": await resetExperiment(); break; default: } } catch (err) { console.error(err); } finally { setLoading(false); } } return (
{/* HEADER */}

Experiment Overview

Phase name: Rhyming fish

1 2 3 4 5

Experiment Controls

{/*Pause button*/} {/*Play button*/} {/*Next button*/} {/*Restart Phase button*/} {/*Restart Experiment button*/}
{RobotConnected()}
{/* MAIN GRID */}

Phase Overview

{/* LOGS */} {/* FOOTER */}
); } export default MonitoringPage;