Skip to content

Commit

Permalink
Details
Browse files Browse the repository at this point in the history
  • Loading branch information
iGEL committed Nov 30, 2023
1 parent b1c6a6f commit b742e9a
Show file tree
Hide file tree
Showing 8 changed files with 109 additions and 102 deletions.
93 changes: 46 additions & 47 deletions src/signals/hl.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,16 @@
:shortened-break-path? (= :shortened-break-path distant-addition)}))

(defui stripe-lamp [{:keys [x color yellow-stripe green-stripe]}]
($ lamp/lamp {:color color
:state (if (= :green color)
green-stripe
yellow-stripe)
:size :small
:x x
:y (if (and (= :green color)
yellow-stripe)
200
227)}))
($ lamp {:color color
:state (if (= :green color)
green-stripe
yellow-stripe)
:size :small
:x x
:y (if (and (= :green color)
yellow-stripe)
200
227)}))

(defui view [{:keys [signal]}]
{:pre [(p/arg! ::signal/signal signal)]}
Expand All @@ -104,41 +104,41 @@
($ :path {:d (if red
"M 0,9 8,0 62,0 l 9,9 0,175 -72,0 z"
"M -0,9 8,0 62,0 l 9,9 0,122 -72,0 z")})
($ lamp/lamp {:color :yellow
:state top-yellow
:size :big
:x 20
:y 30})
($ lamp/lamp {:color :green
:state top-green
:size :big
:x 50
:y 30})
($ lamp/lamp {:color :white
:state top-white
:size :small
:x 53
:y 63})
($ lamp/lamp {:color :red
:state red
:size :big
:x 35
:y 82})
($ lamp/lamp {:color :white
:state bottom-white
:size :small
:x 14
:y 99})
($ lamp/lamp {:color :yellow
:state bottom-yellow
:size :big
:x 20
:y 136})
($ lamp/lamp {:color :red
:state replacement-red
:size :big
:x 50
:y 136})
($ lamp {:color :yellow
:state top-yellow
:size :big
:x 20
:y 30})
($ lamp {:color :green
:state top-green
:size :big
:x 50
:y 30})
($ lamp {:color :white
:state top-white
:size :small
:x 53
:y 63})
($ lamp {:color :red
:state red
:size :big
:x 35
:y 82})
($ lamp {:color :white
:state bottom-white
:size :small
:x 14
:y 99})
($ lamp {:color :yellow
:state bottom-yellow
:size :big
:x 20
:y 136})
($ lamp {:color :red
:state replacement-red
:size :big
:x 50
:y 136})
(when (or yellow-stripe green-stripe)
(let [green {:color :green
:yellow-stripe yellow-stripe
Expand Down Expand Up @@ -166,6 +166,5 @@
(let [speeds (-> slow-speed-lights
set
(intersection #{40 60 100}))]
(or (and (nil? limit)
(seq speeds))
(or (nil? limit)
(speeds limit))))
4 changes: 2 additions & 2 deletions src/signals/hv_light.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,6 @@
(cond
(= :display zs3) true
(= :sign zs3) limit
(some #{40} slow-speed-lights) (or (nil? limit)
(= 40 limit))
(nil? limit) true
(some #{40} slow-speed-lights) (= 40 limit)
:else false))
2 changes: 1 addition & 1 deletion src/signals/ks.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -139,4 +139,4 @@
(case zs3
:display true
:sign limit
false))
(nil? limit)))
74 changes: 41 additions & 33 deletions src/signals/main.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@
($ defs)
(case (:system signal)
:ks ($ :<>
($ :g {:transform "translate(16,0)"})
($ zs3 {:signal signal})
($ :g {:transform "translate(16,0)"}
($ zs3 {:signal signal}))
($ :g {:transform "translate(19,65)"}
($ ks/view {:signal signal}))
($ :g {:transform "translate(16,168)"}
Expand All @@ -53,7 +53,12 @@
(not (= :repeater (-> signal :distant :distant-addition))))
($ :g {:transform "translate(33,500)"}
($ ne/ne2))))
:hl ($ hl/view {:signal signal})

:hl ($ :<> ($ hl/view {:signal signal})
(when (and (= :distant (:type signal))
(not (= :repeater (-> signal :distant :distant-addition))))
($ :g {:transform "translate(17,500)"}
($ ne/ne2 {:shortened-break-path? (-> signal hl/lights :shortened-break-path?)}))))
:hv-light ($ :<>
($ :g {:transform "translate(19,0)"}
($ zs3 {:signal signal}))
Expand All @@ -75,7 +80,7 @@
(when (and (= :distant (:type signal))
(not (= :repeater (-> signal :distant :distant-addition))))
($ :g {:transform "translate(33,500)"}
($ ne/ne2)))))))
($ ne/ne2 {:shortened-break-path? (-> signal hv-semaphore/arms :distant :shortened-break-path?)})))))))

(defui button [{:keys [on-click active? children disabled? type title]
:or {type "primary"}}]
Expand Down Expand Up @@ -137,9 +142,6 @@
:active? active?}
"Langsamfahrt"))))
($ :div.btn-group
($ button {:on-click #(set-state! :zs3 nil)
:type "info"
:active? (nil? (-> state :main :zs3))} "Kein")
(if (= :hl (:system state))
(let [slow-speed-lights (-> state :main :slow-speed-lights)
active-40? (some #{40} slow-speed-lights)
Expand Down Expand Up @@ -168,6 +170,9 @@
:active? active-100?}
"100")))
($ :<>
($ button {:on-click #(set-state! :zs3 nil)
:type "info"
:active? (nil? (-> state :main :zs3))} "Kein")
($ button {:on-click (fn []
(set-state! :zs3 :sign)
(when-not (-> state :main :speed-limit)
Expand Down Expand Up @@ -233,33 +238,34 @@
($ :tr
($ :th "System")
($ :td {:col-span 4}
($ :div
($ button {:on-click (fn []
(set-distant! (assoc distant :system :ks))
(set-repeater! (assoc repeater :system :ks))
(set-combination! (assoc combination :system :ks))
(set-main! (assoc main :system :ks)))
:active? (= :ks (:system main))} "Ks")
($ button {:on-click (fn []
(set-distant! (assoc distant :system :hv-light))
(set-repeater! (assoc repeater :system :hv-light))
(set-combination! (assoc combination :system :hv-light))
(set-main! (assoc main :system :hv-light)))
:active? (= :hv-light (:system main))} "H/V Lichtsignal")
($ button {:on-click (fn []
(set-distant! (assoc distant :system :hv-semaphore))
(set-repeater! (assoc repeater :system :hv-light))
(set-combination! (assoc combination :system :hv-semaphore))
(set-main! (assoc main :system :hv-semaphore)))
:active? (= :hv-semaphore (:system main))} "H/V Formsignal")
($ button {:on-click (fn []
(set-distant! (assoc distant :system :hl))
(set-repeater! (assoc repeater :system :hl))
(set-combination! (assoc combination :system :hl))
(set-main! (assoc main :system :hl)))
:active? (= :hl (:system main))} "Hl"))
(when (= :hv-semaphore (:system main))
($ :div.alert.alert-warning {:role "alert"}
"Positionierung der einzelnen Signale und Animationen sind noch unfertig"))
($ button {:on-click (fn []
(set-distant! (assoc distant :system :ks))
(set-repeater! (assoc repeater :system :ks))
(set-combination! (assoc combination :system :ks))
(set-main! (assoc main :system :ks)))
:active? (= :ks (:system main))} "Ks")
($ button {:on-click (fn []
(set-distant! (assoc distant :system :hv-light))
(set-repeater! (assoc repeater :system :hv-light))
(set-combination! (assoc combination :system :hv-light))
(set-main! (assoc main :system :hv-light)))
:active? (= :hv-light (:system main))} "H/V Lichtsignal")
($ button {:on-click (fn []
(set-distant! (assoc distant :system :hv-semaphore))
(set-repeater! (assoc repeater :system :hv-light))
(set-combination! (assoc combination :system :hv-semaphore))
(set-main! (assoc main :system :hv-semaphore)))
:active? (= :hv-semaphore (:system main))} "H/V Formsignal")
($ button {:on-click (fn []
(set-distant! (assoc distant :system :hl))
(set-repeater! (assoc repeater :system :hl))
(set-combination! (assoc combination :system :hl))
(set-main! (assoc main :system :hl)))
:active? (= :hl (:system main))} "Hl")))
"Positionierung der einzelnen Signale und Animationen müssen noch überarbeitet werden."))))
($ :tr
($ :th "Begriff")
($ :td)
Expand Down Expand Up @@ -334,7 +340,9 @@
($ :div
($ shortened-break-path-btn {:set-state! set-combination! :state combination}))))
($ :tr
($ :th "Zs3")
($ :th "Geschwindigkeits-"
($ :br)
"begrenzung")
($ :td)
($ :td)
($ :td
Expand Down
4 changes: 2 additions & 2 deletions src/signals/ne.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
(:require
[uix.core :refer [$ defui]]))

(defui ne2 [{:keys [semaphore+shortened-break-path?]}]
(defui ne2 [{:keys [shortened-break-path?]}]
($ :g
(when semaphore+shortened-break-path?
(when shortened-break-path?
($ :path.ral9002 {:d "m1,-23 17,20 17,-20 z"
:style {:stroke "#0e0e10"
:stroke-width 2}}))
Expand Down
14 changes: 7 additions & 7 deletions test/signals/hl_test.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -1305,14 +1305,14 @@

(deftest speed-limit-available?
(testing "without slow-speed-lights"
(is (not (hl/speed-limit-available?
(signal/main {:system :hl})
nil)))
(is (hl/speed-limit-available?
(signal/main {:system :hl})
nil))

(is (not (hl/speed-limit-available?
(signal/combination {:main {}
:system :hl})
nil)))
(is (hl/speed-limit-available?
(signal/combination {:main {}
:system :hl})
nil))

(is (not (hl/speed-limit-available?
(signal/main {:system :hl})
Expand Down
6 changes: 3 additions & 3 deletions test/signals/hv_test.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -1184,9 +1184,9 @@

(deftest speed-limit-available?
(testing "without Zs3 / slow-speed-light"
(is (not (hv-light/speed-limit-available?
(signal/main {:system :hv-light})
nil)))
(is (hv-light/speed-limit-available?
(signal/main {:system :hv-light})
nil))

(is (not (hv-light/speed-limit-available?
(signal/main {:system :hv-light})
Expand Down
14 changes: 7 additions & 7 deletions test/signals/ks_test.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -955,14 +955,14 @@

(deftest speed-limit-available?
(testing "without Zs3"
(is (not (ks/speed-limit-available?
(signal/main {:system :ks})
nil)))
(is (ks/speed-limit-available?
(signal/main {:system :ks})
nil))

(is (not (ks/speed-limit-available?
(signal/combination {:main {}
:system :ks})
nil)))
(is (ks/speed-limit-available?
(signal/combination {:main {}
:system :ks})
nil))

(is (not (ks/speed-limit-available?
(signal/main {:system :ks})
Expand Down

0 comments on commit b742e9a

Please sign in to comment.