-
Notifications
You must be signed in to change notification settings - Fork 425
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Translate EMS Example Files to PythonPlugin #7915
Changes from 63 commits
d2af34f
c0a6221
d662f05
59c6a70
0c4da0d
c92288f
1256170
8b8fba6
46ac09c
c9aabad
a6c75db
3c3d6fd
37f887e
d49c125
c4607aa
161166d
88ad6cc
1f1700e
d5110a6
adf90b6
7a9a236
1c8f5fd
f001048
27ec6dc
0e75cfa
f5eb11a
cf78029
62faba6
db29f47
81f6856
21b308a
c4db1a0
6001fc4
884e02f
30b9455
4ee1677
1f493b4
9135109
e8ef4dd
219ae38
939f54c
af3cfe3
9a8e6ec
5dcdc17
86cf437
526c44c
ec07d35
85641eb
744f130
74580c6
0fb250d
f1a3327
e3df126
f6de6b5
9d0ea62
eac1fb1
632287a
966c1c1
cf33794
dc28dd4
9f2b0da
f9bdd72
2a2ff7c
77eee74
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -407,6 +407,17 @@ namespace PluginManagement { | |
callbacks[iCalledFrom].push_back(f); | ||
} | ||
|
||
void onBeginEnvironment() { | ||
// reset vars and trends -- sensors and actuators are reset by EMS | ||
for (auto & v : globalVariableValues) { | ||
v = 0; | ||
} | ||
// reinitialize trend variables so old data are purged | ||
for (auto & tr : trends) { | ||
tr.reset(); | ||
} | ||
} | ||
|
||
int PluginManager::numActiveCallbacks() | ||
{ | ||
return (int)callbacks.size(); | ||
|
@@ -422,8 +433,8 @@ namespace PluginManagement { | |
#if LINK_WITH_PYTHON == 1 | ||
for (auto &plugin : plugins) { | ||
if (plugin.runDuringWarmup || !DataGlobals::WarmupFlag) { | ||
plugin.run(iCalledFrom); | ||
anyRan = true; | ||
bool const didOneRun = plugin.run(iCalledFrom); | ||
if (didOneRun) anyRan = true; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Properly return whether a plugin actually ran, not just if we tried to run plugins. This is another big improvement. |
||
} | ||
} | ||
#endif | ||
|
@@ -1191,8 +1202,9 @@ namespace PluginManagement { | |
} | ||
|
||
#if LINK_WITH_PYTHON == 1 | ||
void PluginInstance::run(int iCalledFrom) const | ||
bool PluginInstance::run(int iCalledFrom) const | ||
{ | ||
// returns true if a plugin actually ran | ||
const char *functionName = nullptr; | ||
if (iCalledFrom == DataGlobals::emsCallFromBeginNewEvironment) { | ||
if (this->bHasBeginNewEnvironment) { | ||
|
@@ -1266,7 +1278,7 @@ namespace PluginManagement { | |
|
||
// leave if we didn't find a match | ||
if (!functionName) { | ||
return; | ||
return false; | ||
} | ||
|
||
// then call the main function | ||
|
@@ -1297,10 +1309,12 @@ namespace PluginManagement { | |
if (EnergyPlus::PluginManagement::apiErrorFlag) { | ||
EnergyPlus::ShowFatalError("API problems encountered while running plugin cause program termination."); | ||
} | ||
return true; | ||
} | ||
#else | ||
void PluginInstance::run(int EP_UNUSED(iCalledFrom)) const | ||
bool PluginInstance::run(int EP_UNUSED(iCalledFrom)) const | ||
{ | ||
return false; | ||
} | ||
#endif | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -415,14 +415,23 @@ ADD_SIMULATION_TEST(IDF_FILE PurchAirWithDaylightingAndShadeControl.idf EPW_FILE | |
ADD_SIMULATION_TEST(IDF_FILE PurchAirWithDaylightingAngleFac.idf EPW_FILE USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.epw) | ||
ADD_SIMULATION_TEST(IDF_FILE PurchAirWithDoubleFacadeDaylighting.idf EPW_FILE USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.epw) | ||
if (LINK_WITH_PYTHON) | ||
ADD_SIMULATION_TEST(IDF_FILE PythonPluginAirflowNetworkOpeningControlByHumidity.idf EPW_FILE USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.epw) | ||
ADD_SIMULATION_TEST(IDF_FILE PythonPluginConstantVolumePurchasedAir.idf EPW_FILE USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.epw) | ||
ADD_SIMULATION_TEST(IDF_FILE PythonPluginCurveOverride_PackagedTerminalHeatPump.idf EPW_FILE USA_FL_Miami.Intl.AP.722020_TMY3.epw) | ||
ADD_SIMULATION_TEST(IDF_FILE PythonPluginCustomOutputVariable.idf EPW_FILE USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.epw) | ||
ADD_SIMULATION_TEST(IDF_FILE PythonPluginCustomTrendVariable.idf EPW_FILE USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.epw) | ||
ADD_SIMULATION_TEST(IDF_FILE PythonPluginCustomSchedule.idf EPW_FILE USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.epw) | ||
ADD_SIMULATION_TEST(IDF_FILE PythonPluginLrgOff_GridStorageSmoothing.idf EPW_FILE USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.epw) | ||
ADD_SIMULATION_TEST(IDF_FILE PythonPluginWindowShadeControl.idf EPW_FILE USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.epw) | ||
ADD_SIMULATION_TEST(IDF_FILE PythonPluginDemandManager_LargeOffice.idf EPW_FILE USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.epw) | ||
ADD_SIMULATION_TEST(IDF_FILE PythonPluginDiscreteAirSystemSizes.idf EPW_FILE USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.epw) | ||
ADD_SIMULATION_TEST(IDF_FILE PythonPluginPlantLoopOverrideControl.idf EPW_FILE USA_FL_Orlando.Intl.AP.722050_TMY3.epw) | ||
ADD_SIMULATION_TEST(IDF_FILE PythonPluginPlantOperation_largeOff.idf EPW_FILE USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.epw) | ||
ADD_SIMULATION_TEST(IDF_FILE PythonPluginReplaceTraditionalManagers_LargeOffice.idf EPW_FILE USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.epw) | ||
ADD_SIMULATION_TEST(IDF_FILE PythonPluginTestMathAndKill.idf EPW_FILE USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.epw EXPECT_FATAL) # Expected to Fatal | ||
ADD_SIMULATION_TEST(IDF_FILE PythonPluginThermochromicWindow.idf EPW_FILE USA_NV_Las.Vegas-McCarran.Intl.AP.723860_TMY3.epw) | ||
ADD_SIMULATION_TEST(IDF_FILE PythonPluginUserDefined5ZoneAirCooled.idf EPW_FILE USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.epw) | ||
ADD_SIMULATION_TEST(IDF_FILE PythonPluginUserDefinedWindACAuto.idf EPW_FILE USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.epw) | ||
ADD_SIMULATION_TEST(IDF_FILE PythonPluginWindowShadeControl.idf EPW_FILE USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.epw) | ||
ADD_SIMULATION_TEST(IDF_FILE PythonPluginLrgOff_GridStorageSmoothing.idf EPW_FILE USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.epw) | ||
ADD_SIMULATION_TEST(IDF_FILE PythonPluginCustomTrendVariable.idf EPW_FILE USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.epw) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added gobs of new python plugin test cases that match the EMS cases. We are showing we can match the results of EMS which is a huge step. |
||
endif() | ||
ADD_SIMULATION_TEST(IDF_FILE QTFtest.idf EPW_FILE USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.epw) | ||
ADD_SIMULATION_TEST(IDF_FILE RadHiTempElecTermReheat.idf EPW_FILE USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.epw) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2115,3 +2115,6 @@ | |
HTML; !- Column Separator | ||
|
||
!- =========== ALL OBJECTS IN CLASS: OUTPUT:VARIABLE =========== | ||
Output:Variable,Zone1PTHPDXCoolCoil,Cooling Coil Total Cooling Rate,timestep; | ||
Output:Variable,Zone2PTHPDXCoolCoil,Cooling Coil Total Cooling Rate,timestep; | ||
Output:Variable,Zone3PTHPDXCoolCoil,Cooling Coil Total Cooling Rate,timestep; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just added a few extra outputs to a couple EMS files for debugging, they aren't hurting anything but I may take them out if I need to do more commits. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a new begin environment calling point in the plugins to clear trends and reset stuff. This is a big improvement.