All pages
Powered by GitBook
1 of 1

Loading...

Appendix A Code Examples

A.1 Request List of Devices

To request a list of devices:

  1. Create an MTSCRANET.MTSCRA object.

  2. Set the connection type with setConnectionType().

  3. Add a handler for OnDeviceList().

  4. Call requestDeviceList().

To open multiple devices:

  1. Create an MTSCRANET.MTSCRA object.

  2. Set the connection type with setConnectionType().

  3. Add a handler for OnDeviceList().

  4. Call requestDeviceList().

Create an MTSCRANET.MTSCRA object for each reader.

  • Set the connection type with setConnectionType() for each reader.

  • Call openDevice() for each reader.

  • A.2 Open Device(s)

    Close Device

    Get Connection Status of Device

    Receiving Card Data from Device

    A.6 Send Command to Device

    MTSCRANET.MTSCRA listMTSCRA = new MTSCRANET.MTSCRA(); 
    listMTSCRA.setConnectionType(MTConnectionType.USB); 
    listMTSCRA.OnDeviceList() += listMTSCRA_OnDeviceList; 
    listMTSCRA.requestDeviceList(MTConnectionType.USB); 
    
    listMTSCRA_OnDeviceList( 
    object sender, 
    MTConnectionType connectionType, 
    List<MTDeviceInformation> deviceList) 
    { 
    //Handle deviceList 
    }
    MTSCRANET.MTSCRA listMTSCRA = new MTSCRANET.MTSCRA();  
    listMTSCRA.setConnectionType(MTConnectionType.USB); 
    listMTSCRA.OnDeviceList() += listMTSCRA_OnDeviceList; 
    MTDeviceInformation listDeviceInfo; 
    listMTSCRA.requestDeviceList(MTConnectionType.USB); 
    
    listMTSCRA_OnDeviceList( 
    object sender, 
    MTConnectionType connectionType, 
    List<MTDeviceInformation> deviceList) 
    { 
        //Handle deviceList 
        For Each (dev in deviceList) 
        { 
        
        } 
        listDeviceInfo.Add(dev) 
    } 
    MTSCRANET.MTSCRA msr1 = new MTSCRANET.MTSCRA(); 
    MTSCRANET.MTSCRA msr2 = new MTSCRANET.MTSCRA(); 
    MTSCRANET.MTSCRA msr3 = new MTSCRANET.MTSCRA(); 
    
    msr1.setConnectionType(MTConnectionType.USB); 
    msr1.setAddress(dev.Address); msr1.openDevice(); 
    if (! msr1.isDeviceConnected()) 
    { 
        msr1.openDevice(); 
    } 
    
    msr2.setConnectionType(MTConnectionType.USB); 
    msr2.setAddress(dev.Address); 
    msr2.openDevice(); 
    if (! msr2.isDeviceConnected()) 
    { 
        msr2.openDevice(); 
        } 
        
    msr3.setConnectionType(MTConnectionType.USB); 
    msr3.setAddress(dev.Address); 
    msr3.openDevice(); 
    if (! msr3.isDeviceConnected()) 
    { 
        msr3.openDevice(); 
    }
    
    if (mMTSCRA != null) 
    { 
        mMTSCRA.closeDevice(); 
    }
    if (! mMTSCRA.isDeviceConnected()) 
    { 
    
    }
    if (! mMTSCRA.isDeviceConnected()) 
    { 
    mMTSCRA.CardDataReceived += OnCardDataReceived; 
    mMTSCRA.openDevice(); 
    } 
    
    public void OnCardDataReceived(Object sender) 
    { // Display last 4 digits of the card 
    CardLast4.Text = mMTSCRA.getCardLast4(); 
    }
    if (mMTSCRA.isDeviceConnected()) 
    { 
        // Send discovery command 
        mMTSCRA.sendCommandToDevice(β€œC10206C20503840900”, 0); 
    }