A Slot in the optical switch allows light to be blocked by a physical object (e.g. a flag passes though the slot)
http://optekinc.com/datasheets/opb960-990_series.pdf
Each red LED simulates an IR source in a Slotted optical switch (there are two switches). The green is an optical coupler input.
The Slotted switch has an NPN photo transistor which I sort of can simulate by driving the base with an IO (e.g. IR source is blocked when IO is zero).
For the detector to trigger in the same physical location each time the slot switch IR source needs to be bright and constant, thus it needs to be driven with a current source. Once the current has passed though the slot IR sources it can be divided up for use by the detector transistors, which is the job of the PNP mirror (which is not part of the optical switch).