////////////////////////////////////////////////////////////////////////////////
// Copyright (c) Datacard Corporation.  All Rights Reserved.
////////////////////////////////////////////////////////////////////////////////
package com.datacard.xpsprinter.sdk.examples;

import common_java.XPS_Java_SDK;

public class Smartcard_Singlewire_Duali_Mifare_Main {
    
    public static void main(String[] args) {
        int i = 0;
        String arg;
        
    	String  printerName     = "";
        boolean nameGiven       = false;
        boolean print          = false;
        boolean parkBack         = false;
        boolean pollCompletion  = false;

        new XPS_Java_SDK(); // construct and extract interop dll

        // parse the command line arguments
        while (i < args.length) {
            arg = args[i++];

            if (arg.equalsIgnoreCase("-n")) {
                if (i < args.length) {
                    printerName = args[i++];
                    nameGiven = true;
                } else {
                    System.err.println("-n requires a printername");
                    break;
                }
            } else if (arg.equals("-p") && nameGiven) {
            	print = true;
            } else if (arg.equals("-b") && nameGiven) {
            	parkBack = true;
            } else if (arg.equals("-c") && nameGiven) {
            	pollCompletion = true;
            } else {
                usage();
                System.exit(0);
            }
        }

        if (i < 2) {
            usage();
            System.exit(0);
        }

        Smartcard_Singlewire_Duali_Mifare smartCard = new Smartcard_Singlewire_Duali_Mifare(printerName);
        smartCard.DemoSmartCard(print, parkBack, pollCompletion);

    }



    
    public static void usage() {
        System.out.println();
        System.out.println("Smartcard_Singlewire_Duali_Mifare.jar demonstrates smartcard personalization using the");
        System.out.println("single-wire embedded reader. Once staged, the app connects to a contact");
        System.out.println("and then a contactless chip. For each, an ATR is issued and some data bytes");
        System.out.println("are sent and received.");
        System.out.println("Optionally prints, and/or waits for job completion.");
        System.out.println();
        System.out.println(" java -jar Smartcard_Singlewire_Duali_Mifare.jar -n <printername> [-p] [-b] [-c] [-f <side>] [-i <inputHopper>]");
        System.out.println();
        System.out.println("options:");
        System.out.println("  -n <printername>. Required. Try -n \"XPS Card Printer\".");
        System.out.println("  -p Print sample text on the card.");
        System.out.println("  -b use back of card for smartcard chip.");
        System.out.println("  -c Poll for job completion.");
        System.out.println();
    }
}
