Commit 6a9dbcb0 by dongshufeng

Merge remote-tracking branch 'origin/master'

parents 841badda 82e43e21
...@@ -5,7 +5,85 @@ ...@@ -5,7 +5,85 @@
## 2. 拓扑分析 ## 2. 拓扑分析
### 2.1 静态拓扑分析 ### 2.1 静态拓扑分析
#### 输入
1. 电气岛
2. 属性定义
3. 资源定义
#### 输出
- 默认输出下面六列
<table>
<th>source</th>
<th>target</th>
<th>id</th>
<th>type</th>
<th>open</th>
<th>name</th>
</table>
- terminal_cn_dev,如果输出的边是该名称,则输出下面几列
<table>
<th>terminal</th>
<th>cn</th>
<th>dev</th>
<th>type</th>
</table>
- point_terminal_phase: 如果输出的边是该名称,则输出下面几列
<table>
<th>point</th>
<th>terminal</th>
<th>phase</th>
</table>
### 2.2 动态拓扑分析 ### 2.2 动态拓扑分析
## 3. 潮流计算 #### 输入
### 3.1 潮流计算模型
\ No newline at end of file - 电气岛
- 量测
- 静态拓扑:上述输出的三个表格
#### 输出
- 默认输出下面几列
<table>
<th>cn</th>
<th>tn</th>
</table>
- dev_topo: 如果输出的边是该名称,则输出下面几列
<table>
<th>terminal</th>
<th>cn</th>
<th>tn</th>
<th>dev</th>
</table>
## 3. 输入参数准备
### 3.1 设备电气参数计算
#### 输入
- 电气岛
- 配置
<table>
<th>config</th>
<th>ohm_per_km</th>
</table>
#### 输出
<table>
<th>dev_id</th>
<th>ohm</th>
</table>
### 3.2 潮流已知量输入
#### 输入
#### 输出
## 4. 潮流计算
### 4.1 潮流计算模型
\ No newline at end of file
...@@ -159,6 +159,7 @@ pub unsafe fn run(ptr: i32, len: u32) -> u64 { ...@@ -159,6 +159,7 @@ pub unsafe fn run(ptr: i32, len: u32) -> u64 {
} }
let mut csv_bytes = Vec::with_capacity(2); let mut csv_bytes = Vec::with_capacity(2);
let mut schema = Vec::with_capacity(2); let mut schema = Vec::with_capacity(2);
// 默认或者指定名称
if outgoing.is_empty() || outgoing.contains(&DYN_TOPO_DF_NAME.to_string()) || if outgoing.is_empty() || outgoing.contains(&DYN_TOPO_DF_NAME.to_string()) ||
(!outgoing.contains(&DYN_TOPO_DF_NAME.to_string()) && !outgoing.contains(&DEV_TOPO_DF_NAME.to_string())) { (!outgoing.contains(&DYN_TOPO_DF_NAME.to_string()) && !outgoing.contains(&DEV_TOPO_DF_NAME.to_string())) {
// build topology // build topology
...@@ -173,8 +174,7 @@ pub unsafe fn run(ptr: i32, len: u32) -> u64 { ...@@ -173,8 +174,7 @@ pub unsafe fn run(ptr: i32, len: u32) -> u64 {
]); ]);
csv_bytes.push((DYN_TOPO_DF_NAME.to_string(), topo_csv.into_bytes())); csv_bytes.push((DYN_TOPO_DF_NAME.to_string(), topo_csv.into_bytes()));
schema.push(topo_schema); schema.push(topo_schema);
} } else if outgoing.contains(&DEV_TOPO_DF_NAME.to_string()) {
if outgoing.contains(&DEV_TOPO_DF_NAME.to_string()) {
// build dev connection // build dev connection
let mut dev_csv = String::from("terminal,cn,tn,dev\n"); let mut dev_csv = String::from("terminal,cn,tn,dev\n");
for (terminal, dev) in terminal_dev { for (terminal, dev) in terminal_dev {
......
...@@ -26,13 +26,17 @@ pub unsafe fn run(ptr: i32, len: u32) -> u64 { ...@@ -26,13 +26,17 @@ pub unsafe fn run(ptr: i32, len: u32) -> u64 {
input input
}; };
let mut error = None; let mut error = None;
// 获取island
let r = get_island_from_plugin_input(&input); let r = get_island_from_plugin_input(&input);
if let Err(s) = &r { if let Err(s) = &r {
error = Some(s.clone()); error = Some(s.clone());
} }
let output = if error.is_none() { let output = if error.is_none() {
// 获取电气岛、属性定义、资源定义
let (island, prop_defs, defines) = r.unwrap(); let (island, prop_defs, defines) = r.unwrap();
let mut outgoing = vec![]; let mut outgoing = vec![];
// 获取输出的
for model_input in &input.model { for model_input in &input.model {
match model_input { match model_input {
ModelType::Outgoing(edge_name) => { ModelType::Outgoing(edge_name) => {
...@@ -53,13 +57,11 @@ pub unsafe fn run(ptr: i32, len: u32) -> u64 { ...@@ -53,13 +57,11 @@ pub unsafe fn run(ptr: i32, len: u32) -> u64 {
// .open(&base) // .open(&base)
// .expect("Could not create file"); // .expect("Could not create file");
// write graph // write graph
let mut is_matched = false; // 根据输出名称来确定形成不同的data frame
if outgoing.is_empty() || outgoing.contains(&STATIC_TOPO_DF_NAME.to_string()) { if outgoing.is_empty() || outgoing.contains(&STATIC_TOPO_DF_NAME.to_string()) {
is_matched = true;
create_static_topo(&island, &prop_defs, &defines, &mut csv_bytes, &mut schema); create_static_topo(&island, &prop_defs, &defines, &mut csv_bytes, &mut schema);
} }
if outgoing.contains(&TERMINAL_DF_NAME.to_string()) { else if outgoing.contains(&TERMINAL_DF_NAME.to_string()) {
is_matched = true;
let mut terminal_csv_str = String::from("terminal,cn,dev,type\n"); let mut terminal_csv_str = String::from("terminal,cn,dev,type\n");
let mut terminal_to_cn = HashMap::with_capacity(2 * island.cns.len()); let mut terminal_to_cn = HashMap::with_capacity(2 * island.cns.len());
// 先建立CN对应的节点 // 先建立CN对应的节点
...@@ -94,8 +96,8 @@ pub unsafe fn run(ptr: i32, len: u32) -> u64 { ...@@ -94,8 +96,8 @@ pub unsafe fn run(ptr: i32, len: u32) -> u64 {
// } else { // } else {
// let _ = file.sync_all(); // let _ = file.sync_all();
// } // }
if outgoing.contains(&POINT_DF_NAME.to_string()) {
is_matched = true; else if outgoing.contains(&POINT_DF_NAME.to_string()) {
let mut point_csv_str = String::from("point,terminal,phase\n"); let mut point_csv_str = String::from("point,terminal,phase\n");
for (_, defines) in &island.measures { for (_, defines) in &island.measures {
for def in defines { for def in defines {
...@@ -112,10 +114,6 @@ pub unsafe fn run(ptr: i32, len: u32) -> u64 { ...@@ -112,10 +114,6 @@ pub unsafe fn run(ptr: i32, len: u32) -> u64 {
Field::new("phase", DataType::Utf8, false), Field::new("phase", DataType::Utf8, false),
])); ]));
} }
// if not matched, default is used
if !is_matched {
create_static_topo(&island, &prop_defs, &defines, &mut csv_bytes, &mut schema);
}
PluginOutput { PluginOutput {
error_msg: None, error_msg: None,
schema: Some(schema), schema: Some(schema),
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论