scenery/

abstract.*

class ts2.scenery.abstract.ResizableItem(parameters)[source]

Bases: ts2.scenery.abstract.TrackItem

ResizableItem is the base class for all TrackItem‘s which can be resized by the user in the editor, such as LineItem‘s or PlatformItem‘s.

__init__(parameters)[source]
Parameters:parameters (dict) –
end
Returns:The end of the TrackItem is generally the right end of the track represented on the TrackItem
Return type:QPointF
for_json()[source]
Returns:Dumps this resizeable item to JSON.
Return type:dict
static getProperties()[source]
Returns:a list of properties
Return type:list
graphicsBoundingRect(itemId)[source]
Returns:the bounding rectangle of this ResizableItem.
Return type:QRect
graphicsMouseMoveEvent(event, itemId=0)[source]

This function is called by the owned TrackGraphicsItem to handle its mouseMoveEvent(). Reimplemented in the ResizableItem class to begin a drag operation on corners.

origin
Returns:The origin of TrackItem is generally the left end of the track represented on the TrackItem
Return type:QPointF
start
Returns:The start of a TrackItem is a point that is in the same place than origin, but resizes the item when moved instead of moving the item.
Return type:QPointF
class ts2.scenery.abstract.TrackItem(parameters)[source]

Bases: PyQt5.QtCore.QObject

A TrackItem is a piece of scenery and is a base class. Each item has defined coordinates in the scenery layout and is connected to other items so that the trains can travel from one to another.

  • The coordinates are expressed in pixels
  • The origin is the top left most corner of the scene
  • The X-axis is from left to right
  • The Y-axis is from top to bottom.
__init__(parameters)[source]
Parameters:parameters – JSON object holding the parameters to create the TrackItem
conflictTI
Returns:The conflicting item
Return type:TrackItem
conflictTiId
Returns:the conflict trackitem ID.
Return type:str
distanceToTrainEnd(pos)[source]
Parameters:pos
Returns:the distance in metres to the closest end (either trainHead or

trainTail) of the closest train when on pos. :rtype: float

drawConnectionRect(painter, point)[source]

Draws a connection rectangle on the given painter at the given point.

Parameters:
  • painter (QPainter) – the painter to paint on
  • point (QPointF) – the point to draw on
end
Returns:The end of the TrackItem is generally the right end of the track represented on the TrackItem
Return type:QPointF
for_json()[source]
Returns:Dumps this item to JSON.
Return type:dict
getFollowingItem(precedingItem, direction=-1)[source]
Parameters:
  • precedingItem – TrackItem where we come from (along a route)
  • direction – The direction
Returns:

the following TrackItem linked

to this one, knowing we come from precedingItem.

Returned isEither _nextItem or _previousItem,depending which way we come from.

Return type:

TrackItem

getPen()[source]
Returns:the standard pen for drawing trackItems
Return type:QPen
graphicsBoundingRect(itemId)[source]
Returns:The bounding rectangle of the owned TrackGraphicsItem.
Return type:QRectF
graphicsDragEnterEvent(event, itemId)[source]

This function is called by the owned TrackGraphicsItem to handle its dragEnterEvent. The implementation in the base class TrackItem does nothing.

graphicsDragLeaveEvent(event, itemId)[source]

This function is called by the owned TrackGraphicsItem to handle its dragLeaveEvent. The implementation in the base class TrackItem does nothing.

graphicsDropEvent(event, itemId)[source]

This function is called by the owned TrackGraphicsItem to handle its dropEvent. The implementation in the base class TrackItem does nothing.

graphicsItem

Returns the graphics item of this TrackItem

graphicsMouseMoveEvent(event, itemId=0)[source]

This function is called by the owned TrackGraphicsItem to handle its mouseMoveEvent. The implementation in the base class TrackItem begins a drag operation.

graphicsMousePressEvent(event, itemId)[source]

This function is called by the owned TrackGraphicsItem to handle its mousePressEvent. The default implementation in the base class trackItem does nothing.

graphicsPaint(painter, options, itemId, widget=None)[source]

This function is called by the owned TrackGraphicsItem to paint its painter. The implementation in the base class TrackItem outlines the shape of the item, if it is selected.

graphicsShape(shape, itemId)[source]

This function is called by the owned TrackGraphicsItem to return its shape. The given argument is the shape given by the parent class.

initialize(simulation)[source]

Initialize the item after all items are loaded.

isOnPosition(p)[source]
Parameters:p
Returns:todo
Return type:bool
maxSpeed
Returns:The maximum speed allowed on this LineItem, in metres per second
Return type:float
name
Returns:the unique name of the trackItem
Return type:str
nextItem
Returns:Next Item
Return type:TrackItem
origin
Returns:The origin of TrackItem is generally the left end of the track represented on the TrackItem
Return type:QPointF
previousItem
Returns:Previous Item
Return type:TrackItem
realLength
Returns:Length of this track item in real life metres.
Return type:int
registerTrain(train)[source]

Registers the given train on this trackItem.

Parameters:train – Train instance to register
removeAllGraphicsItems()[source]

Removes all the graphics items associated with this TrackItem from the scene.

resetActiveRoute()[source]

Resets the activeRoute and activeRoutePreviousItem informations. It is called upon route desactivation.

selected
Returns:True if the item is selected.
Return type:bool
setActiveRoute(r, previous)[source]

Sets the activeRoute and activeRoutePreviousItem informations. It is called upon Route activation. These information are used when other routes are activated in order to check the potential conflicts.

Parameters:
  • r – The newly active Route on this TrackItem.
  • previous – The previous TrackItem on this route (to know the direction).
setupTriggers()[source]

Creates the triggers necessary for this trackItem. Base implementation does nothing.

tiTypeStr
Returns:the type of this TrackItem as a txt to be displayed
Return type:str
toolTipText
Returns:the text to show on the tool tip.
Return type:str
trainHeadActions(trainId)[source]

Performs the actions to be done when a train head reaches this TrackItem

trainPresent()[source]
Returns:True if at least one train is present on this TrackItem.
Return type:bool
trainTailActions(trainId)[source]

Performs the actions to be done when a train tail reaches this TrackItem

unRegisterTrain(train)[source]

Removes the given train from the registry of this item.

Parameters:train – Train instance to unregister
updateTrain()[source]

Updates the graphics item for train only

updateTrainHeadAndTail()[source]

Updates the _trainHeads and _trainTails lists from the _trains data. _trainHeads are always the closest to nextItem() whereas _trainTails are always the closest to previousItem(), whatever the trains’ direction and real trainHead and trainTail.

ts2.scenery.abstract.qPointFDestrizer(attr)[source]

Returns a function which updates a QPointF property from a string representation of a QPointF.

ts2.scenery.abstract.qPointFDetupler(attr)[source]

Returns a function which updates a QPointF property from a tuple representation of a QPointF.

ts2.scenery.abstract.qPointFStrizer(attr)[source]

Returns a function giving the str representation of attr, the latter being a QPointF property.

ts2.scenery.abstract.qPointFTupler(attr)[source]

Returns a function giving the tuple representation of attr, the latter being a QPointF property.

ts2.scenery.abstract.translate(str, str, str disambiguation=None, int n=-1) → str

enditem.*

class ts2.scenery.enditem.EndItem(parameters)[source]

Bases: ts2.scenery.abstract.TrackItem

End items are invisible items to which the free ends of other trackitems must be connected to prevent the simulation from crashing.

End items are defined by:

  • their titype which is “E”
  • and their position (x, y)
  • They are single point items
__init__(parameters)[source]
Parameters:paramaters (dict) –
end
Returns:a point far away of the scene
Return type:QPointF
for_json()[source]

Dumps this end item to JSON.

getFollowingItem(precedingItem, direction=-1)[source]

Reimplemented from TrackItem . getFollowingItem()

Returns:None if going to the free end
Return type:None or TrackItem
graphicsBoundingRect(itemId)[source]

Reimplemented from TrackItem . graphicsBoundingRect()

Returns:The bounding rectangle of the owned TrackGraphicsItem.
Return type:QRectF
graphicsPaint(p, options, itemId, widget=0)[source]

Reimplemented from TrackItem.graphicsPaint

initialize(simulation)[source]

Initialize the item after all items are loaded.

helper.*

class ts2.scenery.helper.TIProperty(name, display, readOnly=False, propType='str', enumNames=None, enumValues=None)[source]

Bases: object

This class holds a TrackItem property that can be edited in the editor

__init__(name, display, readOnly=False, propType='str', enumNames=None, enumValues=None)[source]

Constructor for the TIProperty class

__weakref__

list of weak references to the object (if defined)

class ts2.scenery.helper.TrackGraphicsItem(trackItem, itemId=0)[source]

Bases: PyQt5.QtWidgets.QGraphicsItem

Graphical item of a trackItem

This class is the graphics of a TrackItem on the scene. Each instance belongs to a trackItem which is defined in the constructor and which is responsible for all actions related to this graphical item.

__init__(trackItem, itemId=0)[source]
Parameters:
  • trackItem (TrackItem) – The object to draw for
  • itemId – Id of this item
boundingRect()[source]
Returns:The bounding rectangle of this TrackGraphicsItem. See QGraphicsItem::boundingRect() for more info. Actually calls the graphicsBoundingRect() function of the owning trackItem
Return type:QRectF
dragEnterEvent(event)[source]

Event handler for when drag enters the item. This function calls the graphicsDragEnterEvent function of the owning TrackItem to handle the event

dragLeaveEvent(event)[source]

Event handler for when drag leaves the item. This function calls the graphicsDragLeaveEvent function of the owning TrackItem to handle the event

dropEvent(event)[source]

Event handler for drop event on this item. This function calls the graphicsDropEvent function of the owning TrackItem to handle the event

mouseMoveEvent(event)[source]

Event handler for mouse pressed. This function calls the graphicsMousePressEvent function of the owning TrackItem to handle the event

mousePressEvent(event)[source]

Event handler for mouse pressed. This function calls the graphicsMousePressEvent function of the owning TrackItem to handle the event

paint(painter, option, widget=None)[source]

Painting function for the SignalGraphicsItem. This function calls the graphicsPaint function of the owning TrackItem to paint its painter.

shape()[source]

Returns the shape of this item as a QPainterPath in local coordinates.

class ts2.scenery.helper.TrackPropertiesModel(trackItems)[source]

Bases: PyQt5.QtCore.QAbstractTableModel

This class is a model for accessing TrackItem properties in the editor

__init__(trackItems)[source]

Constructor for the TrackPropertiesModel class

columnCount(parent=None, *args)[source]

Returns the number of columns of the model, i.e. 2, one for the property name, and one for the property value.

data(index, role=0)[source]

Returns the data at the given index

flags(index)[source]

Returns the flags of the model

headerData(section, orientation, role=0)[source]

Returns the header labels

rowCount(parent=None, *args)[source]

Returns the number of rows of the model, corresponding to the number of properties.

setData(index, value, role=2)[source]

Sets the data to the model

ts2.scenery.helper.translate(str, str, str disambiguation=None, int n=-1) → str

invisiblelinkitem.*

class ts2.scenery.invisiblelinkitem.InvisibleLinkItem(parameters)[source]

Bases: ts2.scenery.lineitem.LineItem

InvisibleLinkItem behave like line items, but are not represented at all on the scenery. They are used to make links between lines or to represent bridges and tunnels.

__init__(parameters)[source]

Constructor for the InvisibleLinkItem class

graphicsPaint(p, options, itemId, widget=None)[source]

This function is called by the owned TrackGraphicsItem to paint its painter. Draws nothing during the game.

updateTrain()[source]

Does nothing as this is an invisible link.

lineitem.*

class ts2.scenery.lineitem.LineItem(parameters)[source]

Bases: ts2.scenery.abstract.ResizableItem

A line is a simple track used to connect other items together. The important parameter of a line is its real length, i.e. the length it would have in real life, since this will determine the time the train takes to travel on it.

__init__(parameters)[source]

Constructor for the LineItem class

drawTrain()[source]

Draws the train(s) on the line, if any

end
Returns:The end of the TrackItem is generally the right end of the track represented on the TrackItem
Return type:QPointF
for_json()[source]

Dumps this line item to JSON.

graphicsBoundingRect(itemId)[source]

Returns the bounding rectangle of the line item

graphicsMousePressEvent(event, itemId)[source]

This function is called by the owned TrackGraphicsItem to handle its mousePressEvent. Reimplemented to send the positionSelected signal.

graphicsPaint(p, options, itemId, widget=None)[source]

This function is called by the owned TrackGraphicsItem to paint its painter. Draws the line.

graphicsShape(shape, itemId)[source]

This function is called by the owned TrackGraphicsItem to return its shape. The given argument is the shape given by the parent class.

initialize(simulation)[source]

Initialize the item after all items are loaded.

line

Returns the line as a QLineF in the item’s coordinates.

origin
Returns:The origin of TrackItem is generally the left end of the track represented on the TrackItem
Return type:QPointF
placeCode

Returns the place code corresponding to this LineItem.

realLength
Returns:Length of this track item in real life metres.
Return type:int
sceneLine

Returns the line as a QLineF in the scene’s coordinates.

showTrainLineItem(lines)[source]

Shows the given lines (representing trains) on the scenery.

start
Returns:The start of a TrackItem is a point that is in the same place than origin, but resizes the item when moved instead of moving the item.
Return type:QPointF
trackCode

Returns the track code corresponding to this LineItem. The trackCode enables to identify each line in a place (typically a station)

updateGeometry()[source]

Updates the internal representation of the line and boundingRect when it has been modified

updateGraphics()[source]

Updates the TrackGraphicsItem owned by this LineItem

updateTrain()[source]

Updates the graphics for trains movements only

ts2.scenery.lineitem.translate(str, str, str disambiguation=None, int n=-1) → str

placeitem.*

class ts2.scenery.placeitem.Place(parameters)[source]

Bases: ts2.scenery.abstract.TrackItem

A Place is a place where trains will have a schedule (mainly station, but can also be a main junction for example)

__init__(parameters)[source]

Constructor for the Place class

for_json()[source]

Dumps this place item to JSON.

graphicsBoundingRect(itemId)[source]

This function is called by the owned TrackGraphicsItem to return its bounding rectangle

graphicsPaint(p, options, itemId, widget=None)[source]

This function is called by the owned TrackGraphicsItem to paint its painter.

name
Returns:the unique name of the trackItem
Return type:str
placeCode

Returns the place code of this place

sortTimetable()[source]

Sorts the timetable of the place.

updateBoundingRect()[source]

Updates the bounding rectangle of the graphics item

class ts2.scenery.placeitem.PlacesModel(editor)[source]

Bases: PyQt5.QtCore.QAbstractTableModel

Model listing places to be used in item delegates.

ts2.scenery.placeitem.translate(str, str, str disambiguation=None, int n=-1) → str

platformitem.*

class ts2.scenery.platformitem.PlatformItem(parameters)[source]

Bases: ts2.scenery.abstract.ResizableItem

Platform items are represented as a colored rectangle on the scene to symbolise the platform. This colored rectangle permits user interaction.

__init__(parameters)[source]

Constructor for the PlatformItem class

for_json()[source]

Dumps this platform item to JSON.

graphicsMousePressEvent(e, itemId)[source]

Reimplemented from TrackItem.graphicsMousePressEvent to handle the mousePressEvent of the owned TrackGraphicsItem. It processes mouse clicks on the platform and emits the signal platformSelected.

graphicsPaint(painter, options, itemId, widget=None)[source]

This function is called by the owned TrackGraphicsItem to paint its painter. Draws the rectangle.

initialize(simulation)[source]

Initialize the item after all items are loaded.

placeCode

Returns the place code corresponding to this LineItem.

toolTipText

Returns the string to show on the tool tip

trackCode

Returns the track code corresponding to this LineItem. The trackCode enables to identify each line in a place (typically a station)

ts2.scenery.platformitem.translate(str, str, str disambiguation=None, int n=-1) → str

pointsitem.*

class ts2.scenery.pointsitem.PointsItem(parameters)[source]

Bases: ts2.scenery.abstract.TrackItem

A PointsItem is a three-way junction.

The three ends and called:

  • common end
  • normal end
  • reverse end
                    ____________ reverse
                   /
common ___________/______________normal
  • Trains can go from common end to normal or reverse ends depending on the state of the points.
  • They cannot go from normal end to reverse end.
  • Usually, the normal end is aligned with the common end and the reverse end is sideways, but this is not mandatory.
__init__(parameters)[source]
Parameters:paramaters (dict) –
center
Returns:the center point of the PointsItemn the scene’s coordinates.
Return type:QPointF
commonEnd
Returns:the common end point in the item’s coordinates
Return type:QPointF
commonItem
Returns:the item linked to the common end of this PointsItem,
Return type:TrackItem
end
Returns:the origin point of the PointsItem, which is actually the normal end in the scene coordinates
Return type:QPointF
for_json()[source]

Dumps this points item to JSON.

getFollowingItem(precedingItem, direction=-1)[source]

Overload of TrackItem.getFollowingItem for PointsItem, including the direction

Parameters:
  • precedingItem – The TrackItem we come from
  • direction

    The direction of the points

    • 0 => normal
    • positive => reverse
    • negative => according to self._pointsReversed
static getProperties()[source]
Returns:List of ptoperties
Return type:list
graphicsBoundingRect(itemId)[source]

This function is called by the owned TrackGraphicsItem to return its bounding rectangle. Reimplemented from TrackItem

graphicsMousePressEvent(event, itemId)[source]

This function is called by the owned TrackGraphicsItem to handle its mousePressEvent. In the PointsItem class, this function reverses the points.

graphicsPaint(p, options, itemId, widget=None)[source]

Draws the points on the painter given as parameter. This function is called by PointsGraphicsItem.paint. @param p The painter on which to draw the signal.

initialize(simulation)[source]

Initialize the item after all items are loaded.

middle
Returns:the central poin of the PointsItem, in the item’s coordinates.
Return type:QPointF
normalEnd
Returns:the normal end in the item’s coordinates.
Return type:QPointF
normalItem
Returns:the TrackItem linked to the normal end of this PointsItem,
Return type:TrackItem
origin
Returns:the origin point of the PointsItem, which is actually the common end in the scene coordinates
Return type:QPointF
pointsReversed
Returns:True if the points are reversed, otherwise False
Return type:bool
reverse
Returns:the reverse point of the PointsItem, which is actually the reverse end in the scene coordinates
Return type:QPointF
reverseEnd
Returns:the reverse end in the item’s coordinates.
Return type:QPointF
reverseItem
Returns:the TrackItem linked to the reverse end of this PointsItem,
Return type:TrackItem
setActiveRoute(r, previous)[source]

Sets the active route information (see TrackItem.setActiveRoute()). Here, this function also changes the points direction.

toolTipText
Returns:text to show on the tool tip
Return type:str
ts2.scenery.pointsitem.getEndNames()[source]
Returns:a list of point end names TODO
ts2.scenery.pointsitem.getEndValues()[source]
Returns:a list of values TODO
ts2.scenery.pointsitem.translate(str, str, str disambiguation=None, int n=-1) → str

textitem.*

class ts2.scenery.textitem.TextItem(parameters)[source]

Bases: ts2.scenery.abstract.TrackItem

A TextItem is a prop to display simple text on the layout

__init__(parameters)[source]

Constructor for the TextItem class

graphicsBoundingRect(itemId)[source]

This function is called by the owned TrackGraphicsItem to return its bounding rectangle

graphicsPaint(p, options, itemId, widget=None)[source]

This function is called by the owned TrackGraphicsItem to paint its painter.

initialize(simulation)[source]

Initialize the item after all items are loaded.

text

Returns the text to display

updateBoundingRect()[source]

Updates the bounding rectangle of the graphics item

ts2.scenery.textitem.translate(str, str, str disambiguation=None, int n=-1) → str

signals.signalsaspect.*

class ts2.scenery.signals.signalaspect.SignalAspect(parameters)[source]

Bases: object

SignalAspect class represents an aspect of a signal, that is a combination of on and off lights with a meaning for the train driver.

__init__(parameters)[source]

Constructor for the SignalAspect class.

__weakref__

list of weak references to the object (if defined)

boundingRect()[source]

Return the boundingRect of this aspect.

drawAspect(p, linePen, shapePen, persistent=False)[source]

Draws the aspect on the given painter p. Draws the line with linePen and the shapes with shapePen.

static drawShape(p, shape, rect)[source]

Draws a signal aspect shape.

Parameters:
  • p – The painter on which to draw the shape
  • shape (SignalShape) – The shape to draw
  • rect (QRectF) – The rect inside which to draw the shape on the painter
for_json()[source]

Dumps this SignalAspect to JSON.

meansProceed()[source]

Returns true if this aspect is a proceed aspect, returns false if this aspect requires to stop.

class ts2.scenery.signals.signalaspect.SignalLineStyle[source]

Bases: object

This class holds the possible representation shapes for the line at the base of the signal.

__weakref__

list of weak references to the object (if defined)

class ts2.scenery.signals.signalaspect.SignalShape[source]

Bases: object

This class holds the possible representation shapes for signal lights.

__weakref__

list of weak references to the object (if defined)

class ts2.scenery.signals.signalaspect.Target[source]

Bases: object

This class defines when a speed limit associated with a signal aspect must be applied.

__weakref__

list of weak references to the object (if defined)

signals.signalitem.*

class ts2.scenery.signals.signalitem.SignalItem(parameters)[source]

Bases: ts2.scenery.abstract.TrackItem

Logical item for signals.

  • This class holds the logic of a signal defined by its SignalType.
  • A signal is the item from and to which routes are created.
__init__(parameters)[source]
Parameters:paramaters (dict) –
activeAspect

Returns the current aspect of the signal.

aspectChanged

pyqtSignal()

berthItem

Returns the berth graphics item.

berthOrigin

Returns the origin of the berth graphics item as a QPointF.

berthRect

Returns the boundingRect of the berth graphics items.

end

Returns the end QPointF of the TrackItem. The end is generally the right end of the track represented on the TrackItem

for_json()[source]

Dumps the signalItem to JSON.

getNextSignal()[source]

Helper function that returns the next signal of SignalItem.

If a route starts from this signal, the next signal is the end signal of this route. Otherwise, it is the next signal found on the line.

graphicsBoundingRect(itemId)[source]

Reimplemented from TrackItem.graphicsBoundingRect to return the bounding rectangle of the owned TrackGraphicsItem.

graphicsMouseMoveEvent(event, itemId=0)[source]

This function is called by the owned TrackGraphicsItem to handle its mouseMoveEvent. The implementation in the base class TrackItem begins a drag operation.

graphicsMousePressEvent(e, itemId)[source]

Reimplemented from TrackItem.graphicsMousePressEvent to handle the mousePressEvent of the owned TrackGraphicsItem. It processes mouse clicks on the signal and emits the signals signalSelected, trainSelected, or signalUnselected depending on the case.

graphicsPaint(p, options, itemId, widget=0)[source]

Reimplemented from TrackItem.graphicsPaint to draw the signal on the owned TrackGraphicsItem

initialize(simulation)[source]

Initialize the signal item once everything is loaded.

isOnPosition(p)[source]

Checks that the signalItem is on the position p, i.e. the trackItem and direction are the same :param p: the position :return True if the signalItem is on position p

nextActiveRoute

Returns the active route starting from this signal if it exists.

origin
Returns:The origin of TrackItem is generally the left end of the track represented on the TrackItem
Return type:QPointF
previousActiveRoute

Returns the active route ending at this signal if it exists.

resetActiveRoute()[source]

Overridden here to update signal state.

resetNextActiveRoute(route=None)[source]

Resets the nextActiveRoute information. If route is not None, do this only if the nextActiveRoute is equal to route.

resetPreviousActiveRoute(route=None)[source]

Reset the previousActiveRoute information. If route is not None, do this only if the previousActiveRoute is equal to route.

resetTrainId()[source]

Resets the trainId of this signal.

reverse
Returns:True if the SignalItem is from right to left, otherwise False
Return type:bool
setActiveRoute(r, previous)[source]

Overridden here to update signal state.

setBerthRect()[source]

Sets the berth graphics item boundingRect.

setupTriggers()[source]

Create the triggers necessary for this Item.

signalSelected

pyqtSignal(int, bool, bool)

signalType

Returns the signal type of this SignalItem.

signalTypeStr

Returns the signal type name of this SignalItem.

signalUnselected

pyqtSignal(int)

toolTipText

Returns the string to show on the tool tip

trainHeadActions(trainId)[source]

Actions to be performed when the train head reaches this signal.

Pushes the train code to the next signal.

trainId

Returns the train internal Id.

trainSelected

pyqtSignal(int)

trainServiceCode

Returns the trainServiceCode of this signal. This is for display only.

trainTailActions(trainId)[source]

Actions that are to be done when a train tail reaches this signal. It deals with desactivating this signal.

trainsAhead()[source]

Returns true if there is a train ahead of this signalItem and before the end of the next active route or the next signal if no route is set.

unselect()[source]

Unselect the signal.

updateSignalParams()[source]

Updates signal custom parameters according to the SignalType.

updateSignalState()[source]

Update the signal current aspect.

class ts2.scenery.signals.signalitem.SignalLibrary(parameters)[source]

Bases: object

A SignalLibrary holds the informations about the signal types and signal aspects available in the simulation.

At runtime, each simulation has SignalLibrary instance which is filled with: - The built-in UK_3_ASPECTS and BUFFER signal types and their aspects - The signal types defined in tsl files in the data directory - The signal types defined in the simulation itself.

__init__(parameters)[source]

Constructor for the SignalLibrary class.

__weakref__

list of weak references to the object (if defined)

static createSignalLibrary()[source]

Returns a SignalLibrary with the builtin signal types and those defined in tsl files in the data directory.

for_json()[source]

Dumps this SignalLibrary to JSON.

initialize()[source]

Initializes the SignalLibrary once it is totally loaded.

update(other)[source]

Updates this SignalLibrary instance by adding signal aspects and signal types from the other SignalLibrary. If signal aspects or signal types of the same name exists in both SignalLibrary instance, the data in the other SignalLibray will overwrite the data of this SignalLibrary.

class ts2.scenery.signals.signalitem.SignalState(parameters)[source]

Bases: object

A SignalState is an aspect of a signal with a set of conditions to display this aspect.

__init__(parameters)[source]

Constructor for the SignalState class.

__weakref__

list of weak references to the object (if defined)

conditionsMet(signalItem, params=None)[source]

Returns True if all conditions of this SignalState are met (or if there is no conditions) on the given signalItem instance.

for_json()[source]

Dumps this SignalState to JSON.

initialize(signalLib)[source]

Initializes the SignalState once we know the SignalState it belongs to.

class ts2.scenery.signals.signalitem.SignalType(parameters)[source]

Bases: object

A SignalType describes a type of signals which can have different aspects and the logic for displaying aspects.

__init__(parameters)[source]
Parameters:paramaters (dict) –
__weakref__

list of weak references to the object (if defined)

for_json()[source]

Dumps this signalType to JSON.

getAspect(signalItem)[source]

Returns the aspect that must be active in the context of signalItem.

getCustomParams(signalItem)[source]
Parameters:signalItem – A SignalItem instance
Returns:The custom parameters of SignalItem. The params dict has keys which are condition names and values which are dict with signal aspect name as keys and a list of parameters as values.
Return type:dict
getDefaultAspect()[source]
Returns:The default aspect for this SignalType.
Return type:SignalState
initialize(signalLib)[source]

Initializes this SignalType once the SignalLibrary is loaded.

updateParams(signalItem)[source]

Updates all user parameters of signalItem according to this SignalType.

ts2.scenery.signals.signalitem.condition(cls)[source]

Decorator to register a class as a condition.

Conditions are classes which include: - A ‘code’ class attribute - A ‘solver’ function with a signalItem and a params list as parameters. The solver function must return True if the signalItem currently meets the condition(s) defined by the condition class. - A ‘tiProperty’ class attribute being the TIProperty of custom parameters associated to this condition. The TIProperty name must not finish by ‘Str’. - An ‘updater’ function which takes a signalItem and a params dict as parameters. The params dict has keys which are condition codes and values which are dict with signal aspect name as keys and a list of parameters as values. The updater function must update this params dict according to the signal item. - A ‘trigger’ function which sets up triggers as Qt signals/slot connections between other objects and this signal.

ts2.scenery.signals.signalitem.json_hook(dct)[source]

Hook method for json loading of signal library. :param dict dct: the dictionary to load :return: An class of __type__ :rtype: Class instance

ts2.scenery.signals.signalitem.translate(str, str, str disambiguation=None, int n=-1) → str