Jspice3
dioask.c File Reference
#include "spice.h"
#include <stdio.h>
#include <math.h>
#include "diodefs.h"
#include "tskdefs.h"
#include "sperror.h"
#include "const.h"
#include "util.h"
Include dependency graph for dioask.c:

Go to the source code of this file.

Functions

int DIOask (CKTcircuit *ckt, GENinstance *inst, int which, IFvalue *value, IFvalue *select)
 

Function Documentation

int DIOask ( CKTcircuit ckt,
GENinstance inst,
int  which,
IFvalue value,
IFvalue select 
)

Definition at line 20 of file dioask.c.

27 {
28  DIOinstance *here = (DIOinstance*)inst;
29  static char *msg = "Current and power not available for ac analysis";
30 
31  switch (which) {
32  case DIO_AREA:
33  value->rValue = here->DIOarea;
34  break;
35  case DIO_IC:
36  value->rValue = here->DIOinitCond;
37  break;
38  case DIO_OFF:
39  value->iValue = here->DIOoff;
40  break;
41  case DIO_CURRENT:
42  if (ckt->CKTstate0)
43  value->rValue = here->DIOcd;
44  break;
45  case DIO_VOLTAGE:
46  if (ckt->CKTstate0)
47  value->rValue = *(ckt->CKTstate0 + here->DIOvoltage);
48  break;
49  case DIO_CHARGE:
50  if (ckt->CKTstate0)
51  value->rValue = *(ckt->CKTstate0 + here->DIOcapCharge);
52  break;
53  case DIO_CAPCUR:
54  if (ckt->CKTstate0)
55  value->rValue = *(ckt->CKTstate0 + here->DIOcapCurrent);
56  break;
57  case DIO_CONDUCT:
58  if (ckt->CKTstate0)
59  value->rValue = here->DIOgd;
60  break;
61  case DIO_POWER :
62  if (ckt->CKTcurrentAnalysis & DOING_AC) {
63  errMsg = MALLOC(strlen(msg)+1);
64  errRtn = "DIOask";
65  strcpy(errMsg,msg);
66  return (E_ASKPOWER);
67  }
68  if (ckt->CKTstate0) {
69  value->rValue = here->DIOcd *
70  *(ckt->CKTstate0 + here->DIOvoltage);
71  }
72  break;
73  case DIO_TEMP:
74  value->rValue = here->DIOtemp - CONSTCtoK;
75  break;
76  /* new in 3f2 */
77  case DIO_CAP:
78  value->rValue = here->DIOcap;
79  break;
80  default:
81  return (E_BADPARM);
82  }
83  return (OK);
84 }
double DIOgd
Definition: diodefs.h:61
#define DIO_VOLTAGE
Definition: diodefs.h:169
#define DIO_IC
Definition: diodefs.h:166
char * strcpy()
#define CONSTCtoK
Definition: const.h:11
char * errMsg
Definition: main.c:42
#define DIO_CHARGE
Definition: diodefs.h:170
#define E_BADPARM
Definition: iferrmsg.h:26
double DIOcd
Definition: diodefs.h:60
#define DIO_CAP
Definition: diodefs.h:175
int iValue
Definition: ifsim.h:232
double rValue
Definition: ifsim.h:233
#define DIO_CURRENT
Definition: diodefs.h:168
#define DOING_AC
Definition: tskdefs.h:24
double DIOtemp
Definition: diodefs.h:50
#define OK
Definition: iferrmsg.h:17
unsigned DIOoff
Definition: diodefs.h:42
#define MALLOC(x)
Definition: util.h:9
#define DIO_TEMP
Definition: diodefs.h:174
#define DIO_POWER
Definition: diodefs.h:173
#define DIO_CAPCUR
Definition: diodefs.h:171
double DIOcap
Definition: diodefs.h:62
#define DIO_CONDUCT
Definition: diodefs.h:172
char * errRtn
Definition: main.c:41
#define E_ASKPOWER
Definition: sperror.h:27
#define DIO_AREA
Definition: diodefs.h:165
double DIOarea
Definition: diodefs.h:48
int CKTcurrentAnalysis
Definition: cktdefs.h:130
#define DIO_OFF
Definition: diodefs.h:167
double DIOinitCond
Definition: diodefs.h:49