VVD Glazing Router

How a glazing order (frame + lens) is routed to one of four portals: DC, HUB-A, HUB-B or TOG.

The logic in brief

Checks run in this order. The first match wins.

  1. Interim mode (only when switched on): a client with a HUB is never glazed at DC. The HUB takes the order (frame from the HUB or the client; lens from the HUB or DC, or a lens DC substitutes). If the HUB is over max cap, TOG takes it when it can glaze it directly, otherwise it queues at the HUB. Clients without a HUB follow the checks below.
  2. DC: enough frame stock for the order and open jobs within max cap. The lens never blocks DC.
  3. Client's HUB, whatever its frame stock: each client has one HUB or none. A HUB within max cap that holds the lens glazes the order, because the frame never blocks it. The frame comes from the HUB's own stock (only if at least 1 frame stays after glazing), else the client sends their own.
  4. TOG: TOG lenses only. TOG needs enough frame stock and capacity. It makes its lenses on demand. TOG uses only its own frame stock; nothing is sent to it.
  5. Client's HUB without the lens: if TOG could not take it, a HUB within max cap still glazes the order. The lens ships from DC, or DC substitutes one.
  6. No frame at DC and no usable HUB: the client has no HUB, or its HUB is over max cap, so the client sends their own frame to DC. TOG's stock is not counted.
  7. Nothing else can take it: overflow to DC. A frame is never moved from a HUB to DC, and nothing is sent to or taken from TOG.

On every assignment, the order's frame and lens quantities are deducted from real stock and the portal's open jobs go up by one.