// blokada SBL 4-stawna - pierwszy semafor na szlaku (poprzedni niesamoczynny)
// (p1) - nazwa, (p2)(p3)(p4) - lokacja, (p5) rotacja, (p6) symbol (p7) sterowanie semaforem wyjazdowym (jego nazwa)
// uwaga - do toru za semaforem musi byc przypiane zdarzenie NAZWASEMAFORA_s1
// a do toru przy semaforze oczywiscie zdarzenie NAZWASEMAFORA_sem_info

origin (p2) (p3) (p4)
rotate 0 (p5) 0
//model semafora 4komorowego blokady liniowej:
node -1 0 (p1) model 0 0 0 0 sem/glowice/S4Izcpc_dd.t3d tabl/(p6) Lights 1 0 0 0 endmodel            //glowica 
node -1 0 none model 0 0 0 0 sem/slupy/SBLIbg.t3d sem/slupy.bmp endmodel       //slup
node -1 0 none model 0 0 0 0 sem/drabinki/D4I.t3d sem/slupy.tga endmodel      //drabinka			// wskaznik W1

 
node 800 150 none lines 110 110 110  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

node -1 0 (p1)_sem_mem memcell (p2) (p3) (p4) SetVelocity -1 -1  none endmemcell

//zdarzenia okreslajace predkosc przy tym semaforze
event (p1)_sem_info_stop updatevalues 1.0 (p1)_sem_mem SetVelocity 0.0 20 endevent
event (p1)_sem_info_vmax updatevalues 1.0 (p1)_sem_mem SetVelocity -1 -1 endevent
event (p1)_sem_info_nextstop updatevalues 1.0 (p1)_sem_mem SetVelocity 100 0 endevent
event (p1)_sem_info_nextslow updatevalues 1.0 (p1)_sem_mem Setvelocity 160 100 endevent

event (p1)_s1 multiple 0 none (p1)_sem_ligh0 (p1)_sem_ligh1 (p1)_sem_info_stop endevent
event (p1)_sem_ligh1 lights 1 (p1) 0 1 0 0 endevent

event (p1)_s2 multiple 1 (p1)_sem_mem (p1)_sem_ligh0 (p1)_sem_ligh2 (p1)_sem_info_vmax condition memcompare * 160 100 endevent
event (p1)_sem_ligh2 lights 1 (p1) 1 0 0 0 endevent

event (p1)_s3 multiple 1 none (p1)_sem_ligh0 (p1)_sem_ligh3 (p1)_sem_info_nextslow (p1)_ctrlprev endevent
event (p1)_sem_ligh3 lights 1 (p1) 2 0 0 0 endevent

event (p1)_s5 multiple 0 none (p1)_sem_ligh0 (p1)_sem_ligh5 (p1)_sem_info_nextstop (p1)_ctrlprev endevent
event (p1)_ctrlprev multiple 6 none (p7)_SBLs2 (p7)_SBLs10 endevent
event (p1)_sem_ligh5 lights 1 (p1) 0 0 1 0 endevent


//odczyt z pamieci (zdarzenie przypisane do toru przy semaforze):
event (p1)_sem_info getvalues 5.0 (p1)_sem_mem endevent

//dodatkowo mozliwosc wygaszenia tego semafora:
event (p1)_ciemny multiple 1 none (p1)_sem_ligh0 (p1)_sem_info_vmax endevent
event (p1)_sem_ligh0 lights 0 (p1) 0 0 0 0 endevent


event (p1)_sem_info_s1a updatevalues 0.0 (p1)_sem_mem SetVelocity 0.0 0.0 endevent


//S1a
event (p1)_s1a multiple 2 none (p1)_sem_ligh0 (p1)_sem_lighs1a (p1)_sem_info_s1a (p7)_s5 endevent

//S1a Wygaszanie
event (p1)_s1aWyg multiple 0 none (p1)_s5a endevent
event (p1)_s5a multiple 2 (p1)_sem_mem (p1)_sem_ligh0 (p1)_sem_ligh5 (p1)_sem_info_nextstop  condition memcompare * 0 * endevent

event (p1)_sem_lighs1a lights 1.0 (p1) 0 1 0 2 endevent