马上加入,结交更多好友,共享更多资料,让你轻松玩转电力研学社区!
您需要 登录 才可以下载或查看,没有账号?立即加入
×
这是我写的一段小代码,就是调用BPA对指定的.dat文件计算一次潮流,代码如下
' G1 Z. P& ]: f; }- _. fusing System;1 ?4 ~9 e5 Z- @# t* b: m
using System.Collections.Generic;! `% _, z- z" L9 x' J
using System.Text;( W Q6 n% l2 }4 N4 o! [
using System.Diagnostics;
8 U$ n3 G8 k6 q/ L C A/ A* @2 V( [# k
( U1 _: b2 a6 n- e$ s T: J
namespace 调用BPA
+ t* Q/ I: p. H" h( r& M( V. V% T4 T{
' b8 Y, Q4 I, H- s) U4 B! ?9 E" X; G class Program
4 I& N' p/ ^( k2 ~ {5 e. {$ g8 i2 r/ b; ^
public class powerflow
# ^ P) E; ^+ y+ i6 k {
' S3 F5 p# _" V% S" s: b# i public void powerflow1(string BPApath, string BPAdatapath) //BPApath 为BPA程序的存放路径,BPAdatapath为.dat数据文件的路径$ Y' V( U9 b, \' i& F5 u( o- o4 C
{
: w' ~. C+ C4 \ Process dyBPA = new Process();7 y7 a9 C% ^; ^
dyBPA.StartInfo.FileName = BPApath + "pfnt.exe";
6 C3 h& `. m8 ]6 }9 ` A4 y dyBPA.StartInfo.Arguments = BPAdatapath;& y: W, Z5 D) ]
dyBPA.StartInfo.UseShellExecute = false;
7 u: d9 m- |* y0 ^/ [: Y! ^ dyBPA.StartInfo.RedirectStandardInput = true;5 [: W, M# ?8 Y
dyBPA.StartInfo.RedirectStandardOutput = true;
: E" v4 G7 E1 g9 f G/ y dyBPA.StartInfo.CreateNoWindow = false;0 M& p! n2 a* w: g# s
dyBPA.StartInfo.WorkingDirectory = BPApath.Substring(0,BPApath.Length-1);
* w4 c% g1 N% |% S4 H( S4 D) ?$ h dyBPA.Start();
: i1 A. j( }, t2 a$ A8 y string output = dyBPA.StandardOutput.ReadToEnd();
7 |6 w8 d* Q8 O dyBPA.Close();( i/ a0 X0 o @' f% [8 K
$ w6 d/ p) G2 |0 P+ |; e: b
2 [& M7 W7 |) {9 H* W
}+ D" h, b+ o( M( I' q3 r& q2 r
}
2 n7 t# J5 l t! q static void Main(string[] args)
$ i5 z+ f9 s+ B. [: N {4 S c$ ^& F' o9 }8 q# `! ` _
powerflow calculate = new powerflow();6 _4 ?, e$ L' w3 v, C* T. Z$ ^. U
calculate.powerflow1(@"C:\psap32\psaw", @"E:\广东电网充裕度评估系统\童—潮流计算程序\013bpa");- V* ?' N+ x& B/ i
}) w n, Y* s4 `* Y: S$ V% {4 h; N5 X
}, j+ G2 d7 I4 A& H8 |; u# f* V
}
9 C+ k# c* \" s6 U' F T4 a由于本人是刚刚学习,可能上面代码有许多错误,还请高手赐教~~~小弟不胜感激 |