// use crate::ASICamera2::BayerPattern; // #![allow(non_camel_case_types)] #![allow(non_snake_case)] #![allow(dead_code)] #![feature(alloc_layout_extra)] mod asicam; mod qhyccd; use crate::asicam::ASICamera2::{ControlType, ImageType}; use crate::asicam::Camera; fn main() { let test = true; // println!("Doing qhy..."); // operate_qhy(test); println!("Doing asi..."); operate_asi(test); } fn operate_qhy(test: bool) { use crate::qhyccd::Control; println!("Operating on qhy camera ... or i'll die trying"); let t = std::thread::spawn(move || { let mut camera = qhyccd::acquire(0).unwrap(); camera.set_defaults().unwrap(); camera.set_exposure_ms(400).unwrap(); // camera.set_param(Control::Exposure, 10.0).unwrap(); camera.set_param(Control::Gain, 4000.0); //.unwrap(); camera.set_param(Control::Offset, 00.0).unwrap(); // camera.set_param(Control::USBTraffic, 50.0).unwrap(); // camera.set_param(Control::ManulPwm, 0.0).unwrap(); // camera.set_target_temp(0.0).unwrap(); camera.set_param(Control::Cooler, -25.0).unwrap(); // camera.set_roi(0, 0, 1920 * 2, 1080 * 2).unwrap(); println!("Gain: {:?}", camera.get_param_limits(Control::ManulPwm)); println!("cur pwm ???: {}", camera.get_param(Control::CurPWM)); println!("current temp: {}", camera.get_param(Control::CurTemp)); // camera.set_param(Control::CONTROL_WBR, 2750.0).unwrap(); // camera.set_param(Control::CONTROL_WBG, 2500.0).unwrap(); // camera.set_param(Control::CONTROL_WBB, 3000.0).unwrap(); // camera.set_bin_mode(2).unwrap(); if !test { let object = "veil"; for i in 0..10 { camera.take_image(&format!("{}_{}.png", object, i));//, i)); } } else { camera.take_image("qhy_test_2.png").unwrap(); println!("exposing: {:x}", camera.get_param(Control::IS_EXPOSING_DONE) as u64); } camera.release().unwrap(); }); t.join(); } fn operate_asi(test: bool) { println!("Operating on asi camera ... or i'll die trying"); let mut camera = asicam::acquire(0).unwrap(); println!("{:?}", camera); camera.set_control_value(ControlType::CoolerOn, 1).unwrap(); camera.set_control_value(ControlType::TargetTemp, -200).unwrap(); std::thread::sleep(std::time::Duration::from_millis(500)); println!("Camera temperature is currently {:?}", camera.get_control_value(ControlType::Temperature).unwrap()); /* for exposure in [2000, 5000, 10000, 30000].iter() { camera.set_control_value(ControlType::Exposure, *exposure).unwrap(); for gain in [450, 375, 325, 250, 200].iter() { camera.set_control_value(ControlType::Gain, *gain).unwrap(); for offset in [100, 80, 60, 40, 20, 0].iter() { camera.set_control_value(ControlType::Offset, *offset).unwrap(); take_calibration_images(&camera, 1, &format!("roof_gain_{:03}_offset_{:03}_exposure_{:06}", gain, offset, exposure)); } } } */ camera.set_exposure_ms(30000).unwrap(); // camera.set_control_value(ControlType::Exposure, 70000000).unwrap(); camera.set_control_value(ControlType::Gain, 250).unwrap(); camera.set_control_value(ControlType::Offset, 0).unwrap(); camera.set_control_value(ControlType::HardwareBin, 1).unwrap(); camera.set_roi_format(camera.width, camera.height, 1, ImageType::RAW16).unwrap(); for i in 0..240 { println!("doing image {}", i); println!("Camera temperature is currently {:?}", camera.get_control_value(ControlType::Temperature).unwrap()); camera.take_image(&format!("ngc7380_{}.png", i)).unwrap(); } // take_calibration_images(&camera, 40, "dark_gain_350_exposure_45000"); /* for exposure in [1000 * 1000 * 10].iter() { camera.set_control_value(ControlType::Exposure, *exposure).unwrap(); for gain in [450, 375, 325, 250, 200].iter() { camera.set_control_value(ControlType::Gain, *gain).unwrap(); for offset in [100, 80, 70, 60, 40, 0].iter() { camera.set_control_value(ControlType::Offset, *offset).unwrap(); take_calibration_images( &camera, 30, &format!("images/gain_{:03}_offset_{:03}_exposure_{:06}", gain, offset, exposure)); } } } */ println!("Done!"); } fn take_calibration_images(camera: &Camera, count: u32, path_fragment: &str) { for i in 0..count { println!("{} image {:06}", path_fragment, i); let temp = camera.get_control_value(ControlType::Temperature).unwrap(); println!("Camera temperature is currently {:?}", temp); camera.take_image(&format!("{}_{:06}_temp_{:03}.png", path_fragment, i, temp)).unwrap(); } }