desarrollosconsejeria/adtos-aula/1.7-0/serveradtosaula/clpingportatil.pas @ 23a384b9
23a384b9 | Elisa | {
|
|
adtos 1.3 Software de gestión de Aulas Tecnológicas
|
|||
Copyright (C) 2008-2009, Consejería de Educación,Junta de Extremadura
|
|||
Programación: Manuel Narváez Martínez <mnarvaez007@gmail.com>
|
|||
Diseño gráfico: Ana María Zamora Moreno
|
|||
Desarrollado con Lazarus 0.9.26
|
|||
This program is free software; you can redistribute it and/or modify
|
|||
it under the terms of the GNU General Public License as published by
|
|||
the Free Software Foundation; either version 2 of the License, or
|
|||
(at your option) any later version.
|
|||
This program is distributed in the hope that it will be useful,
|
|||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|||
GNU General Public License for more details.
|
|||
You should have received a copy of the GNU General Public License
|
|||
along with this program; if not, write to the Free Software
|
|||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|||
}
|
|||
unit clpingPortatil;
|
|||
interface
|
|||
uses
|
|||
globales,SysUtils,Classes, IdComponent, IdTCPClient; //unix
|
|||
type
|
|||
TdatEqu=record
|
|||
usuario:String;
|
|||
nombre:String;
|
|||
mac:String;
|
|||
ip:String;
|
|||
Encendido:integer;
|
|||
datos:String
|
|||
end;
|
|||
ThrPingPortatil= class(TThread)
|
|||
private
|
|||
fcliente:TIdTCPClient;
|
|||
ftsEquiposAlumnos:TStringList;
|
|||
fdatosprofe:String;
|
|||
fdequipos:Array of TdatEqu;
|
|||
protected
|
|||
procedure Execute; override;
|
|||
public
|
|||
constructor Create(const datosEquiposA:TArray_datos_equipos;datosprofe:string);
|
|||
end;
|
|||
implementation
|
|||
constructor ThrPingPortatil.Create(const datosEquiposA:TArray_datos_equipos;datosprofe:string);
|
|||
var i:integer;
|
|||
begin
|
|||
inherited Create(true);
|
|||
SetLength(fdequipos,Length(datosEquiposA));
|
|||
for i:= 0 to High(datosEquiposA) do
|
|||
begin
|
|||
fdequipos[i].nombre:=datosEquiposA[i].nombre;
|
|||
fdequipos[i].ip:=datosEquiposA[i].ip;
|
|||
fdequipos[i].mac:=datosEquiposA[i].mac;
|
|||
fdequipos[i].usuario:=' ';
|
|||
fdequipos[i].Encendido:=0;
|
|||
fdequipos[i].datos:='';
|
|||
end;
|
|||
fdatosProfe:=datosprofe;
|
|||
self.FreeOnTerminate:=True;
|
|||
end;
|
|||
procedure ThrPingPortatil.Execute;
|
|||
var
|
|||
datosEq:String;
|
|||
j,i:integer;
|
|||
begin
|
|||
try
|
|||
fcliente:=TIdTCPClient.Create();
|
|||
ftsEquiposAlumnos:=TStringList.Create();
|
|||
ftsEquiposAlumnos.add(fdatosProfe);
|
|||
for j:=0 to 1 do
|
|||
begin
|
|||
for i :=0 to High(fdequipos) do
|
|||
begin
|
|||
try
|
|||
try
|
|||
if (fdequipos[i].Encendido=1) then continue;
|
|||
fdequipos[i].datos:=fdequipos[i].nombre+'&'+fdequipos[i].ip+'&'+fdequipos[i].mac+'& &0';
|
|||
fcliente.ConnectTimeout:=500;
|
|||
fcliente.Host:=fdequipos[i].ip;
|
|||
fcliente.Port:=36999;
|
|||
fcliente.connect;
|
|||
fcliente.GetResponse(200);
|
|||
fcliente.SendCmd('datosEquipo',317);
|
|||
datosEq:= trim(fcliente.LastCmdResult.text.text);
|
|||
if datosEq[Length(datosEq)]='&' then
|
|||
datosEq:=datosEq+' &1'
|
|||
else
|
|||
datosEq:=datosEq+'&1';
|
|||
fdequipos[i].datos:=trim(datosEq);
|
|||
fdequipos[i].Encendido:=1;
|
|||
except
|
|||
if fcliente.Connected then fcliente.Disconnect();
|
|||
end;
|
|||
finally
|
|||
if fcliente.Connected then fcliente.Disconnect();
|
|||
end;
|
|||
end;
|
|||
end;
|
|||
finally
|
|||
for i:=0 to High(fdequipos) do
|
|||
begin
|
|||
if trim(fdequipos[i].datos)<>'' then
|
|||
ftsEquiposAlumnos.add(fdequipos[i].datos);
|
|||
end;
|
|||
g_tsEquiposAlumnos.Text:=ftsEquiposAlumnos.Text;
|
|||
if fcliente.Connected then fcliente.Disconnect;
|
|||
ftsEquiposAlumnos.Free;
|
|||
fcliente.Free;
|
|||
Terminate;
|
|||
end;
|
|||
end;
|
|||
end.
|