The SignalControl library is created with a set of interfaces that describe its responsibility. Interfaces are implemented by classes that implement this responsibility. There may be multiple classes that implement the responsibility.
Each interface and its implementing classes is designed to have only one responsibility. Anything indirectly related is delegated to objects defined by an interface that describes the delegated responsiblities.
Example: The Light
interface describes the responsibility
to show a single light. This light may be on, off or blinking.
Implementing classes define how this is done for example by
representing an LED connected to an output pin.
Gets information somewhere and returns a digital answer.
This inverts the result of a DigitalInput object.
Input:
- DigitalInput - The object to invert the result for.
The operator ! can also be used.
Returns the "logical and" of two DigitalInput objects
Input:
- DigitalInput x 2 - The two objects to combine the result for as "logical and".
The operator && can also be used.
Returns the "logical or" of two DigitalInput objects
Input:
- DigitalInput x 2 - The two objects to combine the result for as "logical or".
The operator && can also be used.
This converts the result of a DistanceInput object to a digital answer. The result is true if the DistanceInput object returns at least one unoccupied track block.
Input:
- DistanceInput - The object that keeps track of how many track blocks are free past the signal.
Returns the result of a digital input pin. The pin is considered to have "Active LOW" logic, i.e. the returned result is true if the pin is LOW.
Input:
- pin number : Pin to return the result for.
The input state is controlled by two input pins. One for setting ON and one for OFF. This is useful for example using a push button for setting a signal to clear, and a train sensor to set the signal to stop once the train passes over the sensor.
Inputs:
- on DigitalInput: input that sets this input to ON.
- off DigitalInput: input that sets this input back to OFF.
Returns a state that can be set programmatically.
Input:
- Initial state (default false)
Returns the number of unoccupied track blocks. This is used by signals to decide which aspect to show.
Example: If there are no unoccupied track blocks a 0 is returned telling the signal that it shall show stop/danger.
Used when the track in advance of the signal has potential obstacles such as a point set against the route ahead of the signal.
Inputs:
- DistanceInput - describes the number of unoccupied track blocks in advance of the signal in normal cases.
- DigitalInput - when this returns falls, makes the signal set to danger/stop.
Used for facing points where the number of free blocks used by the signal depends on the route selected by the point.
Inputs:
- DigitalInput - conditional input from the facing point.
- DistanceInput - normal route. This is the chosen route when the point is set to the normal route, i.e. the conditional input is false.
- DistanceInput - diverging route. This is the chosen route when the point is set to the diverging route, i.e. the conditional input is true.
Uses track sensors to determine how many track blocks are available.
Inputs: One of:
- Trigger and a DistanceInput.
- Trigger is a DigitalInput object for the nearest block.
- DistanceInput is an object representing the route in advance of the nearest block.
- One, two or three triggers. These triggers can be either:
- pin numbers - number of input pin that is connected to the sensor for the each track block in advance of the signal.
- DigitalInput - input objects for each track block.
Instead of counting the actual free blocks this class uses a timer to simulate the number of blocks a passing train would leave unoccupied as time passes. This is a cheap solution as only one trigger is required.
Inputs:
- trigger - can be one of
- DigitalInput - triggers the timer when object returns true.
- pin - pin number that is connected to a sensor that detects a train that passes the signal. Triggers the timer when the pin goes LOW.
Responsible for handling each light in a signal.
Implements blinking of a delegated Light
object.
Inputs:
- Light - Another
Light
object that is delegated to. - blink interval (default=1s)
- start state (default=false)
Implements a simple light that consists of an LED connected to an output pin. The LED can be turned on or off.
Inputs:
- pin number - the pin the LED is connected to.
- pin polarity (default COMMON_CATHODE) - should this pin be HIGH or LOW when the LED is on?
- on (default false) - should this LED be on at startup?
Implements a light that consists of an LED connected to an output pin. This implementation changes the LED slowly by using a PWM pin.
Inputs:
- pin number - the pin the LED is connected to.
- pin polarity (default COMMON_CATHODE) - should this pin be HIGH(255) or LOW(0) when the LED is on?
- transition interval (default 500 ms) - Determines how long it takes for the light to change to on or off.
- on (default false) - should this LED be on at startup?
Not implemented yet. Signal objects share no interface.
A 2 aspect signal. Will show green or red depending on the input object.
Inputs:
- Input object. Can be one of:
- DigitalInput - Show red if input is false and green if input is true.
- DistanceInput - Shows red if there are 0 unoccupied tracks and green otherwise.
- green light - A Light object that shows a green light.
- red light - A Light object that shows a red light.
A 3 aspect signal. Will show green, red or yellow depending on the DistanceInput object.
Inputs:
- DistanceInput - Shows red if there are 0 unoccupied tracks and green otherwise.
- green light - A Light object that shows a green light.
- red light - A Light object that shows a red light.
- yellow light - A Light object that shows a yellow light.
A 4 aspect signal. Will show green, red, yellow or double yellow depending on the DistanceInput object.
Inputs:
- DistanceInput - Shows red if there are 0 unoccupied tracks and green otherwise.
- green light - A Light object that shows a green light.
- red light - A Light object that shows a red light.
- yellow light - A Light object that shows a yellow light.
- second yellow light - A Light object that shows a second yellow light.
Swedish four aspect signal. Included here for pushing capabilities of the library to some tricky aspects.