more worldstate keys
This commit is contained in:
parent
e5e8ad878b
commit
538f13f539
@ -81,12 +81,14 @@ impl Conf {
|
|||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
pub fn dump() {
|
pub fn dump() {
|
||||||
let conf = Conf { laser_id: 0,
|
let conf = Conf {
|
||||||
|
laser_id: 0,
|
||||||
debug: true,
|
debug: true,
|
||||||
redis_url: "redis://127.0.0.1:6379/".to_string(),
|
redis_url: "redis://127.0.0.1:6379/".to_string(),
|
||||||
dac: DacFamily::Helios(HeliosConf { id: 0 }),
|
dac: DacFamily::Helios(HeliosConf { id: 0 }),
|
||||||
transformers: vec![
|
transformers: vec![
|
||||||
TransformConf::Translate(transformer::Translate { x: 2000.0, y: 2000.0 } ),
|
TransformConf::Translate(transformer::Translate { x: 2000.0,
|
||||||
|
y: 2000.0 } ),
|
||||||
TransformConf::Replicate(transformer::Replicate::Until(48))
|
TransformConf::Replicate(transformer::Replicate::Until(48))
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
15
src/main.rs
15
src/main.rs
@ -51,6 +51,7 @@ fn run_all() -> LJResult<()> {
|
|||||||
let mut rs = RedisCtrl::new(&config.redis_url, &config.laser_id)?;
|
let mut rs = RedisCtrl::new(&config.redis_url, &config.laser_id)?;
|
||||||
|
|
||||||
let mut world_state = rs.init_world_state()?;
|
let mut world_state = rs.init_world_state()?;
|
||||||
|
info!("WorldState: {:?}", world_state);
|
||||||
|
|
||||||
// Setup handler for interrupt Signals
|
// Setup handler for interrupt Signals
|
||||||
let running = Arc::new(AtomicBool::new(true));
|
let running = Arc::new(AtomicBool::new(true));
|
||||||
@ -93,15 +94,18 @@ fn run_all() -> LJResult<()> {
|
|||||||
&config,
|
&config,
|
||||||
&transformers,
|
&transformers,
|
||||||
&mut rs,
|
&mut rs,
|
||||||
// order == Order::Black,
|
|
||||||
&world_state
|
&world_state
|
||||||
)?;
|
)?;
|
||||||
// For now, draw all the time
|
// For now, draw all the time
|
||||||
tracer.draw(frame, 2_000)?;
|
tracer.draw(frame, 2_000)?;
|
||||||
}
|
},
|
||||||
|
Order::Intensity => {
|
||||||
|
world_state.intensity = rs.get_int("intensity")?
|
||||||
|
.try_into()?;
|
||||||
|
},
|
||||||
Order::Edh => {
|
Order::Edh => {
|
||||||
world_state.edh = rs.get_edh()?;
|
world_state.edh = rs.get_edh()?;
|
||||||
}
|
},
|
||||||
|
|
||||||
// Order::ClientKey => rs.client_key(),
|
// Order::ClientKey => rs.client_key(),
|
||||||
// Order::ColorBalance => {},
|
// Order::ColorBalance => {},
|
||||||
@ -137,7 +141,10 @@ fn get_next_frame(
|
|||||||
rs: &mut RedisCtrl,
|
rs: &mut RedisCtrl,
|
||||||
world_state : &WorldState
|
world_state : &WorldState
|
||||||
) -> LJResult<Vec<Point>> {
|
) -> LJResult<Vec<Point>> {
|
||||||
let line = rs.get(&format!("/pl/{}/0", config.laser_id))?;
|
let format_key = format!("{}{}",
|
||||||
|
world_state.client_key,
|
||||||
|
config.laser_id);
|
||||||
|
let line = rs.get_line(&format_key)?;
|
||||||
let mut line: Vec<Point> = line.into_iter()
|
let mut line: Vec<Point> = line.into_iter()
|
||||||
.map(|tpl| tpl.into())
|
.map(|tpl| tpl.into())
|
||||||
.collect();
|
.collect();
|
||||||
|
@ -3,7 +3,7 @@ use ron::de::from_str;
|
|||||||
use crate::device::Status;
|
use crate::device::Status;
|
||||||
use crate::errors::{LJError, LJResult};
|
use crate::errors::{LJError, LJResult};
|
||||||
use crate::worldstate::{WorldState,EDH};
|
use crate::worldstate::{WorldState,EDH};
|
||||||
use log::info;
|
// use log::info;
|
||||||
|
|
||||||
#[repr(u8)]
|
#[repr(u8)]
|
||||||
#[derive(Debug, PartialEq)]
|
#[derive(Debug, PartialEq)]
|
||||||
@ -62,7 +62,7 @@ impl RedisCtrl {
|
|||||||
Ok(RedisCtrl { client, connection, laser_id: *laser_id })
|
Ok(RedisCtrl { client, connection, laser_id: *laser_id })
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get(&mut self, key: &str) -> LJResult<Line> {
|
pub fn get_line(&mut self, key: &str) -> LJResult<Line> {
|
||||||
let val: String = self.connection.get(key)?;
|
let val: String = self.connection.get(key)?;
|
||||||
let line: Line = from_str(&val)?;
|
let line: Line = from_str(&val)?;
|
||||||
Ok(line)
|
Ok(line)
|
||||||
@ -100,11 +100,11 @@ impl RedisCtrl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn init_world_state( &mut self) -> LJResult<WorldState>{
|
pub fn init_world_state( &mut self) -> LJResult<WorldState>{
|
||||||
let edh = self.get_edh()?;
|
|
||||||
info!("EDH: {:?}", edh);
|
|
||||||
|
|
||||||
Ok(WorldState {
|
Ok(WorldState {
|
||||||
edh,
|
client_key: self.connection.get("/clientkey")?,
|
||||||
|
edh: self.get_edh()?,
|
||||||
|
kpps: self.get_int("kpps")?.try_into()?,
|
||||||
|
intensity: self.get_int("intensity")?.try_into()?,
|
||||||
..WorldState::default()
|
..WorldState::default()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -117,4 +117,11 @@ impl RedisCtrl {
|
|||||||
let edh = EDH::new(edh)?;
|
let edh = EDH::new(edh)?;
|
||||||
Ok(edh)
|
Ok(edh)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn get_int(&mut self, key: &str ) -> LJResult<u32> {
|
||||||
|
// Get new Int
|
||||||
|
let fmt = format!("/{key}/{}", self.laser_id);
|
||||||
|
let val : u32 = self.connection.get(fmt)?;
|
||||||
|
Ok(val)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@ impl EDH {
|
|||||||
pub struct WorldState {
|
pub struct WorldState {
|
||||||
pub edh: EDH,
|
pub edh: EDH,
|
||||||
pub resampler: Vec<f32>,
|
pub resampler: Vec<f32>,
|
||||||
pub client_key: u8,
|
pub client_key: String, //u8,
|
||||||
pub intensity: u8,
|
pub intensity: u8,
|
||||||
pub kpps: u32,
|
pub kpps: u32,
|
||||||
pub color: Color
|
pub color: Color
|
||||||
|
Loading…
Reference in New Issue
Block a user