Skip to content

Commit 4bbe1bd

Browse files
authored
Merge pull request #462 from cse-sim/setpoint-error-check
Setpoint error check
2 parents ec95afb + 3688671 commit 4bbe1bd

30 files changed

+638
-724
lines changed

doc/src/records/terminal.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ Air heating thermostat set point; implies *set temperature* air capability. May
130130

131131
**tuTC=*float***
132132

133-
Air cooling thermostat set point; implies *set temperature*air capability. May be scheduled as desired; to disable at certain times, schedule an extreme temperature such as 199.
133+
Air cooling thermostat set point; implies *set temperature* air capability. May be scheduled as desired; to disable at certain times, schedule an extreme temperature such as 199.
134134

135135
<%= member_table(
136136
units: "^o^F",

doc/src/records/zone.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -169,41 +169,41 @@ Zone shade closure. Determines insolation through windows (see WINDOW members *w
169169

170170
**znTH=*float***
171171

172-
Heating set point for znModel=CZM.
172+
Heating set point used (and required) when znModel=CZM and zone has no terminals.
173173

174174
<%= member_table(
175175
units: "^o^F",
176-
legal_range: "x $\\geq$ 0",
176+
legal_range: "0 < znTH < znTC",
177177
default: "*none*",
178-
required: "No",
178+
required: "Per above",
179179
variability: "subhourly")
180180
%>
181181

182182
**znTD=*float***
183183

184-
Desired set point (temperature maintained with ventilation if possible) for znModel=CZM
184+
Desired set point (temperature maintained with ventilation if possible) for znModel=CZM. Must be specified when zone ventilation is active.
185185

186186
<%= member_table(
187187
units: "^o^F",
188-
legal_range: "x $\\geq$ 0",
188+
legal_range: "x > 0; znTH < znTD < znTC",
189189
default: "*none*",
190-
required: "No",
190+
required: "if venting",
191191
variability: "subhourly")
192192
%>
193193

194194
**znTC=*float***
195195

196-
Cooling set point for znModel=CZM.
196+
Cooling set point used (and required) when znModel=CZM and zone has no terminals.
197197

198198
<%= member_table(
199199
units: "^o^F",
200-
legal_range: "x $\\geq$ 0",
200+
legal_range: "0 < znTC > znTH",
201201
default: "*none*",
202-
required: "No",
202+
required: "Per above",
203203
variability: "subhourly")
204204
%>
205205

206-
CZM zone heating and cooling is provided either via an RSYS HVAC system or by "magic" heat transfers specified by znQxxx items.
206+
znModel = CZM zone heating and cooling is provided either via an RSYS HVAC system, by "magic" heat transfers specified by znQxxx items, or via TERMINAL (s). One of these must be defined.
207207

208208
**znRSys=*rsysName***
209209

@@ -270,7 +270,7 @@ The following provide parameters for comfort calculations
270270

271271
**znComfClo=*float***
272272

273-
Occupant clothing resistance
273+
Occupant clothing resistance, used only when a comfort model is enabled.
274274

275275
<%= member_table(
276276
units: "clo",
@@ -282,7 +282,7 @@ Occupant clothing resistance
282282

283283
**znComfMet=*float***
284284

285-
Occupant metabolic rate
285+
Occupant metabolic rate, used only when a comfort model is enabled.
286286

287287
<%= member_table(
288288
units: "met",
@@ -294,7 +294,7 @@ Occupant metabolic rate
294294

295295
**znComfAirV=*float***
296296

297-
Nominal air velocity used for comfort model
297+
Nominal air velocity used for comfort model, used only when a comfort model is enabled.
298298

299299
<%= member_table(
300300
units: "",
@@ -306,7 +306,7 @@ Nominal air velocity used for comfort model
306306

307307
**znComfRh=*float***
308308

309-
Nominal zone relative humidity used for comfort model
309+
Nominal zone relative humidity used for comfort model, used only when a comfort model is enabled.
310310

311311
<%= member_table(
312312
units: "",

src/CNRECS.DEF

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -271,9 +271,9 @@ RECORD TOPRAT "top" *RAT /* top level RAT: contains control info and all once-on
271271
*i SI tp_terrainClass // terrain class (1-5) re wind speed adjustment
272272
*i FLOAT_GEZ radBeamF // Beam radiation fctr. appl sees ANISO( <fileVal>) * radBeamF. cgwthr.cpp.
273273
*i FLOAT_GEZ radDiffF // Diffuse radiation fctr. appl sees ANISO( <fileVal>) * radDiffF.
274-
*h VENTAVAILVC tp_ventAvail // all-zone ventilation availability (default=C_VENTAVAILCH_WHOLEHOUSE)
274+
*h VENTAVAILVC tp_ventAvail // all-zone ventilation availability (default=C_VENTAVAILCH_WHOLEBLDG)
275275
// C_VENTAVAILCH_NONE: none
276-
// C_VENTAVAILCH_WHOLEHOUSE: airnet windows / fans
276+
// C_VENTAVAILCH_WHOLEBLDG: airnet windows / fans
277277
// C_VENTAVAILCH_ZONAL: airnet windows / fans (controlled by zone)
278278
// C_VENTAVAILCH_RSYSOAV: RSYS outside air vent (central mechanical)
279279
*declare "int tp_GetVentAvail() const { return CHN( tp_ventAvail); }"
@@ -1322,7 +1322,6 @@ RECORD SFI "surface" *RAT // opaque surface / door / window input info RAT
13221322
*excon // explicit constructor
13231323
*exdes // explicit d'tor
13241324
*ovrcopy
1325-
*declare "virtual SFI& CopyFrom( const record* src, int copyName=1, int dupPtrs=0);"
13261325
*declare "RC sf_TopSf1();"
13271326
*declare "RC sf_CkfSURF( int options);"
13281327
*declare "RC sf_CkfSURFGround( int options);"
@@ -1742,7 +1741,6 @@ RECORD COL "reportCol" *RAT // holds info for columns in user-defined table repo
17421741
*excon
17431742
*exdes
17441743
*ovrcopy
1745-
*declare "virtual record& CopyFrom( const record *src, int copyName=1, int dupPtrs=0);"
17461744
*declare "virtual RC Validate( int options=0);"
17471745

17481746
//input .ownTi is RI subscript of owning report/export. Column order is order of input.
@@ -2114,8 +2112,8 @@ RECORD ZNISUB "zone sub" *SUBSTRUCT
21142112
// zone input info substruct, used in ZNR and ZNI
21152113
*declare "bool IsCountable( int options) const { return options==0 || options==znModel; }"
21162114
*declare "float zn_HeightZ( float f) const;"
2117-
*declare "int zn_IsConvRad() const { return znModel >= C_ZNMODELCH_CZM; }"
2118-
*declare "int zn_IsUZ() const { return znModel >= C_ZNMODELCH_UZM; }"
2115+
*declare "bool zn_IsConvRad() const { return znModel >= C_ZNMODELCH_CZM; }"
2116+
*declare "bool zn_IsUZ() const { return znModel >= C_ZNMODELCH_UZM; }"
21192117

21202118
// ZNISUB general user inputs
21212119
*i ZNMODELCH znModel // zone model (CNE, CSE, CZM, UZM, UZX)
@@ -2246,6 +2244,8 @@ RECORD ZNR "zone" *RAT // zone runtime info RAT. Set mainly from separate ZNI
22462244
*declare "bool zn_HasAirTerminal() const { return zn_airTerminalCount > 0; }"
22472245
*declare "bool zn_HasRSYS() const { return i.zn_rsi != 0; }"
22482246
*declare "bool zn_HasAirHVAC() const { return zn_HasRSYS() || zn_HasAirTerminal(); }"
2247+
*declare "bool zn_HasMagicHVAC() const { return IsSet( ZNI_I + ZNISUB_ZNQMXH) || IsSet( ZNI_I + ZNISUB_ZNQMXC); }"
2248+
*declare "bool zn_UsesZoneSetpoints() const { return i.znModel == C_ZNMODELCH_CZM && !zn_HasTerminal(); }"
22492249
*declare "RSYS* zn_GetRSYS();"
22502250
*declare "const RSYS* zn_GetRSYS() const;"
22512251
*declare "int zn_IsHCAvail( int what) const;"
@@ -2294,7 +2294,7 @@ RECORD ZNR "zone" *RAT // zone runtime info RAT. Set mainly from separate ZNI
22942294
*declare "BOO nxZhxSt( ZHX *&x);"
22952295
*declare "bool IsCountable( int options) const { return i.IsCountable( options); }"
22962296
*declare "int zn_IsConvRad() const { return i.zn_IsConvRad(); }"
2297-
*declare "int zn_IsUZ() const { return i.zn_IsUZ(); }"
2297+
*declare "bool zn_IsUZ() const { return i.zn_IsUZ(); }"
22982298
*declare "int zn_IsSFModelSupported( int sfModel) const;"
22992299
*declare "void zn_SGClearTots();"
23002300
*declare "void zn_SGCavAbs();"
@@ -4132,7 +4132,6 @@ RECORD DHWSYS "DHWSYS" *RAT // input / runtime DHW system
41324132
*prefix ws_
41334133
*exdes
41344134
*ovrcopy
4135-
*declare "virtual DHWSYS& CopyFrom( const record* src, int copyName=1, int dupPtrs=0);"
41364135
*declare "RC ws_CkF();"
41374136
*declare "RC ws_CheckVals( int erOp);"
41384137
*declare "RC ws_CheckSubObject( record* r);"
@@ -4554,7 +4553,6 @@ RECORD DHWHEATER "DHWHeater" *RAT // input / runtime DHW heater
45544553
*excon // explicit constructor
45554554
*exdes // explicit ~DHWHEATER()
45564555
*ovrcopy // overide Copy()
4557-
*declare "virtual DHWHEATER& CopyFrom( const record* pSrc, int copyName=1, int dupPtrs=0);"
45584556

45594557
*declare "RC wh_CkF();"
45604558
*declare "virtual RC RunDup( const record* pSrc, int options=0);"
@@ -5170,7 +5168,6 @@ RECORD DHWSOLARSYS "DHWSolarSys" *RAT // input / runtime DHW solar system
51705168
*prefix sw_
51715169
*exdes
51725170
*ovrcopy // overide Copy()
5173-
*declare "virtual DHWSOLARSYS& CopyFrom( const record *src, int copyName=1, int dupPtrs=0);"
51745171
*declare "virtual void ReceiveRuntimeMessage(const char* msg);"
51755172
*declare "RC sw_CkF();"
51765173
*declare "RC sw_Init();"
@@ -5361,7 +5358,6 @@ RECORD PVARRAY "PVArray" *RAT // input / runtime photovoltaics array
53615358
*prefix pv_
53625359
*excon
53635360
*ovrcopy
5364-
*declare "virtual PVARRAY& CopyFrom( const record* src, int copyName=1, int dupPtrs=0);"
53655361
*declare "void FixUp();" // virtual fixup after basAnc reAl
53665362
*declare "RC Validate( int options=0);"
53675363
*declare "RC pv_CkF();"

src/ancrec.cpp

Lines changed: 36 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
#include "cnglob.h"
3030
#include "ancrec.h"
3131
#include "cse.h"
32-
#include "msghans.h" // MH_X0050
32+
#include "msghans.h"
3333
#include "messages.h" // msgIsHan
3434
#include "exman.h"
3535
#include "cvpak.h"
@@ -124,83 +124,45 @@ int record::IsNameMatch( const char* _name) const
124124
return !_stricmp( _name, Name());
125125
} // record::IsNameMatch
126126
//-----------------------------------------------------------------------------
127-
/*virtual*/ record& record::CopyFrom(
128-
const record* src,
129-
int copyName/*=1*/,
130-
[[maybe_unused]] int dupPtrs/*=0*/)
131-
132-
// copy user and ul data from another record or init data to already-constructed record
133-
134-
// copies user language overhead, and ownTi, and, unless suppressed, name.
135-
// Does not copy ancrec internal overhead except 'gud'
136-
137-
/* "dupPtrs" is for poss future use duplicating heap pointers in derived classes
138-
(in present uses (input to run rat copies) ptrs are not currenly being dup'd 2-92)
139-
(7-92: converting to dup'd ptrs with explicit derived class CopyFrom's and destructors.
140-
"dupPtrs" would shorten code; table bit or different field ty needed to say which ptrs to dup (some CHP's don't get dup'd). */
141-
{
142-
// error if not init (can't constr here: need b, ss). (if needed, do a "copyTo" or a "copy(b,i1,i2)" that constructs dest.)
143-
if (!b) // (or gud? wd error here if init then destroyed)
144-
err( PABT, (char *)MH_X0050); // error msg "record::CopyFrom: unconstructed destination (b is 0)" and abort program.
145-
#ifdef DEBUG2 // message not occuring (1-95) so omit from release version.
146-
b->validate("record::CopyFrom"); // abort if record 'this' not associated with valid anchor
147-
((record *)src)->Validate();
148-
#endif
149-
150-
// use shorter record length
151-
int eSz = b->eSz; // get dest derived class rec length from anchor
152-
if ( src->b && src->b->rt==src->rt // if source has anchor (could be just init data)
153-
&& eSz != src->b->eSz ) // and source record length is different
154-
eSz = min( b->sOff, src->b->sOff); // use the shorter length and do not copy status bytes (3-12-92).
155-
// calls exist (ZNI->ZNR) where source is start of dest record (ug!)
156-
// add logic to copy status bytes to correct place if need found
157-
158-
// copy data after front (bitwise)
159-
// copy start offset: do not copy base class except ownTi and optionally name
160-
int offBeg = offsetof(record, ownTi);
161-
memcpy( (char *)this + offBeg, (char *)src + offBeg, eSz - offBeg );
162-
163-
if (copyName)
164-
name.Set(src->name);
165-
166-
// copy user language front members. another arg option?
167-
li = src->li; // if nz, is subscript of entry it is LIKE
168-
ty = src->ty; // if nz, may be TYPE subscript (future)
169-
fileIx = src->fileIx; // if nz, is index of object input fileName
170-
line = src->line; // if nz, is object input file line
171-
172-
// copy internal good-record flag with possible future user bits
173-
gud = src->gud; // 0 = free, > 0 = in use, sign bit = bad (poss future use).
174-
175-
FixUp(); // virtual: record can e.g. fix ptrs
176-
#if defined( _DEBUG)
177-
Validate(); // virtual
178-
#endif
179-
return *this;
180-
} // record::CopyFrom
181-
//---------------------------------------------------------------------------------------------------------------------------
182127
/*virtual*/ void record::Copy( // copy user and ul data and 'gud' from another record of same type
183-
const record* pSrc,
184-
int options/*=0*/)
128+
const record* pSrc, // source record
129+
int options/*=0*/) // rcoLEAVENAME: do NOT copy name
185130
{
186-
options;
187-
188-
// this implementation requires records already constructed (can't construct here without knowning b, ss).
189-
if (!b) // (or gud? wd error here if init then destroyed)
190-
err( PABT, (char *)MH_X0051); // err msg "record::operator=(): unconstructed destination (b is 0)" and abort program
191-
if (b->rt != pSrc->b->rt) // check for same rt (same derived class)
192-
err( PABT, (char *)MH_X0052); // err msg "record::operator=(): records not same type" and abort program
193-
b->validate("left arg to record::operator="); // abort if records not well anchored
194-
#ifdef DEBUG2
195-
pSrc->b->validate("right arg to record::operator=");
131+
// records must already be constructed (can't construct here without knowning b, ss).
132+
if (!b || !pSrc) // (or gud? wd error here if init then destroyed)
133+
err( PABT, (char *)MH_X0051); // err msg "record::Copy(): unconstructed destination or !pSrc"
134+
#if defined( _DEBUG)
135+
b->validate("Copy() dest"); // abort if records not well anchored
136+
pSrc->b->validate("Copy() src");
196137
#endif
197-
name.Release(); // memcpy will overwrite with pSrc.name
198-
// copy start offset: don't copy internal members
138+
139+
// bitwise copy members preceding name (not including internal members)
199140
int offBeg = offsetof(record, gud);
200-
memcpy((char *)this + offBeg, (char *)pSrc + offBeg, b->eSz - offBeg);
201-
name.FixAfterCopy();
141+
int offEnd = offsetof(record, name);
142+
memcpy((char*)this + offBeg, (const char*)pSrc + offBeg, offEnd - offBeg);
143+
144+
// conditionally copy name
145+
if (!(options & rcoLEAVENAME))
146+
name = pSrc->name;
147+
148+
// bitwisecopy remainder (ownTi, record data, and status array)
149+
offBeg = offsetof(record, ownTi);
150+
if (b->rt == pSrc->b->rt)
151+
{ // same type: single memcpy()
152+
memcpy((char*)this + offBeg, (const char*)pSrc + offBeg, b->eSz - offBeg);
153+
}
154+
else
155+
{ // partial copy (e.g. ZNI->ZNR)
156+
if (pSrc->b->sOff > b->sOff)
157+
err(PABT, (char*)MH_X0052);
158+
else
159+
{ memcpy((char*)this + offBeg, (const char*)pSrc + offBeg, pSrc->b->sOff - offBeg);
160+
memcpy((char*)this + b->sOff, (const char*)pSrc + pSrc->b->sOff, pSrc->b->nFlds);
161+
}
162+
}
202163

203164
FixUp(); // virtual: record can e.g. fix ptrs
165+
204166
#if defined( _DEBUG)
205167
Validate(); // virtual
206168
#endif
@@ -349,7 +311,7 @@ o what );
349311
// else if it has file and line, optionally show them
350312
if (op)
351313
if (fileIx)
352-
return strtprintf("%s [%s(%d)]", what, getFileName( fileIx), line);
314+
return strtprintf("%s [%s(%d)]", what, getFileName( fileIx), inputLineNo);
353315

354316
// else just class name
355317
return what;
@@ -1047,7 +1009,7 @@ RC FC basAnc::del( TI i, int erOp/*=ABT*/) // delete (squeeze out) ith record
10471009
{
10481010
if (!dest.gud)
10491011
conRec(i); // construct destination if nec to insure vftp, rt, b, ss set.
1050-
dest.CopyFrom(&src); // copy record i+1 to i without dup'ing heap ptrs
1012+
dest.Copy( &src); // copy record i+1 to i without dup'ing heap ptrs
10511013
// tentatively no destroy: does nothing in base class, and deriv class might delete heap ptrs we did not dup.
10521014
#if defined( _DEBUG)
10531015
dest.Validate();

src/ancrec.h

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class basAnc // base class for record anchors: basAnc<recordName>
7070
SFIR* fir; // pointer to record type's "small fields-in-record table" (in srfd.cpp)
7171
USI nFlds; // number of fields excluding base-class members (front overhead)
7272
const char* what; // name of the record group (for probes, error messages)
73-
USI eSz; // record size
73+
USI eSz; // overall record size (including overhead and status byte array)
7474
USI sOff; // offset in record to "status byte" array at end
7575
USI ancN; // anchor number
7676
RCT rt; // record type (from rcdef.exe); now mainly for internal checks
@@ -138,19 +138,19 @@ const UCH FsFROZ= 128; // value cannot be changed (spec'd in type)
138138
//***************************************************************************************************************************
139139
class record // base class for records
140140
{ public:
141-
// overhead members set by constructor or ancrec.cpp. CAUTION check operator= if changed. CAUTION code assumes order of members.
142-
RCT rt; // record type (from rcdef.exe); now mainly for internal checks
143-
TI ss; // record subscript
144-
BP b; // pointer to record's anchor; 0 may indicate unconstructed record space.
141+
// overhead members set by constructor or ancrec.cpp. CAUTION Copy() if order changes; code assumes member order
142+
RCT rt; // record type (from rcdef.exe); now mainly for internal checks
143+
TI ss; // record subscript
144+
BP b; // pointer to record's anchor; 0 may indicate unconstructed record space.
145145
SI gud; // 0: free; > 0: good record; [<0, skip/retain]. bits 0x7ffe avail to appl.
146-
// overhead members for appl user language (ul). CAUTION check record::CopyFrom if these members changed.
146+
// overhead members for appl user language (ul). CAUTION check record::Copy if these members changed.
147147
TI ty, li; // 0 or user language TYPE and LIKE subscripts
148148
int fileIx; // 0 or source file name index: see ancrecs:getFileName and getFileIx. 2-94.
149-
int line; // 0 or 1-based file line # of object definition (for err msgs)
149+
int inputLineNo; // 0 or 1-based file line # of object definition (for err msgs)
150150
// base class user members
151151
// rcdef.exe generates table entries and defines for the following as for derived class members;
152-
// they are here for uniformity & access via base class ptrs. CHANGE from old ratpak 2-92: all records have name, ownTi:
153-
// CAUTION check record::CopyFrom if these members changed.
152+
// they are here for uniformity & access via base class ptrs.
153+
// CAUTION check record::Copy if these members changed.
154154
CULSTR name; // user-specified object name
155155
TI ownTi; // 0 or subscript of owning object in anchor b->ownB
156156

@@ -230,11 +230,10 @@ class record // base class for records
230230
{ return (fStat( fn)&FsAS) != 0; }
231231
template <typename T> inline bool IsSetNotAusz(T fn) const
232232
{ return (fStat(fn) & (FsSET | FsAS)) == FsSET; }
233-
// override following for records with specific copying req'ts eg heap pointers to dup (dupPtrs does nothing here in base).
234-
// CAUTION dest's (this) must be init.
235-
virtual record& CopyFrom( const record* src, int copyName=1, int dupPtrs=0); // copy user/ul data from another record or data
236-
record& Copy( const record& d) { Copy( &d); return *this; }
237233
record& operator=( const record& d) { Copy( &d); return *this; }
234+
// override following for records with non-memcpy()able members (e.g. CULSTRs, heap pointers)
235+
// CAUTION dest's (this) must be init.
236+
enum { rcoLEAVENAME=1 };
238237
virtual void Copy( const record* pSrc, int options=0);
239238
virtual bool IsCountable(int /*options*/) const { return true; }
240239
virtual void FixUp() { }; // optional fixup after reAl()

0 commit comments

Comments
 (0)