|
马上加入,结交更多好友,共享更多资料,让你轻松玩转电力研学社区!
您需要 登录 才可以下载或查看,没有账号?立即加入
×
这是我写的一段小代码,就是调用BPA对指定的.dat文件计算一次潮流,代码如下
' [8 f2 A5 J' o8 n* i# }1 e, Z+ S9 nusing System;
! Z A+ C- u% s4 F3 v5 {using System.Collections.Generic;- Q3 h; \+ ]4 g- X6 v
using System.Text;8 |9 T5 w; t# T# K9 `* {' m' n
using System.Diagnostics;* N! B1 O6 n& h$ ?% [1 Q7 Y
/ s0 h( u+ R# v0 k. ^$ y! m5 F
# k& Q! h. v4 q6 L4 @, S
namespace 调用BPA5 C4 |8 w' b# n, W4 ~! G+ ?9 c
{
" O+ n$ r v' t) B& L6 z5 f& u class Program
2 i& {. o) m! u0 F' B {5 Y$ P+ K6 S. I) s$ `8 [3 M
public class powerflow; n9 w! Q! O. Q. ~9 c! O' V# }( s
{: P$ |) M* R: x. x# V l4 n0 N
public void powerflow1(string BPApath, string BPAdatapath) //BPApath 为BPA程序的存放路径,BPAdatapath为.dat数据文件的路径
! y: x& U8 y: | {7 e+ L; ^. N8 }+ d. Q- ^% n
Process dyBPA = new Process();
$ L1 r1 b- _' J8 y0 R dyBPA.StartInfo.FileName = BPApath + "pfnt.exe";
1 \# B Y' w% f& x dyBPA.StartInfo.Arguments = BPAdatapath;
4 P) w1 C# ~% v+ F& k7 E) i dyBPA.StartInfo.UseShellExecute = false;
$ C1 Z1 o9 e+ ^! _8 L1 M/ G dyBPA.StartInfo.RedirectStandardInput = true;7 f. n/ l6 M6 i3 U: T
dyBPA.StartInfo.RedirectStandardOutput = true;
) b! `' U7 C7 W) w2 U# }9 C( | dyBPA.StartInfo.CreateNoWindow = false;" A/ r( _2 U5 [9 M2 G
dyBPA.StartInfo.WorkingDirectory = BPApath.Substring(0,BPApath.Length-1);1 z7 @3 m, R! o1 T: q4 L2 v! k3 E! H
dyBPA.Start();
1 ~5 S# u. J8 ]+ x3 _ string output = dyBPA.StandardOutput.ReadToEnd();
\* }9 x Z( H2 R$ C/ P' X dyBPA.Close();6 F, Q' {- I* j8 _
$ k% w# Q2 f, Y3 R: L; E$ x
# n' H5 p5 i C+ z; A! I5 j! Z }4 r$ e- E( y: B% X3 M8 P
}! @' T: h( k0 p( ]1 O" z
static void Main(string[] args)% h% T9 ^; u1 o( {+ m* e* i9 c8 n
{& v9 y. @# g; T! M- y2 L% J
powerflow calculate = new powerflow();. T" @' R% U$ o' F- Z6 g [
calculate.powerflow1(@"C:\psap32\psaw", @"E:\广东电网充裕度评估系统\童—潮流计算程序\013bpa");; i! {& i3 Y; r+ ~1 X) |; _
}
0 v# b7 r7 D2 [6 ^( X k( ^; A }
$ b: I: |& x* A, r. i2 C1 v}
9 e k* N" L9 j6 g7 T5 B, }由于本人是刚刚学习,可能上面代码有许多错误,还请高手赐教~~~小弟不胜感激 |
|