📄 outinterface.c
字号:
data->regular = false;/* gtri - add - wbk - 4/15/91 - Set new model type member for returning currents to Mspice */ data->specModType = modtype;/* gtri - end - wbk - 4/15/91 - Set new model type member for returning currents to Mspice */ run->numData++; return (OK);}intOUTpData(plotPtr, refValue, valuePtr) GENERIC *plotPtr; IFvalue *refValue; IFvalue *valuePtr;{ runDesc *run = (runDesc *) plotPtr; IFvalue val; int i;/* gtri - add - wbk - 12/19/90 - Add IPC stuff */ Ipc_Complex_t ipc_ctemp;/* gtri - add - wbk - 12/19/90 - Add IPC stuff */ run->pointCount++;/* gtri - add - wbk - 12/19/90 - Add IPC stuff */ if(g_ipc.enabled) { /* Send ground node data for consistancy */ if(g_mif_info.circuit.anal_type != MIF_AC) { ipc_send_double("0", 0.0); } else { ipc_ctemp.real = 0.0; ipc_ctemp.imag = 0.0; ipc_send_complex("0", ipc_ctemp); } /* Send the data from the solution */ for (i = 0; i < run->numData; i++) { if(run->data[i].regular) { /* Regular items are from the solution vector */ /* and include node voltages and Vsource currents */ if(run->data[i].type == IF_REAL) { ipc_send_double(run->data[i].name, valuePtr->v.vec.rVec[run->data[i].outIndex]); } else if(run->data[i].type == IF_COMPLEX) { ipc_ctemp.real = valuePtr->v.vec.cVec[run->data[i].outIndex].real; ipc_ctemp.imag = valuePtr->v.vec.cVec[run->data[i].outIndex].imag; ipc_send_complex(run->data[i].name, ipc_ctemp); } } else if(g_ipc.anal_type != IPC_ANAL_AC) { /* Must be a special (ICLDQJM current) */ if(! getSpecial(&run->data[i], run, &val)) continue; if(run->data[i].type == IF_REAL) { ipc_send_double(run->data[i].specName, val.rValue * run->data[i].specModType); } } } /* Do the stuff this routine does at the end */ if (ft_bpcheck(run->runPlot, run->pointCount) == false) shouldstop = true; return (OK); }/* gtri - end - wbk - 12/19/90 - Add IPC stuff */ if (run->writeOut) { fileStartPoint(run->fp, run->binary, run->pointCount); if (run->refIndex != -1) { if (run->isComplex) fileAddComplexValue(run->fp, run->binary, refValue->cValue); else fileAddRealValue(run->fp, run->binary, refValue->rValue); } for (i = 0; i < run->numData; i++) { /* we've already printed reference vec first */ if (run->data[i].outIndex == -1) continue; if (run->data[i].regular) { if(run->data[i].type == IF_REAL) fileAddRealValue(run->fp, run->binary, valuePtr->v.vec.rVec [run->data[i].outIndex]); else if (run->data[i].type == IF_COMPLEX) fileAddComplexValue(run->fp, run->binary, valuePtr->v.vec.cVec [run->data[i].outIndex]); else fprintf(stderr, "OUTpData: unsupported data type\n"); } else { /* should pre-check instance */ if (!getSpecial(&run->data[i], run, &val)) continue; if (run->data[i].type == IF_REAL) fileAddRealValue(run->fp, run->binary, val.rValue); else if (run->data[i].type == IF_COMPLEX) fileAddComplexValue(run->fp, run->binary, val.cValue); else fprintf(stderr, "OUTpData: unsupported data type\n"); } } fileEndPoint(run->fp, run->binary); } else { for (i = 0; i < run->numData; i++) { if (run->data[i].outIndex == -1) { if (run->data[i].type == IF_REAL) plotAddRealValue(&run->data[i], refValue->rValue); else if (run->data[i].type == IF_COMPLEX) plotAddComplexValue(&run->data[i], refValue->cValue); } else if (run->data[i].regular) { if (run->data[i].type == IF_REAL) plotAddRealValue(&run->data[i], valuePtr->v.vec.rVec [run->data[i].outIndex]); else if (run->data[i].type == IF_COMPLEX) plotAddComplexValue(&run->data[i], valuePtr->v.vec.cVec [run->data[i].outIndex]); } else { /* should pre-check instance */ if (!getSpecial(&run->data[i], run, &val)) continue; if (run->data[i].type == IF_REAL) plotAddRealValue(&run->data[i], val.rValue); else if (run->data[i].type == IF_COMPLEX) plotAddComplexValue(&run->data[i], val.cValue); else fprintf(stderr, "OUTpData: unsupported data type\n"); } } gr_iplot(run->runPlot); } if (ft_bpcheck(run->runPlot, run->pointCount) == false) shouldstop = true; return (OK);}/* ARGSUSED */ /* until some code gets written */intOUTwReference(plotPtr, valuePtr, refPtr) GENERIC *plotPtr; IFvalue *valuePtr; GENERIC **refPtr;{ return (OK);}/* ARGSUSED */ /* until some code gets written */intOUTwData(plotPtr, dataIndex, valuePtr, refPtr) GENERIC *plotPtr; int dataIndex; IFvalue *valuePtr; GENERIC *refPtr;{ return (OK);}/* ARGSUSED */ /* until some code gets written */intOUTwEnd(plotPtr) GENERIC *plotPtr;{ return (OK);}intOUTendPlot(plotPtr) GENERIC *plotPtr;{ runDesc *run = (runDesc *) plotPtr; if (run->writeOut) fileEnd(run); else { gr_end_iplot(); plotEnd(run); } freeRun(run); return (OK);}/* ARGSUSED */ /* until some code gets written */intOUTbeginDomain(plotPtr, refName, refType, outerRefValue) GENERIC *plotPtr; char *refName; int refType; IFvalue *outerRefValue;{ return (OK);}/* ARGSUSED */ /* until some code gets written */intOUTendDomain(plotPtr) GENERIC *plotPtr;{ return (OK);}/* ARGSUSED */ /* until some code gets written */intOUTattributes(plotPtr, varName, param, value) GENERIC *plotPtr; char *varName; int param; IFvalue *value;{ /*runDesc *run = (runDesc *) plotPtr;*/ return (OK);}/* The file writing routines. */static voidfileInit(run) runDesc *run;{ int i; char *name, buf[BSIZE]; int type; /* This is a hack. */ run->isComplex = false; for (i = 0; i < run->numData; i++) if (run->data[i].type == IF_COMPLEX) run->isComplex = true; fprintf(run->fp, "Title: %s\n", run->name); fprintf(run->fp, "Date: %s\n", datestring()); fprintf(run->fp, "Plotname: %s\n", run->type); fprintf(run->fp, "Flags: %s\n", run->isComplex ? "complex" : "real"); fprintf(run->fp, "No. Variables: %d\n", run->numData); fprintf(run->fp, "No. Points: "); fflush(run->fp); /* Gotta do this for LATTICE. */ run->pointPos = ftell(run->fp); fprintf(run->fp, "0 \n"); /* Save 8 spaces here. */ fprintf(run->fp, "Command: version %s\n", SPICE_VERSION); fprintf(run->fp, "Variables:\n"); for (i = 0; i < run->numData; i++) { if (isdigit(*run->data[i].name)) { (void) sprintf(buf, "V(%s)", run->data[i].name); name = buf; } else { name = run->data[i].name; } if (substring("#branch", name)) type = SV_CURRENT; else if (cieq(name, "time")) type = SV_TIME; else if (cieq(name, "frequency")) type = SV_FREQUENCY; else type = SV_VOLTAGE; fprintf(run->fp, "\t%d\t%s\t%s\n", i, name, ft_typenames(type)); } fprintf(run->fp, "%s:\n", run->binary ? "Binary" : "Values"); return;}static voidfileStartPoint(fp, bin, num) FILE *fp; bool bin; int num;{ if (!bin) fprintf(fp, "%d\t", num - 1); return;}static voidfileAddRealValue(fp, bin, value) FILE *fp; bool bin; double value;{ if (bin) fwrite((char *) &value, sizeof (double), 1, fp); else fprintf(fp, "\t%.*e\n", DOUBLE_PRECISION, value); return;}static voidfileAddComplexValue(fp, bin, value) FILE *fp; bool bin; IFcomplex value;{ if (bin) { fwrite((char *) &value.real, sizeof (double), 1, fp); fwrite((char *) &value.imag, sizeof (double), 1, fp); } else { fprintf(fp, "\t%.*e,%.*e\n", DOUBLE_PRECISION, value.real, DOUBLE_PRECISION, value.imag); }}/* ARGSUSED */ /* until some code gets written */static voidfileEndPoint(fp, bin) FILE *fp; bool bin;{ return;}/* Here's the hack... Run back and fill in the number of points. */static voidfileEnd(run) runDesc *run;{ long place; fflush(run->fp); /* For LATTICE... */ place = ftell(run->fp); fseek(run->fp, run->pointPos, 0); fprintf(run->fp, "%d", run->pointCount); fseek(run->fp, place, 0); fflush(run->fp); return;}/* The plot maintenance routines. */static voidplotInit(run) runDesc *run;{ struct plot *pl = plot_alloc(run->type); char buf[100]; struct dvec *v; dataDesc *dd; int i; pl->pl_title = copy(run->name); pl->pl_name = copy(run->type); pl->pl_date = datestring(); plot_new(pl); plot_setcur(pl->pl_typename); run->runPlot = pl; /* This is a hack. */ /* if any of them complex, make them all complex */ run->isComplex = false; for (i = 0; i < run->numData; i++) { if (run->data[i].type == IF_COMPLEX) run->isComplex = true; } for (i = 0; i < run->numData; i++) { dd = &run->data[i]; v = alloc(dvec); if (isdigit(*dd->name)) { (void) sprintf(buf, "V(%s)", dd->name); v->v_name = copy(buf); } else v->v_name = copy(dd->name); if (substring("#branch", v->v_name)) v->v_type = SV_CURRENT; else if (cieq(v->v_name, "time")) v->v_type = SV_TIME; else if (cieq(v->v_name, "frequency")) v->v_type = SV_FREQUENCY; else v->v_type = SV_VOLTAGE; v->v_length = 0; v->v_scale = NULL; if (!run->isComplex) { v->v_flags = VF_REAL; v->v_realdata = (double *) malloc(0); } else { v->v_flags = VF_COMPLEX; v->v_compdata = (complex *) malloc(0); } v->v_flags |= VF_PERMANENT; vec_new(v); dd->vec = v; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -