diff --git a/src/signals/hl.cljs b/src/signals/hl.cljs index 51ce4d9..8db30dc 100644 --- a/src/signals/hl.cljs +++ b/src/signals/hl.cljs @@ -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)]} @@ -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 @@ -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)))) diff --git a/src/signals/hv_light.cljs b/src/signals/hv_light.cljs index 39f037d..1518959 100644 --- a/src/signals/hv_light.cljs +++ b/src/signals/hv_light.cljs @@ -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)) diff --git a/src/signals/ks.cljs b/src/signals/ks.cljs index c83ae08..99368ed 100644 --- a/src/signals/ks.cljs +++ b/src/signals/ks.cljs @@ -139,4 +139,4 @@ (case zs3 :display true :sign limit - false)) + (nil? limit))) diff --git a/src/signals/main.cljs b/src/signals/main.cljs index 8369eb4..20b703a 100644 --- a/src/signals/main.cljs +++ b/src/signals/main.cljs @@ -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)"} @@ -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})) @@ -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"}}] @@ -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) @@ -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) @@ -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) @@ -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 diff --git a/src/signals/ne.cljs b/src/signals/ne.cljs index 37b8b16..f2bb302 100644 --- a/src/signals/ne.cljs +++ b/src/signals/ne.cljs @@ -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}})) diff --git a/test/signals/hl_test.cljs b/test/signals/hl_test.cljs index 4598f10..3365b4e 100644 --- a/test/signals/hl_test.cljs +++ b/test/signals/hl_test.cljs @@ -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}) diff --git a/test/signals/hv_test.cljs b/test/signals/hv_test.cljs index b548d02..e6da6d4 100644 --- a/test/signals/hv_test.cljs +++ b/test/signals/hv_test.cljs @@ -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}) diff --git a/test/signals/ks_test.cljs b/test/signals/ks_test.cljs index 413d669..934e4c1 100644 --- a/test/signals/ks_test.cljs +++ b/test/signals/ks_test.cljs @@ -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})