Line data Source code
1 : // EnergyPlus, Copyright (c) 1996-2025, 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 : // C++ Headers
49 : #include <iostream>
50 : #include <sstream>
51 :
52 : // ObjexxFCL Headers
53 : #include <ObjexxFCL/Fmath.hh>
54 :
55 : // EnergyPlus Headers
56 : #include <EnergyPlus/Data/EnergyPlusData.hh>
57 : #include <EnergyPlus/DataGlobals.hh>
58 : #include <EnergyPlus/DataSystemVariables.hh>
59 : #include <EnergyPlus/DisplayRoutines.hh>
60 :
61 : namespace EnergyPlus {
62 :
63 20386 : void DisplayString(EnergyPlusData &state, std::string const &String) // String to be displayed
64 : {
65 :
66 : // SUBROUTINE INFORMATION:
67 : // AUTHOR Linda Lawrie
68 : // DATE WRITTEN Version 1.0
69 : // MODIFIED na
70 : // RE-ENGINEERED na
71 :
72 : // PURPOSE OF THIS SUBROUTINE:
73 : // This subroutine provides a call to display strings during program execution.
74 :
75 : // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
76 : // na
77 20386 : if (state.dataGlobal->fMessagePtr) {
78 0 : state.dataGlobal->fMessagePtr(String);
79 : }
80 20386 : if (state.dataGlobal->messageCallback) {
81 0 : state.dataGlobal->messageCallback(String.c_str());
82 : }
83 :
84 20386 : if (state.dataGlobal->KickOffSimulation && !state.dataSysVars->DeveloperFlag) {
85 1450 : return;
86 : }
87 18936 : if (!state.dataGlobal->printConsoleOutput) {
88 0 : return;
89 : }
90 18936 : std::cout << String << std::endl;
91 : }
92 :
93 36322 : void DisplayString(EnergyPlusData &state, char const *String) // String to be displayed
94 : {
95 :
96 : // SUBROUTINE INFORMATION:
97 : // AUTHOR Linda Lawrie
98 : // DATE WRITTEN Version 1.0
99 : // MODIFIED na
100 : // RE-ENGINEERED Overload to avoid std::string creation overhead
101 :
102 : // PURPOSE OF THIS SUBROUTINE:
103 : // This subroutine provides a call to display strings during program execution.
104 :
105 36322 : if (state.dataGlobal->fMessagePtr) {
106 0 : state.dataGlobal->fMessagePtr(String);
107 : }
108 36322 : if (state.dataGlobal->messageCallback) {
109 0 : state.dataGlobal->messageCallback(String);
110 : }
111 :
112 36322 : if (state.dataGlobal->KickOffSimulation && !state.dataSysVars->DeveloperFlag) {
113 9900 : return;
114 : }
115 26422 : if (!state.dataGlobal->printConsoleOutput) {
116 0 : return;
117 : }
118 26422 : std::cout << String << std::endl;
119 : }
120 :
121 0 : void DisplayNumberAndString(EnergyPlusData &state,
122 : int const Number, // number to be displayed
123 : std::string const &String // String to be displayed
124 : )
125 : {
126 :
127 : // SUBROUTINE INFORMATION:
128 : // AUTHOR Linda Lawrie
129 : // DATE WRITTEN Version 1.0
130 : // MODIFIED na
131 : // RE-ENGINEERED na
132 :
133 : // PURPOSE OF THIS SUBROUTINE:
134 : // This subroutine provides a call to display (at set point on screen for screen positioning models) card images
135 : // during program parsing.
136 :
137 : // METHODOLOGY EMPLOYED:
138 : // usage:= call DisplayNumberAndString(numbr,string)
139 :
140 : // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
141 0 : std::stringstream sstm;
142 0 : sstm << String << ' ' << Number;
143 0 : if (state.dataGlobal->fMessagePtr) {
144 0 : state.dataGlobal->fMessagePtr(sstm.str());
145 : }
146 0 : if (state.dataGlobal->messageCallback) {
147 0 : state.dataGlobal->messageCallback(sstm.str().c_str());
148 : }
149 :
150 0 : if (state.dataGlobal->KickOffSimulation && !state.dataSysVars->DeveloperFlag) {
151 0 : return;
152 : }
153 0 : if (!state.dataGlobal->printConsoleOutput) {
154 0 : return;
155 : }
156 0 : std::cout << String << ' ' << Number << std::endl;
157 0 : }
158 :
159 5089 : void DisplaySimDaysProgress(EnergyPlusData &state,
160 : int const CurrentSimDay, // Current Simulation Day
161 : int const TotalSimDays // Total number of Simulation Days
162 : )
163 : {
164 :
165 : // SUBROUTINE INFORMATION:
166 : // AUTHOR Linda Lawrie
167 : // DATE WRITTEN Version 1.0
168 : // MODIFIED na
169 : // RE-ENGINEERED na
170 :
171 : // PURPOSE OF THIS SUBROUTINE:
172 : // This subroutine provides a call for "progress" during simulation.
173 : // Progress is percent of current days vs total days.
174 :
175 : // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
176 5089 : int percent(0); // Current percent progress
177 :
178 5089 : if (state.dataGlobal->KickOffSimulation && !state.dataSysVars->DeveloperFlag) {
179 373 : return;
180 : }
181 4716 : if (TotalSimDays > 0) {
182 4716 : percent = nint(((float)CurrentSimDay / (float)TotalSimDays) * 100.0);
183 4716 : percent = min(percent, 100);
184 : } else {
185 0 : percent = 0;
186 : }
187 :
188 4716 : if (state.dataGlobal->fProgressPtr) {
189 0 : state.dataGlobal->fProgressPtr(percent);
190 : }
191 4716 : if (state.dataGlobal->progressCallback) {
192 0 : state.dataGlobal->progressCallback(percent);
193 : }
194 : }
195 :
196 : } // namespace EnergyPlus
|