Esempio n. 1
0
        /// <summary> Listen to the receive queue and check for a specific acknowledge command. </summary>
        /// <param name="ackCmdId">        acknowledgement command ID. </param>
        /// <param name="clearQueueState"> Property to optionally clear the send and receive queues. </param>
        /// <returns> The first received command that matches the command ID. </returns>
        private ReceivedCommand CheckForAcknowledge(int ackCmdId, ClearQueue clearQueueState)
        {
            // Read single command from received queue
            CurrentReceivedCommand = _receiveCommandQueue.DequeueCommand();
            if (CurrentReceivedCommand != null)
            {
                // Check if received command is valid
                if (!CurrentReceivedCommand.Ok)
                {
                    return(CurrentReceivedCommand);
                }

                // If valid, check if is same as command we are waiting for
                if (CurrentReceivedCommand.CmdId == ackCmdId)
                {
                    // This is command we are waiting for, so return
                    return(CurrentReceivedCommand);
                }

                // This is not command we are waiting for
                if (clearQueueState == ClearQueue.KeepQueue || clearQueueState == ClearQueue.ClearSendQueue)
                {
                    // Add to queue for later processing
                    _receiveCommandQueue.QueueCommand(CurrentReceivedCommand);
                }
            }
            // Return not Ok received command
            return(new ReceivedCommand());
        }
Esempio n. 2
0
        /// <summary> Processes the byte message and add to queue. </summary>
        private void ProcessLine(string line)
        {
            // Read line from raw buffer and make command
            var currentReceivedCommand = ParseMessage(line);

            currentReceivedCommand.RawString = line;
            // Set time stamp
            currentReceivedCommand.TimeStamp = LastLineTimeStamp;
            // And put on queue
            _receiveCommandQueue.QueueCommand(currentReceivedCommand);
        }