/// <summary>
            /// Close connection between PC and the PaymentDevice.
            /// </summary>
            /// <returns>A task that can be awaited until the connection is closed.</returns>
            public Task CloseAsync()
            {
                if ((this.fpe != null) && (this.connectionStatus == FPEINTERFACELib.tagTERMINALCONNECTIONSTATUS.TERMINAL_CONNECTED))
                {
                    this.ClearData();
                    this.fpe.CloseSerialPort();
                    this.connectionStatus = FPEINTERFACELib.tagTERMINALCONNECTIONSTATUS.TERMINAL_DISCONNECTED;
                }

                return(Task.Run(() => this.RemoveEvents()));
            }
            private void InitializeInstance()
            {
                try
                {
                    this.fpe = new FPEINTERFACELib.CoFPESO();

                    this.connectionStatus = FPEINTERFACELib.tagTERMINALCONNECTIONSTATUS.TERMINAL_CONNECTION_STATUS_UNKNOWN;
                }
                catch (COMException ex)
                {
                    NetTracer.Warning("L5300Terminal -Unable to create FPE COM object - make sure it is installed: {0}", ex.Message);
                    this.fpe = null;
                }
            }
 private void InitializeConnection()
 {
     try
     {
         if (this.fpe != null)
         {
             this.fpe.UseSerialCommunication();
         }
     }
     catch (COMException ex)
     {
         NetTracer.Warning(ex, "L5300Terminal - FPE COM exception");
         this.connectionStatus = FPEINTERFACELib.tagTERMINALCONNECTIONSTATUS.TERMINAL_CONNECTION_STATUS_UNKNOWN;
     }
 }
            private void FPE_ReceivedTerminalConnectionStatusEvent(FPEINTERFACELib.tagTERMINALCONNECTIONSTATUS terminalConnectionStatus)
            {
                this.connectionStatus = terminalConnectionStatus;

                switch (terminalConnectionStatus)
                {
                case FPEINTERFACELib.tagTERMINALCONNECTIONSTATUS.TERMINAL_CONNECTED:
                    NetTracer.Information("L5300Terminal Connected");
                    Debug.WriteLine("L5300Terminal Connected");
                    break;

                case FPEINTERFACELib.tagTERMINALCONNECTIONSTATUS.TERMINAL_CONNECTION_STATUS_UNKNOWN:
                    NetTracer.Warning("L5300Terminal connection status unknown");
                    Debug.WriteLine("L5300Terminal connection status unknown");
                    break;

                case FPEINTERFACELib.tagTERMINALCONNECTIONSTATUS.TERMINAL_DISCONNECTED:
                    NetTracer.Information("L5300Terminal connection status disconnected");
                    Debug.WriteLine("L5300Terminal connection status disconnected");
                    break;
                }
            }