This commit is contained in:
xin
2025-05-07 11:10:44 +08:00
parent 8820b28ab8
commit fb037dbf6f
56 changed files with 2679 additions and 470 deletions

View File

@ -62,6 +62,7 @@ pub fn sendtoport_andgetreturn(
"sensor_type":"IRIS-Sensor",
"fiber_type":"Single",
"shutter_time":shuttertime,
"has_shutter":true,
});

View File

@ -5,7 +5,7 @@ use std::slice;
use crate::serport::serport::*;
use super::STRSensorInfo;
//void IS3SetShutterOpen(int isopen);
type SerialWrite = Option<unsafe extern "C" fn(data: *mut c_uchar, length: size_t) -> size_t>;
#[link(
name = "D:\\06Learn\\rust\\tarui\\myfirst_tauri\\myis11\\project\\is3\\cmake-build-debug-visual-studio/iris_is3lib",
@ -18,6 +18,7 @@ extern "C" {
pub fn IS3OptSnenser(percent:i32) -> i32;
pub fn IS3GetData(outdata: *mut u16, shuttertime: i32) -> i32;
pub fn IS3SetWeaveLenthCoeff(a:*mut f64,length:i32) -> i32;
pub fn IS3SetShutterOpen(isopen: i32) ;
}
@ -78,6 +79,9 @@ pub fn is3_get_data(shuttertime: i32) -> Vec<u16> {
outdata
}
pub fn is3_set_shutter_open(isopen: i32) {
unsafe { IS3SetShutterOpen(isopen) }
}
pub fn is3_set_weave_length_coeff(a: Vec<f64>) -> i32 {
let mut a = a.clone();

View File

@ -230,4 +230,26 @@ pub fn set_sensor_weave_length_coeff(a: Vec<f64>) -> i32 {
return 0;
},
}
}
pub fn sensor_set_shutter_open(isopen:i32) {
let senortype = SENSORTYPE.lock().unwrap();
match *senortype {
Senortype::IS11 => {
unsafe {
}
},
Senortype::IS3 => {
unsafe {
IS3_sensor::IS3SetShutterOpen(isopen);
}
},
_ => {
},
}
}

View File

@ -11,6 +11,7 @@ use std::fs::File;
use std::mem;
use std::path::Path;
use std::io::Read;
use super::super::algorithm::*;
#[derive(PartialEq)]
enum WorkStat {
IDLE,
@ -54,8 +55,8 @@ lazy_static! {
removedark: false,
computeflat: true,
average_number_data: 1,
average_number_dark: 1,
average_number_flat: 1,
average_number_dark: 10,
average_number_flat: 10,
has_CalidataUP: false,
}));
@ -260,7 +261,9 @@ pub fn collcect_dark(shuttertime:u32)
drop(dev_stat); //释放锁
thread::spawn(move || {
let mut datasum:Vec<u32>=vec![0;bandsunm];
sensor_set_shutter_open(0);
for _i in 0..averagenumber {
let data=super::spectralbase::sensor_get_data(shuttertime as i32);
for i in 0..bandsunm {
datasum[i]=datasum[i]+data[i] as u32;
@ -271,6 +274,7 @@ pub fn collcect_dark(shuttertime:u32)
dev_stat.percent=((_i+1) as f32/averagenumber as f32*100 as f32*0.9) as i32;
drop(dev_stat); //释放锁
}
sensor_set_shutter_open(1);
let data=datasum.iter().map(|x| *x as f32/averagenumber as f32).collect::<Vec<f32>>();