/// <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(); }
/// <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(); }
/// <summary> Initializes this object. </summary> /// <param name="eolSeparator"> The End-Of-Line separator. </param> /// <param name="escapeCharacter"> The escape character. </param> public void Initialize(char eolSeparator, char escapeCharacter) { // Find installed serial ports on hardware _currentSerialSettings.PortNameCollection = SerialPort.GetPortNames(); _currentSerialSettings.PropertyChanged += CurrentSerialSettingsPropertyChanged; // If serial ports are found, we select the first one if (_currentSerialSettings.PortNameCollection.Length > 0) { _currentSerialSettings.PortName = _currentSerialSettings.PortNameCollection[0]; } EolDelimiter = eolSeparator; _isEscaped = new IsEscaped(); _pollBuffer = new TimedAction(SerialBufferPollFrequency, SerialPortDataReceived); }
/// <summary> Removes all occurences of a specific character unless escaped. </summary> /// <param name="input"> The input. </param> /// <param name="removeChar"> The character to remove. </param> /// <param name="escapeChar"> The escape character. </param> /// <returns> The string with all removeChars removed. </returns> public static string Remove(string input, char removeChar, char escapeChar) { var output = string.Empty; var escaped = new IsEscaped(); for (var i = 0; i < input.Length; i++) { char inputChar = input[i]; bool isEscaped = escaped.EscapedChar(inputChar); if (inputChar != removeChar || isEscaped) { output += inputChar; } } return(output); }
/// <summary> Removes all occurences of a specific character unless escaped. </summary> /// <param name="input"> The input. </param> /// <param name="removeChar"> The character to remove. </param> /// <param name="escapeChar"> The escape character. </param> /// <returns> The string with all removeChars removed. </returns> public static string Remove(string input, char removeChar, char escapeChar) { var output = string.Empty; var escaped = new IsEscaped(); for (var i = 0; i < input.Length; i++) { char inputChar = input[i]; bool isEscaped = escaped.EscapedChar(inputChar); if (inputChar != removeChar || isEscaped) { output += inputChar; } } return output; }