// semafor półsamoczynny, trzykomorowy - wersja karzełkowa.
// autorzy: kudłacz, ziomalcl

origin (p2) (p3) (p4)
rotate 0 (p5) 0
node 800 0 (p1) model 0 0 0 0 sem/karzelki/ks3pcz_metro.t3d tabl/(p6) lights 0 1 0 endmodel            //glowica
node 200 0 none model 0 0 0 0 sem/slupy/pod_betonowa_metro.t3d sem/slupy endmodel 


rotate 0 0 0
endorigin

//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_info_stop endevent      
event (p1)_s4 multiple 0 none (p1)_sem_ligh4 (p1)_sem_info_vmax (p1)_sem_distinfo_v40  endevent            
event (p1)_s5 multiple 0 none (p1)_sem_ligh5 (p1)_sem_info_vmax (p1)_sem_distinfo_stop  endevent  
event (p1)_s2 multiple 0 none (p1)_sem_ligh2 (p1)_sem_info_vmax (p1)_sem_distinfo_vmax  endevent
event (p1)_s3 multiple 0 none (p1)_sem_ligh3 (p1)_sem_info_vmax (p1)_sem_distinfo_v100  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 semaforze:
event (p1)_sem_info_stop updatevalues 0.0 (p1)_sem_mem SetVelocity 0.0 0.0 endevent
event (p1)_sem_info_vmax updatevalues 0.0 (p1)_sem_mem SetVelocity -1 * endevent
event (p1)_sem_info_v40 updatevalues 0.0 (p1)_sem_mem SetVelocity 40.0 * endevent
event (p1)_sem_distinfo_v40 updatevalues 0.0 (p1)_sem_mem SetVelocity * 40.0 endevent
event (p1)_sem_distinfo_stop updatevalues 0.0 (p1)_sem_mem SetVelocity * 0.0 endevent
event (p1)_sem_distinfo_vmax updatevalues 0.0 (p1)_sem_mem SetVelocity * -1 endevent
event (p1)_sem_distinfo_v100 updatevalues 0.0 (p1)_sem_mem SetVelocity * 100.0 endevent

//zdarzenia sterujace swiatlami:
event (p1)_sem_ligh1 lights 0.0 (p1) 0 1 0 endevent
event (p1)_sem_ligh4 lights 0.0 (p1) 2 0 0 endevent
event (p1)_sem_ligh5 lights 0.0 (p1) 1 0 0 endevent
event (p1)_sem_ligh2 lights 0.0 (p1) 0 0 1 endevent
event (p1)_sem_ligh3 lights 0.0 (p1) 0 0 2 endevent

// uszkodzony semafor - nieoswietlony:
event (p1)_uszk multiple 0 none (p1)_sem_ligh0 (p1)_sem_info_stop endevent
event (p1)_sem_ligh0 lights 0.0 (p1) 0 0 0 endevent
