Exemplo n.º 1
0
 public Talker()
 {
     PortName = " "; //whitespace
     BaudRate = 9600;
     Parity = Parity.None;
     DataBits = 8;
     StopBits = StopBits.One;
     _lineBreak = new LineBreak{ Type = "linux"};
     _byteListProc += list => {
     };
 }
Exemplo n.º 2
0
 public Talker()
 {
     PortName   = " ";           //whitespace
     BaudRate   = 9600;
     Parity     = Parity.None;
     DataBits   = 8;
     StopBits   = StopBits.One;
     _lineBreak = new LineBreak {
         Type = "linux"
     };
     _byteListProc += list => {
     };
 }
Exemplo n.º 3
0
        /// <summary>
        /// 设置断句函数.
        /// </summary>
        /// <returns>The break line.</returns>
        /// <param name="LineBreak">New line.</param>
        public ChangeFlag SetLineBreak(LineBreak lineBreak)
        {
            var flag = ChangeFlag.Succeed;

            _lineBreak = lineBreak;
            switch (lineBreak.Type)
            {
            case "nt":             //Windows Nt "\r\n"
                _isLineBreak = IsLineBreakForNt;
                break;

            case "linux":             //Linux "\n"
                _isLineBreak = IsLineBreakForLinux;
                break;

            case "mac":             //Mac "\r"
                _isLineBreak = IsLineBreakForMac;
                break;

            case "length":             //stream length
                if (null != lineBreak.Length)
                {
                    _index       = 0;
                    _length      = lineBreak.Length.Value;
                    _isLineBreak = IsLineBreakForLength;
                }
                else
                {
                    flag = ChangeFlag.Failed;
                }
                break;

            case "char":             //break char
                if (null != lineBreak.Char)
                {
                    _breakChar   = lineBreak.Char;
                    _isLineBreak = IsLineBreakForChar;
                }
                else
                {
                    flag = ChangeFlag.Failed;
                }
                break;

            default:
                flag = ChangeFlag.Failed;
                break;
            }
            return(flag);
        }
Exemplo n.º 4
0
        /// <summary>
        /// 设置断句函数.
        /// </summary>
        /// <returns>The break line.</returns>
        /// <param name="LineBreak">New line.</param>
        public ChangeFlag SetLineBreak(LineBreak lineBreak)
        {
            var flag = ChangeFlag.Succeed;
            _lineBreak = lineBreak;
            switch (lineBreak.Type) {
            case "nt": //Windows Nt "\r\n"
                _isLineBreak = IsLineBreakForNt;
                break;

            case "linux": //Linux "\n"
                _isLineBreak = IsLineBreakForLinux;
                break;

            case "mac": //Mac "\r"
                _isLineBreak = IsLineBreakForMac;
                break;

            case "length": //stream length
                if (null != lineBreak.Length) {
                    _index = 0;
                    _length = lineBreak.Length.Value;
                    _isLineBreak = IsLineBreakForLength;
                } else {
                    flag = ChangeFlag.Failed;
                }
                break;

            case "char": //break char
                if (null != lineBreak.Char) {
                    _breakChar = lineBreak.Char;
                    _isLineBreak = IsLineBreakForChar;
                } else {
                    flag = ChangeFlag.Failed;
                }
                break;

            default:
                flag = ChangeFlag.Failed;
                break;
            }
            return flag;
        }