diff --git a/src/device.rs b/src/device.rs index 79f0114..e3a6270 100644 --- a/src/device.rs +++ b/src/device.rs @@ -9,7 +9,6 @@ use crate::device::dummy::DummyDevice; use crate::errors::LJResult; use crate::point::Point; use serde::Serialize; -use crate::redis_ctrl::Line; /* self.protocol_version, diff --git a/src/device/helios.rs b/src/device/helios.rs index 42373f0..59e5a54 100644 --- a/src/device/helios.rs +++ b/src/device/helios.rs @@ -15,7 +15,6 @@ use crate::device::{Device, Status, PlaybackState}; use crate::errors::{LJError, LJResult}; use crate::point::{Color, Point}; use chrono::Utc; -use crate::redis_ctrl::Line; pub struct HeliosDevice { pub conf: HeliosConf, diff --git a/src/main.rs b/src/main.rs index c7e8ccb..16cf14d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -13,7 +13,7 @@ mod worldstate; use device::device_factory; use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::Arc; -use redis_ctrl::{RedisCtrl, Order, Line}; +use redis_ctrl::{RedisCtrl, Order}; use conf::Conf; use errors::LJResult; use point::{Point, Color}; @@ -75,22 +75,15 @@ fn run_all() -> LJResult<()> { rs.set_status(tracer.status())?; let order = rs.get_order(config.laser_id)?; - // 0 : Draw Normal point list - // 2 : Draw BLACK point list - // 3 : Draw GRID point list - // 1 : Get the new EDH = reread redis key /EDH/lasernumber - // 4 : Resampler Change (longs and shorts lsteps) - // 5 : Client Key Change = reread redis key /clientkey - // 6 : Max Intensity Change = reread redis key /intensity - // 7 : kpps change = reread redis key /kpps - // 8 : color balance change = reread redis keys /red /green /blue match order { Order::Draw | Order::Black | Order::Grid => { + // 0 : Draw Normal point list + // 2 : Draw BLACK point list + // 3 : Draw GRID point list world_state.draw_black = order == Order::Black; world_state.draw_grid = order == Order::Grid; - let frame = get_next_frame( &config, &transformers, @@ -101,19 +94,27 @@ fn run_all() -> LJResult<()> { tracer.draw(frame, world_state.kpps)?; } Order::Intensity => { + // 6 : Max Intensity Change = reread redis key /intensity world_state.intensity = rs.get_int("intensity")? .try_into()?; } Order::Edh => { + // 1 : Get the new EDH = reread redis key /EDH/lasernumber world_state.edh = rs.get_edh()?; } Order::Kpps => { + // 7 : kpps change = reread redis key /kpps world_state.kpps = rs.get_int("kpps")?; } - - // Order::ClientKey => rs.client_key(), + Order::ClientKey => { + world_state.client_key = rs.get_client_key()?; + }, // Order::ColorBalance => {}, _ => { + // 4 : Resampler Change (longs and shorts lsteps) + // 5 : Client Key Change = reread redis key /clientkey + // 8 : color balance change = reread redis keys /red /green /blue + // 9 : poweroff LJ world_state.intensity = rs.get_int("intensity")? info!("Order: {:?}", order); } } @@ -151,12 +152,12 @@ fn get_next_frame( // Handle the grid case - let mut line : Vec; + let mut line: Vec; if world_state.draw_grid { line = world_state.grid.clone(); } else { let redis_line = rs.get_line(&format_key)?; - line = redis_line.into_iter() + line = redis_line.into_iter() .map(|tpl| tpl.into()) .collect(); }; diff --git a/src/redis_ctrl.rs b/src/redis_ctrl.rs index 4b13d8a..363fdc1 100644 --- a/src/redis_ctrl.rs +++ b/src/redis_ctrl.rs @@ -118,6 +118,11 @@ impl RedisCtrl { Ok(edh) } + pub fn get_client_key( &mut self ) -> LJResult { + let key : u8 = self.connection.get("/clientkey")?; + Ok(key as u8) + } + pub fn get_int(&mut self, key: &str ) -> LJResult { // Get new Int let fmt = format!("/{key}/{}", self.laser_id); diff --git a/src/worldstate.rs b/src/worldstate.rs index 7461c14..1f6bea2 100644 --- a/src/worldstate.rs +++ b/src/worldstate.rs @@ -2,7 +2,6 @@ use crate::point::{Point, Color}; use nalgebra::base::{Matrix3, Matrix1x3}; use crate::errors::{LJError, LJResult}; use log::debug; -use crate::redis_ctrl::Line; #[derive(Debug, Default)] pub struct EDH { @@ -41,7 +40,7 @@ impl EDH { pub struct WorldState { pub edh: EDH, pub resampler: Vec, - pub client_key: String, + pub client_key: u8, pub intensity: u8, pub kpps: u32, pub color: Color,