예제 #1
0
 private void Window_Closing(object sender, CancelEventArgs e)
 {
     //Stop background worker
     m_Worker.CancelAsync();
     if (m_DocInterface != null)
     {
         m_DocInterface.Terminate();
     }
 }
예제 #2
0
        static async System.Threading.Tasks.Task MainAsync(string[] args)
        {
            Console.WriteLine(".NETCore Console");
            Console.WriteLine("SampleAsync_C#");
            Console.WriteLine("--------------------");
            Console.WriteLine("Library Version: " + iIDReaderLibrary.Version.LibraryVersion);

            //Get DocInterfaceControl instance
            DocInterfaceControl docIntControl = await Console_InitializeDocInterfaceControlAsync();

            if (docIntControl != null)
            {
                //DocInterfaceControl is initialized
                Console.WriteLine("");
                Console.Write("Detecting reader..");
                while (true)
                {
                    //First of all, get the Reader Information
                    Console.Write(".");
                    var readerID = await docIntControl.ReadReaderIDAsync();

                    if (readerID != null)
                    {
                        Console.WriteLine("");
                        Console.WriteLine("Detected Reader:");
                        Console.WriteLine(readerID.ToString());
                        break;
                    }
                }

                //Reader info obtained --> execute functions using menu
                Console.WriteLine("");
                while (await Console_ExecuteAndContinueAsync(docIntControl))
                {
                    ;
                }

                docIntControl.Terminate();
                Console.WriteLine("");
                Console.Write("EXITING in 5");
                Thread.Sleep(1000);
                Console.Write(", 4");
                Thread.Sleep(1000);
                Console.Write(", 3");
                Thread.Sleep(1000);
                Console.Write(", 2");
                Thread.Sleep(1000);
                Console.Write(", 1");
                Thread.Sleep(1000);
            }
            else
            {
                Console.Write("Initialization error <press ENTER to exit>");
                Console.ReadLine();
            }
            m_Completed = true;
        }
        private static DocInterfaceControl Console_InitializeDocInterfaceControl()
        {
            Console.WriteLine("== Select initialize parameters ==");
            //Get PortType
            int    portType = Console_InitializePortType();
            string portName = "";

            switch (portType)
            {
            case 0:
            case 2:
                //For Serial & bluetooth, PortName needed.
                portName = Console_InitializePortName();
                break;
            }
            //Initialize InterfaceCommunicationSettings class
            var readerPortSettings = InterfaceCommunicationSettings.GetForSerialDevice(portType, portName);
            //InterfaceType = 13.56MHz for TELID®200
            int interfaceType = 1356;

            //Parameters selected --> Initialize class instance
            Console.WriteLine("");
            DocInterfaceControl result = new DocInterfaceControl(readerPortSettings, interfaceType);

            Console.WriteLine(string.Format("Selected parameters: PortType: {0} | PortName: {1} | IntType: {2}", portType, portName, interfaceType));

            //Call initialize to open the communication port
            result.InitializeCompleted += DocInterfaceControl_InitializeCompleted;
            result.StartInitialize();
            Console.Write("Initializing...");
            //For demo purposes, just wait blocking execution until "Initialize" process is completed (notified using "InitializeCompleted" event)
            while (!initializeCompleted) //Alternative, call "IsInitializing"
            {
                Thread.Sleep(100);
                Console.Write(".");
            }
            Console.WriteLine("");
            if (result.IsInitialized)
            {
                Console.WriteLine("\tInitialized");
                result.DocResultChanged += DocInterfaceControl_DocResultChanged;
                return(result);
            }
            else
            {
                //Initialization failed: Terminate class instance & try again
                Console.WriteLine("\tInitialize failed");
                result.Terminate();
                return(Console_InitializeDocInterfaceControl());
            }
        }
예제 #4
0
        static void Main(string[] args)
        {
            Console.WriteLine(".NETCore Console");
            Console.WriteLine("SampleThreads_C#");
            Console.WriteLine("--------------------");
            Console.WriteLine("Library Version: " + iIDReaderLibrary.Version.LibraryVersion);

            //Get DocInterfaceControl instance
            DocInterfaceControl docIntControl = Console_InitializeDocInterfaceControl();

            if (docIntControl != null)
            {
                //DocInterfaceControl is initialized
                Console.WriteLine("");
                Console.Write("Detecting reader..");
                while (true)
                {
                    //First of all, get the Reader Information
                    Console.Write(".");
                    var readerID = docIntControl.ReadReaderID();
                    if (readerID != null)
                    {
                        Console.WriteLine("");
                        Console.WriteLine("Detected Reader:");
                        Console.WriteLine(readerID.ToString());
                        break;
                    }
                }

                //Reader info obtained --> execute functions using menu
                Console.WriteLine("");
                while (Console_ExecuteAndContinue(docIntControl))
                {
                    Thread.Sleep(500);
                }

                docIntControl.Terminate();
                Console.WriteLine("");
                Console.Write("EXITING in 5");
                Thread.Sleep(1000);
                Console.Write(", 4");
                Thread.Sleep(1000);
                Console.Write(", 3");
                Thread.Sleep(1000);
                Console.Write(", 2");
                Thread.Sleep(1000);
                Console.Write(", 1");
                Thread.Sleep(1000);
            }
        }
예제 #5
0
        private static async System.Threading.Tasks.Task <DocInterfaceControl> Console_InitializeDocInterfaceControlAsync()
        {
            Console.WriteLine("== Select initialize parameters ==");
            //Get PortType
            int    portType = Console_InitializePortType();
            string portName = "";

            switch (portType)
            {
            case 0:
            case 2:
                //For Serial & bluetooth, PortName needed.
                portName = Console_InitializePortName();
                break;
            }
            //Initialize InterfaceCommunicationSettings class
            var readerPortSettings = InterfaceCommunicationSettings.GetForSerialDevice(portType, portName);
            //InterfaceType = 13.56MHz for TELID®200
            int interfaceType = 1356;

            //Parameters selected --> Initialize class instance
            Console.WriteLine("");
            DocInterfaceControl result = new DocInterfaceControl(readerPortSettings, interfaceType);

            Console.WriteLine(string.Format("Selected parameters: PortType: {0} | PortName: {1} | IntType: {2}", portType, portName, interfaceType));
            Console.WriteLine("Initializing...");

            //Call initialize to open the communication port
            try
            {
                if (await result.InitializeAsync())
                {
                    Console.WriteLine("\tInitialized");
                    return(result);
                }
                else
                {
                    //Initialization failed: Terminate class instance & try again
                    Console.WriteLine("\tInitialize failed");
                    result.Terminate();
                    return(await Console_InitializeDocInterfaceControlAsync());
                }
            }
            catch { }
            return(null);
        }