Zone Closure Driver
Closes space over and over on a schedule, so a model does not write the same six lines again.
Packaging rather than semantics, and worth being plain that this adds no capability at all: everything here is holdZonesFor and an event, and a model that wants something this does not do should write the event itself rather than bend this into shape. What it saves is the shape that is written identically every time -- sample an interval, sample a duration, make a holder, ask, repeat -- and the two errors that shape invites.
The first error is sampling the duration twice: once for the hold and once for a separate "space free again" event, so that the zones reopen at one instant and whatever was waiting on the closure resumes at another. Requiring a ZoneHoldActionIfc made that hard to write; taking the duration once here makes it impossible.
The second is a holder reused across closures. A holder is the identity of one closure, so a driver that kept one object and asked twice would be told, correctly and unhelpfully, that it already holds space. This mints a new holder per closure, which is the whole reason a holder is an interface with two members and not a model element.
ZoneClosureDriver(
this, system,
zones = { network.link("Aisle3")!!.zones },
timeBetween = ExponentialRV(240.0),
duration = LognormalRV(20.0, 25.0),
name = "Aisle3Maintenance"
)Parameters
where this sits in the model
the guide path whose zones are closed
what to close, read afresh at every closure so the extent may be sampled too
how long between the end of one closure being asked for and the next
how long each closure holds its space once the hold begins
what to do when the space is already promised to another closure; the default refuses loudly, which is the right default for a driver whose whole job is to run unattended
when the first closure is asked for; defaults to one sample of timeBetween
the driver's name in the model
Constructors
Properties
Functions
Called once, when the space has drained and the hold has taken effect.
Called once, when the space has been given back -- by the holder, or by the clock.
This method should be overridden by subclasses that need actions performed to initialize prior to a replication. It is called once before each replication occurs if the model element wants initialization. It is called after beforeReplication() is called