// semafor ksztaltowy 2-ramienny:
// (p1) - nazwa, (p2)(p3)(p4) - lokacja, (p5) rotacja, (p6) - symbol semafora
// Ze względu na błędy w sterowaniu AI sygnał Sr2 ogranicza prędkość pociągu do 40 km/h. - Siecool / Całkowo
origin (p2) (p3) (p4)
rotate 0 (p5) 0
node 1000 0 (p1)_sk12 model 0 0 0 0 pkp/sk12krat.t3d tabl/(p6) lights 0 0 0 0 endmodel
node 1200 0 none lines 90 90 95 2.0                                          
-0.3 0.0 0.1	 -0.3 7.5 0.1 
endline
node 1200 0 none lines 55 50 50 20.0                                          
0.0 0.0 0.0	 0.0 7.5 0.0 
endline
rotate 0 0 0
endorigin

//stany semafora:

// stoj:
event (p1)_sr1 multiple 1 none 
	(p1)_sem_anim11 
	(p1)_sem_anim11p 
	(p1)_sem_anim21 
	(p1)_sem_anim21p 
	(p1)_sem_info_stop 
	(p1)_status_sem_1
	(p1)_sem_sr1n
endevent

// wolna droga:
event (p1)_sr2 multiple 1 none 
	(p1)_sem_anim12 
	(p1)_sem_anim12p 
	(p1)_sem_anim21 
	(p1)_sem_anim21p 
	(p1)_sem_info_v40 
	(p1)_status_sem_2
	(p1)_sem_sr2n
endevent

// wolna droga ze zmniejszona do 40 km/h predkoscia
event (p1)_sr3 multiple 1 none 
	(p1)_sem_anim12 
	(p1)_sem_anim12p 
	(p1)_sem_anim22 
	(p1)_sem_anim22p 
	(p1)_sem_info_v40 
	(p1)_status_sem_3
	(p1)_sem_sr3n
endevent

// wazne dla ai maszynisty!
// ponizsze zdarzenie jest wyzwalane z toru przy semaforze 
event (p1)_sem_info getvalues 1.0 (p1)_sem_mem endevent

// komorka pamietajaca predkosci oraz nazwy odpowiednich torow
node -1 0 (p1)_sem_mem memcell (p2) (p3) (p4) SetVelocity 0.0 0.0 none endmemcell
node -1 0 (p1)_sem_swiatlo memcell (p2) (p3) (p4) * 1 0 none endmemcell

// animacja semafora
event (p1)_sem_anim11 animation 1.0 (p1)_sk12 rotate ramie_gora 0 0 0 40 endevent
event (p1)_sem_anim12 animation 0 (p1)_sk12 rotate ramie_gora 0 45 0 40 endevent
event (p1)_sem_anim11p animation 1.0 (p1)_sk12 rotate przeslona_01 0 0 0 45 endevent
event (p1)_sem_anim12p animation 0 (p1)_sk12 rotate przeslona_01 0 -45 0 45 endevent

event (p1)_sem_anim21 animation 1.0 (p1)_sk12 rotate ramie_dol 0 0 0 40 endevent
event (p1)_sem_anim22 animation 0 (p1)_sk12 rotate ramie_dol 0 -45 0 40 endevent
event (p1)_sem_anim21p animation 1.0 (p1)_sk12 rotate przeslona_02 0 0 0 45 endevent
event (p1)_sem_anim22p animation 0 (p1)_sk12 rotate przeslona_02 0 -45 0 45 endevent

// wpisanie informacji do komorki
event (p1)_sem_info_stop updatevalues 0.0 (p1)_sem_mem SetVelocity 0.0 0.0 endevent
event (p1)_sem_info_vmax updatevalues 1.0 (p1)_sem_mem SetVelocity -1 -1 endevent
event (p1)_sem_info_v40 updatevalues 1.0 (p1)_sem_mem SetVelocity 40.0 -1 endevent

event (p1)_sem_sr1n multiple 1.0 (p1)_sem_swiatlo (p1)_sem_ligh1n condition memcompare * 1 1 endevent
event (p1)_sem_sr2n multiple 1.0 (p1)_sem_swiatlo (p1)_sem_ligh2n condition memcompare * 2 1 endevent
event (p1)_sem_sr3n multiple 1.0 (p1)_sem_swiatlo (p1)_sem_ligh3n condition memcompare * 3 1 endevent

event (p1)_sem_ligh1n lights 0.0 (p1)_sk12 1 1 0 0 endevent
event (p1)_sem_ligh2n lights 0.0 (p1)_sk12 1 0 1 0 endevent
event (p1)_sem_ligh3n lights 0.0 (p1)_sk12 1 0 1 1 endevent

event (p1)_sem_lighd lights 0.0 (p1)_sk12 0 0 0 0 endevent

event (p1)_dzienny multiple 0.0 none (p1)_zmien_na_dzien (p1)_sem_lighd endevent
event (p1)_nocny multiple 0.0 none (p1)_zmien_na_noc (p1)_sem_sr1n (p1)_sem_sr2n (p1)_sem_sr3n endevent

event (p1)_zmien_na_dzien updatevalues 0.0 (p1)_sem_swiatlo * * 0 endevent
event (p1)_zmien_na_noc updatevalues 0.0 (p1)_sem_swiatlo * * 1 endevent

event (p1)_status_sem_1 updatevalues 0.0 (p1)_sem_swiatlo * 1 * endevent
event (p1)_status_sem_2 updatevalues 0.0 (p1)_sem_swiatlo * 2 * endevent
event (p1)_status_sem_3 updatevalues 0.0 (p1)_sem_swiatlo * 3 * endevent
