Exemple #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 = "";
        }
Exemple #2
0
        /// <summary> Initializes this object. </summary>
        /// <param name="receiveCommandQueue"></param>
        /// <param name="commandSeparator">    The End-Of-Line separator. </param>
        /// <param name="fieldSeparator"></param>
        /// <param name="escapeCharacter"> The escape character. </param>
        /// <param name="disposeStack"> The DisposeStack</param>
        /// /// <param name="transport"> The Transport Layer</param>
        public void Initialize(DisposeStack disposeStack, ITransport transport, ReceiveCommandQueue receiveCommandQueue, char commandSeparator, char fieldSeparator, char escapeCharacter)
        {
            disposeStack.Push(this);
            _transport                  = transport;
            _receiveCommandQueue        = receiveCommandQueue;
            _transport.NewDataReceived += NewDataReceived;
            _commandSeparator           = commandSeparator;
            _fieldSeparator             = fieldSeparator;
            _escapeCharacter            = escapeCharacter;

            _isEscaped = new IsEscaped();
        }
Exemple #3
0
        /// <summary> Constructor. </summary>
        /// <param name="receiveCommandQueue"></param>
        /// <param name="boardType">The Board Type. </param>
        /// <param name="commandSeparator">The End-Of-Line separator. </param>
        /// <param name="fieldSeparator"></param>
        /// <param name="escapeCharacter"> The escape character. </param>
        /// <param name="transport"> The Transport Layer</param>
        public CommunicationManager(ITransport transport, ReceiveCommandQueue receiveCommandQueue,
                                    BoardType boardType, char commandSeparator, char fieldSeparator, char escapeCharacter)
        {
            _transport = transport;
            _transport.DataReceived += NewDataReceived;

            _receiveCommandQueue = receiveCommandQueue;

            BoardType        = boardType;
            CommandSeparator = commandSeparator;
            FieldSeparator   = fieldSeparator;
            EscapeCharacter  = escapeCharacter;

            _isEscaped = new IsEscaped();
        }
Exemple #4
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;
        }
Exemple #5
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();
        }
Exemple #6
0
 /// <summary> Constructor. </summary>
 /// <param name="receiveCommandQueue"></param>
 /// <param name="commandSeparator">    The End-Of-Line separator. </param>
 /// <param name="fieldSeparator"></param>
 /// <param name="escapeCharacter"> The escape character. </param>
 /// <param name="disposeStack"> The DisposeStack</param>
 /// <param name="transport"> The Transport Layer</param>
 public CommunicationManager(DisposeStack disposeStack, ITransport transport, ReceiveCommandQueue receiveCommandQueue, char commandSeparator, char fieldSeparator, char escapeCharacter)
 {
     Initialize(disposeStack, transport, receiveCommandQueue, commandSeparator, fieldSeparator, escapeCharacter);
 }
Exemple #7
0
        private char _escapeCharacter;                                      // The escape character


        /// <summary> Default constructor. </summary>
        /// /// <param name="disposeStack"> The DisposeStack</param>
        /// <param name="transport"> The Transport Layer</param>
        /// <param name="receiveCommandQueue"></param>
        public CommunicationManager(DisposeStack disposeStack, ITransport transport, ReceiveCommandQueue receiveCommandQueue)
        {
            Initialize(disposeStack, transport, receiveCommandQueue, ';', ',', '/');
        }
Exemple #8
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;
        }
        private readonly Object _sendCommandDataLock = new Object(); // The process serial data lock

        #endregion Fields

        #region Constructors

        public Sender(CommunicationManager communicationManager, ReceiveCommandQueue receiveCommandQueue)
        {
            _communicationManager = communicationManager;
            _receiveCommandQueue = receiveCommandQueue;
        }
Exemple #10
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>
        /// <param name="sendBufferMaxLength"> The maximunm 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 = "";
        }
Exemple #11
0
 public Sender(CommunicationManager communicationManager, ReceiveCommandQueue receiveCommandQueue)
 {
     _communicationManager = communicationManager;
     _receiveCommandQueue  = receiveCommandQueue;
 }