|
|
马上加入,结交更多好友,共享更多资料,让你轻松玩转电力研学社区!
您需要 登录 才可以下载或查看,没有账号?立即加入
×
这是我写的一段小代码,就是调用BPA对指定的.dat文件计算一次潮流,代码如下. D7 R$ v/ Y, ^" r0 f, i. ]
using System;7 c- z! K6 @8 d+ r
using System.Collections.Generic;
* N8 L# Q; x1 i3 J( g3 nusing System.Text;
; W& M. B+ J; G) K6 Pusing System.Diagnostics;
$ R" J/ B/ e* z7 }: z. U9 _& C, A$ w2 i$ ~
( x; |9 s5 V S" m7 p, Nnamespace 调用BPA
+ N' U% n$ W* o' K{
/ K% ]! D: O9 z" [9 J* r class Program
4 \' P" X/ T4 b- H( L0 o {
! F! G+ W4 i) I8 ?6 |3 c( a8 u public class powerflow' k: d# p- R6 J. t
{7 e7 ?' O& n% t! H' j$ P! l
public void powerflow1(string BPApath, string BPAdatapath) //BPApath 为BPA程序的存放路径,BPAdatapath为.dat数据文件的路径
7 ~0 U7 W0 [- O8 h# \& o; M {6 e, ^: F, ^2 W3 Z
Process dyBPA = new Process();, R* E) F* f {* I7 Y @5 q' b7 w
dyBPA.StartInfo.FileName = BPApath + "pfnt.exe";
; ~! c1 B$ m* L+ M& M& g# _ dyBPA.StartInfo.Arguments = BPAdatapath;
2 q! J* b8 p' p+ l dyBPA.StartInfo.UseShellExecute = false;
6 P/ z0 v: y1 h" C% W+ {( @ dyBPA.StartInfo.RedirectStandardInput = true;
" C$ i8 r/ e( C! |; x6 N dyBPA.StartInfo.RedirectStandardOutput = true;
6 g0 B6 ~* o! t% u dyBPA.StartInfo.CreateNoWindow = false;6 L7 ^( h* ?9 l/ o. l& b. o
dyBPA.StartInfo.WorkingDirectory = BPApath.Substring(0,BPApath.Length-1);+ f9 e- g1 M! r; v
dyBPA.Start();4 h- w4 c& {. X2 v- t
string output = dyBPA.StandardOutput.ReadToEnd();
( S( T. ]9 I% z) _; l dyBPA.Close();
$ F$ n2 a" i0 \6 G2 Y ; e% _) x) N" a& P* T
w% V* E9 K S; I }8 e2 E5 Y7 l" P* W: F1 W% H4 U1 J
}
7 Z, P2 m4 X6 U* _3 d' ` static void Main(string[] args)
+ n2 q9 g+ m, _" ? u1 {" w {
; @0 G# C% z3 R+ T powerflow calculate = new powerflow();1 o9 D) j- b( b+ @
calculate.powerflow1(@"C:\psap32\psaw", @"E:\广东电网充裕度评估系统\童—潮流计算程序\013bpa");8 p J; G. b( o. W$ ^
}' M" O6 p& \1 r( p2 k# L1 j) P
}
9 C/ b) t( ^: J* o z}* f6 F1 V0 U6 B! N2 v
由于本人是刚刚学习,可能上面代码有许多错误,还请高手赐教~~~小弟不胜感激 |
|