This is a visual class.. but I would like to get off all visuals, and encapsulate this functionatily on class that I instantiate, and call it method and get a tt back? Just starting to get into
OO.. Thnaks.
/*------------------------------------------------------------------------
File : FingerPrint
Purpose : Get template from a FingerPrint
Syntax :
Description :
Author(s) :
Created : Nov 23 15:04:32 CST 2015
Notes :
----------------------------------------------------------------------*/
BLOCK-LEVEL ON ERROR UNDO, THROW.
USING Progress.Windows.Form FROM ASSEMBLY.
USING Suprema.UFS_STATUS FROM ASSEMBLY.
USING Suprema.UFScanner FROM ASSEMBLY.
USING Suprema.UFScannerManager FROM ASSEMBLY.
USING System.Text.*.
CLASS Procs.enroll.Act.FingerPrint INHERITS Form:
DEFINE PRIVATE VARIABLE btnEscanear AS System.Windows.Forms.Button NO-UNDO.
DEFINE PRIVATE VARIABLE components AS System.ComponentModel.IContainer NO-UNDO.
DEFINE PRIVATE VARIABLE scannerManager AS Suprema.UFScannerManager NO-UNDO.
DEFINE PRIVATE VARIABLE template_size AS INTEGER NO-UNDO.
DEFINE PRIVATE VARIABLE max_template_size AS INTEGER NO-UNDO INITIAL 512.
DEFINE PRIVATE VARIABLE Template AS "System.Byte[]" NO-UNDO.
DEFINE PRIVATE VARIABLE TemplateSize AS INTEGER NO-UNDO.
DEFINE PRIVATE VARIABLE StrByteValue AS CHARACTER.
// output parameters
DEFINE TEMP-TABLE tt1 NO-UNDO
FIELD f1 AS BLOB.
DEFINE VARIABLE Resultado AS CHARACTER NO-UNDO.
CONSTRUCTOR PUBLIC FingerPrint ( ):
SUPER().
InitializeComponent().
THIS-OBJECT:ComponentsCollection:ADD(THIS-OBJECT:components).
CATCH e AS Progress.Lang.Error:
UNDO, THROW e.
END CATCH.
END CONSTRUCTOR.
/*------------------------------------------------------------------------------
Purpose:
Notes:
------------------------------------------------------------------------------*/
@VisualDesigner.
METHOD PRIVATE VOID BioLogin_KeyDown( INPUT sender AS System.Object, INPUT e AS System.Windows.Forms.KeyEventArgs ):
MESSAGE e:KeyValue
VIEW-AS ALERT-BOX.
END METHOD.
/*------------------------------------------------------------------------------
Purpose:When the form loads, it checks if scanner is connected.
Notes:
------------------------------------------------------------------------------*/
@VisualDesigner.
METHOD PRIVATE VOID BioLogin_Load( INPUT sender AS System.Object, INPUT e AS System.EventArgs ):
DEFINE VARIABLE ufs_res AS UFS_STATUS NO-UNDO.
DEFINE VARIABLE Scanner AS UFScanner NO-UNDO.
/* ASSIGN */
/* Scanner = ? */
/* scannerManager = NEW UFScannerManager(THIS-OBJECT) */
/* ufs_res = scannerManager:Init(). */
/* */
/* IF STRING(ufs_res) = STRING(UFS_STATUS:OK) THEN */
/* ASSIGN */
/* Scanner = scannerManager:Scanners[0]*/
/* Scanner:Timeout = 9000 */
/* Scanner:TemplateSize = max_template_size */
/* Scanner:DetectCore = FALSE. */
/* ELSE */
/* ASSIGN */
/* resultado = msgError(ufs_res:value__). */
//ufs_res = scannerManager:UnInit().
END METHOD.
/*------------------------------------------------------------------------------
Purpose:Start scanning
Notes:
------------------------------------------------------------------------------*/
@VisualDesigner.
METHOD PRIVATE VOID btnStart_Click( INPUT sender AS System.Object, INPUT e AS System.EventArgs ):
DEFINE VARIABLE ufs_res AS UFS_STATUS NO-UNDO.
DEFINE VARIABLE Scanner AS UFScanner NO-UNDO.
DEFINE VARIABLE EnrollQuality AS INTEGER NO-UNDO.
ASSIGN
Scanner = ?
scannerManager = NEW UFScannerManager(THIS-OBJECT)
ufs_res = scannerManager:Init().
IF STRING(ufs_res) = STRING(UFS_STATUS:OK) THEN
ASSIGN
Scanner = scannerManager:Scanners[0]
Scanner:Timeout = 9000
Scanner:TemplateSize = max_template_size
Scanner:DetectCore = FALSE
.
ELSE
DO:
ASSIGN
resultado = msgError(ufs_res:value__).
ufs_res = scannerManager:Uninit() .
RETURN.
END.
IF Scanner <> ? THEN
DO:
ASSIGN
Scanner:nTemplateType = 2001.
Scanner:ClearCaptureImageBuffer().
ufs_res = Scanner:CaptureSingleImage().
IF STRING(ufs_res) <> STRING(UFS_STATUS:OK) THEN
DO:
ASSIGN
Resultado = "No se pudo leer ".
ufs_res = scannerManager:Uninit() .
RETURN.
END.
ASSIGN
Template = NEW "System.Byte[]" (max_template_size)
ufs_res = Scanner:Extract(Template,TemplateSize, EnrollQuality).
IF STRING(UFS_STATUS:OK) <> "OK" THEN
ASSIGN
resultado = "Lectura incorrecta".
IF EnrollQuality < 40 THEN
ASSIGN
resultado = "Repita la lectura de la huella".
ELSE
DO:
CREATE tt1.
ASSIGN
tt1.f1 = ByteArrayToMemptr(template).
COPY-LOB FROM OBJECT f1 TO FILE "e:\t\fingerprint.dat". // aqui tenemos el template
END.
END.
ELSE
ASSIGN
resultado = msgError(ufs_res:value__).
ufs_res = scannerManager:Uninit() .
RETURN.
END METHOD.
METHOD PRIVATE VOID InitializeComponent( ):
/* NOTE: The following method is automatically generated.
We strongly suggest that the contents of this method only be modified using the
Visual Designer to avoid any incompatible modifications.
Modifying the contents of this method using a code editor will invalidate any support for this file. */
THIS-OBJECT:components = NEW System.ComponentModel.Container().
THIS-OBJECT:btnEscanear = NEW System.Windows.Forms.Button().
THIS-OBJECT:SuspendLayout().
/* */
/* btnEscanear */
/* */
THIS-OBJECT:btnEscanear:Location = NEW System.Drawing.Point(106, 31).
THIS-OBJECT:btnEscanear:Name = "btnEscanear".
THIS-OBJECT:btnEscanear:Size = NEW System.Drawing.Size(83, 23).
THIS-OBJECT:btnEscanear:TabIndex = 2.
THIS-OBJECT:btnEscanear:Text = "Escanear".
THIS-OBJECT:btnEscanear:UseCompatibleTextRendering = TRUE.
THIS-OBJECT:btnEscanear:UseVisualStyleBackColor = TRUE.
THIS-OBJECT:btnEscanear:Click:Subscribe(THIS-OBJECT:btnStart_Click).
/* */
/* FingerPrint */
/* */
THIS-OBJECT:ClientSize = NEW System.Drawing.Size(311, 77).
THIS-OBJECT:Controls:Add(THIS-OBJECT:btnEscanear).
THIS-OBJECT:FormBorderStyle = System.Windows.Forms.FormBorderStyle:FixedSingle.
THIS-OBJECT:Name = "FingerPrint".
THIS-OBJECT:StartPosition = System.Windows.Forms.FormStartPosition:CenterScreen.
THIS-OBJECT:Text = "BioLogin".
THIS-OBJECT:Load:Subscribe(THIS-OBJECT:BioLogin_Load).
THIS-OBJECT:KeyDown:Subscribe(THIS-OBJECT:BioLogin_KeyDown).
THIS-OBJECT:ResumeLayout(FALSE).
THIS-OBJECT:PerformLayout().
CATCH e AS Progress.Lang.Error:
UNDO, THROW e.
END CATCH.
END METHOD.
/*------------------------------------------------------------------------------
Purpose: msgError. Genera un mensje de error, de acuerdo a los codigos enviados por ufs_res:value__
Notes:
------------------------------------------------------------------------------*/
METHOD PUBLIC CHARACTER msgError( INPUT ndx AS INTEGER):
DEFINE VARIABLE Cadena AS CHARACTER NO-UNDO.
CASE ndx:
WHEN 0 THEN
cadena = "Success".
WHEN -1 THEN
cadena = "(1) General error".
WHEN -101 THEN
cadena = "(101) System has no license".
WHEN -102 THEN
cadena = "(102) License is not match".
WHEN -103 THEN
cadena = "(103) License is expired".
WHEN -111 THEN
cadena = "(111) This function is not supported".
WHEN -112 THEN
cadena = "(112) Input parameters are invalid".
WHEN -201 THEN
cadena = "(201) Module is already initialized".
WHEN -202 THEN
cadena = "(202) Module is not initialized".
WHEN -203 THEN
cadena = "(203) Device number is exceed".
WHEN -204 THEN
cadena = "(204) Error on loading scanner library".
WHEN -211 THEN
cadena = "(211) Capturing is started USING UFS_CaptureSingleImage OR UFS_StartCapturing".
WHEN -212 THEN
cadena = "(212) Capturing is timeout or aborted".
WHEN -301 THEN
cadena = "(301) Input image is not good".
WHEN -302 THEN
cadena = "(302) Extraction is failed".
WHEN -351 THEN
cadena = "(351) Core is not detected".
WHEN -352 THEN
cadena = "(352) Move finger to left".
WHEN -353 THEN
cadena = "(353) Move finger to left-top".
WHEN -354 THEN
cadena = "(354) Move finger to top".
WHEN -355 THEN
cadena = "(355) Move finger to right-top".
WHEN -356 THEN
cadena = "(356) Move finger to right".
WHEN -357 THEN
cadena = "(357) Move finger to right-bottom".
WHEN -358 THEN
cadena = "(358) Move finger to bottom".
WHEN -359 THEN
cadena = "(359) Move finger to left-bottom".
END CASE.
RETURN Cadena.
END METHOD.
METHOD PUBLIC STATIC MEMPTR ByteArrayToMemptr (poBytes AS "System.Byte[]":U):
DEFINE VARIABLE myMemptr AS MEMPTR NO-UNDO .
DEFINE VARIABLE oIntPointer AS System.IntPtr NO-UNDO .
SET-SIZE (myMemptr) = poBytes:Length .
oIntPointer = NEW System.IntPtr (GET-POINTER-VALUE (myMemptr)).
System.Runtime.InteropServices.Marshal:Copy (poBytes, 0, oIntPointer, poBytes:Length).
RETURN myMemptr .
FINALLY:
DELETE OBJECT oIntPointer.
END FINALLY.
END METHOD .
DESTRUCTOR PUBLIC FingerPrint ( ):
DEFINE VARIABLE ufs_res AS UFS_STATUS NO-UNDO.
ufs_res = scannerManager:Uninit() .
END DESTRUCTOR.
END CLASS.
View online
|