Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 29 additions & 20 deletions src/CNDTYPES.DEF
Original file line number Diff line number Diff line change
Expand Up @@ -59,28 +59,40 @@
Type Extern
Name Name Decl
------- ----- ------------------------- */
INT XINT "int"
INTP XINTP "int*"
SI XSI "short"
// BOOL -- "short" // added 2-92, deleted 2-94 cuz 32 bits in 32 bit windows.
BOO -- "short" // unambiguous 16-bit Boolean 2-94.
USI XUSI "unsigned short"
// char and variants: always 8 bits
CH -- "char"
UCH -- "unsigned char"

// SI and variants: always 16 bits
SI -- "int16_t"
USI -- "uint16_t"
BOO -- "int16_t" // unambiguous 16-bit Boolean
TI -- "SI" // (rat) table index (subscript); 0 means unset.

// INT and variants: always 32 bits
INT -- "int32_t"
UINT -- "uint32_t"

// LI and variants: same size as pointer (4 on 32 bit / 8 on 64 bit)
#if CSE_ARCH == 64
LI XLI "int64_t"
ULI XULI "uint64_t"
LI -- "int64_t"
ULI -- "uint64_t"
#else
LI XLI "long"
ULI XULI "unsigned long"
LI -- "int32_t"
ULI -- "uint32_t"
#endif
FLOAT XF "float"
FLOATP -- "float *"
VOIDP -- "void *"

FLOAT -- "float"
FLOATP -- "float *"
// PERCENT -- "float" // restoring PERCENT restores code in cvpak.cpp
DBL -- "double"

CULSTR -- "struct CULSTR" // string accessed via 4 byte handle

VOIDP -- "void *"

DOW -- "short" // day of week, sun=0 in tdpak (1 less than DOWCH)
MONTH -- "short" // month, jan=1 in tdpak
CH XCH "char"
CULSTR -- "struct CULSTR"
UCH -- "unsigned char"
TI -- "SI" // (rat) table index (subscript); 0 means unset.

ANAME -- "char[64]" // name string for use in RATs:
IDATE -- "struct {SI year;SI month;SI mday;SI wday;}"
Expand All @@ -92,9 +104,6 @@ SHOY -- "unsigned" // subhour of year: (jday*24 + ihr)*4 + subhr
// CAUTION: code in tdpak.cpp (at least) assumes IDATETIME is same as an IDATE followed by an ITIME. 9-89.
IDATETIME -- "struct {SI year;SI month;SI mday;SI wday;SI hour;SI min;SI sec;}"
LDATETIME -- "time_t"
DBL -- "double"
DBLP -- "double*"
// PERCENT -- "float" // restoring PERCENT restores code in cvpak.cpp
SGTARGP -- "struct SGTARG *" // pointer to SGTARG for SGRAT.targ
MASSLAYERP -- "struct MASSLAYER *"
MASSMODELP -- "class MASSMODEL *"
Expand Down
3 changes: 0 additions & 3 deletions src/CNFIELDS.DEF
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ TypeName Datatype Limits Units
//
//========== I. Basic data types + limit variations. Mostly used in CSE.
INT INT LMNONE UNNONE
INTP INTP LMNONE UNNONE
SI SI LMNONE UNNONE
SI_GEZ SI LMGEZ UNNONE
SI_GZ SI LMGZ UNNONE
Expand All @@ -53,8 +52,6 @@ FLOAT_LZ FLOAT LMLZ UNNONE
FRAC FLOAT LMFR UNNONE
FRAC_GZ FLOAT LMFGZ UNNONE
DBL DBL LMNONE UNNONE
FLOATP FLOATP LMNONE UNNONE
DBLP DBLP LMNONE UNNONE
//VOIDP VOIDP LMNONE UNNONE unused 5-95
IDATE IDATE LMNONE UNNONE

Expand Down
60 changes: 29 additions & 31 deletions src/CNRECS.DEF
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ RECORD TOPRAT "top" *RAT /* top level RAT: contains control info and all once-on
// C_VENTAVAILCH_WHOLEHOUSE: airnet windows / fans
// C_VENTAVAILCH_ZONAL: airnet windows / fans (controlled by zone)
// C_VENTAVAILCH_RSYSOAV: RSYS outside air vent (central mechanical)
*declare "ULI tp_GetVentAvail() const { return CHN( tp_ventAvail); }"
*declare "int tp_GetVentAvail() const { return CHN( tp_ventAvail); }"

*s *e FLOAT tp_fVent // consensus whole building vent fraction (if not RSYSOAV)
// = fraction of full vent flow to use
Expand All @@ -283,10 +283,10 @@ RECORD TOPRAT "top" *RAT /* top level RAT: contains control info and all once-on
// mostly for debugging.
*f SI verbose // screen messages: autosizing: 0 none, 1 some (dflt?), 2-5 more
// -1: suppress progress messages ("Input", "Warmup", etc.) via setScreenQuiet()
*h LI tp_dbgPrintMask // debug print mask, controls DbPrintf() etc., schedulable via std capabilities
*i LI tp_dbgPrintMaskC // debug print mask constant portion (value known during setup)
*declare "LI tp_SetDbMask();" // combine tp_dbgPrintMask and tp_dbgPrintMaskC, call DbSetMask
*s LI tp_dbgFlag // debug flag value for passing testing info to code; normally no effect
*h INT tp_dbgPrintMask // debug print mask, controls DbPrintf() etc., schedulable via std capabilities
*i INT tp_dbgPrintMaskC // debug print mask constant portion (value known during setup)
*declare "int tp_SetDbMask();" // combine tp_dbgPrintMask and tp_dbgPrintMaskC, call DbSetMask
*s INT tp_dbgFlag // debug flag value for passing testing info to code; normally no effect

//TOP: inputs: autoSizing
*i FRAC_GZ auszTol // autosizing result tolerance, dfl .005
Expand Down Expand Up @@ -707,7 +707,7 @@ RECORD WFILE "weatherFile" *RAT // weather file info, one static instance "Wfile
*declare "RC wf_GetDsDayHr( WDHR* pWd, int iHr, int erOp = WRN);"
*declare "RC wf_Read( WDHR* pWd, int jDay, int iHr, int erOp = WRN);"
*declare "USI* wf_PackedHrRead( int jDay, int iHr, int erOp = WRN);"
*declare "LI wf_PackedHrOffset( int jDay, int iHr, int erOp = WRN);"
*declare "int wf_PackedHrOffset( int jDay, int iHr, int erOp = WRN);"
*declare "RC wf_CSWOpen( const char* wfName, int erOp );"
*declare "RC wf_CSWRead( WDHR* pwd, int jDay, int iHr, int erOp );"
*declare "RC wf_CSWHdrVal( const char* key, const char* val, float& v, RC& rcAll, int erOp=WRN);"
Expand Down Expand Up @@ -1559,8 +1559,8 @@ RECORD SGRAT "solarGain" *RAT *hideall // HIDE 1-92 due to doubts about whether
#ifdef SOLAVNEND // undef in cndefns.h (via cnglob.h) 1-18-94: only if computing & using end-ivl as well as ivl avg solar values
o BOO sg_isEndIvl // non-0 to use end-interval value (zones) not interval average value (masses)
#endif
FLOATP sg_pControl // &0..1.f to multiply gain, or NULL to use 1.0
// standard time hourly factors
*declare "FLOAT* sg_pControl;" // &0..1.f to multiply gain, or NULL to use 1.0
// standard time hourly factors
// = Btuh to target per unit weather file irrad (Btuh/ft2)
*mh *e *array 24 DBL sg_bmXBmF // beam per unit beam
*mh *e *array 24 DBL sg_dfXBmF // diffuse per unit beam (e.g. ground reflected)
Expand Down Expand Up @@ -1716,7 +1716,7 @@ RECORD RI "report" *RAT // REPORT (RiB) and EXPORT (XiB) (.what altered) input r
*i DOY rpDayBeg // start 1-based Julian day of year, where applicable
*i DOY rpDayEnd // end ..
*i FLOAT_GZ rpBtuSf // energy (Btu) scale factor
*s *e LI rpCond // condition: if given, rpt lines omitted when FALSE (SI; LI used to hold NAN) (LI currently unprobeable)
*s *e INT rpCond // condition: if given, rpt lines omitted when FALSE (INT used to hold NAN)
*i CULSTR rpTitle // title, for UDT, in dm
*i SI rpCpl // chars per line, inputtable re UDT's (default -1="as wide as needed")
*i RPTHDCH rpHeader // table header or export header yes/no (default yes)
Expand Down Expand Up @@ -1770,7 +1770,7 @@ RECORD DVRI "dvri" *hideall *RAT // Date-dependent Virtual Report Info -- at run
*r DOY rpDayBeg // start 1-based Julian day of year
*r DOY rpDayEnd // end ..
*r float rpBtuSf // energy (Btu) scale factor
*s LI rpCond // condition: if given, report lines omitted when FALSE (SI; LI used to hold NAN for expression)
*s INT rpCond // condition: if given, report lines omitted when FALSE (INT used to hold NAN for expression)
*r SI rpCondGiven // nz if user-given condition: may be reflected in title (when 0, rpCond is TRUE).
*r CULSTR rpTitle // title, for UDT, in dm
*r SI rpCpl // chars per line, inputtable for UDT's
Expand Down Expand Up @@ -1813,7 +1813,7 @@ RECORD IMPF "importFile" *RAT // IMPORTFILE input (Impfib) and run (ImpfiB) reco
//file
*declare "bool isOpen;" // true iff file is open and buffer has been allocated successfully
*declare "FILE* fh;" // file handle. Initial value, NULL, is not a valid file handle.
*r LI posEndHdr // file pointer after header, for repositioning file after warmup
*r INT posEndHdr // file pointer after header, for repositioning file after warmup
//buffer
*declare "char* buf;" // file buffer, in heap
*r USI bufSz // 0 or allocated size of buffer (actually 1 larger to hold \0)
Expand Down Expand Up @@ -1880,7 +1880,7 @@ RECORD AUSZ "autoSizing sub" *SUBSTRUCT // AUTOSIZING VARIABLES substructure for

//---runtime
// set at initialization
*r *e *hide FLOATP az_px // pointer to value being autosized, set at beginning of autosize phase.
*declare "FLOAT* az_px;" // pointer to value being autosized, set at beginning of autosize phase.
// CAUTION: storing pointer presumes record won't move during run.
// x is ASSUMED to be followed by:
// float x_As: receives x as autoSized, or user's x at end autoSize phase if not autoSized
Expand Down Expand Up @@ -2263,7 +2263,7 @@ RECORD ZNR "zone" *RAT // zone runtime info RAT. Set mainly from separate ZNI
*declare "int zn_AssessVentUtility();"
*declare "int zn_OAVAttempt( double tSup);"
*declare "int zn_FVentCR();"
*declare "RC zn_CondixCR( ULI ventAvail);"
*declare "RC zn_CondixCR( int ventAvail);"
*declare "RC zn_AirRequest( RSYS* rs, int options=0);"
*declare "RC zn_AirX( double amfX=0., double _tz=-99.f);"
*declare "double zn_HumRat( double amfX, double mwX, double _tz, double* pXLGain=nullptr);"
Expand Down Expand Up @@ -2717,19 +2717,19 @@ RECORD ZNRES_IVL_SUB "zone interval results sub" *SUBSTRUCT // zone interval res

INT n // accumulate call count (to convert sums to averages)
// code assumes this is 1st member
//ints. code in cnguts.h and cnguts.cpp:cgaccum assumes SI members are together, start with nHrHeat, end with nHrCeilFan.
// 6-92 there is now no code to set these hourly+ SI members... eventually use or delete; work out sh-->hr accumulation.
// SIs. code in cnguts.h and cnguts.cpp:cgaccum assumes SI members are together, start with nHrHeat, end with nHrCeilFan.
// 6-92 there is now no code to set these hourly+ SI members... eventually use or delete; work out sh-->hr accumulation.
SI nHrHeat // # of hours in which any heating occurred; 1st "# of hours"
SI nHrCool // ditto cooling
SI nHrFanv // ditto fan vent
SI nHrNatv // ditto natural vent
SI nHrCeilFan // ditto ceiling fan operation; last "# of hours"
//LIs. code in cnguts.h and .cpp assumes LI members together, first is nIter, last is nSubhrLX.
LI nIter // # of iterations
LI nShVentH // # of substeps int this interval when ventilation caused heating
// INTs (32-bit) code in cnguts.h and .cpp assumes INT members together, first is nIter, last is nSubhrLX.
INT nIter // # of iterations
INT nShVentH // # of substeps int this interval when ventilation caused heating
// (initial implementation for OAV only, 10-13)
LI nSubhr // subhour counter (convenience)
LI nSubhrLX // # subhours with condensation (excess latent gain)
INT nSubhr // subhour counter (convenience)
INT nSubhrLX // # subhours with condensation (excess latent gain)
//floats. code in cnguts.h and cnguts.cpp:cgaccum assumes float members together, including subgroups to average and to sum.
//floats to average
float tAir // zone air temp; must be 1st float, is first float to average (see cnguts.h)
Expand Down Expand Up @@ -2798,7 +2798,7 @@ RECORD ZNRES_SUB "zone results sub" *SUBSTRUCT
RECORD ZNRES "znRes" *RAT // holds zones and all-zones simulation results (later at subscript # zones + 1)
// .name (base class): same as corresponding zone, or sum_of_zones.
*declare "ZNR* zr_GetZone() const;"
*declare "LI zr_GetRunTotalLI( int fn) const;"
*declare "int zr_GetAllIntervalTotal( int fn) const;"
*declare "void zr_InitPrior();"
*declare "void zr_InitCurr();"

Expand Down Expand Up @@ -3805,7 +3805,7 @@ x *declare "RC rs_SetDefaultsClg();"
*s *e DBL rs_outSenTot // average total sensible heat delivery rate for last subhr, Btuh
// = rs_outSen + rs_outFan + rs_outDefrost + rs_outAux

*y *e *array 2 LI rs_calcCount; // # calls to rs_SupplyAirState, re optimizing rs_FindRequiredSpeedF()
*y *e *array 2 INT rs_calcCount; // # calls to rs_SupplyAirState, re optimizing rs_FindRequiredSpeedF()
// [ 0] = heating, [1] = cooling

*s *e DBL rs_inPrimary // primary input, Btuh (compressor, burner, )
Expand Down Expand Up @@ -5768,11 +5768,9 @@ RECORD COOLCOIL "coolCoil sub" *SUBSTRUCT *BASECLASS COIL /* COOLing COIL SUBREC
//*s *e FLOAT eir COIL member above: current (dx,elec) energy input ratio: eir = p / q
//*s *e POWER qPr COIL member; currently 10-92 not used for coolcoil
//*s *e TEMP tsPr plant supply temp at which coil last computed, for compute-flagging coil: COIL member
#if 1 // 10-96
*s *e ENERGY xLGain // condensation heat added to air (const enthalpy) to fix supersaturated wen, this subhr.
*s *e ENERGY xLGainYr // .. cumulative over run, for message at end run.
*s *e LI nSubhrsLX // number of subhours in which supersaturated entering air fixed
#endif
*s *e INT nSubhrsLX // number of subhours in which supersaturated entering air fixed
//flags for messages at end autoSize (or run, future?)
*s *e BOO minTLtd // output limited by minTEvap b4 reaching ahTsMn (DX, 7-95)
*s *e BOO cfm2Few // too little flow to permit sizing coil to meet load at min temp (DX, 7-95)
Expand Down Expand Up @@ -6453,12 +6451,12 @@ RECORD AHRES_IVL_SUB "air handler interval results sub" *SUBSTRUCT // ah result
ENERGY pAuxH ENERGY pAuxC // heat and cool aux energy
ENERGY pFan // fans input energy
HOURS hrsOn // time air handler on: accumulated Top.tp_subhrDur
//long integer members to sum in accumulation. cnguts.h defines assume nSubhr is 1st, nIterFan is last.
LI nSubhr // subhour counter: for convenience / possibly making cluster-dependent
LI nIter1 // iteration counter 1: # times called, including immediate exits
LI nIter2 // iteration counter 2: # times executed
LI nIter4 // iteration counter 4: # inner loops (calls to pute4Fs)
LI nIterFan // # fan adjustment iterations, counting both ups and downs
// int members to sum in accumulation. cnguts.h defines assume nSubhr is 1st, nIterFan is last.
INT nSubhr // subhour counter: for convenience / possibly making cluster-dependent
INT nIter1 // iteration counter 1: # times called, including immediate exits
INT nIter2 // iteration counter 2: # times executed
INT nIter4 // iteration counter 4: # inner loops (calls to pute4Fs)
INT nIterFan // # fan adjustment iterations, counting both ups and downs
*END // AHRES_IVL_SUB

//=============================================================================
Expand Down
6 changes: 3 additions & 3 deletions src/RCDEF/rcdef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ ULI Dttab[MAXDTH + MAXDTC + 1];
// Snake offset is used here for choice text, stored in sizeof(char *) 2-94 to match appl's struct
// re checking that data types don't collide.
// array: # of elements
int dttabsz = 0; // [next] slot in Dttab = next data type; is size of table (in LI's) at end.
int dttabsz = 0; // [next] slot in Dttab = next data type; is size of table (in ULI's) at end.
// non-sparse data type arrays: subscripts are dtnmi[datatype].
const char* dtnames[MAXDT]; // data type names, set w luadd(dtlut..)
static LUTAB dtlut(dtnames, MAXDT);
Expand Down Expand Up @@ -1204,7 +1204,7 @@ LOCAL void wDttab() // write C++ source data types table dttab.cpp

// write size of data types table (to provide same variables as recdef vsrn)
fprintf( f,
"\n\n// size of data types table (in LI's)\n"
"\n\n// size of data types table (in ULI's)\n"
"\nsize_t Dttmax = %d;\n", dttabsz );

// terminate file, close, update if different
Expand Down Expand Up @@ -1884,7 +1884,7 @@ LOCAL RC recs( // do records
if (nextRcType >= MAXRCS) // prevent exceeding tables
{
rcderr( "Record handle 0x%x is too big (max 0x%x).",
(UI)nextRcType, (UI)MAXRCS-1 );
nextRcType, MAXRCS-1 );
goto nexTokRec; // get token and reiterate record loop
}
rcseq = nextRcType++;
Expand Down
21 changes: 8 additions & 13 deletions src/ancrec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,7 @@ RC record::notGzEr(int fn) // issue error message for field not greater than 0.
//-----------------------------------------------------------------------------
RC record::AtMost( // check for interacting input
int setMax, // max # of fields that can be set in this group
int fn1, ...) // list of field #, 0 terminated, REMEMBER THE 0
int fn, ...) // list of field #, 0 terminated, REMEMBER THE 0

// returns RCOK iff # set args with group <= setMax
// else RCBAD (msg issued)
Expand All @@ -724,17 +724,17 @@ RC record::AtMost( // check for interacting input
std::vector< const char*> fnIdList;

va_list ap;
va_start(ap, setMax);
va_start(ap, fn);
int setCount = 0; // # of IsSet() fields
int fnCount; // # of fields
for (fnCount = 0; ; ++fnCount)
{
int fn = va_arg(ap, int);
if (!fn)
break;
if (IsSet(fn))
++setCount;
fnIdList.push_back(mbrIdTx(fn));
fn = va_arg(ap, int);
}

if (setCount > setMax)
Expand Down Expand Up @@ -958,14 +958,9 @@ RC FC basAnc::reAl( TI _n, int erOp/*=ABT*/) // allocate space for n (0=default
if (_n < 1)
_n = 1 + 1024/eSz; // if # records not specified, use 1k's worth plus 1
TI _nAl = _n+1; // space [0] not used (all 0's for grounding) --> max subscr+1 is n+1
size_t sz = (ULI)(USI)_nAl * eSz; // size that must be allocated
#if 0 // remove 64k limit, 9-10
x if (sz >= 0xFFF0) // leave a few bytes for overhead.
x return err( erOp, "Attempt to allocate more than 64K worth of '%s' records",
x (char /*far!*/ *)what ); // returns RCBAD
#endif
desRecs(_nAl, 32767); // insurance: destroy any excess existing records if making block smaller
record* ptrWas = ptr(); // NULL if this is initial allocation
size_t sz = _nAl * eSz; // size that must be allocated
desRecs(_nAl, 32767); // insurance: destroy any excess existing records if making block smaller
record* ptrWas = ptr(); // NULL if this is initial allocation
RC rc = dmral( pptr(), sz, erOp|DMZERO); // (re)alloc memory, zero new space, dmpak.cpp
if (rc) // if failed
; // leave variables unchanged
Expand Down Expand Up @@ -1025,7 +1020,7 @@ RC basAnc::add( // construct record i (0 = next). Allocs if nec.
if ( i >= nAl // if (more) record spaces must be allocated (nAl is +1; i,n are not)
|| !ptr() ) // insurance
{
ULI sz = (ULI)nAl*eSz + 1024; // new size in bytes to add 1 + 1K's worth of record spaces (nAl is +1)
UINT sz = (UINT)nAl*eSz + 1024; // new size in bytes to add 1 + 1K's worth of record spaces (nAl is +1)
TI _n = max( (USI)(sz/eSz), (USI)i); // add 1 + 1K's worth of spaces, or to req'd rec # if more.
if (reAl(_n, erOp))
return RCBAD; // (re)alloc rec spaces 1.._n, init nAl, ptr(), space[0], etc. above.
Expand Down Expand Up @@ -1099,7 +1094,7 @@ BP FC basAnc::anc4n( USI an, int erOp/*=ABT*/) // access anc for anchor number
{
if (an < 1 || an > Nanc || !ancs || ancs[an]==0)
{
err( erOp, (char *)MH_X0053, (INT)an); // "anc4n: bad or unassigned record anchor number %d"
err( erOp, (char *)MH_X0053, an); // "anc4n: bad or unassigned record anchor number %d"
return 0;
}
return ancs[an];
Expand Down
2 changes: 1 addition & 1 deletion src/ancrec.h
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ class record // base class for records
void CDEC chafSelf( SI chafFn, ...);
void CDEC chafN( BP _b, TI i, USI off, ...);
void chafNV( BP _b, TI i, USI off, va_list ap);
RC AtMost(int setMax, int fn1, ...);
RC AtMost(int setMax, int fn, ...);
RC CheckArray(int fn, int nSetExpected);

RC limitCheck( int fn, double vMin, double vMax,
Expand Down
Loading