Skip to content

Commit 35b4876

Browse files
authored
Merge pull request #11525 from NatLabRockies/unused_actuator_warn
Fix #10944: unused EMS actuator warning never fires
2 parents 8c598f1 + 0c0130a commit 35b4876

13 files changed

Lines changed: 152 additions & 51 deletions

src/EnergyPlus/DataRuntimeLanguage.hh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,7 @@ namespace DataRuntimeLanguage {
327327
bool CheckedOkay; // set to true once matched to available actuator
328328
int ErlVariableNum; // points to global Erl variable, matches Name
329329
int ActuatorVariableNum; // points to index match in EMSActuatorAvailable structure
330+
bool wasActuated = false; // issue #10944: true once any Erl program has set this actuator
330331

331332
// Default Constructor
332333
ActuatorUsedType() : CheckedOkay(false), ErlVariableNum(0), ActuatorVariableNum(0)

src/EnergyPlus/EMSManager.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ namespace EMSManager {
325325
state.dataRuntimeLang->NumExternalInterfaceFunctionalMockupUnitImportActuatorsUsed +
326326
state.dataRuntimeLang->NumExternalInterfaceFunctionalMockupUnitExportActuatorsUsed;
327327
++ActuatorUsedLoop) {
328-
auto const &thisActuatorUsed = state.dataRuntimeLang->EMSActuatorUsed(ActuatorUsedLoop);
328+
auto &thisActuatorUsed = state.dataRuntimeLang->EMSActuatorUsed(ActuatorUsedLoop);
329329

330330
int ErlVariableNum = thisActuatorUsed.ErlVariableNum;
331331
if (ErlVariableNum <= 0) {
@@ -1983,9 +1983,9 @@ namespace EMSManager {
19831983
void checkForUnusedActuatorsAtEnd(EnergyPlusData &state)
19841984
{
19851985
// call at end of simulation to check if any of the user's actuators were never initialized.
1986-
// Could be a mistake we want to help users catch // Issue #4404.
1986+
// Could be a mistake we want to help users catch // Issues #4404, #10944.
19871987
for (int actuatorUsedLoop = 1; actuatorUsedLoop <= state.dataRuntimeLang->numActuatorsUsed; ++actuatorUsedLoop) {
1988-
if (!state.dataRuntimeLang->ErlVariable(state.dataRuntimeLang->EMSActuatorUsed(actuatorUsedLoop).ErlVariableNum).Value.initialized) {
1988+
if (!state.dataRuntimeLang->EMSActuatorUsed(actuatorUsedLoop).wasActuated) {
19891989
ShowWarningError(state,
19901990
"checkForUnusedActuatorsAtEnd: Unused EMS Actuator detected, suggesting possible unintended programming error or "
19911991
"spelling mistake.");

src/EnergyPlus/RuntimeLanguageProcessor.cc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,16 @@ void ParseStack(EnergyPlusData &state, int const StackNum)
458458
VariableNum = NewEMSVariable(state, Variable, StackNum);
459459
// Check for invalid variable name
460460

461+
// issue #10944: static reference check — if this SET targets an actuator's ErlVariable,
462+
// mark the actuator as referenced. Catches typos at parse time; avoids false positives
463+
// for conditional NULL-branch patterns that never fire during the run.
464+
for (int aUsed = 1; aUsed <= state.dataRuntimeLang->numActuatorsUsed; ++aUsed) {
465+
if (state.dataRuntimeLang->EMSActuatorUsed(aUsed).ErlVariableNum == VariableNum) {
466+
state.dataRuntimeLang->EMSActuatorUsed(aUsed).wasActuated = true;
467+
break;
468+
}
469+
}
470+
461471
if (Pos + 1 < Remainder.length()) {
462472
Expression = stripped(Remainder.substr(Pos + 1));
463473
} else {

src/EnergyPlus/api/datatransfer.cc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,14 @@ int getActuatorHandle(EnergyPlusState state, const char *componentType, const ch
421421
std::string const actuatorIDUC = EnergyPlus::Util::makeUPPER(availActuator.UniqueIDName);
422422
std::string const actuatorControlUC = EnergyPlus::Util::makeUPPER(availActuator.ControlTypeName);
423423
if (typeUC == actuatorTypeUC && keyUC == actuatorIDUC && controlUC == actuatorControlUC) {
424+
// issue #10944: mark any IDF-declared EMSActuatorUsed entry as referenced once Python
425+
// retrieves its handle — Python catches typos itself, so handle retrieval is the usage signal.
426+
for (auto &usedActuator : thisState->dataRuntimeLang->EMSActuatorUsed) {
427+
if (usedActuator.ActuatorVariableNum == handle) {
428+
usedActuator.wasActuated = true;
429+
break;
430+
}
431+
}
424432
if (availActuator.handleCount > 0) {
425433
// If the handle is already used by an IDF EnergyManagementSystem:Actuator, we should warn the user
426434
bool foundActuator = false;

testfiles/ASHRAE901_Hospital_STD2019_Denver.idf

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28006,12 +28006,6 @@
2800628006
Schedule:Compact, !- Actuated Component Type
2800728007
Schedule Value; !- Actuated Component Control Type
2800828008

28009-
EnergyManagementSystem:Actuator,
28010-
BypassHXStatus, !- Name
28011-
Bypass Heat Exchanger Status, !- Actuated Component Unique Name
28012-
Schedule:Constant, !- Actuated Component Type
28013-
Schedule Value; !- Actuated Component Control Type
28014-
2801528009
EnergyManagementSystem:Actuator,
2801628010
HRC_SPM_Reset, !- Name
2801728011
Heat Recovery Chiller Bypass Loop Setpoint Schedule, !- Actuated Component Unique Name
@@ -28036,12 +28030,6 @@
2803628030
Plant Component Pump:ConstantSpeed, !- Actuated Component Type
2803728031
On/Off Supervisory; !- Actuated Component Control Type
2803828032

28039-
EnergyManagementSystem:Actuator,
28040-
Chiller1PumpFlow, !- Name
28041-
COOLSYS1 CHILLER1 PUMP, !- Actuated Component Unique Name
28042-
Pump, !- Actuated Component Type
28043-
Pump Mass Flow Rate; !- Actuated Component Control Type
28044-
2804528033
EnergyManagementSystem:Actuator,
2804628034
Chiller2PumpFlow, !- Name
2804728035
COOLSYS1 CHILLER2 PUMP, !- Actuated Component Unique Name

testfiles/ASHRAE901_OfficeLarge_STD2019_Denver.idf

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13925,12 +13925,6 @@
1392513925
Plant Component Pump:ConstantSpeed, !- Actuated Component Type
1392613926
On/Off Supervisory; !- Actuated Component Control Type
1392713927

13928-
EnergyManagementSystem:Actuator,
13929-
Chiller1PumpFlow, !- Name
13930-
COOLSYS1 CHILLER1 PUMP, !- Actuated Component Unique Name
13931-
Pump, !- Actuated Component Type
13932-
Pump Mass Flow Rate; !- Actuated Component Control Type
13933-
1393413928
EnergyManagementSystem:Actuator,
1393513929
Chiller2PumpFlow, !- Name
1393613930
COOLSYS1 CHILLER2 PUMP, !- Actuated Component Unique Name

testfiles/ASHRAE901_OfficeLarge_STD2019_Denver_Chiller205.idf

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13911,12 +13911,6 @@
1391113911
Plant Component Pump:ConstantSpeed, !- Actuated Component Type
1391213912
On/Off Supervisory; !- Actuated Component Control Type
1391313913

13914-
EnergyManagementSystem:Actuator,
13915-
Chiller1PumpFlow, !- Name
13916-
COOLSYS1 CHILLER1 PUMP, !- Actuated Component Unique Name
13917-
Pump, !- Actuated Component Type
13918-
Pump Mass Flow Rate; !- Actuated Component Control Type
13919-
1392013914
EnergyManagementSystem:Actuator,
1392113915
Chiller2PumpFlow, !- Name
1392213916
COOLSYS1 CHILLER2 PUMP, !- Actuated Component Unique Name

testfiles/ASHRAE901_OfficeLarge_STD2019_Denver_Chiller205_Detailed.idf

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13946,12 +13946,6 @@
1394613946
Plant Component Pump:ConstantSpeed, !- Actuated Component Type
1394713947
On/Off Supervisory; !- Actuated Component Control Type
1394813948

13949-
EnergyManagementSystem:Actuator,
13950-
Chiller1PumpFlow, !- Name
13951-
COOLSYS1 CHILLER1 PUMP, !- Actuated Component Unique Name
13952-
Pump, !- Actuated Component Type
13953-
Pump Mass Flow Rate; !- Actuated Component Control Type
13954-
1395513949
EnergyManagementSystem:Actuator,
1395613950
Chiller2PumpFlow, !- Name
1395713951
COOLSYS1 CHILLER2 PUMP, !- Actuated Component Unique Name

testfiles/ASHRAE901_OfficeLarge_STD2019_Denver_ChillerEIR.idf

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13962,12 +13962,6 @@
1396213962
Plant Component Pump:ConstantSpeed, !- Actuated Component Type
1396313963
On/Off Supervisory; !- Actuated Component Control Type
1396413964

13965-
EnergyManagementSystem:Actuator,
13966-
Chiller1PumpFlow, !- Name
13967-
COOLSYS1 CHILLER1 PUMP, !- Actuated Component Unique Name
13968-
Pump, !- Actuated Component Type
13969-
Pump Mass Flow Rate; !- Actuated Component Control Type
13970-
1397113965
EnergyManagementSystem:Actuator,
1397213966
Chiller2PumpFlow, !- Name
1397313967
COOLSYS1 CHILLER2 PUMP, !- Actuated Component Unique Name

testfiles/EMSDemandManager_LargeOffice.idf

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10141,12 +10141,6 @@
1014110141
0.0000, !- On Cycle Parasitic Electric Load {W}
1014210142
1.0000; !- Sizing Factor
1014310143

10144-
EnergyManagementSystem:Actuator,
10145-
HeatSys1_Boiler_Setpoint,!- Name
10146-
HeatSys1 Supply Equipment Outlet Node, !- Actuated Component Unique Name
10147-
System Node Setpoint, !- Actuated Component Type
10148-
Temperature Setpoint; !- Actuated Component Control Type
10149-
1015010144
Branch,
1015110145
HeatSys1 Supply Equipment Bypass Branch, !- Name
1015210146
, !- Pressure Drop Curve Name

0 commit comments

Comments
 (0)