impl data receive
This commit is contained in:
parent
5b3347bb00
commit
27e69bf301
1 changed files with 16 additions and 4 deletions
|
@ -1,22 +1,34 @@
|
||||||
use std::{collections::VecDeque, ops::{Deref, Div, Index, Range, Sub}};
|
use std::{collections::VecDeque, ops::{Deref, Div, Index, Range, Sub}};
|
||||||
|
|
||||||
use common::{CamState, ControlPacket, SensorData};
|
use common::{CamState, ControlPacket, SensorData, TelemetryPacket};
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
|
use tokio::sync::{broadcast, mpsc, watch};
|
||||||
|
|
||||||
pub struct AutoConfig {
|
pub struct AutoConfig {
|
||||||
turn_gain: f32,
|
turn_gain: f32,
|
||||||
auto_fire_distance: f32,
|
auto_fire_distance: f32,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Clone)]
|
||||||
pub struct AutoInterface {
|
pub struct AutoInterface {
|
||||||
|
command_sender: Option<mpsc::Sender<ControlPacket>>,
|
||||||
|
data_receiver: watch::Receiver<TelemetryPacket>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AutoInterface {
|
impl AutoInterface {
|
||||||
/// change active command, fails if not in control
|
/// change active command, fails if not in control
|
||||||
pub fn run_command(&self, command: ControlPacket) -> Result<()> {unimplemented!()}
|
pub fn run_command(&self, command: ControlPacket) -> Result<()> {unimplemented!()}
|
||||||
pub fn sensor_data(&self) -> SensorData {unimplemented!()}
|
pub fn sensor_data(&mut self) -> SensorData {
|
||||||
pub fn cam_state(&self) -> CamState {unimplemented!()}
|
self.data_receiver.borrow_and_update().sensors.clone()
|
||||||
pub async fn sensor_update(&self) -> SensorData {unimplemented!()}
|
}
|
||||||
|
pub fn cam_state(&mut self) -> CamState {
|
||||||
|
self.data_receiver.borrow_and_update().cam_state.clone()
|
||||||
|
}
|
||||||
|
pub async fn sensor_update(&mut self) -> SensorData {
|
||||||
|
self.data_receiver.changed().await.unwrap();
|
||||||
|
self.data_receiver.borrow().sensors.clone()
|
||||||
|
|
||||||
|
}
|
||||||
/// disable auto
|
/// disable auto
|
||||||
pub fn disable(&self) {unimplemented!()}
|
pub fn disable(&self) {unimplemented!()}
|
||||||
/// request auto enable, fails if the driver does not grant it
|
/// request auto enable, fails if the driver does not grant it
|
||||||
|
|
Loading…
Reference in a new issue