ZoneClosureDriver

class ZoneClosureDriver(parent: ModelElement, val space: GuidedPathSpace, zones: () -> List<Zone>, timeBetween: RVariableIfc, duration: RVariableIfc, var onOverlap: ZoneOverlap = ZoneOverlap.RAISE, firstAt: Double = Double.NaN, name: String? = null) : ModelElement, ZoneHoldActionIfc(source)

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

parent

where this sits in the model

space

the guide path whose zones are closed

zones

what to close, read afresh at every closure so the extent may be sampled too

timeBetween

how long between the end of one closure being asked for and the next

duration

how long each closure holds its space once the hold begins

onOverlap

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

firstAt

when the first closure is asked for; defaults to one sample of timeBetween

name

the driver's name in the model

Constructors

Link copied to clipboard
constructor(parent: ModelElement, space: GuidedPathSpace, zones: () -> List<Zone>, timeBetween: RVariableIfc, duration: RVariableIfc, onOverlap: ZoneOverlap = ZoneOverlap.RAISE, firstAt: Double = Double.NaN, name: String? = null)

Properties

Link copied to clipboard

How many closures this driver saw through from start to finish.

Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
open override fun holdBegan(allocation: ZoneAllocation)

Called once, when the space has drained and the hold has taken effect.

Link copied to clipboard
open override fun holdEnded(allocation: ZoneAllocation)

Called once, when the space has been given back -- by the holder, or by the clock.

Link copied to clipboard
protected open override fun initialize()

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