Commit 5d889fbf by dongshufeng

fix bug in read

parent c3b776c2
......@@ -57,7 +57,7 @@ pub fn read_terminal_cn_dev(records: &mut StringRecordsIter<&[u8]>) -> Result<Ve
if let Ok(id) = str.parse() {
terminals[row][col] = id;
} else {
return Err(format!("Wrong terminal input, row {row} col {col}"));
return Err(format!("Wrong terminal input, row {row} col {col}: {str}"));
}
col += 1;
if col == 3 {
......@@ -99,34 +99,31 @@ pub fn read_static_topo(records: &mut StringRecordsIter<&[u8]>,
if let Ok(id) = str.parse() {
edges[row][col] = id;
} else {
return Err(format!("Wrong static topology input, row {row} col {col}"));
return Err(format!("Wrong static topology input, row {row} col {col}: {str}"));
}
} else if col == 3 {
if let Ok(type_u16) = str.parse::<u16>() {
is_switch = type_u16 == swich_type;
if dev_type.is_some() {
dev_type.as_mut().unwrap().insert(edges[row][2], type_u16);
}
} else {
return Err(format!("Wrong static topology input, row {row} col {col}"));
return Err(format!("Wrong static topology input, row {row} col {col}: {str}"));
}
} else if col == 4 && is_switch && normal_open.is_some() {
if let Ok(b) = str.parse::<bool>() {
normal_open.as_mut().unwrap().insert(edges[row][2], b);
} else {
return Err(format!("Wrong static topology input, row {row} col {col}"));
}
} else if col == 5 && is_switch && dev_type.is_some() {
if let Ok(v) = str.parse::<u16>() {
dev_type.as_mut().unwrap().insert(edges[row][2], v);
} else {
return Err(format!("Wrong static topology input, row {row} col {col}"));
return Err(format!("Wrong static topology input, row {row} col {col}: {str}"));
}
}
col += 1;
if col == 6 {
if col == 5 {
break;
}
}
if col != 5 {
return Err(format!("Wrong static topology input, expected col at least 6, actual {col}"));
return Err(format!("Wrong static topology input, expected col at least 5, actual {col}"));
}
}
Some(Err(e)) => {
......
......@@ -20,13 +20,13 @@ pub fn read_shunt_measures(records: &mut StringRecordsIter<&[u8]>)
if let Ok(id) = str.parse() {
point = id;
} else {
return Err(format!("Wrong terminal input, row {row} col {col}"));
return Err(format!("Wrong shunt measure input, row {row} col {col}"));
}
} else if col == 1 {
if let Ok(id) = str.parse() {
terminal = id;
} else {
return Err(format!("Wrong terminal input, row {row} col {col}"));
return Err(format!("Wrong shunt measure input, row {row} col {col}"));
}
} else if col == 2 {
meas.insert(point, (terminal, MeasPhase::from(str)));
......@@ -37,11 +37,11 @@ pub fn read_shunt_measures(records: &mut StringRecordsIter<&[u8]>)
}
}
if col != 3 {
return Err(format!("Wrong terminal input, expected col at least 3, actual {col}"));
return Err(format!("Wrong shunt measure input, expected col at least 3, actual {col}"));
}
}
Some(Err(e)) => {
return Err(format!("Wrong terminal input, err: {:?}", e));
return Err(format!("Wrong shunt measure input, err: {:?}", e));
}
None => {
break;
......
......@@ -38,7 +38,7 @@ pub unsafe fn run(ptr: i32, len: u32) -> u64 {
if let Err(s) = &r2 {
error = Some(s.clone());
} else {
let from = r2.unwrap();
let mut from = r2.unwrap();
for i in 0..input.dfs_len.len() {
let size = input.dfs_len[i] as usize;
let end = from + size;
......@@ -81,6 +81,7 @@ pub unsafe fn run(ptr: i32, len: u32) -> u64 {
Err(s) => error = Some(s),
}
}
from += size;
}
}
if error.is_some() {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论