devices/asrc, rewrite #6/10, check for errors right at the beginning

This commit is contained in:
rlar 2015-04-12 18:17:52 +02:00
parent 1c53a425f0
commit b3860ac599
1 changed files with 9 additions and 8 deletions

View File

@ -27,6 +27,15 @@ ASRCsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states)
for (; model; model = model->ASRCnextModel) {
for (here = model->ASRCinstances; here; here=here->ASRCnextInstance) {
if (!here->ASRCtree)
return E_PARMVAL;
if (here->ASRCtype == ASRC_VOLTAGE)
if (here->ASRCposNode == here->ASRCnegNode) {
SPfrontEnd->IFerrorf(ERR_FATAL, "instance %s is a shorted ASRC", here->ASRCname);
return(E_UNSUPP);
}
if (!here->ASRCtc1Given)
here->ASRCtc1 = 0.0;
if (!here->ASRCtc2Given)
@ -58,16 +67,8 @@ ASRCsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states)
/* For each controlling variable set the entries
in the vector of the positions of the SMP */
if (!here->ASRCtree)
return E_PARMVAL;
if (here->ASRCtype == ASRC_VOLTAGE) {
if (here->ASRCposNode == here->ASRCnegNode) {
SPfrontEnd->IFerrorf(ERR_FATAL, "instance %s is a shorted ASRC", here->ASRCname);
return(E_UNSUPP);
}
here->ASRCposptr = TREALLOC(double *, here->ASRCposptr, j + 4);
TSTALLOC(ASRCposptr[j++], here->ASRCposNode, here->ASRCbranch);