09.03.2013 Views

Simulator 16 User Guide - PowerWorld

Simulator 16 User Guide - PowerWorld

Simulator 16 User Guide - PowerWorld

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

ListOfDevices Function: Sample Code for Borland® Delphi<br />

Sample Code<br />

// Runs Available Transfer Capability Routine<br />

// Executes ATC Calculations among all areas<br />

// and sends results to Excel<br />

procedure TMainForm.RunATCClick(Sender: TObject);<br />

var<br />

i, j, LowB, HighB : Integer;<br />

ValuesAreaArray : OLEVariant;<br />

begin<br />

// Obtain all the areas<br />

Output := SimAuto.ListOfDevices('area', '');<br />

if (string(Output[0]) '') then<br />

StatusBar1.Panels[1].Text := 'Error: ' + string(Output[0])<br />

else<br />

begin<br />

ValuesAreaArray := Output[1][0];<br />

LowB := VarArrayLowBound(ValuesAreaArray, 1);<br />

HighB := VarArrayHighBound(ValuesAreaArray, 1);<br />

// Executes loop<br />

for i := LowB to HighB do<br />

for j := LowB to HighB do begin<br />

if (i j) then begin<br />

// Runs ATC calculations<br />

OutputATC := SimAuto.RunScriptCommand('entermode(atc); ' +<br />

'atcdetermine([Area ' + IntToStr(ValuesAreaArray[i]) +<br />

'], [Area ' + IntToStr(ValuesAreaArray[j]) + '])');<br />

if (string(OutputATC[0]) '') then<br />

StatusBar1.Panels[1].Text := 'Error: ' + string(OutputATC[0])<br />

else begin<br />

// Sends ATC results to Excel<br />

Output := SimAuto.SendToExcel('transferlimiter', '', 'all');<br />

if (string(Output[0]) '') then<br />

StatusBar1.Panels[1].Text := 'Error: ' + string(Output[0])<br />

else<br />

StatusBar1.Panels[1].Text := 'ATC calculations done.';<br />

end;<br />

end;<br />

©2011 <strong>PowerWorld</strong> Corporation<br />

1425

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!