Skip to content

Repository files navigation

Signals!

Build StatusDemo: Try yourself!

This is a toy project written in ClojureScript. It renders some German railway signals as SVG. You can try it yourself!

Setup

To be written 😱

Usage in your own project

The project is still being developed, so it can't yet be used from JavaScript directly. But you can use the signals from cljs.

(def!distant (atom {:type:distant:system:ks:distant {:aspect:stop}}))
(def!combination (atom {:type:combination:system:hv-light:distant {:aspect:proceed}
:main {:aspect:stop}}))
(def!main (atom {:type:main:system:hv-semaphore:main {:aspect:proceed}}))

To display the signals, you need to include the signals.css (or signals.styl if you use Stylus) and create a React component returning a svg element. Inside, you have to once include signals.signal/defs, then you can call signals.signal/signal passing the signal you want with the :signal key.

Here an example using UIx:

(require '[signals.signal :as signal])
($:svg {:version"1.1":viewBox"0 0 140 600":width"200":height"600"}
($ signal/defs)
($ signal/signal {:signal @!main}))

You can configure signals by adding features to the top level, to the :distant or :main part of the signal.

AttributewhereDescription
:systemtop levelType of the signal system, can be :ks, :hv-light, :hv-semaphore, or :hl
:typetop levelType of the signal, can be :distant, :main, or :combination
:aspect:distant/:mainThe aspect of the signal, valid values are :proceed, :stop, :stop+sh1, :stop+zs1, or :stop+zs7
:speed-limit:distant/:mainThe current speed limit. Only displayed with a :zs3 or :slow-speed-lights and :proceed aspect
:slow-speed-lights:distant/:mainA vector of possible speeds. For :hv-light & :hv-semaphore, only 40 is supported, for :hl, it can be 40, 60 and 100. :ks ignores this
:zs3:distant/:mainDoes the signal have a zs3? Possible values are nil (no zs3), :display or :sign. Ignored for :hl
:sh1?:mainBoolean, set to true when the signal when it's capable to display a Sh1/Ra12 aspect
:zs1?:mainBoolean, set to true if the signal has a Zs1
:zs7?:mainBoolean, set to true when the signal has a Zs7
:distant-addition:distantCan be nil (nothing), :repeater (if this is a repeater), or :shortened-break-path when the break path is shortened

Example:

(swap! !combination #(-> %1
(assoc:system:hv-semaphore)
(assoc-in [:main:aspect] :stop+sh1)
(assoc-in [:main:sh1?] true)
(assoc-in [:main:zs1?] true)
(assoc-in [:main:slow-speed-lights] [40])
(assoc-in [:main:speed-limit] 40)
(assoc-in [:distant:aspect] :proceed)
(assoc-in [:distant:distant-addition] :shortened-break-path)))

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages