当前位置: 首页>>代码示例>>C#>>正文


C# Parity类代码示例

本文整理汇总了C#中Parity的典型用法代码示例。如果您正苦于以下问题:C# Parity类的具体用法?C# Parity怎么用?C# Parity使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Parity类属于命名空间,在下文中一共展示了Parity类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ParityDecode

        static public ushort ParityDecode(Parity aParity)
        {
            ushort zReturn;            

            switch (aParity)
            {
                case Parity.Even:
                    zReturn = 1;
                    break;
                case Parity.Mark:
                    zReturn = 2;
                    break;
                case Parity.None:
                    zReturn = 4;
                    break;
                case Parity.Odd:
                    zReturn = 0;
                    break;
                case Parity.Space:
                    zReturn = 3;
                    break;
                default:
                    throw new ArgumentOutOfRangeException();                    
            }

            return zReturn;
        }
开发者ID:MegaYanuardi,项目名称:GSMLibrary.Net,代码行数:27,代码来源:CharacterFramingCommand.cs

示例2: SerialTerminal

 public SerialTerminal(string portName, int baudRate, Parity parity, int dataBits, StopBits stopBits)
     : base(portName, baudRate, parity, dataBits, stopBits)
 {
     Open();
     Handshake = Handshake.XOnXOff;
     OperatingMode = IBM3151.OperatingModes.Echo;
 }
开发者ID:32bitkid,项目名称:FalloutTerminal,代码行数:7,代码来源:SerialTerminal.cs

示例3: SetComboBoxes

        public void SetComboBoxes(String comPortName, int baudRate, Parity parity, int dataBits, StopBits stopBits)
        {
            try
               {
                    cmbComPortName.Text = GetValidPortName(cmbComPortName.Text);
               }
               catch (Exception ex)
               {
                    MessageBox.Show(ex.ToString());
                    cmbComPortName.Text = "NONE";
               }

               cmbBaudRate.Text = baudRate.ToString();
               cmbParity.SelectedIndex = GetIndexOfValue(cmbParity.Items, parity.ToString());
               cmbDataBits.SelectedIndex = GetIndexOfValue(cmbDataBits.Items, dataBits.ToString());
               switch (stopBits)
               {
                    case StopBits.One:
                         cmbStopBits.SelectedIndex = GetIndexOfValue(cmbStopBits.Items, "1");
                         break;
                    case StopBits.OnePointFive:
                         cmbStopBits.SelectedIndex = GetIndexOfValue(cmbStopBits.Items, "1.5");
                         break;
                    case StopBits.Two:
                         cmbStopBits.SelectedIndex = GetIndexOfValue(cmbStopBits.Items, "2");
                         break;
                    case StopBits.None:
                         cmbStopBits.SelectedIndex = GetIndexOfValue(cmbStopBits.Items, "1");
                         break;
                    default:
                         cmbStopBits.SelectedIndex = GetIndexOfValue(cmbStopBits.Items, "1");
                         break;
               }
        }
开发者ID:mrpenguin7,项目名称:MessageProfilingActivityCommunicator,代码行数:34,代码来源:ComPortConfigForm.cs

示例4: Open

            /// <summary>
            /// Opens the serial port using the specified baud rate, parity bit, data bits, and stop bit.
            /// </summary>
            /// <param name="baudRate">The baud rate.</param>
            /// <param name="parity">One of the Parity values.</param>
            /// <param name="dataBits">The data bits value.</param>
            /// <param name="stopBits">One of the StopBits values.</param>
            public Windows.Foundation.IAsyncAction Open(
                uint baudRate,
                Parity parity,
                int dataBits,
                StopBits stopBits
            )
            {
                return Task.Run(async () =>
                {
                    this.baudRate  = baudRate;
                    this.parity    = parity;
                    this.dataBits  = dataBits;
                    this.stopBits  = stopBits;

                    if (this.cdcControl == null)
                    {
                        return;
                    }

                    // Do SetLineCoding
                    var len = await SetLineCoding(this.cdcControl.InterfaceNumber, this.baudRate, (byte)this.stopBits, (byte)this.parity, (byte)this.dataBits);
                    if (len != Constants.ExpectedResultSetLineCoding)
                    {
                        throw new System.NotSupportedException("SetLineCoding request is not supported.");
                    }

                    // Do SetControlLineState
                    len = await SetControlLineState(this.cdcControl.InterfaceNumber);
                    
                    return;

                }).AsAsyncAction();
            }
开发者ID:oldnewthing,项目名称:old-Windows8-samples,代码行数:40,代码来源:SerialPort.cs

示例5: Open

        public bool Open(string portName, int baudRate, int databits, Parity parity, StopBits stopBits)
        {
            //Ensure port isn't already opened:
            if (!sp.IsOpen)
            {
                //Assign desired settings to the serial port:
                sp.PortName = portName;
                sp.BaudRate = baudRate;
                sp.DataBits = databits;
                sp.Parity = parity;
                sp.StopBits = stopBits;
                //These timeouts are default and cannot be editted through the class at this point:
                sp.ReadTimeout = 2000;
                sp.WriteTimeout = 2000;
                try
                {
                    sp.Open();
                }
                catch (Exception err)
                {

                    return false;
                }

                return true;
            }
            else
            {

                return false;
            }
        }
开发者ID:goodwin3000,项目名称:ModBus_TCP_RTU_Proxy,代码行数:32,代码来源:MbDevice.cs

示例6: SerialConfig

 public SerialConfig(string cfg)
 {
     var parts = cfg.Split(new Char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
     this.initialConfig = cfg;
     int index = 0;
     if (!parts[index].StartsWith("COM"))
     {
         this.DeviceName = parts[index];
         index++;
     }
     this.PortName = parts[index]; index++;
     this.AutoConnect = Boolean.Parse(parts[index]); index++;
     this.Speed = UInt32.Parse(parts[index]); index++;
     this.DataBits = Byte.Parse(parts[index]); index++;
     this.Parity = (Parity)Byte.Parse(parts[index]); index++;
     this.StopBits = (StopBits)Byte.Parse(parts[index]); index++;
     //this.PacketType = (PacketType)Byte.Parse(parts[index]); index++;
     this.RxPacketType = (PacketType)Byte.Parse(parts[index]); index++;
     this.TxPacketType = (PacketType)Byte.Parse(parts[index]); index++;
     this.PacketType = this.RxPacketType;
     if (parts.Length > index)
     {
         this.ReceiverCRC = Byte.Parse(parts[index]); index++;
         this.TransmitterCRC = Byte.Parse(parts[index]); index++;
     }
     if (parts.Length > index)
     {
         this.DefaultDeviceAddr = Byte.Parse(parts[index]); index++;
     }
 }
开发者ID:WebManufacture,项目名称:Legacy.NET,代码行数:30,代码来源:SerialConfig.cs

示例7: SerialPortSetting

 /// <summary>
 /// 
 /// </summary>
 /// <param name="bardRate"></param>
 /// <param name="parity"></param>
 /// <param name="dataBits"></param>
 /// <param name="stopBits"></param>
 public SerialPortSetting(int baudRate, Parity parity, int dataBits, StopBits stopBits)
 {
     this.BaudRate = baudRate;
         this.Parity = parity;
         this.DataBits = dataBits;
         this.StopBits = stopBits;
 }
开发者ID:hkiaipc,项目名称:c2,代码行数:14,代码来源:SerialPortSetting.cs

示例8: RTU_Client

        public RTU_Client(string PortName, int BaudRate = 9600, Parity Parity = Parity.None, int DataBits = 8, StopBits StopBits = StopBits.One, int Timeout = 2500)
        {
            try
            {
                Port = new SerialPort(PortName, BaudRate, Parity, DataBits, StopBits);
            }
            catch (IOException ex)
            {
                throw new RTU_Exception("Ошибка настроек коммуникационного порта. " + ex.Message, ex);
            }
            ByteTimeout = 20;
            MaxCount = 5;
            this.Timeout = Timeout;

            this.Buffer = new List<byte>(256);


            ReqSendEvent += delegate { };
            ByteRecievedEvent += delegate { };

            try
            {
                Port.Open();
            }
            catch (Exception ex)
            {
                throw new RTU_Exception("Ошибка открытия коммуникационного порта. " + ex.Message, ex);
            }

        }
开发者ID:mrLunatic,项目名称:NET_Modbus,代码行数:30,代码来源:RTU+Client.cs

示例9: setportvalues

 public void setportvalues(UInt32 BaudRate, int DataBits, StopBits StopBits, Parity Parity)
 {
     vBaudRate = BaudRate;
     vDataBits = DataBits;
     vStopBits = StopBits;
     vParity = Parity;
 }
开发者ID:anbarrasu,项目名称:RdrClient,代码行数:7,代码来源:serialPortM.cs

示例10: initialize

 public static void initialize(string COM_port_Name, int baudRate, Parity parity, int dataBits, StopBits stopBits)
 {
     try
     {
         if (COM_port != null)
         {
             if (COM_port.IsOpen)
             {
                 COM_port.Close();
             }
         }
         COM_port = new SerialPort(COM_port_Name, baudRate, parity, dataBits, stopBits);
         COM_port.DataReceived += new SerialDataReceivedEventHandler(DataReceived);
         if (!COM_port.IsOpen)
         {
             COM_port.Open();
         }
         initialized = 1;
         Receiver.Interval = 10;
         Receiver.Elapsed += new System.Timers.ElapsedEventHandler(Receiver_time_out);
         Receiver.AutoReset = false;
         Synchro.Interval = 50;
         Synchro.Elapsed += new System.Timers.ElapsedEventHandler(Synchro_time_out);
         Synchro.AutoReset = false;
     }
     catch (Exception exception)
     {
         Error_messager.Invoke("Ошибка инициализации!\r\nRadist: \r\n" + exception.Message);
         initialized = 2;
     }
 }
开发者ID:dkflsrj,项目名称:processor-test,代码行数:31,代码来源:Radist.cs

示例11: RCRadio

 public RCRadio(string id, string port = "COM1", int baudRate = 115200, Parity parity = Parity.None, int dataBits = 8, StopBits stopBits = StopBits.One)
 {
     Port = new SerialPort(port, baudRate, parity, dataBits, stopBits);
     AutoPing = true;
     PingPeriod = 3000;
     DataQueue = new StringFifoQueue();
 }
开发者ID:ianlee74,项目名称:NETMFx,代码行数:7,代码来源:RCRadio.cs

示例12: PortManager

        public PortManager(String portName, int baudRate, Parity parity, int dataBits, StopBits stopBits, Form1 form )
        {
            if (this.port == null)
            {
                this.portName = portName;
                this.baudRate = baudRate;
                this.parity = parity;
                this.dataBits = dataBits;
                this.stopBits = stopBits;

                this.port = new SerialPort(portName, baudRate, parity, dataBits, stopBits);
                this.port.DtrEnable = true;
                this.port.RtsEnable = true;
                this.port.DataReceived += new SerialDataReceivedEventHandler(port_DataReceived);

                Form = form;
            }
            else
            {
                this.port.BaudRate = baudRate;
                this.port.Parity = parity;
                this.port.DataBits = dataBits;
                this.port.StopBits = stopBits;
            }
        }
开发者ID:LucasPadovan,项目名称:altoscan,代码行数:25,代码来源:PortManager.cs

示例13: Start

 public static EM406aGPS Start(string portName, int baudRate = 4800, Parity parity = Parity.None, int dataBits = 8, StopBits stopBits = StopBits.One)
 {
     EM406aGPS gps = new EM406aGPS(portName, baudRate, parity, dataBits, stopBits);
     gps._thread = new Thread(gps.Run);
     gps._thread.Start();
     return gps;
 }
开发者ID:adamgilmore,项目名称:Bewarro,代码行数:7,代码来源:EM406aGPS.cs

示例14: PortInitInfo

 public PortInitInfo(int mBaudRate,Parity mParity, int mDataBits, StopBits mStopBits)
 {
     this._BaudRate    = mBaudRate;
     this._Parity      = mParity;
     this._DataBits    = mDataBits;
     this._StopBits    = mStopBits;
 }
开发者ID:wxgb9801,项目名称:Measurer,代码行数:7,代码来源:cProt.cs

示例15: SerialPort

 /// <summary>Initializes a new instance of the <see cref="SerialPort"/> class using the specified port name, baud rate, and parity bit.
 /// </summary>
 /// <param name="portName">The port to use (for example, COM1)</param>
 /// <param name="baudRate">The baud rate</param>
 /// <param name="parity">One of the <see cref="Parity"/> values</param>
 public SerialPort(string portName, int baudRate, Parity parity)
     : this()
 {
     PortName = portName;
     BaudRate = baudRate;
     Parity = parity;
 }
开发者ID:hanseartic,项目名称:interopcom,代码行数:12,代码来源:SerialPort.cs


注:本文中的Parity类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。