// semafor drogowskazowy odchylony 5-komorowy+pas zielony: p1=nazwa p2,p3,p4=lokacja, p5=rotacja, p6=symbol, p7=nazwa nastepnego semafora
// semafor ten stosuje sie jako wyjazdowy, (p7) jest nazwa semafora SBL lub wyjazdowego sprzezonego z tym semaforem!
// wskazania na tym semaforze uzaleznione sa od semafora nastepnego, zewnetrzne zdarzenia: S1, S2, S6, S10
// od SSd5* rozni sie dodatkowym zdarzeniem zewnetrzym s6 (vmax=100km/h)
// wskaznik W24 powinien byc podswietlony przy jezdzie na tor niewlasciwy (podswietlenie jest kasowane przy podaniu S1)

origin (p2) (p3) (p4)
rotate 0 (p5) 0
//model semafora 5komorowego odchylonego:
node -1 0 (p1) model 0 0 0 0 sem/glowice/S5YPzpcpb_dd.t3d tabl/(p6) Lights 0 0 1 0 0 endmodel            //glowica 
node -1 0 none model 0 0 0 0 sem/slupy/S5YPbl.t3d sem/slupy.bmp endmodel       //slup
node -1 0 none model 0 0 0 0 sem/drabinki/D5YP.t3d sem/slupy.tga endmodel      //drabinka
node -1 0 (p1)S model 0 0 0 0 sem/Pasy/PZ.t3d sem/slupy.bmp Lights 0 endmodel 
node -1 0 (p1)W24 model 0 0 0 0 sem/wskazniki/W24v2.t3d none Lights 0 endmodel 

node 800 150 none lines 100 50 20 100.0                                           //linia zeby byl maszt widoczny z daleka
0.0 0.0 0.0	0.0 4.0 0.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.0 (p1)_sem_mem endevent

//stany semafora:

event (p1)_s1 multiple 0 none (p1)_sem_ligh1 (p1)_sem_lighs1 (p1)_sem_info_stop (p1)_W24off endevent

event (p1)_s2 multiple 0 none (p1)-s2 (p1)-s3 (p1)-s4 (p1)-s5 endevent  //wybierane zaleznie od nastepnego semafora (p7)

event (p1)_s6 multiple 0 none (p1)-s6 (p1)-s7 (p1)-s8 (p1)-s9 endevent  //wybierane zaleznie od nastepnego semafora (p7)

event (p1)_s10 multiple 0 none (p1)-s10 (p1)-s11 (p1)-s12 (p1)-s13 endevent //wybierane zaleznie od nastepnego semafora (p7)

event (p1)_ms2 multiple 0 none (p1)_sem_lighm2 (p1)_sem_info_shunt2 endevent

event (p1)_sz1 multiple 0 none (p1)_sem_lighz1 (p1)_sem_info_v20 endevent

//podswietlanie wskaznika W24:
event (p1)_W24 lights 1.0 (p1)W24 1 endevent

//gaszenie wskaznika W24
event (p1)_W24off lights 0.0 (p1)W24 0 endevent


//dla nastepnego SBL zeby mogl zmienic stan:
event (p1)_SBLs2 multiple 0 (p1)_sem_mem (p1)-s2 (p1)-s3  condition memcompare * -1 0 endevent
event (p1)_SBLs10 multiple 1 (p1)_sem_mem  (p1)-s10 condition memcompare * 40 0 endevent


//powyzsze zdarzenia skladaja sie z:
//zdarzen uwarunkowanych nastepnym semaforem:

event (p1)-s2 multiple 0 (p7)_sem_mem (p1)_sem_ligh2 (p1)_sem_info_vmax (p1)_sem_distinfo_vmax condition memcompare * -1 * endevent
event (p1)-s3 multiple 1 (p7)_sem_mem (p1)_sem_ligh3 (p1)_sem_info_vmax (p1)_sem_distinfo_v100 condition memcompare * 100 * endevent
event (p1)-s4 multiple 2 (p7)_sem_mem (p1)_sem_ligh4 (p1)_sem_info_vmax (p1)_sem_distinfo_v40 condition memcompare * 40 * endevent
event (p1)-s5 multiple 3 (p7)_sem_mem (p1)_sem_ligh5 (p1)_sem_info_vmax (p1)_sem_distinfo_stop condition memcompare * 0 * endevent
event (p1)-s6 multiple 0 (p7)_sem_mem (p1)_sem_ligh10 (p1)_sem_lighs2 (p1)_sem_info_v100 (p1)_sem_distinfo_vmax condition memcompare * -1 * endevent
event (p1)-s7 multiple 1 (p7)_sem_mem (p1)_sem_ligh11 (p1)_sem_lighs2 (p1)_sem_info_v100 (p1)_sem_distinfo_v100 condition memcompare * 100 * endevent
event (p1)-s8 multiple 2 (p7)_sem_mem (p1)_sem_ligh12 (p1)_sem_lighs2 (p1)_sem_info_v100 (p1)_sem_distinfo_v40 condition memcompare * 40 * endevent
event (p1)-s9 multiple 3 (p7)_sem_mem (p1)_sem_ligh13 (p1)_sem_lighs2 (p1)_sem_info_v100 (p1)_sem_distinfo_stop condition memcompare * 0 * endevent
event (p1)-s10 multiple 0 (p7)_sem_mem (p1)_sem_ligh10 (p1)_sem_info_v40 (p1)_sem_distinfo_vmax condition memcompare * -1 *  endevent
event (p1)-s11 multiple 1 (p7)_sem_mem (p1)_sem_ligh11 (p1)_sem_info_v40 (p1)_sem_distinfo_v100 condition memcompare * 100 * endevent
event (p1)-s12 multiple 2 (p7)_sem_mem (p1)_sem_ligh12 (p1)_sem_info_v40 (p1)_sem_distinfo_v40 condition memcompare * 40 * endevent
event (p1)-s13 multiple 3 (p7)_sem_mem (p1)_sem_ligh13 (p1)_sem_info_v40 (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 0.0 none endmemcell

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

//zdarzenia sterujace swiatlami:
event (p1)_sem_ligh1 lights 0.0 (p1)  0 0 1 0 0 endevent
event (p1)_sem_lighs1 lights 0.0 (p1)S  0 endevent
event (p1)_sem_ligh2 lights 0.0 (p1)  1 0 0 0 0 endevent
event (p1)_sem_lighs2 lights 0.0 (p1)S  1 endevent
event (p1)_sem_ligh3 lights 0.0 (p1)  2 0 0 0 0 endevent
event (p1)_sem_ligh4 lights 0.0 (p1)  0 2 0 0 0 endevent
event (p1)_sem_ligh5 lights 0.0 (p1)  0 1 0 0 0 endevent
event (p1)_sem_ligh10 lights 0.0 (p1) 1 0 0 1 0 endevent
event (p1)_sem_ligh11 lights 0.0 (p1) 2 0 0 1 0 endevent
event (p1)_sem_ligh12 lights 0.0 (p1) 0 2 0 1 0 endevent
event (p1)_sem_ligh13 lights 0.0 (p1) 0 1 0 1 0 endevent
event (p1)_sem_lighm2 lights 0.0 (p1) 0 0 0 0 1 endevent
event (p1)_sem_lighz1 lights 0.0 (p1) 0 0 1 0 2 endevent
