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

Display state transition messages in Console #107

Merged
merged 8 commits into from
Jun 1, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
31 changes: 27 additions & 4 deletions control-station/src/components/SensorBoxes/Console.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,37 @@
import { useContext, useEffect, useRef, useState } from "react";
import "./SensorData.css";
import PodContext from "@/services/PodContext";

function Console() {
const { podData } = useContext(PodContext);
const [stateList, setStateList] = useState<string[]>([]);
const listEndRef = useRef<HTMLLIElement | null>(null);

useEffect(() => {
if (podData.state) {
setStateList((prev) => [...prev, podData.state]);
}
}, [podData.state]);
vrushang1234 marked this conversation as resolved.
Show resolved Hide resolved

useEffect(() => {
if (listEndRef.current) {
listEndRef.current.scrollIntoView({ behavior: "smooth" });
}
}, [stateList]);

return (
<div className="console">
<h2>Console</h2>
<ul className="console-list">
<li className="console-list-item">Start Sent</li>
<li className="console-list-item">Stop Sent</li>
<li className="console-list-item">Load Sent</li>
<li className="console-list-item">Force Stop Sent</li>
{stateList.map((prop, index) => (
<li
key={index}
className="console-list-item"
ref={index === stateList.length - 1 ? listEndRef : null}
>
{prop} State
</li>
))}
</ul>
</div>
);
Expand Down
10 changes: 5 additions & 5 deletions pod-operation/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,17 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
let lidar = Lidar::new();
tokio::spawn(demo::read_lidar(lidar));

let mut state_machine = StateMachine::new(io);
tokio::spawn(async move {
state_machine.run().await;
});

let limcurrent = LimCurrent::new(ads1x1x::SlaveAddr::Default);
tokio::spawn(demo::read_lim_current(limcurrent));

let inverter_board = InverterBoard::new();
tokio::spawn(demo::inverter_control(inverter_board));

let mut state_machine = StateMachine::new(io);
tokio::spawn(async move {
state_machine.run().await;
});

let app = axum::Router::new().layer(layer);

info!("Starting server on port 5000");
Expand Down