|
|
|
马上加入,结交更多好友,共享更多资料,让你轻松玩转电力研学社区!
您需要 登录 才可以下载或查看,没有账号?立即加入
×
这是我写的一段小代码,就是调用BPA对指定的.dat文件计算一次潮流,代码如下
: H5 X9 H( Z5 K. o! ^using System;/ ]9 ]& D& W, W& ~$ N& O1 {
using System.Collections.Generic;
4 ~7 m1 x4 K. n! `5 r# Z9 z( \4 ?using System.Text;4 w! O! B* a6 T9 i) x/ ]- z
using System.Diagnostics;
/ {0 @1 `2 y* y1 ?0 [% S1 u0 [' b: Y6 M" L4 L; G% p
9 v' |1 Z3 Q: ?9 jnamespace 调用BPA1 H( f- P2 e2 t: _, K
{
# @- W% f$ d1 h! i class Program
" a( \5 V- U c: n+ G: X9 l0 q0 h {* t/ L) t- ?% |/ _/ l4 Z7 i9 \! y n
public class powerflow
+ I" ? h6 N( C/ H3 Y4 i {
; C0 \1 k1 w0 f# E" d9 ] public void powerflow1(string BPApath, string BPAdatapath) //BPApath 为BPA程序的存放路径,BPAdatapath为.dat数据文件的路径6 \8 | g& T: i$ n9 j
{
9 {( P1 x4 D- l+ x Process dyBPA = new Process();
' b) Z" w: b5 @6 q/ d# j dyBPA.StartInfo.FileName = BPApath + "pfnt.exe";
$ F5 ]2 a) O( ], E dyBPA.StartInfo.Arguments = BPAdatapath;7 @( b. E' ]9 H3 S: G% Y
dyBPA.StartInfo.UseShellExecute = false;
w6 s6 i4 B9 Q% [ dyBPA.StartInfo.RedirectStandardInput = true;0 e$ S/ ~+ f- U
dyBPA.StartInfo.RedirectStandardOutput = true;
/ ^( d- _3 A4 O1 G. D0 { dyBPA.StartInfo.CreateNoWindow = false;4 o" t2 o- k2 e( Y7 B
dyBPA.StartInfo.WorkingDirectory = BPApath.Substring(0,BPApath.Length-1);+ T$ k% z- M5 p0 } |# f
dyBPA.Start();; v- N" b% h" q
string output = dyBPA.StandardOutput.ReadToEnd();
# W0 k* d9 f) p' I dyBPA.Close();! o2 M7 @4 W+ `. |- ?) [
, @/ C/ T8 Z @ a' V ( K ]: h+ G' _
}
: Y- x# k6 c; _ |9 _% ` }
. c& R A3 I6 m$ D b7 z7 ? static void Main(string[] args)+ r; T; Q& D k. `
{
8 ]$ y5 ?. c, K9 Y8 | powerflow calculate = new powerflow();' h* a4 i B9 u5 ]. b; @
calculate.powerflow1(@"C:\psap32\psaw", @"E:\广东电网充裕度评估系统\童—潮流计算程序\013bpa");" B8 \; P3 V( r& n! T- V
}; ], t$ S, e: ^7 T+ p5 q
}
( G; b8 \( @( j+ t" R+ O) |( N}
( F" f% d$ m% b* T$ S. l由于本人是刚刚学习,可能上面代码有许多错误,还请高手赐教~~~小弟不胜感激 |
|