Пример #1
0
        /// <summary> Initializes this object. </summary>
        /// <param name="transport">   The transport layer. </param>
        /// <param name="fieldSeparator">   The field separator. </param>
        /// <param name="commandSeparator"> The command separator. </param>
        /// <param name="escapeCharacter">  The escape character. </param>
        /// <param name="sendBufferMaxLength"> The maximum size of the send buffer</param>
        private void Init(ITransport transport, char fieldSeparator, char commandSeparator,
                          char escapeCharacter, int sendBufferMaxLength)
        {
            _controlToInvokeOn = null;

            _receiveCommandQueue  = new ReceiveCommandQueue(DisposeStack, this);
            _communicationManager = new CommunicationManager(DisposeStack, transport, _receiveCommandQueue, commandSeparator, fieldSeparator, escapeCharacter);
            _sender           = new Sender(_communicationManager, _receiveCommandQueue);
            _sendCommandQueue = new SendCommandQueue(DisposeStack, this, _sender, sendBufferMaxLength);

            _receiveCommandQueue.NewLineReceived += (o, e) => InvokeNewLineEvent(NewLineReceived, e);
            _sendCommandQueue.NewLineSent        += (o, e) => InvokeNewLineEvent(NewLineSent, e);

            _fieldSeparator   = fieldSeparator;
            _commandSeparator = commandSeparator;
            PrintLfCr         = false;

            Command.FieldSeparator   = _fieldSeparator;
            Command.CommandSeparator = _commandSeparator;
            Command.PrintLfCr        = PrintLfCr;

            Escaping.EscapeChars(_fieldSeparator, _commandSeparator, escapeCharacter);
            _callbackList = new Dictionary <int, MessengerCallbackFunction>();
            //CurrentSentLine = "";
            CurrentReceivedLine = "";
        }
Пример #2
0
        /// <summary> Initialises this object. </summary>
        /// <param name="transport">   The transport layer. </param>
        /// <param name="fieldSeparator">   The field separator. </param>
        /// <param name="commandSeparator"> The command separator. </param>
        /// <param name="escapeCharacter">  The escape character. </param>
        private void Init(ITransport transport, char fieldSeparator, char commandSeparator,
                          char escapeCharacter)
        {
            _controlToInvokeOn = null;

            _sendCommandQueue     = new SendCommandQueue(DisposeStack, this);
            _receiveCommandQueue  = new ReceiveCommandQueue(DisposeStack, this);
            _communicationManager = new CommunicationManager(DisposeStack, transport, _receiveCommandQueue, commandSeparator, fieldSeparator, escapeCharacter);

            _fieldSeparator   = fieldSeparator;
            _commandSeparator = commandSeparator;

            Escaping.EscapeChars(fieldSeparator, commandSeparator, escapeCharacter);
            _callbackList = new Dictionary <int, MessengerCallbackFunction>();
            PrintLfCr     = false;
        }
Пример #3
0
        /// <summary> Initializes this object. </summary>
        /// <param name="transport">   The transport layer. </param>
        /// <param name="boardType"> Embedded Processor type. Needed to translate variables between sides. </param>
        /// <param name="fieldSeparator">   The field separator. </param>
        /// <param name="commandSeparator"> The command separator. </param>
        /// <param name="escapeCharacter">  The escape character. </param>
        /// <param name="sendBufferMaxLength"> The maximum size of the send buffer</param>
        private void Init(ITransport transport, BoardType boardType, char fieldSeparator, char commandSeparator,
                          char escapeCharacter, int sendBufferMaxLength)
        {
            //Logger.Open(@"sendCommands.txt");
            Logger.DirectFlush = true;

            _receiveCommandQueue  = new ReceiveCommandQueue(HandleMessage);
            _communicationManager = new CommunicationManager(transport, _receiveCommandQueue, boardType, commandSeparator, fieldSeparator, escapeCharacter);
            _sendCommandQueue     = new SendCommandQueue(_communicationManager, sendBufferMaxLength);

            PrintLfCr = false;

            _receiveCommandQueue.NewLineReceived += (o, e) => InvokeNewLineEvent(NewLineReceived, e);
            _sendCommandQueue.NewLineSent        += (o, e) => InvokeNewLineEvent(NewLineSent, e);

            Escaping.EscapeChars(fieldSeparator, commandSeparator, escapeCharacter);
            _callbackList = new Dictionary <int, MessengerCallbackFunction>();

            _sendCommandQueue.Start();
            _receiveCommandQueue.Start();
        }
Пример #4
0
 public Sender(CommunicationManager communicationManager, ReceiveCommandQueue receiveCommandQueue)
 {
     _communicationManager = communicationManager;
     _receiveCommandQueue  = receiveCommandQueue;
 }