|
{
|
|
Adtos 1.0 Software de gestión de Aulas Tecnológicas
|
|
|
|
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 clequiposervidoraula;
|
|
interface
|
|
uses IdURI,globales,ExtCtrls,SysUtils,clcomandos,clcomandosroot,clcuestion,clenviararchivo,clenviararchivoroot,clenviarcarpeta,clenviarcarpetaroot, HTTPDefs;
|
|
type
|
|
|
|
{ Tequipo }
|
|
|
|
Tequipo= class
|
|
private
|
|
fEstadoActividadEquipo:TEstadoActividadEquipo;
|
|
fMiNumero:integer;
|
|
fCurso:String;
|
|
fDominio:String;
|
|
fmihost,fmac,fIP:String;
|
|
fUsuarioActivo:string;
|
|
fNombreMonitor:string;
|
|
fPuerto:integer;
|
|
fL,fT:integer;
|
|
fcuestion_respuesta:integer;
|
|
fcuestion_tiempo:integer;
|
|
fcuestion_resultado:integer;
|
|
fcuestion_terminada:boolean;
|
|
fcuestion_hace:boolean;
|
|
fproceso_resultado:ansistring;
|
|
fproceso_terminado:boolean;
|
|
fproceso_id:String;
|
|
fproceso_hace:boolean;
|
|
|
|
|
|
procedure EjecutarComandos(codigo:integer;comando:string);
|
|
procedure EjecutarComandosRoot ( mhost:string;codigo : integer ; comando : string);
|
|
procedure ejecutarProcesoAsiNo();
|
|
procedure EnviarCarpeta(comando,carpeta: string);
|
|
procedure EnviarCarpetaRoot(comando, carpeta: string;codigo:integer);
|
|
function getNombreMonitor: string;
|
|
procedure mensajeNo();
|
|
procedure archivo();
|
|
procedure archivoNo();
|
|
|
|
procedure archivoRootNo();
|
|
procedure carpeta();
|
|
procedure carpetaNo();
|
|
procedure EnviarArchivos(comando,miarchivo:string);
|
|
procedure EnviarArchivosRoot(comando,miarchivo:string;codigo:integer);
|
|
procedure EnviarCuestion(comando,miarchivo:string);
|
|
|
|
|
|
public
|
|
fIconoMonitor:Array of Integer;
|
|
fMonitorPulsado:Array of Boolean;
|
|
procedure ejecutarProcesoAsi();
|
|
constructor create(numero:integer;host,ip,mac:string;estado:boolean;mcurso,dominio:String);
|
|
destructor Destroy; override;
|
|
property EstadoActivadEquipo:TEstadoActividadEquipo read fEstadoActividadEquipo write fEstadoActividadEquipo;
|
|
property mihost:string read Fmihost write Fmihost;
|
|
property Dominio:string read fDominio write fDominio;
|
|
property IP:string read fIP write fIP;
|
|
property Puerto:integer read fPuerto write fPuerto;
|
|
property MAC:string read fMAC write fMAC;
|
|
property UsuarioActivo:string read fUsuarioActivo write fUsuarioActivo;
|
|
property NombreMonitor:string read getNombreMonitor;
|
|
property L:integer read fL write fL;
|
|
property T:integer read fT write fT;
|
|
property Curso:String read fCurso write fCurso;
|
|
|
|
property CuestionTerminada:Boolean read fcuestion_terminada write fcuestion_terminada;
|
|
property CuestionHace:Boolean read fcuestion_hace write fcuestion_hace;
|
|
property CuestionRespuesta:integer read fcuestion_respuesta write fcuestion_respuesta;
|
|
property CuestionTiempo:integer read fcuestion_tiempo write fcuestion_tiempo;
|
|
property CuestionResultado:integer read fcuestion_resultado write fcuestion_resultado;
|
|
|
|
property ProcesoId:String read fproceso_id write fproceso_id;
|
|
property ProcesoTerminado:Boolean read fproceso_terminado write fproceso_terminado;
|
|
property ProcesoResultado:ansistring read fproceso_resultado write fproceso_resultado;
|
|
property ProcesoHace:Boolean read fproceso_hace write fproceso_hace;
|
|
|
|
procedure ElegirOrden(numpant:integer;mestado:boolean);
|
|
Function IconoEquipo(numpan:integer):integer;
|
|
procedure mensaje();
|
|
procedure encender();
|
|
procedure encenderNo();
|
|
procedure iniciarCuestion();
|
|
procedure apagarEncenderAlumosAula(tipo: integer);
|
|
procedure apagarEncenderEquipoAlumno(ipomac:string;tipo:string);
|
|
procedure cargarEvaluacionCuestion(solucion: integer; respuesta: integer=0; tiempo: integer=30);
|
|
|
|
end;
|
|
const
|
|
NUM_PANTALLAS:integer=15;
|
|
TIEMPO_ENCENDIENDO:INTEGER=50;
|
|
TIEMPO_APAGANDO:INTEGER=40;
|
|
|
|
implementation
|
|
|
|
uses inicio,globales1;
|
|
|
|
procedure Tequipo.cargarEvaluacionCuestion(solucion:integer;respuesta:integer=0;tiempo:integer=30);
|
|
begin
|
|
fcuestion_terminada:=true;
|
|
fcuestion_tiempo:=tiempo;
|
|
fcuestion_respuesta:=respuesta;
|
|
if fcuestion_respuesta = 0 then
|
|
fcuestion_resultado:=0
|
|
else if fcuestion_respuesta=solucion then
|
|
fcuestion_resultado:=1
|
|
else
|
|
fcuestion_resultado:=2;
|
|
end;
|
|
|
|
|
|
procedure Tequipo.iniciarCuestion();
|
|
var
|
|
orden_cuestion:string;
|
|
begin
|
|
orden_cuestion:='iniciarCuestion';
|
|
EnviarCuestion(orden_cuestion,equipoAdministrador.ArcCuestion);
|
|
end;
|
|
procedure Tequipo.ejecutarProcesoAsiNo();
|
|
begin
|
|
fproceso_resultado:='Equipo apagado o averiado';
|
|
|
|
end;
|
|
procedure Tequipo.ejecutarProcesoAsi();
|
|
var
|
|
nombrearchivo,orden_consulta:string;
|
|
begin
|
|
fproceso_resultado:='Equipo apagado o averiado';
|
|
if fEstadoActividadEquipo in [eAveriado,eApagado] then exit;
|
|
fproceso_id:=equipoAdministrador.IdProcesos;
|
|
fproceso_hace:=true;
|
|
fproceso_terminado:=false;
|
|
fproceso_resultado:='Aún no se ha recibido respuesta de este equipo';
|
|
case g_tipo_comando of
|
|
-1:
|
|
begin
|
|
orden_consulta:='hallaProcesosActivosAsi '+equipoAdministrador.IdProcesos +' '+equipoAdministrador.Procesos +' '+ g_contraServidores +' '+ IntToStr(fMiNumero) + ' '+ IntToStr(g_comando_consulta);
|
|
EjecutarComandosRoot(fIP,402,orden_consulta);
|
|
end;
|
|
0:
|
|
begin
|
|
nombrearchivo:=HTTPEncode(g_archivo_nombre_root);
|
|
orden_consulta:='archivoAulaAsi ' + nombrearchivo+' ' + g_carpeta_destino_root + ' ' +g_contraServidores+' ' + equipoAdministrador.idProcesos +' '+ IntToStr(fMiNumero) ;
|
|
EnviarArchivosRoot(orden_consulta,g_archivo_path_root,403);
|
|
end;
|
|
3:
|
|
begin
|
|
orden_consulta:='carpetaAulaAsi ' + g_carpeta_destino_root + ' ' +g_contraServidores+' ' + equipoAdministrador.idProcesos +' '+ IntToStr(fMiNumero) ;
|
|
EnviarCarpetaRoot(orden_consulta,g_carpeta_enviar_path_root,406);
|
|
end;
|
|
1:
|
|
begin
|
|
nombrearchivo:=HTTPEncode(g_archivo_nombre_root);
|
|
orden_consulta:='instalaPaqueteDebian ' + nombrearchivo+' ' + g_carpeta_destino_root + ' ' +g_contraServidores+' ' +equipoAdministrador.idProcesos +' '+ IntToStr(fMiNumero);
|
|
EnviarArchivosRoot(orden_consulta,g_archivo_path_root,405);
|
|
end;
|
|
2:
|
|
begin
|
|
nombrearchivo:=HTTPEncode(g_archivo_nombre_root);
|
|
orden_consulta:='ejecutaScriptAsi '+ nombrearchivo+' ' + '/tmp' + ' ' +g_contraServidores+' ' +equipoAdministrador.idProcesos +' '+ IntToStr(fMiNumero);
|
|
EnviarArchivosRoot(orden_consulta,g_archivo_path_root,404);
|
|
|
|
end;
|
|
end;
|
|
//writeln(orden_consulta);
|
|
//inc(equipoAdministrador.NumeroConsultados);
|
|
end;
|
|
procedure Tequipo.EnviarCuestion(comando,miarchivo:string);
|
|
begin
|
|
if fEstadoActividadEquipo <> eUsuario then exit;
|
|
with ThrCuestion.create(fIP,comando,miarchivo) do Resume;
|
|
end;
|
|
Function Tequipo.IconoEquipo(numpan:integer):integer;
|
|
begin
|
|
result :=fIconoMonitor[numpan];
|
|
end;
|
|
|
|
procedure TEquipo.ElegirOrden(numpant:integer;mestado:boolean);
|
|
begin
|
|
if fEstadoActividadEquipo=eAveriado then Exit;
|
|
case numpant of
|
|
0://eEncender:
|
|
begin
|
|
if mestado then
|
|
begin
|
|
encender();
|
|
end
|
|
else
|
|
begin
|
|
encenderNo();
|
|
end;
|
|
end;
|
|
3://eMensaje:
|
|
begin
|
|
if mestado then
|
|
begin
|
|
mensaje();
|
|
end
|
|
else
|
|
begin
|
|
mensajeNo();
|
|
end;
|
|
end;
|
|
4://eArchivo:
|
|
begin
|
|
if mestado then
|
|
begin
|
|
archivo();
|
|
end
|
|
else
|
|
begin
|
|
//archivoNo();
|
|
end;
|
|
end;
|
|
5://eCarpeta:
|
|
begin
|
|
if mestado then
|
|
begin
|
|
carpeta();
|
|
end
|
|
else
|
|
begin
|
|
carpetaNo();
|
|
end;
|
|
end;
|
|
|
|
6://eEjecutar:
|
|
begin
|
|
if mestado then
|
|
begin
|
|
ejecutarProcesoAsi();
|
|
end
|
|
else
|
|
begin
|
|
ejecutarProcesoAsiNo()
|
|
end;
|
|
end;
|
|
7://eArchivoRoot:
|
|
begin
|
|
if mestado then
|
|
begin
|
|
ejecutarProcesoAsi();
|
|
end
|
|
else
|
|
begin
|
|
ejecutarProcesoAsiNo();
|
|
end;
|
|
end;
|
|
end;
|
|
fMonitorPulsado[numpant]:=mestado;
|
|
if mestado then
|
|
fIconoMonitor[numpant]:=1
|
|
else
|
|
fIconoMonitor[numpant]:=0;
|
|
end;
|
|
destructor Tequipo.Destroy;
|
|
begin
|
|
FreeAndnil(fIconoMonitor);
|
|
FreeAndnil(fMonitorPulsado);
|
|
inherited Destroy;
|
|
end;
|
|
|
|
constructor TEquipo.create(numero:integer;host,ip,mac:string;estado:Boolean;mcurso,dominio:String);
|
|
var
|
|
i:integer;
|
|
begin
|
|
inherited Create;
|
|
if estado=false then
|
|
fEstadoActividadEquipo:=eAveriado
|
|
else
|
|
fEstadoActividadEquipo:=eApagado;
|
|
fUsuarioActivo:='';
|
|
fDominio:=dominio;
|
|
fCurso:=mcurso;
|
|
fmihost:=host;
|
|
fNombreMonitor:= fmihost;
|
|
Fminumero:=numero;
|
|
fip:=ip;
|
|
fpuerto:=PUERTO_ROOT;
|
|
fmac:=mac;
|
|
fproceso_hace:=false;
|
|
fproceso_terminado:=true;
|
|
fproceso_resultado:='';
|
|
fproceso_id:='S';
|
|
setlength(fMonitorPulsado,NUM_PANTALLAS);
|
|
setlength(fIconoMonitor,NUM_PANTALLAS);
|
|
for i:=0 to NUM_PANTALLAS -1 do
|
|
begin
|
|
fMonitorPulsado[i]:=false;
|
|
fIconoMonitor[i]:=0;
|
|
if fEstadoActividadEquipo=eAveriado then fIconoMonitor[i]:=2;
|
|
end;
|
|
end;
|
|
|
|
|
|
procedure Tequipo.EjecutarComandos(codigo:integer;comando:string);
|
|
begin
|
|
if fEstadoActividadEquipo <> eUsuario then exit;
|
|
with ThrComandos1.create(codigo,fIP,comando) do Resume;
|
|
end;
|
|
|
|
procedure Tequipo.EjecutarComandosRoot( mhost:string;codigo:integer;comando:string);
|
|
begin
|
|
with ThrComandosRoot.create(codigo,mhost,comando) do Resume;
|
|
end;
|
|
|
|
|
|
procedure Tequipo.EnviarArchivos(comando,miarchivo:string);
|
|
begin
|
|
if fEstadoActividadEquipo <> eUsuario then exit;
|
|
with ThrEnviar.create(fIP,comando,miarchivo) do Resume;
|
|
end;
|
|
procedure Tequipo.EnviarArchivosRoot(comando,miarchivo:string;codigo:integer);
|
|
begin
|
|
with ThrEnviarRoot.create(fIP,comando,miarchivo,codigo) do Resume;
|
|
end;
|
|
|
|
procedure Tequipo.EnviarCarpeta(comando,carpeta:string);
|
|
begin
|
|
if fEstadoActividadEquipo <> eUsuario then exit;
|
|
with ThrEnviarCarpeta.create(Fminumero,fIP,comando,carpeta) do Resume;
|
|
end;
|
|
procedure Tequipo.EnviarCarpetaRoot(comando,carpeta:string;codigo:integer);
|
|
begin
|
|
if not (fEstadoActividadEquipo in [eUsuario, eEncendido]) then exit;
|
|
with ThrEnviarCarpetaRoot.create(Fminumero,fIP,comando,carpeta,codigo) do Resume;
|
|
end;
|
|
|
|
function Tequipo.getNombreMonitor: string;
|
|
begin
|
|
if fUsuarioActivo<>''then
|
|
result:=fUsuarioActivo
|
|
else
|
|
result:=fmihost;
|
|
end;
|
|
|
|
procedure Tequipo.encender();
|
|
const
|
|
ORD_ENCENDER:STRING= 'wakeonlan %s &';
|
|
var
|
|
orden:string;
|
|
begin
|
|
if (fEstadoActividadEquipo =eApagado) then
|
|
begin
|
|
fEstadoActividadEquipo:=eEncendiendo;
|
|
if trim(fmac)<>'' then
|
|
begin
|
|
|
|
orden:=format(ORD_ENCENDER,[fMAC]);
|
|
Ejecutar(Orden);
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
procedure Tequipo.EncenderNo();
|
|
var
|
|
i:integer;
|
|
begin
|
|
if fEstadoActividadEquipo in [eEncendido,eUsuario] then
|
|
begin
|
|
EjecutarComandosRoot(fIP,302,'ApagarEquipo '+g_contraServidores);
|
|
fEstadoActividadEquipo:=eApagando;
|
|
for i:=0 to 35 do
|
|
begin
|
|
g_equiposAulas[fMiNumero][i].estadoActividad:=eApagado;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
procedure Tequipo.mensaje();
|
|
var
|
|
orden:string;
|
|
begin
|
|
orden:='mensaje ' + g_mensaje_prioridad+' '+ g_mensaje_asunto+' '+ g_mensaje_texto;
|
|
EjecutarComandos(204,orden);
|
|
end;
|
|
|
|
procedure Tequipo.mensajeNo();
|
|
begin
|
|
EjecutarComandos(205,'mensajeNo');
|
|
end;
|
|
procedure Tequipo.apagarEncenderAlumosAula(tipo:integer);
|
|
var
|
|
orden:string;
|
|
begin
|
|
if fEstadoActividadEquipo in [eApagado,eAveriado] then exit;
|
|
orden:='apagarEncenderAlumnosAula ' + inttostr(tipo) +' ' + g_contraServidores;
|
|
//writeln('apagarEncenderAlumnosAula ',orden);
|
|
EjecutarComandosRoot(fIP,500,orden);
|
|
|
|
end;
|
|
procedure Tequipo.apagarEncenderEquipoAlumno(ipomac:string;tipo:string);
|
|
var
|
|
orden:string;
|
|
begin
|
|
orden:='apagarEquipoAlumno ' + ipomac +' ' +tipo+ ' ' + g_contraServidores;
|
|
EjecutarComandosRoot(fIP,501,orden);
|
|
end;
|
|
procedure Tequipo.archivo();
|
|
var
|
|
nombrearchivo,orden:string;
|
|
begin
|
|
nombrearchivo:=HTTPEncode(g_archivo_nombre);
|
|
orden:='archivo ' + nombrearchivo+' ' + g_archivo_mensaje;
|
|
EnviarArchivos(orden,g_archivo_path);
|
|
end;
|
|
|
|
procedure Tequipo.archivoRootNo();
|
|
begin
|
|
//
|
|
end;
|
|
procedure Tequipo.archivoNo();
|
|
begin
|
|
//
|
|
end;
|
|
|
|
procedure Tequipo.Carpeta();
|
|
var
|
|
orden_carpeta:string;
|
|
begin
|
|
orden_carpeta:='carpeta '+ g_carpeta_mensaje;
|
|
// writeln(orden_carpeta);
|
|
EnviarCarpeta(orden_carpeta,g_carpeta_enviar_path);
|
|
end;
|
|
|
|
procedure Tequipo.CarpetaNo();
|
|
begin
|
|
//
|
|
end;
|
|
|
|
|
|
end.
|