Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   OOP (https://www.clubdelphi.com/foros/forumdisplay.php?f=5)
-   -   Interceptar Eventos Externos (https://www.clubdelphi.com/foros/showthread.php?t=93776)

Neftali [Germán.Estévez] 27-02-2019 08:43:57

Algunas consideraciones...


1) Los procedimientos definidos, colócalos dentro de la parte privada.
Código Delphi [-]
   ...

    dbgrd1: TDBGrid;
    mmoLOG: TMemo;
    lbl1: TLabel;
  private

    procedure FormCreate(Sender: TObject);
    procedure LeerHuella(Sender: Tobject);

    procedure AttTransactionProc(ASender: TObject; EnrollNumber: Integer; IsInValid: Integer;
                                 AttState: Integer; VerifyMethod: Integer;
                                 Year: Integer; Month: Integer; Day: Integer;
                                 Hour: Integer; Minute: Integer;
                                 Second: Integer);
    procedure GeneralEventProc(ASender: TObject; const DataStr: WideString);
  public


2) Define un par más para ver otros eventos:
Código Delphi [-]
    procedure AttTransactionProc(ASender: TObject; EnrollNumber: Integer; IsInValid: Integer;
                                 AttState: Integer; VerifyMethod: Integer;
                                 Year: Integer; Month: Integer; Day: Integer;
                                 Hour: Integer; Minute: Integer;
                                 Second: Integer);
    procedure GeneralEventProc(ASender: TObject; const DataStr: WideString);


3) Añade la implementación con el Log.
Código Delphi [-]
procedure TForm1.GeneralEventProc(ASender: TObject; const DataStr: WideString);
begin
  Log('TForm1.GeneralEventProc');
  Log('  - DataString: ' + DataStr);
end;

procedure TForm1.AttTransactionProc(ASender: TObject; EnrollNumber, IsInValid,
  AttState, VerifyMethod, Year, Month, Day, Hour, Minute, Second: Integer);
begin
  Log('TForm1.AttTransactionProc');
  Log('  - EnrollNumber: ' + IntToStr(EnrollNumber));
  Log('  - IsInValid: ' + IntToStr(IsInValid));
  Log('  - AttState: ' + IntToStr(AttState));
  Log('  - VerifyMethod: ' + IntToStr(VerifyMethod));
  Log('  - Year: ' + IntToStr(Year));
  Log('  - Month: ' + IntToStr(Month));
  Log('  - Day: ' + IntToStr(Day));
  Log('  - Hour: ' + IntToStr(Hour));
  Log('  - Minute: ' + IntToStr(Minute));
  Log('  - Second: ' + IntToStr(Second));
end;


4) Y asignalos todos en la creación del componente:
Código Delphi [-]
...

  ZK1 := TCZKEM.Create(nil);
  ZK1.OnConnected := OnConnect;
  ZK1.OnFinger := LeerHuella;
  ZK1.OnDisConnected := OnDisconnect;
  ZK1.OnAttTransaction := AttTransactionProc;
  ZK1.OnGeneralEvent := GeneralEventProc;


Por último, estaría bien que nos pusieras la salida del Log, cuando ejecutas y cuando pones el dedo en el lector.

oscarac 27-02-2019 15:12:39

Cita:

Empezado por Neftali [Germán.Estévez] (Mensaje 530876)
Yo hasta aquí lo veo bien.
Crear el componente, le assignas los eventos OnFinger y OnConnect (el OnDisconnect no).
Y luego haces el Connect_Net.


A partir de ahí si llegas al punto en que está conectado (suponiendo que no haya que llamar algún método más para inicializar) deberían empezar a llegarte eventos cuando pongas el dedo.
Cada vez que se ejecute el evento en el dispositivo (OnFinger), a tu programa llegará el control al procedimniento LeerHuella.



¿Es correcto?

Correcto, hasta aqui funciona
voy a probar lo que has mencionado posteriormente y les aviso

oscarac 27-02-2019 15:17:00

Cita:

Empezado por Neftali [Germán.Estévez] (Mensaje 530877)
Algunas consideraciones...


1) Los procedimientos definidos, colócalos dentro de la parte privada.
Código Delphi [-]
   ...

    dbgrd1: TDBGrid;
    mmoLOG: TMemo;
    lbl1: TLabel;
  private

    procedure FormCreate(Sender: TObject);
    procedure LeerHuella(Sender: Tobject);

    procedure AttTransactionProc(ASender: TObject; EnrollNumber: Integer; IsInValid: Integer;
                                 AttState: Integer; VerifyMethod: Integer;
                                 Year: Integer; Month: Integer; Day: Integer;
                                 Hour: Integer; Minute: Integer;
                                 Second: Integer);
    procedure GeneralEventProc(ASender: TObject; const DataStr: WideString);
  public


2) Define un par más para ver otros eventos:
Código Delphi [-]
    procedure AttTransactionProc(ASender: TObject; EnrollNumber: Integer; IsInValid: Integer;
                                 AttState: Integer; VerifyMethod: Integer;
                                 Year: Integer; Month: Integer; Day: Integer;
                                 Hour: Integer; Minute: Integer;
                                 Second: Integer);
    procedure GeneralEventProc(ASender: TObject; const DataStr: WideString);


3) Añade la implementación con el Log.
Código Delphi [-]
procedure TForm1.GeneralEventProc(ASender: TObject; const DataStr: WideString);
begin
  Log('TForm1.GeneralEventProc');
  Log('  - DataString: ' + DataStr);
end;

procedure TForm1.AttTransactionProc(ASender: TObject; EnrollNumber, IsInValid,
  AttState, VerifyMethod, Year, Month, Day, Hour, Minute, Second: Integer);
begin
  Log('TForm1.AttTransactionProc');
  Log('  - EnrollNumber: ' + IntToStr(EnrollNumber));
  Log('  - IsInValid: ' + IntToStr(IsInValid));
  Log('  - AttState: ' + IntToStr(AttState));
  Log('  - VerifyMethod: ' + IntToStr(VerifyMethod));
  Log('  - Year: ' + IntToStr(Year));
  Log('  - Month: ' + IntToStr(Month));
  Log('  - Day: ' + IntToStr(Day));
  Log('  - Hour: ' + IntToStr(Hour));
  Log('  - Minute: ' + IntToStr(Minute));
  Log('  - Second: ' + IntToStr(Second));
end;


4) Y asignalos todos en la creación del componente:
Código Delphi [-]
...

  ZK1 := TCZKEM.Create(nil);
  ZK1.OnConnected := OnConnect;
  ZK1.OnFinger := LeerHuella;
  ZK1.OnDisConnected := OnDisconnect;
  ZK1.OnAttTransaction := AttTransactionProc;
  ZK1.OnGeneralEvent := GeneralEventProc;


Por último, estaría bien que nos pusieras la salida del Log, cuando ejecutas y cuando pones el dedo en el lector.

la idea es que yo declaro un procedimiento para cuando se dispare un evento, eso lo tengo clarisimo, pero me esta saliendo un error cuando defino el procedimiento

Código Delphi [-]
[dcc32 Error] FrmMain_f.pas(22): E2065 Unsatisfied forward or external declaration: 'TForm1.AttTransactionProc'

oscarac 27-02-2019 15:29:27

el error fue mi culpa, no estaba definiendo el procedimiento dentro del form

cuando coloco la huella, solo se activa el evento leerhuella, los demas no

tengo entendido, segun lo que vi en el manual que en la instruccion

Código Delphi [-]
    if not ZK1.RegEvent(1, 65535) then  //65535   2 = Solo OnFinger

se van a disparar todos los eventos relacionados con el lector


pero el evento OnttTransaction no se dispara

oscarac 27-02-2019 15:46:09

otro tema estoy usando el Evento OnAttTransactionEx porque dentro de sus parametros devuelve el codigo del usuario en string

Código Delphi [-]
    procedure AttTransactionExProc(ASender: TObject; EnrollNumber: WideString; IsInValid: Integer;
                                 AttState: Integer; VerifyMethod: Integer;
                                 Year: Integer; Month: Integer; Day: Integer;
                                 Hour: Integer; Minute: Integer;
                                 Second: Integer; WorkCode: Integer);

y al momento de compilar me sale este mensaje

Código Delphi [-]
[dcc32 Error] FrmMain_f.pas(55): E2009 Incompatible types: 'Parameter lists differ'

la unica diferencia con el OnAttTransaction es que el parametro EnrollNumber es string y tiene un campo adicional al final WorkCode Long (Integer)

no entiendo

oscarac 27-02-2019 16:32:28

Esto lo estoy tratando de documentar y dar la mejor explicacion en caso alguien mas tenga ese problema

Era mi error

fui a la libreria zkemkeeper_TLB

esta es su definicion

Código Delphi [-]
    procedure OnAttTransactionEx(const EnrollNumber: WideString; IsInValid: Integer; 
                                 AttState: Integer; VerifyMethod: Integer; Year: Integer; 
                                 Month: Integer; Day: Integer; Hour: Integer; Minute: Integer; 
                                 Second: Integer; WorkCode: Integer); dispid 17;

al momento de yo declarar el procedimiento no le coloque la palabra CONST

entonces la definicion de los procedimientos debe ser exactamente igual a como esta en la libreria

con esto ya funciona

colooco el dedo y funciona EUREKA

pero no todo es felicidad, por algun motivo los eventos se disparan 2 veces
y me sale este mensaje (displayados en el log)

Cita:

6.2.5.50
Conectado...
Huella Detectada
Huella Detectada
TForm1.AttTransactionExProc
- EnrollNumber:
ð*º
ð*º
ð*º
ð*º
ð*º
ð*º
- IsInValid: -1
- AttState: 0
- VerifyMethod: 13
- Year: 1917
- Month: -70
- Day: 13
- Hour: -16
- Minute: -83
- Second: -70
TForm1.AttTransactionExProc
- EnrollNumber: 123
- IsInValid: 0
- AttState: 0
- VerifyMethod: 0
- Year: 2019
- Month: 2
- Day: 27
- Hour: 10
- Minute: 26
- Second: 10

si se dan cuenta en el primer grupo de mensaje los valores salen distorcionados, no corresponde la informacion a lo que se supone debe salir (como aparece en el segundo bloque)


coloque zk1.Pullmode := 1

y cuando hago eso no pasa por el evento LeerHuella

antes de concluir y de solicitar mas ayuda quiero agradecer a todos los que me han dado una mano en este tema, de verdad que lo hacen desinteresadamente, mas personas como uds. en el mundo

Neftali [Germán.Estévez] 27-02-2019 17:09:22

Cita:

Empezado por oscarac (Mensaje 530885)
con esto ya funciona
colooco el dedo y funciona EUREKA

^\||/^\||/^\||/

Cita:

Empezado por oscarac (Mensaje 530885)

si se dan cuenta en el primer grupo de mensaje los valores salen distorcionados, no corresponde la informacion a lo que se supone debe salir (como aparece en el segundo bloque)

Es posible que te devuelva diferentes lecturas. Me llama la atención el parámetro IsInvlid.

Es posible que devuelva lecturas hasta que hay una correcta o que realice un número fijo (como si fueran reintentos) hasta un número fijo o una lectura correcta.
Haz diferentes pruebas y verás en patrón. De todas formas en la documentación debe explicar el funcionamiento.

oscarac 02-03-2019 19:23:30

Esta pasando algo raro
en la computadora donde hice las pruebas funciona perfectamente, pero cuando instalo el programa en otra computadora (registrando el zkemkeeper.dll)
colocando la misma ip, no logra conectar el lector

he instalado el xe7 para depurar y no logro conectar el lector, he instalado como package el dll compila bien pero no conecta

aparece en los mensajes de event Log

Module Unload: wshtcpip.dll. Process Reloj
Module Unload: Nlaapi.dll
Module Unload Napinsp.dll
...
...

asi sucesivamente


me faltara instalar algo?

Neftali [Germán.Estévez] 04-03-2019 09:57:50

¿No hay ningun log de lo que está pasando?
Revisa que las librerías sean las correctas. Revisa 32/64 bits de las librerías.


La franja horaria es GMT +2. Ahora son las 15:38:08.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi