Skip to content

Commit

Permalink
Final commit
Browse files Browse the repository at this point in the history
  • Loading branch information
vrushang1234 committed Jun 1, 2024
1 parent 7987c5b commit 1a177d3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
19 changes: 13 additions & 6 deletions control-station/src/components/SensorBoxes/Console.tsx
Original file line number Diff line number Diff line change
@@ -1,30 +1,37 @@
import { useContext, useEffect, useState } from "react";
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]);

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

return (
<div className="console">
<h2>Console</h2>
<ul className="console-list">
{stateList.map((prop, index) => (
<li key={index} className="console-list-item">
<li
key={index}
className="console-list-item"
ref={index === stateList.length - 1 ? listEndRef : null}
>
{prop} State
</li>
))}
<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>
</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

0 comments on commit 1a177d3

Please sign in to comment.