{ 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 Unit2; interface uses {$IFDEF LINUX} Libc, {$ENDIF} Qt {Windows}, {Messages} SysUtils, Variants, Classes, QGraphics, QControls, QForms, QDialogs, QExtCtrls,Unit3; type Tfsalidas = class(TForm) Image1: TImage; Image2: TImage; Image3: TImage; Image4: TImage; Image5: TImage; procedure Image2Click(Sender: TObject); procedure Image1Click(Sender: TObject); procedure Image3Click(Sender: TObject); procedure Image4Click(Sender: TObject); procedure Image5Click(Sender: TObject); procedure FormCreate(Sender: TObject); private { Private declarations } simple:integer; estado:integer; comando:string; potencia:string; salida:string; inicial:integer; extx,exty:integer; public tipo:integer; fpotencia:Tfpotencia; procedure inicializar(estad,posix,posiy,tip,ini,simpl:integer;salid:string;pot:integer); procedure cambiaestado; function dar_comando:string; function dar_potencia:string; function dar_estado:string; { Public declarations } end; implementation {$R *.xfm} procedure Tfsalidas.inicializar(estad,posix,posiy,tip,ini,simpl:integer;salid:string;pot:integer); begin estado:=estad; Top:=posiy; left:=posix; width:=60; simple:=simpl; salida:=salid; extx:=255; if ini=0 then extx:=193; if ini=1 then extx:=256; if ini=2 then extx:=320; inicial:=ini; tipo:=tip; if tipo=2 then begin if ansicomparestr(salida,'A')=0 then begin image1.picture:=image2.Picture; comando:='OnRev(OUT_'+salid+');'; if simple=1 then fpotencia.Visible:=true; end; if ((ansicomparestr(salida,'B')=0) OR (ansicomparestr(salida,'C')=0)) then begin image1.picture:=image2.Picture; comando:='OnFwd(OUT_'+salid+');'; if simple=1 then fpotencia.Visible:=true; end; end; if tipo=1 then begin if ansicomparestr(salida,'A')=0 then begin image1.picture:=image3.Picture; comando:='OnFwd(OUT_'+salid+');'; if simple=1 then fpotencia.Visible:=true; end; if ((ansicomparestr(salida,'B')=0) OR (ansicomparestr(salida,'C')=0)) then begin image1.picture:=image3.Picture; comando:='OnRev(OUT_'+salid+');'; if simple=1 then fpotencia.Visible:=true; end; end; if tipo=3 then begin image1.picture:=image4.Picture; comando:='On(OUT_'+salid+');'; if simple=1 then fpotencia.Visible:=true; end; if tipo=4 then begin image1.picture:=image5.Picture; comando:='Off(OUT_'+salida+');'; if simple=1 then fpotencia.Visible:=false; end; salida:=salid; // freeandnil(fpotencia); fpotencia.inicializar(posix+2,posiy+66,pot); if (tipo<>4) and (simple=1) then fpotencia.Visible:=true else fpotencia.Visible:=false; end; procedure Tfsalidas.cambiaestado; begin if estado=1 then begin width:=60; estado:=0; end else begin width:=extx; estado:=1; end; end; procedure Tfsalidas.Image2Click(Sender: TObject); begin if ansicomparestr(salida,'A')=0 then begin image1.picture:=image2.Picture; cambiaestado; comando:='OnRev(OUT_'+salida+');'; tipo:=2; if simple=1 then fpotencia.visible:=true; end; if ((ansicomparestr(salida,'B')=0) OR (ansicomparestr(salida,'C')=0)) then begin image1.picture:=image2.Picture; cambiaestado; comando:='OnFwd(OUT_'+salida+');'; tipo:=2; if simple=1 then fpotencia.visible:=true; end; end; procedure Tfsalidas.Image1Click(Sender: TObject); begin //if estado=1 then cambiaestado // estado:=1; // width:=extx; //end; end; procedure Tfsalidas.Image3Click(Sender: TObject); begin if ansicomparestr(salida,'A')=0 then begin image1.picture:=image3.Picture; cambiaestado; comando:='OnFwd(OUT_'+salida+');'; tipo:=1; if simple=1 then fpotencia.visible:=true; end; if ((ansicomparestr(salida,'B')=0) OR (ansicomparestr(salida,'C')=0)) then begin image1.picture:=image3.Picture; cambiaestado; comando:='OnRev(OUT_'+salida+');'; tipo:=1; if simple=1 then fpotencia.visible:=true; end; end; procedure Tfsalidas.Image4Click(Sender: TObject); begin image1.picture:=image4.Picture; cambiaestado; if simple=1 then fpotencia.visible:=true; comando:='On(OUT_'+salida+');'; tipo:=3; end; procedure Tfsalidas.Image5Click(Sender: TObject); begin image1.picture:=image5.Picture; cambiaestado; comando:='Off(OUT_'+salida+');'; tipo:=4; fpotencia.visible:=false; end; function Tfsalidas.dar_comando:string; begin dar_comando:= comando; end; function Tfsalidas.dar_potencia:string; begin if fpotencia.dar_potencia = 1 then dar_potencia:= 'SetPower(OUT_'+salida+',OUT_LOW);'; if (fpotencia.dar_potencia = 2) or (fpotencia.dar_potencia = 3) then dar_potencia:= 'SetPower(OUT_'+salida+',OUT_HALF);'; if (fpotencia.dar_potencia = 4) or (fpotencia.dar_potencia = 5) then dar_potencia:= 'SetPower(OUT_'+salida+',OUT_FULL);'; end; function Tfsalidas.dar_estado:string; var cadena:string; sest,sposix,sposiy,sini,ssimpl,stipo,pote:string; cnum:integer; begin str(estado,sest); str(left,sposix); str(top,sposiy); str(inicial,sini); str(simple,ssimpl); str(tipo,stipo); str(fpotencia.dar_potencia,pote); dar_estado:=sest+' '+sposix+' '+sposiy+' '+stipo+' '+sini+' '+ssimpl+' '+pote+' '+salida; end; procedure Tfsalidas.FormCreate(Sender: TObject); begin Application.CreateForm(Tfpotencia, fpotencia); end; end.