Can someone help me to translate this visual class to some i

Posted by OctavioOlguin on 18-Feb-2017 09:16

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.

All Replies

Posted by Mike Fechner on 19-Feb-2017 01:00

What are you actually struggling with?
 
Did you try to move the methods btnStart_Click, msgError and ByteArrayToMemptr to a class? btnStart_Click does all the actual work and needs to be PUBLIC then.
 
What you need to obtain from the documentation of the UFScannerManager class is, if it’s required to pass a System.Windows.Forms.Form instance (THIS-OBJECT here) to the constructor or not.
 
A warning:
 
                CREATE tt1.
                ASSIGN
                    tt1.f1 = ByteArrayToMemptr(template).
                COPY-LOB FROM OBJECT f1 TO FILE "e:\t\fingerprint.dat".    // aqui tenemos el template
The method ByteArrayToMemptr returns a MEMPTR which you never set back to 0 – so you never give back the memory allocated.
 
DEFINE VARIABLE mptr AS MEMPTR NO-UNDO .
mptr = ByteArrayToMemptr(template).
COPY-LOB FROM mptr TO FILE “e:\t\fingerprint.dat” .
SET-SIZE (mptr) = 0 .
 
 
 
Von: OctavioOlguin [mailto:bounce-OctavioOlguin@community.progress.com]
Gesendet: Samstag, 18. Februar 2017 16:17
An: CodeShare@community.progress.com
Betreff: [Code Share - Forum] Can someone help me to translate this visual class to some instantiable class
 
Update from Progress Community
 

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

 

You received this notification because you subscribed to the forum.  To stop receiving updates from only this thread, go here.

Flag this post as spam/abuse.

 

Posted by OctavioOlguin on 20-Feb-2017 10:31


You nailed!!!

That's exactly my problem.... I don't know how to resolve that problem... this is doc: from class:



// Add Suprema UFScanner library (bin\Suprema.UFScanner.dll) using browse tap in the Add References dialog // Add following statements in the source using Suprema // We use 384 bytes template size in this tutorial const int MAX_TEMPLATE_SIZE = 384; UFS_STATUS ufs_res; UFScannerManager ScannerManager; int nScannerNumber; // Create an instance of ScannerManager ScannerManager = new UFScannerManager(this); // Initialize scanner module ufs_res = ScannerManager.Init(); // Always check status return codes after running SDK functions // Meaning of status return code can be retrieved using UFScanner.GetErrorString() // In the tutorial, we omit error check codes // Check number of scanners nScannerNumber = ScannerManager.Scanners.Count; UFScanner Scanner = null; // Using first scanner (0 means first scanner) Scanner = ScannerManager.Scanners[0]; Scanner.Timeout = 5000; // Set template size to 384 bytes Scanner.TemplateSize = MAX_TEMPLATE_SIZE; // Set not to detect core when extracting template Scanner.DetectCore = false; UFS_STATUS ufs_res; byte[] Template = new byte[MAX_TEMPLATE_SIZE]; int TemplateSize; int EnrollQuality; // Clear capture buffer ufs_res = Scanner.ClearCaptureImageBuffer(); // Capture single image ufs_res = Scanner.CaptureSingleImage(); // If capturing images is fail, iterate above capture routine or show error message // Extract template from captured image ufs_res = Scanner.Extract(Template, out TemplateSize, out EnrollQuality); // If extraction is succeed, check nEnrollQuality is above predefined quality threshold UFS_STATUS ufs_res; // Uninitialize scanner module ufs_res = ScannerManager.Uninit();

It is not you can say it is a good doc. But that's all there is for aquiring a template

Posted by Mike Fechner on 20-Feb-2017 11:00

They might need a reference to a Control for thread synchronization (background thread to UI thread).
 
But that does not prevent you from changing your code, so that it’s a class with no UI. You will just have to provide your class a reference to a Form instance (the application’s main menu form) and pass that on to the constructor of that UFScannerManager.
 
 
Von: OctavioOlguin [mailto:bounce-OctavioOlguin@community.progress.com]
Gesendet: Montag, 20. Februar 2017 17:32
An: CodeShare@community.progress.com
Betreff: RE: [Code Share - Forum] Can someone help me to translate this visual class to some instantiable class
 
Update from Progress Community
 

You nailed!!!

That's exactly my problem.... I don't know how to resolve that problem... this is doc: from class:



// Add Suprema UFScanner library (bin\Suprema.UFScanner.dll)
using browse tap in the Add References dialog
// Add following statements in the source
using Suprema
// We use 384 bytes template size in this tutorial
const int MAX_TEMPLATE_SIZE = 384;
UFS_STATUS ufs_res;
 
UFScannerManager ScannerManager;
int nScannerNumber;
 
// Create an instance of ScannerManager
ScannerManager = new UFScannerManager(this);
 
// Initialize scanner module
ufs_res = ScannerManager.Init();
// Always check status return codes after running SDK
functions
// Meaning of status return code can be retrieved using
UFScanner.GetErrorString()
// In the tutorial, we omit error check codes
// Check number of scanners
nScannerNumber = ScannerManager.Scanners.Count;
 
UFScanner Scanner = null;
// Using first scanner (0 means first scanner)
Scanner = ScannerManager.Scanners[0];
 
Scanner.Timeout = 5000;
// Set template size to 384 bytes
Scanner.TemplateSize = MAX_TEMPLATE_SIZE;
// Set not to detect core when extracting template
Scanner.DetectCore = false;
 
UFS_STATUS ufs_res;
byte[] Template = new byte[MAX_TEMPLATE_SIZE];
int TemplateSize;
 
int EnrollQuality;
// Clear capture buffer
ufs_res = Scanner.ClearCaptureImageBuffer();
// Capture single image
ufs_res = Scanner.CaptureSingleImage();
// If capturing images is fail, iterate above capture
routine or show error message
// Extract template from captured image
ufs_res = Scanner.Extract(Template, out TemplateSize, out
EnrollQuality);
// If extraction is succeed, check nEnrollQuality is above
predefined quality threshold
 
UFS_STATUS ufs_res;
// Uninitialize scanner module
ufs_res = ScannerManager.Uninit();

It is not you can say it is a good doc. But that's all there is for aquiring a template

View online

 

You received this notification because you subscribed to the forum.  To unsubscribe from only this thread, go here.

Flag this post as spam/abuse.

 

Posted by OctavioOlguin on 20-Feb-2017 11:25

As I'm  behind schedule, I'll preserve the little class form with a button just to process, but how could end the class from the button, to return control toa UIB window?

also, I copyed the runtime code by the PDSOE to tun the form, and ended with this:

ON CHOOSE OF bAdd IN FRAME DEFAULT-FRAME /* Add fingerprintr */
    DO:
DEFINE VARIABLE rTemp AS CLASS FingerPrint NO-UNDO.
        DO ON ERROR  UNDO, LEAVE
            ON ENDKEY UNDO, LEAVE
            ON STOP   UNDO, LEAVE
            ON QUIT   UNDO, LEAVE:
            rTemp = NEW FingerPrint (OUTPUT TABLE tt1, OUTPUT resultadoProceso ) .
            WAIT-FOR System.Windows.Forms.Application:Run ( rTemp ).
            
            IF resultadoProceso <> "" THEN 
            DO:
                MESSAGE "se presentó el siguiente error:" SKIP
                    resultadoProceso
                    VIEW-AS ALERT-BOX ERROR.
            END.
            ELSE 
            DO:
                MESSAGE "Si se proceso."
                    VIEW-AS ALERT-BOX.                
                FIND FIRST tt1.
                COPY-LOB FROM tt1.f1 TO FILE "c:\t\t1.txt".
                
                RUN procs\tdi\tdi01001.w("c:\t\t1.txt").
                
            END.
            
            
            DEFINE VARIABLE i AS INTEGER NO-UNDO.
            CATCH e1 AS Progress.Lang.AppError:
                DO i = 1 TO e1:NumMessages:
                    MESSAGE e1:GetMessage(i) 
                        VIEW-AS ALERT-BOX BUTTONS OK TITLE "Error".
                END.
                IF e1:ReturnValue > "" THEN
                    MESSAGE e1:ReturnValue VIEW-AS ALERT-BOX BUTTONS OK TITLE "Return Value".
            END CATCH.
            CATCH e2 AS Progress.Lang.Error:
                DO i = 1 TO e2:NumMessages:
                    MESSAGE e2:GetMessage(i) VIEW-AS ALERT-BOX BUTTONS OK TITLE "Error".
                END.
            END CATCH.
        END.
      
    
        RUN CargaLocales.
        RUN CopiaTemplates.
        {&OPEN-QUERY-BROWSE-14}


and on the class, this is the constructor

   // output parameters    
    DEFINE TEMP-TABLE tt1 NO-UNDO
        FIELD f1 AS BLOB.
    DEFINE VARIABLE Resultado AS CHARACTER NO-UNDO.
        
    CONSTRUCTOR PUBLIC FingerPrint ( OUTPUT table tt1, OUTPUT resultado AS CHARACTER):
        SUPER().
        InitializeComponent().
        THIS-OBJECT:ComponentsCollection:ADD(THIS-OBJECT:components).
       
        CATCH e AS Progress.Lang.Error:
            UNDO, THROW e.
        END CATCH.
    END CONSTRUCTOR.

Posted by Mike Fechner on 20-Feb-2017 13:24

From within the Form class, just execute THIS-OBJECT:Close ().
Von: OctavioOlguin [mailto:bounce-OctavioOlguin@community.progress.com]
Gesendet: Montag, 20. Februar 2017 18:26
An: CodeShare@community.progress.com
Betreff: RE: [Code Share - Forum] Can someone help me to translate this visual class to some instantiable class
 
Update from Progress Community
 

As I'm  behind schedule, I'll preserve the little class form with a button just to process, but how could end the class from the button, to return control toa UIB window?

also, I copyed the runtime code by the PDSOE to tun the form, and ended with this:

ON CHOOSE OF bAdd IN FRAME DEFAULT-FRAME /* Add fingerprintr */
    DO:
DEFINE VARIABLE rTemp AS CLASS FingerPrint NO-UNDO.
        DO ON ERROR  UNDO, LEAVE
            ON ENDKEY UNDO, LEAVE
            ON STOP   UNDO, LEAVE
            ON QUIT   UNDO, LEAVE:
            rTemp = NEW FingerPrint (OUTPUT TABLE tt1, OUTPUT resultadoProceso ) .
            WAIT-FOR System.Windows.Forms.Application:Run ( rTemp ).
            
            IF resultadoProceso <> "" THEN 
            DO:
                MESSAGE "se presentó el siguiente error:" SKIP
                    resultadoProceso
                    VIEW-AS ALERT-BOX ERROR.
            END.
            ELSE 
            DO:
                MESSAGE "Si se proceso."
                    VIEW-AS ALERT-BOX.                
                FIND FIRST tt1.
                COPY-LOB FROM tt1.f1 TO FILE "c:\t\t1.txt".
                
                RUN procs\tdi\tdi01001.w("c:\t\t1.txt").
                
            END.
            
            
            DEFINE VARIABLE i AS INTEGER NO-UNDO.
            CATCH e1 AS Progress.Lang.AppError:
                DO i = 1 TO e1:NumMessages:
                    MESSAGE e1:GetMessage(i) 
                        VIEW-AS ALERT-BOX BUTTONS OK TITLE "Error".
                END.
                IF e1:ReturnValue > "" THEN
                    MESSAGE e1:ReturnValue VIEW-AS ALERT-BOX BUTTONS OK TITLE "Return Value".
            END CATCH.
            CATCH e2 AS Progress.Lang.Error:
                DO i = 1 TO e2:NumMessages:
                    MESSAGE e2:GetMessage(i) VIEW-AS ALERT-BOX BUTTONS OK TITLE "Error".
                END.
            END CATCH.
        END.
      
    
        RUN CargaLocales.
        RUN CopiaTemplates.
        {&OPEN-QUERY-BROWSE-14}


and on the class, this is the constructor
   // output parameters    
    DEFINE TEMP-TABLE tt1 NO-UNDO
        FIELD f1 AS BLOB.
    DEFINE VARIABLE Resultado AS CHARACTER NO-UNDO.
        
    CONSTRUCTOR PUBLIC FingerPrint ( OUTPUT table tt1, OUTPUT resultado AS CHARACTER):
        SUPER().
        InitializeComponent().
        THIS-OBJECT:ComponentsCollection:ADD(THIS-OBJECT:components).
       
        CATCH e AS Progress.Lang.Error:
            UNDO, THROW e.
        END CATCH.
    END CONSTRUCTOR.

View online

 

You received this notification because you subscribed to the forum.  To unsubscribe from only this thread, go here.

Flag this post as spam/abuse.

 

This thread is closed