/// <summary>
        ///
        /// </summary>
        ///
        public void Unsubscribe(string typeOfChannel)
        {
            PerfTiming perfTimer1 = new PerfTiming();

            perfTimer1.Start();


            // Validate current state of Reader API
            if (!RfReaderApi.IsValid)
            {
                throw new RfReaderApiInvalidModeException();
            }

            if (RfReaderApi.TER == typeOfChannel || RfReaderApi.ALARM == typeOfChannel || RfReaderApi.ALL == typeOfChannel)
            {
                UnSubscribeChannelListener(typeOfChannel);
            }
            else
            {
                throw new RfReaderApiException(RfReaderApiException.ResultCode_System, RfReaderApiException.Error_InvalidParameter);
            }

            // Send unsubscribe command to ReaderService
            // We do this deliberately after turning down our channels in order not
            // to prevent channel shutdowns if exception during unsubscribe commands occur
            // Do a security check whether we are connected at all
            if (!this.CommandChannel.IsConnected())
            {
                throw new RfReaderApiException(RfReaderApiException.ResultCode_System, RfReaderApiException.Error_NoConnection);
            }
            List <ParameterDesc> unsubscribeParams = new List <ParameterDesc>();

            unsubscribeParams.Add(new ParameterDesc("type", typeOfChannel));

            Command      rpCommand = new Command("unsubscribe", unsubscribeParams);
            string       commandID = "";
            string       replyMsg  = this.CommandChannel.execute(rpCommand.getXmlCommand(ref commandID), commandID);
            CommandReply rpReply   = CommandReply.DecodeXmlCommand(replyMsg);

            if (rpReply == null)
            {
                // There is no reply from our connected reader
                throw new RfReaderApiException(RfReaderApiException.ResultCode_System,
                                               RfReaderApiException.Error_NoReply);
            }
            if (rpReply.ResultCode != 0)
            {
                // forward errors as exceptions
                throw new RfReaderApiException(rpReply.ResultCode, rpReply.Error,
                                               rpReply.Cause);
            }

            if (RfReaderApi.showPerformanceInfo)
            {
                ProvideInformation(this, "Unsubscribe took " + perfTimer1.End().ToString("##.###") + "s");
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="iPAddress">IP Address of listener, to which channel send data</param>
        ///  <param name="port">Port of listener, to which channel send data</param>
        /// <param name="bufferTag">If true: buffers data during offline. Listener must acknowledge data</param>
        /// <returns></returns>
        public void Subscribe(string typeOfChannel, IPAddress iPAddress, int port, bool bufferTag)

        {
            // Validate current state of Reader API
            if (!RfReaderApi.IsValid)
            {
                throw new RfReaderApiInvalidModeException();
            }

            // Tssting only: Setup listener, but do not send commands to reader
            if (RfReaderApi.testFlag_ListenOnly)
            {
                SubscribeChannelListener(typeOfChannel, iPAddress, port, bufferTag);
            }
            else
            {
                PerfTiming perfTimer1 = new PerfTiming();
                perfTimer1.Start();


                // Security check for preconditions: Are we connected at all?
                if (!this.CommandChannel.IsConnected())
                {
                    throw new RfReaderApiException(RfReaderApiException.ResultCode_System, RfReaderApiException.Error_NoConnection);
                }

                // setup channel Listener for alarms
                if (RfReaderApi.TER == typeOfChannel || RfReaderApi.ALARM == typeOfChannel || RfReaderApi.ALL == typeOfChannel)
                {
                    // Tssting only: send subscribe command, but don't listen
                    if (false == RfReaderApi.testFlag_SubscribeOnly)
                    {
                        if (IPAddress.None != iPAddress)
                        {
                            SubscribeChannelListener(typeOfChannel, iPAddress, port, bufferTag);
                        }
                        else
                        {
                            UnSubscribeChannelListener(typeOfChannel);
                        }
                    }
                }
                else
                {
                    throw new RfReaderApiException(RfReaderApiException.ResultCode_System, RfReaderApiException.Error_InvalidParameter);
                }

                List <ParameterDesc> subscribeParams = new List <ParameterDesc>();
                subscribeParams.Add(new ParameterDesc("type", typeOfChannel));
                if (IPAddress.None != iPAddress)
                {
                    subscribeParams.Add(new ParameterDesc("iPAddress", iPAddress.ToString()));
                    subscribeParams.Add(new ParameterDesc("port", port.ToString()));
                }
                subscribeParams.Add(new ParameterDesc("bufferTag", bufferTag.ToString()));

                Command      rpCommand = new Command("subscribe", subscribeParams);
                string       commandID = "";
                string       replyMsg  = this.CommandChannel.execute(rpCommand.getXmlCommand(ref commandID), commandID);
                CommandReply rpReply   = CommandReply.DecodeXmlCommand(replyMsg);
                if (rpReply == null)
                {
                    // There is no reply from our connected reader
                    throw new RfReaderApiException(RfReaderApiException.ResultCode_System,
                                                   RfReaderApiException.Error_NoReply);
                }
                if (rpReply.ResultCode != 0)
                {
                    // forward errors as exceptions
                    throw new RfReaderApiException(rpReply.ResultCode, rpReply.Error,
                                                   rpReply.Cause);
                }

                if (RfReaderApi.showPerformanceInfo)
                {
                    ProvideInformation(this, "Subscribe took " + perfTimer1.End().ToString("##.###") + "s");
                }
            }
        }