Line data Source code
1 : // EnergyPlus, Copyright (c) 1996-2023, The Board of Trustees of the University of Illinois,
2 : // The Regents of the University of California, through Lawrence Berkeley National Laboratory
3 : // (subject to receipt of any required approvals from the U.S. Dept. of Energy), Oak Ridge
4 : // National Laboratory, managed by UT-Battelle, Alliance for Sustainable Energy, LLC, and other
5 : // contributors. All rights reserved.
6 : //
7 : // NOTICE: This Software was developed under funding from the U.S. Department of Energy and the
8 : // U.S. Government consequently retains certain rights. As such, the U.S. Government has been
9 : // granted for itself and others acting on its behalf a paid-up, nonexclusive, irrevocable,
10 : // worldwide license in the Software to reproduce, distribute copies to the public, prepare
11 : // derivative works, and perform publicly and display publicly, and to permit others to do so.
12 : //
13 : // Redistribution and use in source and binary forms, with or without modification, are permitted
14 : // provided that the following conditions are met:
15 : //
16 : // (1) Redistributions of source code must retain the above copyright notice, this list of
17 : // conditions and the following disclaimer.
18 : //
19 : // (2) Redistributions in binary form must reproduce the above copyright notice, this list of
20 : // conditions and the following disclaimer in the documentation and/or other materials
21 : // provided with the distribution.
22 : //
23 : // (3) Neither the name of the University of California, Lawrence Berkeley National Laboratory,
24 : // the University of Illinois, U.S. Dept. of Energy nor the names of its contributors may be
25 : // used to endorse or promote products derived from this software without specific prior
26 : // written permission.
27 : //
28 : // (4) Use of EnergyPlus(TM) Name. If Licensee (i) distributes the software in stand-alone form
29 : // without changes from the version obtained under this License, or (ii) Licensee makes a
30 : // reference solely to the software portion of its product, Licensee must refer to the
31 : // software as "EnergyPlus version X" software, where "X" is the version number Licensee
32 : // obtained under this License and may not use a different name for the software. Except as
33 : // specifically required in this Section (4), Licensee shall not use in a company name, a
34 : // product name, in advertising, publicity, or other promotional activities any name, trade
35 : // name, trademark, logo, or other designation of "EnergyPlus", "E+", "e+" or confusingly
36 : // similar designation, without the U.S. Department of Energy's prior written consent.
37 : //
38 : // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
39 : // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
40 : // AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
41 : // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
42 : // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
43 : // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
44 : // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
45 : // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
46 : // POSSIBILITY OF SUCH DAMAGE.
47 :
48 : #ifndef DataRuntimeLanguage_hh_INCLUDED
49 : #define DataRuntimeLanguage_hh_INCLUDED
50 :
51 : // C++ Headers
52 : #include <functional>
53 : #include <unordered_set>
54 : #include <utility>
55 :
56 : // ObjexxFCL Headers
57 : #include <ObjexxFCL/Array1D.hh>
58 : #include <ObjexxFCL/Array2D.hh>
59 : #include <ObjexxFCL/Reference.hh>
60 :
61 : // EnergyPlus Headers
62 : #include <EnergyPlus/Data/BaseData.hh>
63 : #include <EnergyPlus/DataGlobals.hh>
64 : #include <EnergyPlus/EMSManager.hh>
65 : #include <EnergyPlus/EnergyPlus.hh>
66 :
67 : namespace EnergyPlus {
68 :
69 : // Data only module for EMS runtime language
70 :
71 : namespace DataRuntimeLanguage {
72 :
73 : // Data module should be available to other modules and routines.
74 : // Thus, all variables in this module must be PUBLIC.
75 :
76 : enum class ErlKeywordParam // keyword parameters for types of Erl statements
77 : {
78 : Invalid = -1,
79 : None, // statement type not set
80 : Return, // Return statement, as in leave program
81 : Goto, // Goto statement, used in parsing to manage IF-ElseIf-Else-EndIf and nesting
82 : Set, // Set statement, as in assign RHS to LHS
83 : Run, // Run statement, used to call a subroutine from a main program
84 : If, // If statement, begins an IF-ElseIf-Else-EndIf logic block
85 : ElseIf, // ElseIf statement, begins an ElseIf block
86 : Else, // Else statement, begins an Else block
87 : EndIf, // EndIf statement, terminates an IF-ElseIf-Else-EndIf logic block
88 : While, // While statement, begins a While block
89 : EndWhile, // EndWhile statement, terminates a While block
90 : Num
91 : };
92 :
93 : enum class Value
94 : {
95 : Invalid = -1,
96 : Null, // Erl entity type, "Null" value
97 : Number, // Erl entity type, hard numeric value
98 : String, // Erl entity type, character data
99 : Array, // Erl entity type, not used yet, for future array type
100 : Variable, // Erl entity type, Erl variable
101 : Expression, // Erl entity type, Erl expression
102 : Trend, // Erl entity type, Erl trend variable
103 : Error, // Erl entity type, processing of an expression failed, returned error
104 : Num
105 : };
106 :
107 : enum class PtrDataType
108 : {
109 : Invalid = -1,
110 : Real, // data type for overloaded pointer management, double real
111 : Integer, // data type for overloaded pointer management, integer
112 : Logical, // data type for overloaded pointer management, logical
113 : Num
114 : };
115 :
116 : // Parameters for identifying operator types in Erl
117 : // The number of these parameters indicates the order of precedence
118 : enum class ErlFunc
119 : {
120 : Invalid = -1,
121 : Null,
122 : Literal, // Just stores a literal value
123 : Negative, // - (unary) No LHS?
124 : Divide, // /
125 : Multiply, // *
126 : Subtract, // - (binary)
127 : Add, // + (binary)
128 : Equal, // ==
129 : NotEqual, // <>
130 : LessOrEqual, // <=
131 : GreaterOrEqual, // >=
132 : LessThan, // <
133 : GreaterThan, // >
134 : RaiseToPower, // ^
135 : LogicalAND, // &&
136 : LogicalOR, // ||
137 : // note there is an important check "> 15" to distinguish operators from functions
138 : // so be careful if renumber these parameters. Binary operator additions should get inserted here rather than appended
139 :
140 : // parameters for built-in Erl functions, these are processed like operators and numbering
141 : // must be sequential with the operators.
142 : // math functions
143 : Round, // accessor for Fortran's DNINT()
144 : Mod, // accessor for Fortran's MOD()
145 : Sin, // accessor for Fortran's SIN()
146 : Cos, // accessor for Fortran's COS()
147 : ArcSin, // accessor for Fortran's ASIN()
148 : ArcCos, // accessor for Fortran's ACOS()
149 : DegToRad, // Multiplies degrees by DegToRad
150 : RadToDeg, // Divides radians by DegToRad
151 : Exp, // accessor for Fortran's EXP()
152 : Ln, // accessor for Fortran's LOG()
153 : Max, // accessor for Fortran's MAX()
154 : Min, // accessor for Fortran's MIN()
155 : ABS, // accessor for Fortran's ABS()
156 : RandU, // accessor for Fortran's Random_Number() intrinsic, uniform distribution
157 : RandG, // accessor for Gaussian/normal distribution random number
158 : RandSeed, // accessor for Fortran's Random_Seed() intrinsic
159 :
160 : // begin psychrometric routines
161 : RhoAirFnPbTdbW, // accessor for E+ psych routine
162 : CpAirFnW, // accessor for E+ psych routine
163 : HfgAirFnWTdb, // accessor for E+ psych routine
164 : HgAirFnWTdb, // accessor for E+ psych routine
165 : TdpFnTdbTwbPb, // accessor for E+ psych routine
166 : TdpFnWPb, // accessor for E+ psych routine
167 : HFnTdbW, // accessor for E+ psych routine
168 : HFnTdbRhPb, // accessor for E+ psych routine
169 : TdbFnHW, // accessor for E+ psych routine
170 : RhovFnTdbRh, // accessor for E+ psych routine
171 : RhovFnTdbRhLBnd0C, // accessor for E+ psych routine
172 : RhovFnTdbWPb, // accessor for E+ psych routine
173 : RhFnTdbRhov, // accessor for E+ psych routine
174 : RhFnTdbRhovLBnd0C, // accessor for E+ psych routine
175 : RhFnTdbWPb, // accessor for E+ psych routine
176 : TwbFnTdbWPb, // accessor for E+ psych routine
177 : VFnTdbWPb, // accessor for E+ psych routine
178 : WFnTdpPb, // accessor for E+ psych routine
179 : WFnTdbH, // accessor for E+ psych routine
180 : WFnTdbTwbPb, // accessor for E+ psych routine
181 : WFnTdbRhPb, // accessor for E+ psych routine
182 : PsatFnTemp, // accessor for E+ psych routine
183 : TsatFnHPb, // accessor for E+ psych routine
184 : TsatFnPb, // not public in PsychRoutines.cc so not really available in EMS.
185 : CpCW, // accessor for E+ psych routine
186 : CpHW, // accessor for E+ psych routine
187 : RhoH2O, // accessor for E+ psych routine
188 :
189 : // Simulation Management Functions
190 : FatalHaltEp, // accessor for E+ error management, "Fatal" level
191 : SevereWarnEp, // accessor for E+ error management, "Severe" level
192 : WarnEp, // accessor for E+ error management, "Warning" level
193 :
194 : // Trend variable handling Functions
195 : TrendValue, // accessor for Erl Trend variables, instance value
196 : TrendAverage, // accessor for Erl Trend variables, average value
197 : TrendMax, // accessor for Erl Trend variables, max value
198 : TrendMin, // accessor for Erl Trend variables, min value
199 : TrendDirection, // accessor for Erl Trend variables, slope value
200 : TrendSum, // accessor for Erl Trend variables, sum value
201 :
202 : // Curve and Table access function
203 : CurveValue,
204 :
205 : // Weather data query functions
206 : TodayIsRain, // Access TodayIsRain(hour, timestep)
207 : TodayIsSnow, // Access TodayIsSnow(hour, timestep)
208 : TodayOutDryBulbTemp, // Access TodayOutDryBulbTemp(hour, timestep)
209 : TodayOutDewPointTemp, // Access TodayOutDewPointTemp(hour, timestep)
210 : TodayOutBaroPress, // Access TodayOutBaroPress(hour, timestep)
211 : TodayOutRelHum, // Access TodayOutRelHum(hour, timestep)
212 : TodayWindSpeed, // Access TodayWindSpeed(hour, timestep)
213 : TodayWindDir, // Access TodayWindDir(hour, timestep)
214 : TodaySkyTemp, // Access TodaySkyTemp(hour, timestep)
215 : TodayHorizIRSky, // Access TodayHorizIRSky(hour, timestep)
216 : TodayBeamSolarRad, // Access TodayBeamSolarRad(hour, timestep)
217 : TodayDifSolarRad, // Access TodayDifSolarRad(hour, timestep)
218 : TodayAlbedo, // Access TodayAlbedo(hour, timestep)
219 : TodayLiquidPrecip, // Access TodayLiquidPrecip(hour, timestep)
220 : TomorrowIsRain, // Access TomorrowIsRain(hour, timestep)
221 : TomorrowIsSnow, // Access TomorrowIsSnow(hour, timestep)
222 : TomorrowOutDryBulbTemp, // Access TomorrowOutDryBulbTemp(hour, timestep)
223 : TomorrowOutDewPointTemp, // Access TomorrowOutDewPointTemp(hour, timestep)
224 : TomorrowOutBaroPress, // Access TomorrowOutBaroPress(hour, timestep)
225 : TomorrowOutRelHum, // Access TomorrowOutRelHum(hour, timestep)
226 : TomorrowWindSpeed, // Access TomorrowWindSpeed(hour, timestep)
227 : TomorrowWindDir, // Access TomorrowWindDir(hour, timestep)
228 : TomorrowSkyTemp, // Access TomorrowSkyTemp(hour, timestep)
229 : TomorrowHorizIRSky, // Access TomorrowHorizIRSky(hour, timestep)
230 : TomorrowBeamSolarRad, // Access TomorrowBeamSolarRad(hour, timestep)
231 : TomorrowDifSolarRad, // Access TomorrowDifSolarRad(hour, timestep)
232 : TomorrowAlbedo, // Access TomorrowAlbedo(hour, timestep)
233 : TomorrowLiquidPrecip, // Access TomorrowLiquidPrecip(hour, timestep)
234 : Num
235 : };
236 :
237 : int constexpr NumPossibleOperators(96); // total number of operators and built-in functions
238 :
239 : int constexpr MaxWhileLoopIterations(1000000); // protect from infinite loop in WHILE loops
240 :
241 : // Types
242 :
243 3654 : struct OutputVarSensorType
244 : {
245 : // Members
246 : std::string Name; // name of associated Erl Variable
247 : std::string UniqueKeyName; // unique key name associated with output variable
248 : std::string OutputVarName; // name of output variable
249 : bool CheckedOkay; // set to true once checked out okay
250 : OutputProcessor::VariableType VariableType;
251 : int Index; // ref index in output processor, points to variable
252 : int VariableNum; // ref to global variable in runtime language
253 : int SchedNum; // ref index ptr to schedule service (filled if Schedule Value)
254 : // INTEGER :: VarType = 0
255 :
256 : // Default Constructor
257 50 : OutputVarSensorType() : CheckedOkay(false), VariableType(OutputProcessor::VariableType::NotFound), Index(0), VariableNum(0), SchedNum(0)
258 : {
259 50 : }
260 : };
261 :
262 1892504 : struct InternalVarsAvailableType
263 : {
264 : // Members
265 : // structure for internal data available for use in Erl that are not sourced by output variables
266 : std::string DataTypeName; // general internal variable name registered, All uppercase
267 : std::string UniqueIDName; // unique id for internal var, All uppercase
268 : std::string Units; // registered units, used for reporting and checks.
269 : PtrDataType PntrVarTypeUsed; // data type used: integer (PntrInteger) or real (PntrReal)
270 : Real64 *RealValue; // POINTER to the REAL value that is being accessed
271 : int *IntValue; // POINTER to the Integer value that is being accessed
272 :
273 : // Default Constructor
274 358 : InternalVarsAvailableType() : PntrVarTypeUsed(PtrDataType::Invalid), RealValue(nullptr), IntValue(nullptr)
275 : {
276 358 : }
277 : };
278 :
279 1138 : struct InternalVarsUsedType
280 : {
281 : // Members
282 : // structure for internal data that user has selected to use in Erl.
283 : std::string Name; // Erl variable name
284 : std::string InternalDataTypeName; // general internal variable name, All uppercase
285 : std::string UniqueIDName; // unique id for internal var, All uppercase
286 : bool CheckedOkay; // set to true once matched to available internal var
287 : int ErlVariableNum; // points to global Erl variable, matches Name
288 : int InternVarNum; // points to index match in EMSInternalVarsAvailable structure
289 :
290 : // Default Constructor
291 28 : InternalVarsUsedType() : CheckedOkay(false), ErlVariableNum(0), InternVarNum(0)
292 : {
293 28 : }
294 : };
295 :
296 1098163 : struct EMSActuatorAvailableType
297 : {
298 : // Members
299 : // structure for all the actuators available for use in Erl
300 : std::string ComponentTypeName; // general actuator name registered, All uppercase
301 : std::string UniqueIDName; // unique id for actuator, All uppercase
302 : std::string ControlTypeName; // control type id for actuator, All uppercase
303 : std::string Units; // control value units, used for reporting and checks.
304 : int handleCount; // Number of times you tried to get a handle on this actuator,
305 : // whether from EMS:Actuator or getActuatorHandle (API)
306 : PtrDataType PntrVarTypeUsed; // data type used: integer (PntrInteger), real (PntrReal) or logical (PntrLogical)
307 : bool *Actuated; // POINTER to the logical value that signals EMS is actuating
308 : Real64 *RealValue; // POINTER to the REAL value that is being actuated
309 : int *IntValue; // POINTER to the Integer value that is being actuated
310 : bool *LogValue; // POINTER to the Logical value that is being actuated
311 :
312 : // Default Constructor
313 163 : EMSActuatorAvailableType()
314 163 : : handleCount(0), PntrVarTypeUsed(PtrDataType::Invalid), Actuated(nullptr), RealValue(nullptr), IntValue(nullptr), LogValue(nullptr)
315 : {
316 163 : }
317 : };
318 :
319 1438 : struct ActuatorUsedType
320 : {
321 : // Members
322 : // structure for actuators user selected to use in Erl
323 : std::string Name; // Erl variable name
324 : std::string ComponentTypeName; // general actuator name, All uppercase
325 : std::string UniqueIDName; // unique id for actuator, All uppercase
326 : std::string ControlTypeName; // control type id for actuator, All uppercase
327 : bool CheckedOkay; // set to true once matched to available actuator
328 : int ErlVariableNum; // points to global Erl variable, matches Name
329 : int ActuatorVariableNum; // points to index match in EMSActuatorAvailable structure
330 :
331 : // Default Constructor
332 44 : ActuatorUsedType() : CheckedOkay(false), ErlVariableNum(0), ActuatorVariableNum(0)
333 : {
334 44 : }
335 : };
336 :
337 1130 : struct EMSProgramCallManagementType
338 : {
339 : // Members
340 : // structure for Erl program calling managers
341 : std::string Name; // user defined name for calling manager
342 : EMSManager::EMSCallFrom CallingPoint; // EMS Calling point for this manager, see parameters emsCallFrom*
343 : int NumErlPrograms; // count of total number of Erl programs called by this manager
344 : Array1D_int ErlProgramARR; // list of integer pointers to Erl programs used by this manager
345 :
346 : // Default Constructor
347 52 : EMSProgramCallManagementType() : CallingPoint(EMSManager::EMSCallFrom::Invalid), NumErlPrograms(0)
348 : {
349 52 : }
350 : };
351 :
352 748434881 : struct ErlValueType
353 : {
354 : // Members
355 : // instance data structure for the values taken by Erl variables, nested structure in ErlVariable
356 : Value Type; // value type, eg. ValueNumber,
357 : Real64 Number; // numeric value instance for Erl variable
358 : std::string String; // string data types in Erl (not used yet)
359 : int Variable; // Pointer to another Erl variable
360 : // Might be good to change names to VariableNum and ExpressionNum just to be clear
361 : int Expression; // Pointer to another Erl expression (e.g. compound operators)
362 : bool TrendVariable; // true if Erl variable is really a trend variable
363 : int TrendVarPointer; // index to match in TrendVariable structure
364 : std::string Error; // holds error message string for reporting
365 : bool initialized; // true if number value has been SET (ie. has been on LHS in SET expression)
366 :
367 : // Default Constructor
368 239461148 : ErlValueType() : Type(Value::Null), Number(0.0), Variable(0), Expression(0), TrendVariable(false), TrendVarPointer(0), initialized(false)
369 : {
370 239461148 : }
371 :
372 : // Member Constructor
373 2313 : ErlValueType(Value const Type, // value type, eg. ValueNumber,
374 : Real64 const Number, // numeric value instance for Erl variable
375 : std::string const &String, // string data types in Erl (not used yet)
376 : int const Variable, // Pointer to another Erl variable
377 : int const Expression, // Pointer to another Erl expression (e.g. compound operators)
378 : bool const TrendVariable, // true if Erl variable is really a trend variable
379 : int const TrendVarPointer, // index to match in TrendVariable structure
380 : std::string const &Error, // holds error message string for reporting
381 : bool const initialized)
382 2313 : : Type(Type), Number(Number), String(String), Variable(Variable), Expression(Expression), TrendVariable(TrendVariable),
383 2313 : TrendVarPointer(TrendVarPointer), Error(Error), initialized(initialized)
384 : {
385 2313 : }
386 : };
387 :
388 3220160 : struct ErlVariableType
389 : {
390 : // Members
391 : // structure for Erl variables
392 : std::string Name; // Erl Variable Name
393 : int StackNum; // 0 for global Erl variables, index in ErlStack structure if local
394 : ErlValueType Value; // values taken by Erl variables
395 : bool ReadOnly; // true if Erl variable is read-only
396 : bool SetByExternalInterface; // set to true if value is set by ExternalInterface
397 :
398 : // Default Constructor
399 7180 : ErlVariableType() : StackNum(0), ReadOnly(false), SetByExternalInterface(false)
400 : {
401 7180 : }
402 : };
403 :
404 : struct InstructionType
405 : {
406 : // Members
407 : // nested structure inside ErlStack that holds program instructions
408 : int LineNum; // Erl program line number reference
409 : DataRuntimeLanguage::ErlKeywordParam Keyword; // type of instruction for this line, e.g. KeywordSet, KeywordIf, etc
410 : int Argument1; // Index to a variable, function, expression, or stack
411 : int Argument2; // Index to a variable, function, expression, or stack
412 :
413 : // Default Constructor
414 9791 : InstructionType() : LineNum(0), Keyword(DataRuntimeLanguage::ErlKeywordParam::None), Argument1(0), Argument2(0)
415 : {
416 9791 : }
417 : };
418 :
419 20282 : struct ErlStackType // Stores Erl programs in a stack of statements/instructions
420 : {
421 : // Members
422 : std::string Name; // Erl program or subroutine name, user defined
423 : int NumLines; // count of lines in Erl program or subroutine
424 : Array1D_string Line; // string array holding lines of Erl code (for processing)
425 : int NumInstructions; // count of program instructions in stack
426 : Array1D<InstructionType> Instruction; // structure array of program instructions
427 : int NumErrors; // count of errors during stack parsing
428 : Array1D_string Error; // array of error messages from stack parsing
429 :
430 : // Default Constructor
431 9862 : ErlStackType() : NumLines(0), NumInstructions(0), NumErrors(0)
432 : {
433 9862 : }
434 : };
435 :
436 22548303 : struct ErlExpressionType
437 : {
438 : // Members
439 : ErlFunc Operator; // indicates the type of operator or function 1..64
440 : int NumOperands; // count of operands in expression
441 : Array1D<ErlValueType> Operand; // holds Erl values for operands in expression
442 :
443 : // Default Constructor
444 11507 : ErlExpressionType() : Operator(ErlFunc::Invalid), NumOperands(0)
445 : {
446 11507 : }
447 : };
448 :
449 10036 : struct OperatorType
450 : {
451 : // Members
452 : // structure for operators and functions, used to look up information about each operator or function
453 : std::string Symbol; // string representation of operator or function (for reporting)
454 : ErlFunc Code; // integer code 1..64, identifies operator or function
455 : int NumOperands; // count of operands or function arguments.
456 :
457 : // Default Constructor
458 52 : OperatorType() : Code(ErlFunc::Invalid), NumOperands(0)
459 : {
460 52 : }
461 : };
462 :
463 13 : struct TrendVariableType
464 : {
465 : // Members
466 : std::string Name;
467 : int ErlVariablePointer; // the Erl variable being logged in trend
468 : int LogDepth; // number of timesteps back
469 : Array1D<Real64> TrendValARR; // the main storage of trend data
470 : Array1D<Real64> tempTrendARR; // temporary holder during push
471 : Array1D<Real64> TimeARR; // hours back in time for trend points
472 :
473 : // Default Constructor
474 3 : TrendVariableType() : ErlVariablePointer(0), LogDepth(0)
475 : {
476 3 : }
477 : };
478 :
479 : // EMS Actuator fast duplicate check lookup support
480 : typedef std::tuple<std::string, std::string, std::string> EMSActuatorKey;
481 : struct EMSActuatorKey_hash
482 : {
483 1305900 : inline static void hash_combine(std::size_t &seed, std::string const &s)
484 : {
485 : std::hash<std::string> hasher;
486 1305900 : seed ^= hasher(s) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
487 1305900 : }
488 :
489 435300 : inline std::size_t operator()(EMSActuatorKey const &key) const
490 : {
491 435300 : std::size_t seed(0);
492 435300 : hash_combine(seed, std::get<0>(key));
493 435300 : hash_combine(seed, std::get<1>(key));
494 435300 : hash_combine(seed, std::get<2>(key));
495 435300 : return seed;
496 : }
497 : };
498 :
499 : void ValidateEMSVariableName(EnergyPlusData &state,
500 : std::string const &cModuleObject, // the current object name
501 : std::string const &cFieldValue, // the field value
502 : std::string const &cFieldName, // the current field name
503 : bool &errFlag, // true if errors found in this routine, false otherwise.
504 : bool &ErrorsFound // true if errors found in this routine, untouched otherwise.
505 : );
506 :
507 : void ValidateEMSProgramName(EnergyPlusData &state,
508 : std::string const &cModuleObject, // the current object name
509 : std::string const &cFieldValue, // the field value
510 : std::string const &cFieldName, // the current field name
511 : std::string const &cSubType, // sub type = Program or Subroutine
512 : bool &errFlag, // true if errors found in this routine, false otherwise.
513 : bool &ErrorsFound // true if errors found in this routine, untouched otherwise.
514 : );
515 :
516 : } // namespace DataRuntimeLanguage
517 :
518 1542 : struct RuntimeLanguageData : BaseGlobalStruct
519 : {
520 :
521 : int NumProgramCallManagers = 0; // count of Erl program managers with calling points
522 : int NumSensors = 0; // count of EMS sensors used in model (data from output variables)
523 : int numActuatorsUsed = 0; // count of EMS actuators used in model
524 : int numEMSActuatorsAvailable = 0; // count of EMS actuators available for use in such a model
525 : int maxEMSActuatorsAvailable = 0; // count of EMS current maximum actuators available for use in such a model
526 : int NumInternalVariablesUsed = 0; // count of EMS internal variables used in model
527 : int numEMSInternalVarsAvailable = 0; // count of EMS internal variables available for use in such a model
528 : int maxEMSInternalVarsAvailable = 0; // count of EMS current maximum internal variables available for use in such a model
529 : int varsAvailableAllocInc = 1000; // allocation increment for variable arrays
530 : int NumErlPrograms = 0; // count of Erl programs in model
531 : int NumErlSubroutines = 0; // count of Erl subroutines in model
532 : int NumUserGlobalVariables = 0; // count of global EMS variables defined by user
533 : int NumErlVariables = 0; // count of Erl variables
534 : int NumErlStacks = 0; // count of Erl program stacks in model. sum of programs and subroutines
535 : int NumExpressions = 0; // count of Erl expressions
536 : int NumEMSOutputVariables = 0; // count of EMS output variables, custom output variables from Erl
537 : int NumEMSMeteredOutputVariables = 0; // count of EMS metered output variables, custom meters from Erl
538 : int NumErlTrendVariables = 0; // count of EMS trend variables in model
539 : int NumEMSCurveIndices = 0; // count of EMS curve index variables in model
540 : int NumEMSConstructionIndices = 0; // count of EMS construction index variables in model
541 :
542 : //######################################################################################################################################
543 : // code for ExternalInterface
544 : int NumExternalInterfaceGlobalVariables = 0; // count of ExternalInterface runtime variable
545 : int NumExternalInterfaceFunctionalMockupUnitImportGlobalVariables = 0; // count of ExternalInterface runtime variable for FMUImport
546 : // will be updated with values from ExternalInterface
547 : int NumExternalInterfaceFunctionalMockupUnitExportGlobalVariables = 0; // count of ExternalInterface runtime variable for FMUExport
548 : // will be updated with values from ExternalInterface
549 : int NumExternalInterfaceActuatorsUsed = 0; // count of ExternalInterface Actuators
550 : int NumExternalInterfaceFunctionalMockupUnitImportActuatorsUsed = 0; // count of ExternalInterface Actuators for FMUImport
551 : int NumExternalInterfaceFunctionalMockupUnitExportActuatorsUsed = 0; // count of ExternalInterface Actuators for FMUExport
552 :
553 : //######################################################################################################################################
554 :
555 : bool OutputEDDFile = false; // set to true if user requests EDD output file be written
556 : bool OutputFullEMSTrace = false; // how much to write out to trace, if true do verbose for each line
557 : bool OutputEMSErrors = false; // how much to write out to trace, if true include Erl error messages
558 : bool OutputEMSActuatorAvailFull = false; // how much to write out to EDD file, if true dump full combinatorial actuator list
559 : bool OutputEMSActuatorAvailSmall = false; // how much to write out to EDD file, if true dump actuator list without key names
560 : bool OutputEMSInternalVarsFull = false; // how much to write out to EDD file, if true dump full combinatorial internal list
561 : bool OutputEMSInternalVarsSmall = false; // how much to write out to EDD file, if true dump internal list without key names
562 :
563 : Array2D_bool EMSConstructActuatorChecked;
564 : Array2D_bool EMSConstructActuatorIsOkay;
565 :
566 : // Object Data
567 : Array1D<DataRuntimeLanguage::ErlVariableType> ErlVariable; // holds Erl variables in a structure array
568 : Array1D<DataRuntimeLanguage::ErlStackType> ErlStack; // holds Erl programs in separate "stacks"
569 : Array1D<DataRuntimeLanguage::ErlExpressionType> ErlExpression; // holds Erl expressions in structure array
570 : Array1D<DataRuntimeLanguage::OperatorType> PossibleOperators; // hard library of available operators and functions
571 : Array1D<DataRuntimeLanguage::TrendVariableType> TrendVariable; // holds Erl trend variables in a structure array
572 : Array1D<DataRuntimeLanguage::OutputVarSensorType> Sensor; // EMS:SENSOR objects used (from output variables)
573 : Array1D<DataRuntimeLanguage::EMSActuatorAvailableType> EMSActuatorAvailable; // actuators that could be used
574 : Array1D<DataRuntimeLanguage::ActuatorUsedType> EMSActuatorUsed; // actuators that are used
575 : Array1D<DataRuntimeLanguage::InternalVarsAvailableType> EMSInternalVarsAvailable; // internal data that could be used
576 : Array1D<DataRuntimeLanguage::InternalVarsUsedType> EMSInternalVarsUsed; // internal data that are used
577 : Array1D<DataRuntimeLanguage::EMSProgramCallManagementType> EMSProgramCallManager; // program calling managers
578 : DataRuntimeLanguage::ErlValueType Null = DataRuntimeLanguage::ErlValueType(
579 : DataRuntimeLanguage::Value::Null, 0.0, "", 0, 0, false, 0, "", true); // special "null" Erl variable value instance
580 : DataRuntimeLanguage::ErlValueType False = DataRuntimeLanguage::ErlValueType(
581 : DataRuntimeLanguage::Value::Null, 0.0, "", 0, 0, false, 0, "", true); // special "false" Erl variable value instance
582 : DataRuntimeLanguage::ErlValueType True = DataRuntimeLanguage::ErlValueType(
583 : DataRuntimeLanguage::Value::Null, 0.0, "", 0, 0, false, 0, "", true); // special "True" Erl variable value instance, gets reset
584 :
585 : // EMS Actuator fast duplicate check lookup support
586 : std::unordered_set<std::tuple<std::string, std::string, std::string>, DataRuntimeLanguage::EMSActuatorKey_hash>
587 : EMSActuator_lookup; // Fast duplicate lookup structure
588 :
589 0 : void clear_state() override
590 : {
591 0 : this->NumProgramCallManagers = 0;
592 0 : this->NumSensors = 0;
593 0 : this->numActuatorsUsed = 0;
594 0 : this->numEMSActuatorsAvailable = 0;
595 0 : this->maxEMSActuatorsAvailable = 0;
596 0 : this->NumInternalVariablesUsed = 0;
597 0 : this->numEMSInternalVarsAvailable = 0;
598 0 : this->maxEMSInternalVarsAvailable = 0;
599 0 : this->varsAvailableAllocInc = 1000;
600 0 : this->NumErlPrograms = 0;
601 0 : this->NumErlSubroutines = 0;
602 0 : this->NumUserGlobalVariables = 0;
603 0 : this->NumErlVariables = 0;
604 0 : this->NumErlStacks = 0;
605 0 : this->NumExpressions = 0;
606 0 : this->NumEMSOutputVariables = 0;
607 0 : this->NumEMSMeteredOutputVariables = 0;
608 0 : this->NumErlTrendVariables = 0;
609 0 : this->NumEMSCurveIndices = 0;
610 0 : this->NumEMSConstructionIndices = 0;
611 0 : this->NumExternalInterfaceGlobalVariables = 0;
612 0 : this->NumExternalInterfaceFunctionalMockupUnitImportGlobalVariables = 0;
613 0 : this->NumExternalInterfaceFunctionalMockupUnitExportGlobalVariables = 0;
614 0 : this->NumExternalInterfaceActuatorsUsed = 0;
615 0 : this->NumExternalInterfaceFunctionalMockupUnitImportActuatorsUsed = 0;
616 0 : this->NumExternalInterfaceFunctionalMockupUnitExportActuatorsUsed = 0;
617 0 : this->OutputEDDFile = false;
618 0 : this->OutputFullEMSTrace = false;
619 0 : this->OutputEMSErrors = false;
620 0 : this->OutputEMSActuatorAvailFull = false;
621 0 : this->OutputEMSActuatorAvailSmall = false;
622 0 : this->OutputEMSInternalVarsFull = false;
623 0 : this->OutputEMSInternalVarsSmall = false;
624 0 : this->EMSConstructActuatorChecked.deallocate();
625 0 : this->EMSConstructActuatorIsOkay.deallocate();
626 0 : this->ErlVariable.deallocate();
627 0 : this->ErlStack.deallocate();
628 0 : this->ErlExpression.deallocate();
629 0 : this->PossibleOperators.deallocate();
630 0 : this->TrendVariable.deallocate();
631 0 : this->Sensor.deallocate();
632 0 : this->EMSActuatorAvailable.deallocate();
633 0 : this->EMSActuatorUsed.deallocate();
634 0 : this->EMSInternalVarsAvailable.deallocate();
635 0 : this->EMSInternalVarsUsed.deallocate();
636 0 : this->EMSProgramCallManager.deallocate();
637 0 : this->EMSActuator_lookup.clear();
638 0 : this->Null = DataRuntimeLanguage::ErlValueType(DataRuntimeLanguage::Value::Null, 0.0, "", 0, 0, false, 0, "", true);
639 0 : this->False = DataRuntimeLanguage::ErlValueType(DataRuntimeLanguage::Value::Null, 0.0, "", 0, 0, false, 0, "", true);
640 0 : this->True = DataRuntimeLanguage::ErlValueType(DataRuntimeLanguage::Value::Null, 0.0, "", 0, 0, false, 0, "", true);
641 0 : }
642 : };
643 :
644 : } // namespace EnergyPlus
645 :
646 : #endif
|