//semafor półsamoczynny, pięciokomorowy z zielonym pasem świetlnym i wskaźnikiem w24.
//autorzy: kudłacz, ziomalcl
//Ra 2f9u: dodałem W20 - robi jako semafor D w Blachowni - na wprost jazda po krzyżowym (sem. C), na bok po przejściu (S10)

origin (p2) (p3) (p4)
rotate 0 (p5) 0
//model semafora 5komorowego prostego z zielonym pasem oraz W20 i W24:
node 1000 0 (p1) model 0 0 0 0 sem/glowice/s5izpcpb_dd.t3d tabl/(p6) lights 0 0 1 0 0 endmodel //głowica 
node 200 0 none model 0 0 0 0 sem/slupy/s5ibg.t3d sem/slupy endmodel //slup
node 200 0 none model 0 0 0 0 sem/drabinki/d5i.t3d sem/slupy endmodel //drabinka
node 800 0 (p1)s model 0 0 0 0 sem/pasy/pz.t3d sem/slupy lights 0 endmodel
node 400 0 (p1)w20 model 0 -0.5 0 0 sem/wskazniki/w20v1s.t3d none lights 0 endmodel  
node 400 0 (p1)w24 model 0 -0.5 0 0 sem/wskazniki/w24v2.t3d none lights 0 endmodel //wskaznik w24 


node 700 200 none lines 100 50 20 100 //linia zeby byl maszt widoczny z daleka
0 0 0.0	0 4 0 
endline
rotate 0 0 0
endorigin

// podstawowe zdarzenia:

//odczyt z pamieci (zdarzenie przypisane do toru przy ktorym stoi semafor):
event (p1)_sem_info getvalues 1 (p1)_sem_mem endevent

//stany semafora:
event (p1)_s1 multiple 0 none (p1)_sem_ligh1 (p1)_sem_lighs1 (p1)_sem_info_stop (p1)_w20off (p1)_w24off endevent
event (p1)_s2 multiple 0 none (p1)-s2 (p1)-s3 (p1)-s4 (p1)-s5 endevent  //zaleznie od (p7) - nieużywane w Blachowni
event (p1)_s6 multiple 0 none (p1)-s6 (p1)-s7 (p1)-s8 (p1)-s9 (p1)_w20 endevent  //zielony pas na prosto i zaleznie od (p7)
event (p1)_s10 multiple 0 none (p1)_sem_ligh10 (p1)_sem_info_v40 (p1)_w24 endevent //bez zielonego na bok z pominięciem (p7)
event (p1)_ms2 multiple 0 none (p1)_sem_lighm2 (p1)_sem_info_Shunt25 endevent
event (p1)_m40 multiple 0 none (p1)_sem_lighm2 (p1)_sem_info_Shunt40 endevent
event (p1)_sz multiple 0 none (p1)_sem_lighz1 (p1)_sem_info_v40 (p1)_sem_distinfo_stop (p1)_wyg_sz endevent //zastępczy z innym sygnałem
event (p1)_sz1 multiple 0 none (p1)_sem_ligh1 (p1)_sem_lighz1 (p1)_sem_info_v40 (p1)_wyg_sz endevent //zastępczy z S1
event (p1)_wyg_sz multiple 90 (p1)_sem_mem (p1)_sem_lighz0 (p1)_w24off (p1)_sem_info_stop condition memcompare SetVelocity 40 0 endevent

//podswietlanie i gaszenie wskaznika w20 (robi się samo):
event (p1)_w20 lights 0 (p1)w20 1 endevent
event (p1)_w20off lights 0 (p1)w20 0 endevent

//podswietlanie i gaszenie wskaznika w24 (robi się samo):
event (p1)_w24 lights 0 (p1)w24 1 endevent
event (p1)_w24off lights 0 (p1)w24 0 endevent

//powyzsze zdarzenia skladaja sie z:
//zdarzen uwarunkowanych nastepnym semaforem (opóźnienie na wypadek jednoczesnego podania sygnałów):
event (p1)-s2 multiple 0.5 (p7)_sem_mem (p1)_sem_ligh2 (p1)_sem_info_vmax (p1)_sem_distinfo_vmax condition memcompare * -1 * endevent
event (p1)-s3 multiple 0.5 (p7)_sem_mem (p1)_sem_ligh3 (p1)_sem_info_vmax (p1)_sem_distinfo_v100 condition memcompare * 100 * endevent
event (p1)-s4 multiple 0.5 (p7)_sem_mem (p1)_sem_ligh4 (p1)_sem_info_vmax (p1)_sem_distinfo_v40 condition memcompare * 40 * endevent
event (p1)-s5 multiple 0.5 (p7)_sem_mem (p1)_sem_ligh5 (p1)_sem_info_vmax (p1)_sem_distinfo_stop condition memcompare * 0 * endevent
event (p1)-s6 multiple 0.5 (p7)_sem_mem (p1)_sem_ligh10 (p1)_sem_lighs2 (p1)_w20 (p1)_sem_info_v100 (p1)_sem_distinfo_vmax condition memcompare * -1 * endevent
event (p1)-s7 multiple 0.5 (p7)_sem_mem (p1)_sem_ligh11 (p1)_sem_lighs2 (p1)_w20 (p1)_sem_info_v100 (p1)_sem_distinfo_v100 condition memcompare * 100 * endevent
event (p1)-s8 multiple 0.5 (p7)_sem_mem (p1)_sem_ligh12 (p1)_sem_lighs2 (p1)_w20 (p1)_sem_info_v100 (p1)_sem_distinfo_v40 condition memcompare * 40 * endevent
event (p1)-s9 multiple 0.5 (p7)_sem_mem (p1)_sem_ligh13 (p1)_sem_lighs2 (p1)_w20 (p1)_sem_info_v100 (p1)_sem_distinfo_stop condition memcompare * 0 * endevent

//memcell do pamietania predkosci:
node -1 0 (p1)_sem_mem memcell (p2) (p3) (p4) SetVelocity 0 0 none endmemcell

//zdarzenia wpisujace w memcell predkosci przy tym (info) i przy nastepnym (distinfo) semaforze:
event (p1)_sem_info_stop updatevalues 0 (p1)_sem_mem SetVelocity 0 0 endevent
event (p1)_sem_info_vmax updatevalues 0 (p1)_sem_mem SetVelocity -1 * endevent
event (p1)_sem_info_v40 updatevalues 0 (p1)_sem_mem SetVelocity 40 * endevent
event (p1)_sem_info_v100 updatevalues 0 (p1)_sem_mem SetVelocity 100 * endevent
event (p1)_sem_distinfo_stop updatevalues 0.5 (p1)_sem_mem SetVelocity * 0 endevent
event (p1)_sem_distinfo_vmax updatevalues 0.5 (p1)_sem_mem SetVelocity * -1 endevent
event (p1)_sem_distinfo_v40 updatevalues 0.5 (p1)_sem_mem SetVelocity * 40 endevent
event (p1)_sem_distinfo_v100 updatevalues 0.5 (p1)_sem_mem SetVelocity * 100 endevent
// dziala tylko na pojazdy w trybie manewrowym:
event (p1)_sem_info_Shunt25 updatevalues 1 (p1)_sem_mem ShuntVelocity 25 0 endevent
event (p1)_sem_info_Shunt40 updatevalues 1 (p1)_sem_mem ShuntVelocity 40 0 endevent

//zdarzenia sterujace swiatlami:
event (p1)_sem_ligh1 lights 0 (p1)  0 0 1 0 -1 endevent
event (p1)_sem_ligh2 lights 0 (p1)  1 0 0 0 -1 endevent
event (p1)_sem_ligh3 lights 0 (p1)  2 0 0 0 -1 endevent
event (p1)_sem_ligh4 lights 0 (p1)  0 2 0 0 -1 endevent
event (p1)_sem_ligh5 lights 0 (p1)  0 1 0 0 -1 endevent
event (p1)_sem_ligh10 lights 0 (p1) 1 0 0 1 -1 endevent
event (p1)_sem_ligh11 lights 0 (p1) 2 0 0 1 -1 endevent
event (p1)_sem_ligh12 lights 0 (p1) 0 2 0 1 -1 endevent
event (p1)_sem_ligh13 lights 0 (p1) 0 1 0 1 -1 endevent
event (p1)_sem_lighz0 lights 0 (p1) -1 -1 -1 -1 0 endevent //wygaszenie zastępczego bez ruszania innych
event (p1)_sem_lighz1 lights 0 (p1) -1 -1 -1 -1 2 endevent //zastępczy bez ruszania innych
event (p1)_sem_lighm0 lights 0 (p1) 0 0 1 0 0 endevent //wygaszenie manewrowego do S1
event (p1)_sem_lighm2 lights 0 (p1) 0 0 0 0 1 endevent //manewrowe
event (p1)_sem_lighs1 lights 0 (p1)s  0 endevent //pasek
event (p1)_sem_lighs2 lights 0 (p1)s  1 endevent
// uszkodzony semafor - nieoswietlony:
event (p1)_uszk multiple 0 none (p1)_sem_ligh0 (p1)_sem_lighs1 (p1)_w24off (p1)_sem_info_stop endevent
event (p1)_sem_ligh0 lights 0 (p1) 0 0 0 0 0 endevent
