using int/bool convention instead of new enum type

This commit is contained in:
Sam Hatchett
2023-09-13 09:14:57 -04:00
parent 06a43cdb4e
commit d0ab568a5d
7 changed files with 13 additions and 15 deletions

View File

@@ -505,4 +505,7 @@ typedef enum {
#define EN_SET_CLOSED -1.E10 //!< Link set closed indicator #define EN_SET_CLOSED -1.E10 //!< Link set closed indicator
#define EN_SET_OPEN 1.E10 //!< Link set open indicator #define EN_SET_OPEN 1.E10 //!< Link set open indicator
#define EN_FALSE 0 // boolean false
#define EN_TRUE 1 // boolean true
#endif //EPANET2_ENUMS_H #endif //EPANET2_ENUMS_H

View File

@@ -5283,7 +5283,7 @@ int DLLEXPORT EN_setcontrolenabled(EN_Project p, int index, int enabled)
Scontrol *control; Scontrol *control;
// Check for valid arguments // Check for valid arguments
if (enabled != ENABLED && enabled != DISABLED) if (enabled != TRUE && enabled != FALSE)
return 202; // illegal numeric value return 202; // illegal numeric value
if (!p->Openflag) if (!p->Openflag)
return 102; return 102;
@@ -5742,7 +5742,7 @@ int DLLEXPORT EN_setruleenabled(EN_Project p, int index, int enabled)
Srule *rule; Srule *rule;
// Check for valid arguments // Check for valid arguments
if (enabled != ENABLED && enabled != DISABLED) if (enabled != TRUE && enabled != FALSE)
return 202; // illegal numeric value return 202; // illegal numeric value
if (!p->Openflag) if (!p->Openflag)
return 102; return 102;

View File

@@ -557,7 +557,7 @@ int controls(Project *pr)
{ {
// Make sure that link is defined // Make sure that link is defined
control = &net->Control[i]; control = &net->Control[i];
if (control->isEnabled == DISABLED) if (!control->isEnabled)
{ {
continue; continue;
} }
@@ -733,7 +733,7 @@ int controltimestep(Project *pr, long *tstep)
{ {
t = 0; t = 0;
control = &net->Control[i]; control = &net->Control[i];
if (control->isEnabled == DISABLED) if (!control->isEnabled)
{ {
continue; continue;
} }

View File

@@ -943,7 +943,7 @@ int controldata(Project *pr)
control->Time = (long)(3600.0 * time); control->Time = (long)(3600.0 * time);
if (ctltype == TIMEOFDAY) control->Time %= SECperDAY; if (ctltype == TIMEOFDAY) control->Time %= SECperDAY;
control->Grade = level; control->Grade = level;
control->isEnabled = ENABLED; control->isEnabled = TRUE;
return 0; return 0;
} }

View File

@@ -1232,7 +1232,7 @@ int setcontrol(EN_Project p, int type, int linkIndex, double setting,
control->Setting = s; control->Setting = s;
control->Time = t; control->Time = t;
control->Grade = lvl; control->Grade = lvl;
control->isEnabled = ENABLED; control->isEnabled = TRUE;
return 0; return 0;
} }

View File

@@ -528,7 +528,7 @@ int checkrules(Project *pr, long dt)
for (i = 1; i <= net->Nrules; i++) for (i = 1; i <= net->Nrules; i++)
{ {
// skip if the rule is disabled // skip if the rule is disabled
if (net->Rule[i].isEnabled == DISABLED) if (!net->Rule[i].isEnabled)
{ {
continue; continue;
} }
@@ -689,7 +689,7 @@ void newrule(Project *pr)
rule->ThenActions = NULL; rule->ThenActions = NULL;
rule->ElseActions = NULL; rule->ElseActions = NULL;
rule->priority = 0.0; rule->priority = 0.0;
rule->isEnabled = ENABLED; rule->isEnabled = TRUE;
pr->rules.LastPremise = NULL; pr->rules.LastPremise = NULL;
pr->rules.LastThenAction = NULL; pr->rules.LastThenAction = NULL;
pr->rules.LastElseAction = NULL; pr->rules.LastElseAction = NULL;

View File

@@ -196,11 +196,6 @@ typedef enum {
TIMEOFDAY // act when time of day occurs TIMEOFDAY // act when time of day occurs
} ControlType; } ControlType;
typedef enum {
DISABLED,
ENABLED
} EnabledType;
typedef enum { typedef enum {
XHEAD, // pump cannot deliver head (closed) XHEAD, // pump cannot deliver head (closed)
TEMPCLOSED, // temporarily closed TEMPCLOSED, // temporarily closed
@@ -479,7 +474,7 @@ typedef struct // Control Statement
double Setting; // new link setting double Setting; // new link setting
StatusType Status; // new link status StatusType Status; // new link status
ControlType Type; // control type ControlType Type; // control type
EnabledType isEnabled; // control enabled? int isEnabled; // control enabled?
} Scontrol; } Scontrol;
typedef struct // Field Object of Report Table typedef struct // Field Object of Report Table
@@ -531,7 +526,7 @@ typedef struct // Control Rule Structure
{ {
char label[MAXID+1]; // rule label char label[MAXID+1]; // rule label
double priority; // priority level double priority; // priority level
EnabledType isEnabled; // is the rule enabled? int isEnabled; // is the rule enabled?
Spremise *Premises; // list of premises Spremise *Premises; // list of premises
Saction *ThenActions; // list of THEN actions Saction *ThenActions; // list of THEN actions
Saction *ElseActions; // list of ELSE actions Saction *ElseActions; // list of ELSE actions