OpenWaterAnalytics / EPANET

The Water Distribution System Hydraulic and Water Quality Analysis Toolkit
MIT License
273 stars 203 forks source link

Incorrect hour value set with time based simple controls with nine or greater input tokens #709

Closed lbutler closed 1 year ago

lbutler commented 1 year ago

If you create a simple control with nine or more input tokens, the logic skips over assigning the hour variable and EPANET will activate the control at hour zero.

An example simple control would look like this: LINK PUMP-1 OPEN AT TIME 8 PM EXTRA_TOKEN

I believe we should add another check for the correct amount of input tokens at the following location in input3.c

https://github.com/OpenWaterAnalytics/EPANET/blob/4d8d82ddc260fce216af9321fc3d9a4646ac6827/src/input3.c#L899-L906

LRossman commented 1 year ago

I believe the simplest fix is to change the '==' in line 904 to '>='.

lbutler commented 1 year ago

@LRossman your right, that's the simplest option. I can submit a one character PR later today if there are no further comments