|
马上加入,结交更多好友,共享更多资料,让你轻松玩转电力研学社区!
您需要 登录 才可以下载或查看,没有账号?立即加入
×
这是我写的一段小代码,就是调用BPA对指定的.dat文件计算一次潮流,代码如下
% o9 w- n! U# ]* qusing System;
) X3 f& z' M' K7 s2 susing System.Collections.Generic;
9 h/ e- T2 J0 @% [6 Zusing System.Text;
. |8 W* E. ]. f) a! D' v5 H* ?using System.Diagnostics; G) k' t2 N) R c) n& `
8 _# g; s' R0 J$ d' e" [2 S c4 V M
namespace 调用BPA$ A' C; d \4 o& v
{. }- R+ R: C. p6 ^/ F
class Program
9 N& {- g, Z) z% e _ {) H" b# s8 Z y- d$ j$ k( a1 ^( L
public class powerflow; S9 k0 C& E6 s* Q3 x/ S
{
$ [; s3 \+ H1 X: o public void powerflow1(string BPApath, string BPAdatapath) //BPApath 为BPA程序的存放路径,BPAdatapath为.dat数据文件的路径
( ?, p9 `: Q# u$ I# \; ` {
/ V) ~3 k% R# C+ G D) x9 W0 E. ] Process dyBPA = new Process();
- o+ g6 I+ \9 O5 Z dyBPA.StartInfo.FileName = BPApath + "pfnt.exe";
, z1 W9 Y" w* ]. M( l, C* E dyBPA.StartInfo.Arguments = BPAdatapath;2 u* a' B6 z2 z* H5 M; N5 \
dyBPA.StartInfo.UseShellExecute = false;! h6 C) X f, E9 r
dyBPA.StartInfo.RedirectStandardInput = true;
) S: y/ q; _' O- r$ k1 {" m dyBPA.StartInfo.RedirectStandardOutput = true;# ~# s$ x; R g) [
dyBPA.StartInfo.CreateNoWindow = false;( l4 Z* Y' P6 j5 g/ m
dyBPA.StartInfo.WorkingDirectory = BPApath.Substring(0,BPApath.Length-1);
4 [7 s4 \! W$ I, B4 V3 i5 R7 c& y dyBPA.Start();
6 |: }5 n6 r% G) Y1 A string output = dyBPA.StandardOutput.ReadToEnd();
% ]% V- R& e5 I, V" } dyBPA.Close();
+ r1 E) G: }4 }0 z ! l3 ~( {( O, }: I) w N5 n
( p9 Q/ O; I3 w, `; F
}
: l. \: N) \1 ?" r7 K+ _' o, E }% H- p8 Y: I7 n1 j' T G
static void Main(string[] args)" H1 L1 v* U5 j/ i0 R0 r C" d
{
4 ^0 Q# g' i; ]9 w7 h8 M powerflow calculate = new powerflow();- T# N) `: t, F2 Y
calculate.powerflow1(@"C:\psap32\psaw", @"E:\广东电网充裕度评估系统\童—潮流计算程序\013bpa");
! F6 m. S6 T4 t; m E }
: w; F, p, l, l6 q! w+ _ }
* x# Z1 c; d# k. l. ~}+ a3 ]) i" m7 h# f8 J( j% `
由于本人是刚刚学习,可能上面代码有许多错误,还请高手赐教~~~小弟不胜感激 |