马上加入,结交更多好友,共享更多资料,让你轻松玩转电力研学社区!
您需要 登录 才可以下载或查看,没有账号?立即加入
×
这是我写的一段小代码,就是调用BPA对指定的.dat文件计算一次潮流,代码如下
2 _, o0 P- O& M) T, Lusing System;
k' d, ]7 ]+ j: |using System.Collections.Generic;
5 J3 u; D% |, ~3 z$ cusing System.Text;
4 J: ~5 f! G/ I. i" V1 vusing System.Diagnostics;
; `" S. _( B8 S4 [7 ?/ X) C. J. n4 K7 u. t3 C/ j' F' \
1 S* k, G7 b$ Q0 s% h" Q+ s
namespace 调用BPA
- R0 J& D+ }; ]) W7 y; `8 R# m{
7 |9 V3 l0 B1 R5 M class Program% E6 W* [: _) A" I, \& `1 _$ X
{
H' k% g, C9 N0 [/ ` public class powerflow t8 v2 z. }- t
{
9 A% |" l; t" u H0 C public void powerflow1(string BPApath, string BPAdatapath) //BPApath 为BPA程序的存放路径,BPAdatapath为.dat数据文件的路径
# {, z# J d/ i! B3 g p {
* X2 y3 c9 J) Z Process dyBPA = new Process();
5 \" x7 w$ c1 Z% G( K dyBPA.StartInfo.FileName = BPApath + "pfnt.exe";
, {: z- N! @; |1 \: }5 w- ~ dyBPA.StartInfo.Arguments = BPAdatapath;
6 d6 E* E7 S% [" O( k/ `' S dyBPA.StartInfo.UseShellExecute = false;
( J4 C$ I2 X( n+ k. S2 E S Z dyBPA.StartInfo.RedirectStandardInput = true;
. i' m- U7 y2 Y5 }$ U dyBPA.StartInfo.RedirectStandardOutput = true;9 U B# c% c/ X/ d0 `4 O( L$ j
dyBPA.StartInfo.CreateNoWindow = false;
6 t2 S2 t4 E6 f- @7 w9 D dyBPA.StartInfo.WorkingDirectory = BPApath.Substring(0,BPApath.Length-1);( }3 f2 Z4 H: V2 p! v/ X) u+ Z
dyBPA.Start();
, @1 q% q2 D$ ^ string output = dyBPA.StandardOutput.ReadToEnd();$ y! H M; g& \+ r
dyBPA.Close();
: O4 C9 \+ H9 V0 N; M " o8 {5 g7 x$ `; z) _* i
, L( A, \0 C# I' O( k, L }9 g7 V& M+ [% B8 a* C" Y) q8 u3 K
}
" B6 Y# x& s. b! I6 } static void Main(string[] args)7 t6 y' b- s$ h9 l6 ? D
{
9 n; r; E7 D4 J0 C% T. u U( E powerflow calculate = new powerflow();; l& Z' a% Z/ J8 \
calculate.powerflow1(@"C:\psap32\psaw", @"E:\广东电网充裕度评估系统\童—潮流计算程序\013bpa");8 _* t) O: H) @( H
}
' m5 R2 v7 J9 y! ^8 S) _1 m, y6 [ }
: ]: w4 R6 \7 T }+ R8 D}
# R: I/ A2 h B由于本人是刚刚学习,可能上面代码有许多错误,还请高手赐教~~~小弟不胜感激 |