Sei sulla pagina 1di 3

set aShcLocs;

object pObj,
pTmp;

int ierr,
faulttype,
iline,
iBus,
iTmp,
iCountShc,
iCountBus,
iLineLen;

string aShc;

iCountShc= 0;
iCountBus= 0;
iLineLen = 153;
pObj = NULL;

EchoOff();

! first reset calculation


ResetCalculation();

! method
if (method=0) { ! iec
shc:iopt_mde=1;
aShc = 'IEC';
} else { ! complete
shc:iopt_mde=3;
aShc = 'complete';
}

! configure short circuit command


! filter busbars
if (iall) {
Info('Calculating short circuits (%s) at all busbars',aShc);
shc:iopt_allbus = 1;
} else {
aShcLocs = SEL.GetContents();
for (pTmp=aShcLocs.First(); pTmp; pTmp=aShcLocs.Next()) {
pObj = pTmp:obj_id;
if (pObj) {
iTmp = pObj.IsNode();
if (iTmp) {
iCountBus = iCountBus + 1; ! increase number of busbars
} else {
pTmp:obj_id = NULL; ! reset reference
}
}
}
aShcLocs.Clear();
if (iCountBus=0) {
Error('Please select busbars or calculate short circuit ar all busbars
(parameter iall)');
exit();
} else {
Info('Calculating short circuits (%s) at selected busbars',aShc);
shc:iopt_allbus = 0;
shc:shcobj = SEL;
}
}

! fault resistance
shc:Rf = Rf;
shc:Xf = Xf;

ierr=0;
faulttype = 0;

faulttype = -1;
while (faulttype<2) { ! 3-1 -> increased in loop !

faulttype = faulttype + 1; ! increase at the beginning (continue)


ierr = ShcCalc.Execute(shc,faulttype); ! calculate short circuits
if (ierr) {
continue;
}

if (iCountShc=0) { ! only first time


! collect the short circuit buses
if (iall) { ! selected busbars
aShcLocs = AllRelevant();
} else { ! all busbars
aShcLocs = SEL.AllBars();
}
iCountBus = aShcLocs.Count();

iline=1;
for (iBus=iCountBus-1; iBus>=0; iBus=iBus-1) {
pTmp = aShcLocs.Obj(iBus);
iTmp = pTmp.IsNode();
if (iTmp) {
iTmp = pTmp.IsShortCircuited();
if (iTmp) {
pTmp:dpl1 = iline; ! line in matrix
iline = iline+1;
continue;
}
}
aShcLocs.Remove(pTmp);
}
iCountBus = aShcLocs.Count();
if (iCountBus) {
aShcLocs.SortToVar(0,'loc_name');
InitMatrix.Execute(Results,aShcLocs);
}
}

if (iCountBus=0) {
continue;
}
! store results in matrix
WriteMatrix.Execute(Results,aShcLocs,faulttype);
iCountShc = iCountShc + 1;
}

shc:shcobj = NULL;

! calculate dependend values


CalcMatrix.Execute(Results);

! produce output
if (iExcel) {
ToExcel.Execute(aShcLocs,Results);
} else {
Output.Execute(iLineLen,aShcLocs,Results);
}

EchoOn();

Potrebbero piacerti anche