Second Life Railroad/SLRR Switch

__TOC__	
500px|center
==Description==
The following page describes the working and standards used on the LDPW switch. The SLRR switch is part of the greater SLRR rail network and will be implemented over the next months.
==Background information==
On the Northern Continent (Heterocera Atoll) there are a few sections of railway line (see SLRR Map ). Some are under construction and other are in full operation. The LDPW has started work to get the 'Branch lines' and 'Passing tracks' connected to each other. In order to do this a rail switch was designed by .
The basis for the design of the switch was the concept; "The switch should work for the greatest number of existing rolling stock". For that reason the switch is design without active scripts inside the guide rail prims. Most of the parts of the switch are mostly cosmetics. The actual switching is done by changing the (invisible) center guide rail. This is done in such a way that physical trains as well as sensor driven train can use the switch. (see below for more details).
Some SL merchants already have made commercial version of a switch for the Guide rail available. Due to legal reasons the LDPW is not able to use these and therefor opted to make their own system.
==Drawing==
====Diagram of Switch parts====
* Guide rail (normally invisible but as example colored in)
*# white normal Guide rail
*# green normal Guide rail on the switch named "Guide" made not phantom, in other words, made solid
*# red switched off Guide rail and renamed "Alternate Guide" and made phantom
* Switch stand
* Sensors
*# A for trains going down the main line, from the merge side toward the heading of the switch
*# B for trains going down the branch line, from the merge side toward the heading of the switch
* Touch start Prim to allow SL Residents to change the switch setting
* Dwarf Signal Lights
====Switch stand signaling diagram====
==System description==
===Basics===
*A Guide rail in use (direction of travel, depicted in green)
 prim attributes
 - prim name: 'Guide'
 - NOT phantom
 - Material: Glass
 - Texture: Transparent 
*A Guide rail not in use (switched off, depicted in red)
 prim attributes
 - prim name: 'Alternate Guide'
 - phantom
 - Material: Glass
 - Texture: Transparent 
*Switch Stand Signal rotates 90deg. to reveal appropriate signal. It houses the main scripts that talk to the Guide rail sections as well as the train sensors A and B.
*Large invisible prim covering the Switch Stand to provide Touch start support (click-able switches)
*Sensors look straight up for 4 meters, sensing ACTIVE unflagged, with an arc as wide as the Loading Gauge. If a train is detected it will automatically switch to the appropriate setting. However, If you go too fast into a merge they may miss detecting the train. As sensors fire only once per second.
*Dwarf Signal Lights on the Merge side of the switch display a Green or Red light. A green Dwarf Signal on the side of the merge you are on, means the switch is set correctly. A red Dwarf Signal on the side of the merge you are on, mean switch set incorrectly. Going on past a red light may cause trains to derail.
===Switch stand Prim/linkset parameters and changes and data string===
 prim attributes
 - prim name: 'Switch Stand'
 - prim description: (see details below)
 - phantom
 - linked set: includes switch stand, touch prim and dwarf signals
 - Texture: multiple
 - Texture: full bright in parts
To provide touch support to each switch, there is a larger invisible cube placed over each switch (see drawing: purple box over the switch).<BR>
Simply hover your mouse over the area and click. These are very large and part of the linkset of the Switch.
The Object Description of the Switch Stand root prim holds a data string. This data will make it possible for train builders to semi-automate trains / train routes, as well as get enough information to message switches appropriately. i.e. control switches by sending messages 'main' or 'branch' to it.<BR>
String format -Identifier~Status~Heading Name~Mainline Name~Branch Name~messaging channel<BR>
Format uses ~ to separate fields of data and "." to designate hierarchies within fields
 Notation example:
 SimName.x.y.z~Main~Heading~Mainline~branch~channel
 Live example:
 Tuliptree.30.42.30~Branch~Calleta Station~TulipTree Station~VRC Yard~133
explanation of the live example:
* The switch is located in Tuliptree/30/42/30 (the coordinates reflect the root prim of the Switch Stands position)
* It is currently set to the branch
* The heading side goes to Calleta Station
* The main side goes to Tuliptree Station
* The branch side goes to VRC Yard
* It listens and talks on channel 133
So in this example the switch is set to the branch line that links the VRC-Yard in Tuliptree to the Calleta Station.
 If the switch was turned the other way (to mainline going straight ahead) it would read:
 Tuliptree.30.42.30~Main~Calleta Station~TulipTree Station~VRC Yard~133
The data string changes only the Status field during normal operation. The 'Status' field will display "Main" or "Branch" for train builders/scripters to sense and react.
The standard for the data string currently specifies the minimal info that a script can expect, but it is unclear if the standard forbids that extra information is added (and it should not). For maximal flexibility indexes could be used to read the data string from the description. Changes to the future data string inside the switches may happen. It is wise to plan for that when creating scripts that sense switches remotely.
===System messaging===
 *All switch systems message on a unique channel published in the Object Description of the switch stand linkset.
 *All switch systems listen for the message "Main" OR(not and) "Branch" on appropriate channel.
 *All switch systems llShout (100 meter) "Main" or "Branch" on the same channel once switch has completed changes. 
This allows signal changes up to 100 meters further up and down line. Including communication between LDPW construct and private installations.
===Sensors and mainline resets===
*Each switch installed on a mainline will reset to the mainline position 2.5 minutes after it is put in the branch position.
*On the merge side of each switch are two sensors. One for each side of the merge. These effectively "Spring" the switch correctly for traffic heading into the merge. When tripped they messages the switch and set it to the correct position.
*The llSensor scripts are placed in a prim 1.0x0.5x0.5 meter always with the X axis looking straight up and positioned/rotated with the top of the sensor flush with the top of the guide.
*These sensors look straight up for 4 meters, sensing ACTIVE unflagged, with an arc as wide as the Loading Gauge. However, If you go too fast into a merge they may miss detecting the train, as the sensors fire only once per second.
==Scripts==
It is the intention of the LDPW to publish scripts used in the switch setup here in the future.
 *I would like to publish the sensor code here, so everyone can verify that their trains are being sensed. 
 *Also i would like to post some code showing some examples of data wrangling from the Switch Stand Description.
 *Once approved, actual Switch code will be placed here as well.(Sylvan Mole)
Fine with me! (Michael Linden)
==Source==
The above information was provided by LDPW and edited for the wiki by . Thank You very much Stryker! Information confirmed and minor edits added by .
==References==
Here is a list of Related resources. You can find more information about the SLRR and other Rail related articles on these wiki pages and external websites.
Wiki pages:
* Second_Life_Railroad (main page)
* SLRR History
* SLRR Standards
* SLRR Switch
* Linden Department of Public Works
* Linden_Vehicle_Tutorial
* Virtual_Railway_Consortium Group wiki page
* Virtual_Railway_Consortium/SLRR_History SLRR History main page compiled by the VRC 
* Virtual_Railway_Consortium/SLRR_Stations SLRR and Resident station along the SLRR
External information:
* Wikipedia: Rail gauge
* Physics related LSL on LSLwiki.net
* Vehicle related LSL on LSLwiki.net
* Virtual Railway Consortium
Category:SL_Railroad