feat: add get_client_key + cleanup
This commit is contained in:
parent
e4580e0e53
commit
6fa8846997
@ -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,
|
||||
|
@ -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,
|
||||
|
29
src/main.rs
29
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)?;
|
||||
|
||||
|
||||
match order {
|
||||
Order::Draw | Order::Black | Order::Grid => {
|
||||
// 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 => {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -118,6 +118,11 @@ impl RedisCtrl {
|
||||
Ok(edh)
|
||||
}
|
||||
|
||||
pub fn get_client_key( &mut self ) -> LJResult<u8> {
|
||||
let key : u8 = self.connection.get("/clientkey")?;
|
||||
Ok(key as u8)
|
||||
}
|
||||
|
||||
pub fn get_int(&mut self, key: &str ) -> LJResult<u32> {
|
||||
// Get new Int
|
||||
let fmt = format!("/{key}/{}", self.laser_id);
|
||||
|
@ -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<f32>,
|
||||
pub client_key: String,
|
||||
pub client_key: u8,
|
||||
pub intensity: u8,
|
||||
pub kpps: u32,
|
||||
pub color: Color,
|
||||
|
Loading…
Reference in New Issue
Block a user