{ RoboLinex 1.5 Programa de control de dispositivos RCX de Lego en entorno grfico. Copyright (C) 2003 Prodel S.A Programador: Daniel Pascual Dominguez Este programa es software libre. Puede redistribuirlo y/o modificarlo bajo los términos de la Licencia Pública General de GNU según es publicada por la Free Software Foundation, bien de la versión 2 de dicha Licencia o bien (según su elección) de cualquier versión posterior. Este programa se distribuye con la esperanza de que sea útil, pero SIN NINGUNA GARANTÍA, incluso sin la garantía MERCANTIL implícita o sin garantizar la CONVENIENCIA PARA UN PROPÓSITO PARTICULAR. Véase la Licencia Pública General de GNU para más detalles. Debería haber recibido una copia de la Licencia Pública General junto con este programa. Si no ha sido así, escriba a la Free Software Foundation, Inc., en 675 Mass Ave, Cambridge, MA 02139, EEUU. } unit Unit4; interface uses {$IFDEF LINUX} Libc, {$ENDIF} Qt {Windows}, {Messages} SysUtils, Variants, Classes, QGraphics, QControls, QForms, QDialogs, QExtCtrls, selentradas; type Tfentradas = class(TForm) Image1: TImage; Image2: TImage; Image3: TImage; Image4: TImage; Image5: TImage; Image6: TImage; Image7: TImage; Image8: TImage; Image9: TImage; Image10: TImage; Image11: TImage; procedure Image1Click(Sender: TObject); procedure Image2Click(Sender: TObject); procedure Image3Click(Sender: TObject); procedure Image4Click(Sender: TObject); procedure Image5Click(Sender: TObject); procedure Image6Click(Sender: TObject); procedure Image7Click(Sender: TObject); procedure Image8Click(Sender: TObject); procedure Image9Click(Sender: TObject); procedure Image10Click(Sender: TObject); procedure Image11Click(Sender: TObject); procedure FormCreate(Sender: TObject); private estado:integer; comando:string; comandoset:string; entrada:string; tipo:string; extx,exty:integer; inicial:integer; simple:integer; limiteluz:integer; { Private declarations } public { Public declarations } selecentrada: Tselecentrada; procedure inicializar(est,posix,posiy:integer;tip:string;ini,simpl:integer;entrad:string); procedure cambiaestado; function dar_comando_ini:string; function dar_comando:string; function dar_comando_clear:string; function dar_comando_fin:string; function dar_estado:string; end; //var // fentradas: Tfentradas; implementation {$R *.xfm} procedure Tfentradas.inicializar(est,posix,posiy:integer;tip:string;ini,simpl:integer;entrad:string); begin estado:=est; Top:=posiy; left:=posix; width:=63; height:=64; inicial:=ini; simple:=simpl; selecentrada.entrada:=entrad; limiteluz:=40; extx:=255; if inicial=1 then exty:=127; if inicial=2 then exty:=193; if inicial=3 then exty:=257; tipo:=tip; if tipo='1' then begin image1.picture:=image2.Picture; comando:='Wait(100);'; comandoset:=''; // selecentrada.Hide; end; if tipo='2' then begin image1.picture:=image3.Picture; comando:='Wait(200);'; comandoset:=''; // selecentrada.Hide; end; if tipo='3' then begin image1.picture:=image4.Picture; comando:='Wait(400);'; comandoset:=''; // selecentrada.Hide; end; if tipo='4' then begin image1.picture:=image5.Picture; comando:='Wait(600);'; comandoset:=''; // selecentrada.Hide; end; if tipo='5' then begin image1.picture:=image6.Picture; comando:='Wait(800);'; comandoset:=''; // selecentrada.Hide; end; if tipo='6' then begin image1.picture:=image7.Picture; comando:='Wait(1000);'; comandoset:=''; // selecentrada.Hide; end; if tipo='7' then begin image1.picture:=image8.Picture; comando:=''; comandoset:=''; // selecentrada.show; end; if tipo='8' then begin image1.picture:=image9.Picture; comando:=''; comandoset:=''; // selecentrada.show; end; if tipo='9' then begin image1.picture:=image10.Picture; comando:=''; // selecentrada.show; end; if tipo='10' then begin image1.picture:=image11.Picture; comando:=''; // selecentrada.show; end; entrada:=entrad; // freeandnil(selecentrada); // Application.CreateForm(Tselecentrada, selecentrada); selecentrada.inicializar(posix+15,posiy-37,entrada); // selecentrada.show; end; procedure Tfentradas.cambiaestado; begin if estado=1 then begin width:=63; height:=64; estado:=0; end else begin width:=extx; height:=exty; estado:=1; end; if (tipo='1') or (tipo ='2') or (tipo ='3')or (tipo ='4')or (tipo ='5')or (tipo ='6') then selecentrada.Hide else selecentrada.show; end; procedure Tfentradas.Image1Click(Sender: TObject); begin //if simple=1 then //begin // width:=extx; // height:=exty; // estado:=1; cambiaestado; //end; end; procedure Tfentradas.Image2Click(Sender: TObject); begin image1.picture:=image2.Picture; comando:='Wait(100);'; tipo:='1'; cambiaestado; // selecentrada.hide; end; procedure Tfentradas.Image3Click(Sender: TObject); begin image1.picture:=image3.Picture; comando:='Wait(200);'; tipo:='2'; cambiaestado; // selecentrada.hide; end; procedure Tfentradas.Image4Click(Sender: TObject); begin image1.picture:=image4.Picture; tipo:='3'; comando:='Wait(400);'; cambiaestado; // selecentrada.hide; end; procedure Tfentradas.Image5Click(Sender: TObject); begin image1.picture:=image5.Picture; comando:='Wait(600);'; tipo:='4'; cambiaestado; // selecentrada.hide; end; procedure Tfentradas.Image6Click(Sender: TObject); begin image1.picture:=image6.Picture; comando:='Wait(800);'; tipo:='5'; cambiaestado; // selecentrada.hide; end; procedure Tfentradas.Image7Click(Sender: TObject); begin image1.picture:=image7.Picture; comando:='Wait(1000);'; tipo:='6'; cambiaestado; // selecentrada.hide; end; procedure Tfentradas.Image8Click(Sender: TObject); begin image1.picture:=image8.Picture; comando:=''; tipo:='7'; cambiaestado; // selecentrada.show; end; procedure Tfentradas.Image9Click(Sender: TObject); begin image1.picture:=image9.Picture; comando:=''; tipo:='8'; cambiaestado; // selecentrada.show; end; procedure Tfentradas.Image10Click(Sender: TObject); begin image1.picture:=image10.Picture; comando:=''; tipo:='9'; cambiaestado; // selecentrada.show; end; procedure Tfentradas.Image11Click(Sender: TObject); begin image1.picture:=image11.Picture; comando:=''; tipo:='10'; cambiaestado; // selecentrada.show; end; function Tfentradas.dar_comando:string; begin dar_comando:=comando; end; function Tfentradas.dar_comando_ini:string; begin dar_comando_ini:=''; if (tipo = '7') or (tipo='8')then dar_comando_ini:='SetSensor(SENSOR_'+selecentrada.dar_entrada+',SENSOR_TOUCH);'; // showmessage(tipo); if (tipo = '9') or (tipo='10')then dar_comando_ini:='SetSensor(SENSOR_'+selecentrada.dar_entrada+',SENSOR_LIGHT);'; end; function Tfentradas.dar_comando_fin:string; var limite:string; begin str(limiteluz,limite); dar_comando_fin:=''; if (tipo='7') then dar_comando_fin:='until(SENSOR_'+selecentrada.dar_entrada+' == 1);'; if (tipo='8') then dar_comando_fin:='until(SENSOR_'+selecentrada.dar_entrada+' == 0);'; if (tipo='9') then dar_comando_fin:='until(SENSOR_'+selecentrada.dar_entrada+' > '+limite+');'; if (tipo='10') then dar_comando_fin:='until(SENSOR_'+selecentrada.dar_entrada+' <= '+limite+');'; end; function Tfentradas.dar_comando_clear:string; begin dar_comando_clear:=''; dar_comando_clear:='ClearSensor(SENSOR_'+selecentrada.dar_entrada+');'; end; function Tfentradas.dar_estado:string; var cadena:string; sest,sposix,sposiy,sini,ssimpl:string; begin str(estado,sest); str(left,sposix); str(top,sposiy); str(inicial,sini); str(simple,ssimpl); dar_estado:=sest+' '+sposix+' '+sposiy+' '+tipo+' '+sini+' '+ssimpl+' '+selecentrada.entrada; end; procedure Tfentradas.FormCreate(Sender: TObject); begin Application.CreateForm(Tselecentrada, selecentrada); //selecentrada.Visible:=false; //selecentrada.inicializar(posix+15,posiy-37,entrada); end; end.