//Semafor półsamoczynny, trzykomorowy na słupie odchylonym.
//Autorzy: Kudłacz, ZiomalCl

origin (p2) (p3) (p4)
rotate 0 (p5) 0
//model semafora 3komorowego:
node -1 0 (p1) model 0 0 0 0 sem/glowice/S3YPzcp_dd.t3d tabl/(p6) Lights 0 1 0 endmodel            //glowica 
node -1 0 none model 0 0 0 0 sem/slupy/S3YPmg.t3d sem/slupy.dds endmodel       //slup
node -1 0 none model 0 0 0 0 sem/drabinki/D4YP.t3d sem/slupy.dds endmodel     //drabinka

node 800 50 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


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


//zdarzenia okreslajace predkosc przy tym semaforze
event (p1)_sem_info_stop updatevalues 0.0 (p1)_sem_mem SetVelocity 0.0 0 endevent
event (p1)_sem_info_vmax updatevalues 1.0 (p1)_sem_mem SetVelocity -1 -1 endevent
event (p1)_sem_info_v160 updatevalues 1.0 (p1)_sem_mem SetVelocity 160 100 endevent
event (p1)_sem_info_v20 updatevalues 1.0 (p1)_sem_mem SetVelocity 20 0 endevent
event (p1)_sem_distinfo_stop updatevalues 1.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 1.0 (p1)_sem_mem SetVelocity * 100 endevent
event (p1)_sem_distinfo_v40 updatevalues 0.0 (p1)_sem_mem SetVelocity * 40 endevent

event (p1)_os1 updatevalues 1.0 (p1)_sem_mem2 * * 0 endevent
event (p1)_os2 updatevalues 1.0 (p1)_sem_mem2 * * -1 endevent
event (p1)_os3 updatevalues 1.0 (p1)_sem_mem2 * * 100 endevent
event (p1)_os4 updatevalues 1.0 (p1)_sem_mem2 * * 40 endevent

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

event (p1)-s2 multiple 0 (p1)_sem_mem2 (p1)_sem_ligh2 (p1)_sem_info_vmax (p1)_sem_distinfo_vmax condition memcompare * * -1 endevent
event (p1)-s3 multiple 1 (p1)_sem_mem2 (p1)_sem_ligh3 (p1)_sem_info_v160 (p1)_sem_distinfo_v100 condition memcompare * * 100 endevent
event (p1)-s4 multiple 2 (p1)_sem_mem2 (p1)_sem_ligh4 (p1)_sem_info_vmax (p1)_sem_distinfo_v40 condition memcompare * * 40 endevent
event (p1)-s5 multiple 3 (p1)_sem_mem2 (p1)_sem_ligh5 (p1)_sem_info_vmax (p1)_sem_distinfo_stop condition memcompare * * 0 endevent

event (p1)_sem_ligh1 lights 0.0 (p1) 0 1 0 endevent
event (p1)_sem_ligh2 lights 0.0 (p1) 1 0 0 endevent
event (p1)_sem_ligh3 lights 0.0 (p1) 2 0 0 endevent
event (p1)_sem_ligh4 lights 0.0 (p1) 0 0 2 endevent
event (p1)_sem_ligh5 lights 0.0 (p1) 0 0 1 endevent

//odczyt z pamieci:
event (p1)_sem_info getvalues 1.0 (p1)_sem_mem endevent