Jspice3
srcask.c
Go to the documentation of this file.
1 /***************************************************************************
2 JSPICE3 adaptation of Spice3f2 - Copyright (c) Stephen R. Whiteley 1992
3 Copyright 1990 Regents of the University of California. All rights reserved.
4 Authors: 1985 Thomas L. Quarles
5  1987 Kanwar Jit Singh
6  1992 Stephen R. Whiteley
7 ****************************************************************************/
8 
9 #include "spice.h"
10 #include <stdio.h>
11 #include "srcdefs.h"
12 #include "tskdefs.h"
13 #include "sperror.h"
14 #include "util.h"
15 #include "cktext.h"
16 
17 
18 /* ARGSUSED */
19 int
20 SRCask(ckt,inst,which,value,select)
21 
22 /*
23  * This routine gives access to the internal device parameters
24  * of Sources
25  */
26 
27 CKTcircuit *ckt;
28 GENinstance *inst;
29 int which;
30 IFvalue *value;
31 IFvalue *select;
32 {
33  SRCinstance *here = (SRCinstance*)inst;
34  static char *msg = "Current and power not available in ac analysis";
35 
36  switch (which) {
37  case SRC_DEP:
38  value->iValue = here->SRCdep;
39  break;
40  case SRC_DC:
41  value->rValue = here->SRCdcValue;
42  break;
43  case SRC_AC:
44  value->v.numValue = 2;
45  value->v.vec.rVec = here->SRCacVec;
46  break;
47  case SRC_AC_MAG:
48  value->rValue = here->SRCacMag;
49  break;
50  case SRC_AC_PHASE:
51  value->rValue = here->SRCacPhase;
52  break;
53  case SRC_FUNC:
54  value->tValue = here->SRCtree;
55  break;
56  case SRC_GAIN:
57  value->rValue = here->SRCcoeff;
58  break;
59  case SRC_CONTROL:
60  value->uValue = here->SRCcontName;
61  break;
62  case SRC_POS_NODE:
63  value->iValue = here->SRCposNode;
64  break;
65  case SRC_NEG_NODE:
66  value->iValue = here->SRCnegNode;
67  break;
68  case SRC_AC_REAL:
69  value->rValue = here->SRCacReal;
70  break;
71  case SRC_AC_IMAG:
72  value->rValue = here->SRCacImag;
73  break;
74  case SRC_CURRENT:
75  if (ckt->CKTcurrentAnalysis & DOING_AC) {
76  errMsg = MALLOC(strlen(msg)+1);
77  errRtn = "SRCask";
78  strcpy(errMsg,msg);
79  return (E_ASKCURRENT);
80  }
81  if (ckt->CKTrhsOld)
82  value->rValue = *(ckt->CKTrhsOld+here->SRCbranch);
83  break;
84  case SRC_POWER:
85  if (ckt->CKTcurrentAnalysis & DOING_AC) {
86  errMsg = MALLOC(strlen(msg)+1);
87  errRtn = "SRCask";
88  strcpy(errMsg,msg);
89  return (E_ASKPOWER);
90  }
91  if (ckt->CKTrhsOld)
92  value->rValue = (*(ckt->CKTrhsOld+here->SRCposNode)
93  - *(ckt->CKTrhsOld + here->SRCnegNode)) *
94  -*(ckt->CKTrhsOld + here->SRCbranch);
95  break;
96  case SRC_CONT_P_NODE:
97  value->iValue = here->SRCcontPosNode;
98  break;
99  case SRC_CONT_N_NODE:
100  value->iValue = here->SRCcontNegNode;
101  break;
102  default:
103  return (E_BADPARM);
104  }
105  return (OK);
106 }
#define SRC_AC_REAL
Definition: srcdefs.h:230
int numValue
Definition: ifsim.h:240
#define E_ASKCURRENT
Definition: sperror.h:26
double SRCcoeff
Definition: srcdefs.h:71
char * strcpy()
IFuid SRCcontName
Definition: srcdefs.h:74
union uIFvalue::@13::@14 vec
int SRCnegNode
Definition: srcdefs.h:38
char * errMsg
Definition: main.c:42
int SRCposNode
Definition: srcdefs.h:35
#define SRC_POWER
Definition: srcdefs.h:233
#define E_BADPARM
Definition: iferrmsg.h:26
double SRCdcValue
Definition: srcdefs.h:77
#define SRC_AC
Definition: srcdefs.h:220
int iValue
Definition: ifsim.h:232
double rValue
Definition: ifsim.h:233
#define DOING_AC
Definition: tskdefs.h:24
#define SRC_CURRENT
Definition: srcdefs.h:232
#define SRC_AC_MAG
Definition: srcdefs.h:221
int SRCdep
Definition: srcdefs.h:68
#define OK
Definition: iferrmsg.h:17
int SRCask(CKTcircuit *ckt, GENinstance *inst, int which, IFvalue *value, IFvalue *select)
Definition: srcask.c:20
double SRCacReal
Definition: srcdefs.h:85
#define SRC_CONTROL
Definition: srcdefs.h:227
int SRCcontNegNode
Definition: srcdefs.h:44
int SRCbranch
Definition: srcdefs.h:47
#define MALLOC(x)
Definition: util.h:9
#define SRC_AC_PHASE
Definition: srcdefs.h:222
int SRCcontPosNode
Definition: srcdefs.h:41
#define SRC_NEG_NODE
Definition: srcdefs.h:229
IFparseTree * tValue
Definition: ifsim.h:238
#define SRC_CONT_N_NODE
Definition: srcdefs.h:235
#define SRC_FUNC
Definition: srcdefs.h:223
#define SRC_DEP
Definition: srcdefs.h:218
char * errRtn
Definition: main.c:41
#define E_ASKPOWER
Definition: sperror.h:27
struct uIFvalue::@13 v
#define SRC_POS_NODE
Definition: srcdefs.h:228
double SRCacVec[2]
Definition: srcdefs.h:80
#define SRC_GAIN
Definition: srcdefs.h:226
IFparseTree * SRCtree
Definition: srcdefs.h:103
#define SRC_DC
Definition: srcdefs.h:219
#define SRC_AC_IMAG
Definition: srcdefs.h:231
double SRCacImag
Definition: srcdefs.h:88
#define SRC_CONT_P_NODE
Definition: srcdefs.h:234
IFuid uValue
Definition: ifsim.h:236