start implementing orders
This commit is contained in:
parent
f7f5c00d0f
commit
511a37e740
@ -14,7 +14,7 @@ use helios_dac::NativeHeliosDacController;
|
|||||||
use std::sync::atomic::{AtomicBool, Ordering};
|
use std::sync::atomic::{AtomicBool, Ordering};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use redis_ctrl::RedisCtrl;
|
use redis_ctrl::{RedisCtrl,Order};
|
||||||
|
|
||||||
const CENTER : (u16,u16) = (2000, 2000);
|
const CENTER : (u16,u16) = (2000, 2000);
|
||||||
|
|
||||||
@ -35,7 +35,12 @@ pub fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
let device = devices.into_iter().next().unwrap();
|
let device = devices.into_iter().next().unwrap();
|
||||||
let mut device = device.open()?;
|
let mut device = device.open()?;
|
||||||
|
|
||||||
while running.load(Ordering::SeqCst) {
|
while running.load(Ordering::SeqCst) {
|
||||||
|
let order = rs.get_order(0)?;
|
||||||
|
if order != Order::Draw {
|
||||||
|
println!("{:?}", order);
|
||||||
|
}
|
||||||
|
|
||||||
let frame = get_next_frame(1000, &mut rs)?;
|
let frame = get_next_frame(1000, &mut rs)?;
|
||||||
|
|
||||||
while let Ok(DeviceStatus::NotReady) = device.status() {
|
while let Ok(DeviceStatus::NotReady) = device.status() {
|
||||||
|
@ -5,6 +5,45 @@ use redis::{
|
|||||||
};
|
};
|
||||||
use ron::de::from_str;
|
use ron::de::from_str;
|
||||||
|
|
||||||
|
#[repr(u8)]
|
||||||
|
#[derive(Debug,PartialEq)]
|
||||||
|
pub enum Order {
|
||||||
|
Draw = 0,
|
||||||
|
Edh, //homography
|
||||||
|
Black,
|
||||||
|
Grid,
|
||||||
|
Resampler,
|
||||||
|
ClientKey,
|
||||||
|
Intensity,
|
||||||
|
Kpps,
|
||||||
|
ColorBalance
|
||||||
|
}
|
||||||
|
|
||||||
|
impl TryFrom<u8> for Order {
|
||||||
|
type Error = String;
|
||||||
|
|
||||||
|
fn try_from(value: u8) -> Result<Self, Self::Error> {
|
||||||
|
use Order::*;
|
||||||
|
|
||||||
|
if value > 8 {
|
||||||
|
return Err("order out of range".to_string());
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(match value {
|
||||||
|
0 => Draw,
|
||||||
|
1 => Edh,
|
||||||
|
2 => Black,
|
||||||
|
3 => Grid,
|
||||||
|
4 => Resampler,
|
||||||
|
5 => ClientKey,
|
||||||
|
6 => Intensity,
|
||||||
|
7 => Kpps,
|
||||||
|
8 => ColorBalance,
|
||||||
|
_ => panic!("Can't be there")
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub type Line = Vec<(f32,f32,u32)>;
|
pub type Line = Vec<(f32,f32,u32)>;
|
||||||
|
|
||||||
pub struct RedisCtrl {
|
pub struct RedisCtrl {
|
||||||
@ -28,5 +67,20 @@ impl RedisCtrl {
|
|||||||
let line : Line = from_str(&val)?;
|
let line : Line = from_str(&val)?;
|
||||||
Ok(line)
|
Ok(line)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn get_order(
|
||||||
|
&mut self,
|
||||||
|
id: u8
|
||||||
|
) -> Result<Order, Box<dyn std::error::Error>> {
|
||||||
|
let path = format!("/order/{id}");
|
||||||
|
let val : u8 = self.connection.get(path.clone())?;
|
||||||
|
|
||||||
|
if val == 1 || val >= 4 {
|
||||||
|
self.connection.set(path, 0)?;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(val.try_into()?)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user