|
马上加入,结交更多好友,共享更多资料,让你轻松玩转电力研学社区!
您需要 登录 才可以下载或查看,没有账号?立即加入
×
这是我写的一段小代码,就是调用BPA对指定的.dat文件计算一次潮流,代码如下) x& i# N9 Z7 |! Q. O
using System;6 S5 ~! p) e; h
using System.Collections.Generic;
) j6 F- r9 m) q8 K. k: C& Y; Susing System.Text;
6 q. N/ F, N0 U+ T6 X. ~9 M+ Pusing System.Diagnostics;
7 e4 [0 A) ~' ~9 M2 `3 y' ?. B% f* o0 F4 ~+ K! v8 Y J
9 {) x8 i1 i, y( D, Knamespace 调用BPA& t1 u4 C* f0 w8 E# o
{/ ]7 W. g% I) _
class Program
u8 U7 L; A& |1 G6 k- v { \ N: c8 p. W% y
public class powerflow. {4 x/ p1 ^0 _4 h5 c/ w
{
- n4 {- l; U, a- _3 f2 m public void powerflow1(string BPApath, string BPAdatapath) //BPApath 为BPA程序的存放路径,BPAdatapath为.dat数据文件的路径0 B6 ?7 n6 Z, V3 r- T1 {
{
, J% N$ S( T. o! B/ ^/ o Process dyBPA = new Process();
- u8 k* b' H& F5 z dyBPA.StartInfo.FileName = BPApath + "pfnt.exe";9 t9 |% K4 ~$ I+ H$ X8 g
dyBPA.StartInfo.Arguments = BPAdatapath;
: G$ T. G0 k! d8 j) ? dyBPA.StartInfo.UseShellExecute = false;+ M+ A4 _3 L' o) G( \
dyBPA.StartInfo.RedirectStandardInput = true;
% ?$ j' C+ {. i# t6 p4 F dyBPA.StartInfo.RedirectStandardOutput = true;0 P1 j O9 G3 |' b, i- ]
dyBPA.StartInfo.CreateNoWindow = false;4 e$ `2 K3 ?' `, \! |
dyBPA.StartInfo.WorkingDirectory = BPApath.Substring(0,BPApath.Length-1);: t6 Q8 M5 Q/ ^" X" B( b! x
dyBPA.Start();
. O. G2 \$ Y! b3 L5 O string output = dyBPA.StandardOutput.ReadToEnd();+ G2 ?, A# Z' d3 F, Y) r) J. A+ H
dyBPA.Close();/ L$ |+ ?8 W& J( v, F
& g8 x& q0 I% A( J/ K
/ R0 _" N# a: Q$ @4 I) `. \& x ] }
6 j9 E/ d; c" R: D }
; J5 ]5 y5 ]2 S/ D2 t static void Main(string[] args) n. @( i/ Q2 a$ }6 l
{
* {; |, c$ V1 `/ g powerflow calculate = new powerflow();
& c! A/ k$ K5 x* x7 A calculate.powerflow1(@"C:\psap32\psaw", @"E:\广东电网充裕度评估系统\童—潮流计算程序\013bpa");# v! x# b( v: H8 p) W+ U1 d
}' s* k' A8 Q4 ~- P6 j( ]" q k+ [# w
}$ d, [& h9 T4 N
}
+ M8 d4 M7 ?$ R% Q& F由于本人是刚刚学习,可能上面代码有许多错误,还请高手赐教~~~小弟不胜感激 |