Compare commits

..

No commits in common. "6bcfc831a6a9871c3176f5a50c7cf7047469b5b7" and "8962d8b214d9801f84ed931ac9588dc90f4fcff6" have entirely different histories.

5 changed files with 2 additions and 80 deletions

21
.gitignore vendored
View File

@ -1,20 +1 @@
# Configuration file
Settings.*
# Generated by Cargo
# will have compiled files and executables
debug/
target/
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
Cargo.lock
# These are backup files generated by rustfmt
**/*.rs.bk
# MSVC Windows builds of rustc generate these, which store debugging information
*.pdb
.idea
target

View File

@ -6,7 +6,6 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
config = "0.13.3"
ctrlc = "3.4.0"
helios-dac = { version = "0.1", default-features = false, features = ["native"] }
redis = "0.23.0"

View File

@ -1,6 +0,0 @@
laser_id = 1
debug = "true"
redis_url = "127.0.0.1"
dac_family = "Helios"
dac_id = 1
dac_url = "192.168.1.68"

View File

@ -1,47 +0,0 @@
use config::Config;
use serde::Deserialize;
#[derive(Deserialize,Debug)]
pub enum DacFamily {
Helios,
Etherdream
}
#[derive(Deserialize,Debug)]
pub struct Conf{
laser_id : u8,
debug : bool,
redis_url : String,
dac_family: DacFamily,
dac_id : Option<u8>,
dac_url : Option<String>
}
pub fn load_config( path : &str )-> Result<Conf, Box<dyn std::error::Error>> {
let conf_builder = Config::builder()
.add_source(config::File::with_name(path));
let settings = match conf_builder.build() {
Ok(conf) => conf,
Err(err) => {
println!("Invalid configuration file / missing file: {:?}", err);
return Err(Box::new(err))
}
};
let conf = settings
.try_deserialize::<Conf>()?;
// .try_deserialize::<HashMap<String, String>>()?;
println!(
"{:?}",
conf
);
Ok(conf)
}

View File

@ -4,7 +4,6 @@
///
mod redis_ctrl;
mod conf;
use helios_dac::{Frame,
Point,
@ -16,15 +15,11 @@ use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Arc;
use redis_ctrl::{RedisCtrl,Order};
use conf::{load_config};
const CENTER : (u16,u16) = (2000, 2000);
pub fn main() -> Result<(), Box<dyn std::error::Error>> {
let config = load_config("Settings")?;
let running = Arc::new(AtomicBool::new(true));
let r = running.clone();