segunda-feira, 6 de abril de 2009

THUNDERBIRD

Visto que fiz este programa em tempo record (15min) e fiquei mesmo feliz por dar à primeira vou deixar-vos aqui com código do meu thunderbird.

(*MUDANÇA DE ESTADO INICIAL PARA STATE:=1 E INICIALIZAÇÃO DOS TEMPORIZADORES*)
if(state=0) then
t0.mode:=tOn;
t0.p:=5;
t1.mode:=tOn;
t1.p:=10;
t2.mode:=tOn;
t2.p:=5;
state:=1;
(*SEQUENCIA ESQUERDA*)
elsif((state=1)and(ESQ))then
state:=2;
elsif((state=2)and(NOT ESQ))then
state:=1;
elsif((state=3)and(NOT ESQ))then
state:=1;
elsif((state=4)and(NOT ESQ))then
state:=1;
elsif((state=10)and(NOT ESQ))then
state:=1;
elsif((state=2)and(t0.q)and(ESQ))then
state:=3;
elsif((state=3)and(t0.q)and(ESQ))then
state:=4;
elsif((state=4)and(t0.q)and(ESQ))then
state:=10;
elsif((state=10)and(t0.q)and(ESQ))then
state:=2;

(*SEQUENCIA EMERGÊNCIA*)
elsif((state=1)and(EMR))then
state:=5;
elsif((state=5)and(NOT EMR))then
state:=1;
elsif((state=9)and(NOT EMR))then
state:=1;
elsif((state=5)and(t1.q)and(EMR))then
state:=9;
elsif((state=9)and(t1.q)and(EMR))then
state:=5;

(*SEQUENCIA DIREITA*)
elsif((state=1)and(DIR))then
state:=6;
elsif((state=6)and(NOT DIR))then
state:=1;
elsif((state=7)and(NOT DIR))then
state:=1;
elsif((state=8)and(NOT DIR))then
state:=1;
elsif((state=11)and(NOT DIR))then
state:=1;
elsif((state=6)and(t2.q)and(DIR))then
state:=7;
elsif((state=7)and(t2.q)and(DIR))then
state:=8;
elsif((state=8)and(t2.q)and(DIR))then
state:=11;
elsif((state=11)and(t2.q)and(DIR))then
state:=6;
end_if;

(*TEMPORIZADORES*)
if((RE ESQ)or(t0.q)) then
START t0;
end_if;
if((RE EMR)or(t1.q)) then
START t1;
end_if;
if((RE DIR)or(t2.q)) then
START t2;
end_if;

(*SAIDAS*)
LEA:=((state=2)or(state=5));
LEB:=((state=3)or(state=5));
LEC:=((state=4)or(state=5));
LDA:=((state=6)or(state=5));
LDB:=((state=7)or(state=5));
LDC:=((state=8)or(state=5));




KA BONITO!!!!!!!!

1 comentário:

  1. Desculpa Timoneiro mas acho que tens partes do código mal.
    No trabalho diz que na viragem a esquerda ou a direita as luzes ligam e ficam ligadas não ligam e desligam como no teu código. Tás a ver?

    Se tiveres o DIR ligada e ligares o EMR continua a funcionar o DIR. Não é suposto funcionar o EMR em vez do DIR?

    Tenho um problema e não sei se é do meu pc ou não, mas tanto no meu codigo como no teu nao acontece nada se ligar o ESQ. Essa parte do teu codigo estava a funcionar?

    É só obrigado pelo codigo foi grande ajuda. XD

    ResponderEliminar