manual mode
This commit is contained in:
parent
f95c9cea35
commit
6b42ac19d1
2 changed files with 13 additions and 0 deletions
|
@ -102,6 +102,7 @@ async fn main() -> Result<(), Error> {
|
|||
.route("/turtle/:id/setGoal", post(set_goal))
|
||||
.route("/turtle/:id/dig", post(dig))
|
||||
.route("/turtle/:id/cancelTask", post(cancel))
|
||||
.route("/turtle/:id/manual", post(run_command))
|
||||
.route("/turtle/:id/info", get(turtle_info))
|
||||
//.route("/turtle/:id/placeUp", get(place_up))
|
||||
.route("/turtle/updateAll", get(update_turtles))
|
||||
|
@ -163,6 +164,17 @@ async fn place_up(
|
|||
Json(response)
|
||||
}
|
||||
|
||||
async fn run_command(
|
||||
Path(id): Path<u32>,
|
||||
State(state): State<SharedControl>,
|
||||
Json(req): Json<TurtleCommand>,
|
||||
) -> Json<TurtleCommandResponse> {
|
||||
let state = state.read().await;
|
||||
let commander = state.get_turtle(id).await.unwrap().clone();
|
||||
drop(state);
|
||||
Json(commander.execute(req).await.ret)
|
||||
}
|
||||
|
||||
async fn dig(
|
||||
Path(id): Path<u32>,
|
||||
State(state): State<SharedControl>,
|
||||
|
|
|
@ -355,6 +355,7 @@ pub(crate) async fn process_turtle_update(
|
|||
}
|
||||
}
|
||||
|
||||
println!("{} idle, connected", turtle.name.to_str());
|
||||
Ok(TurtleCommand::Wait(IDLE_TIME))
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue