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


C# StopBits.ToString方法代码示例

本文整理汇总了C#中StopBits.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# StopBits.ToString方法的具体用法?C# StopBits.ToString怎么用?C# StopBits.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在StopBits的用法示例。


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

示例1: SaveSettingss

        private async void SaveSettingss(string port, int baud, Parity parity, Handshake handshake, int dataBits, StopBits stopBits)
        {
            writing = true;
            XmlWriterSettings settings = new XmlWriterSettings { Indent = true, NewLineOnAttributes = true };
            XmlWriter writer = XmlWriter.Create("Settings.xml", settings);

            writer.WriteStartDocument();
            writer.WriteStartElement("Settings");

            writer.WriteElementString("Port", port);
            writer.WriteElementString("Baudrate", baud.ToString());
            writer.WriteElementString("Parity", parity.ToString());
            writer.WriteElementString("Handshake", handshake.ToString());
            writer.WriteElementString("Data_Bits", dataBits.ToString());
            writer.WriteElementString("Stop_Bits", stopBits.ToString());

            writer.WriteEndElement();
            writer.WriteEndDocument();
            writer.Flush();
            writer.Close();
            writing = false;
            if(!initialization)
            {
                MessageDialogResult result = await MessageService.ShowMessage("Gespeichert!", "Settings wurden gespeichert!", MessageDialogStyle.Affirmative).ConfigureAwait(false);
            }
            
        }
开发者ID:arminhenres,项目名称:BeerBot,代码行数:27,代码来源:MainViewModel.cs

示例2: Open

        public bool Open(string portName, int baudRate, Parity parity, int dataBits, StopBits stopBits)
        {
            try
            {
                log.Debug(string.Format("准备打开串口{0},波特率{1},奇偶校验位{2},数据位{3},停止位{4}", portName, baudRate.ToString(), parity.ToString(), dataBits.ToString(), stopBits.ToString()));
                comPort = new SerialPort(portName, baudRate, parity, dataBits, stopBits);
                if (comPort.IsOpen)
                {
                    comPort.Close();
                }
                comPort.Open();
                log.Debug(string.Format("成功打开串口{0}!", portName));

                return true;
            }
            catch (Exception ex)
            {
                log.Info(string.Format("打开串口:{0}异常:{1}", portName, ex.ToString()));
                return false;
            }
        }
开发者ID:romanu6891,项目名称:fivemen,代码行数:21,代码来源:SerialPortHelper.cs

示例3: SetPortStopBits

        public static StopBits SetPortStopBits(StopBits defaultPortStopBits)
        {
            string stopBits;

            Console.WriteLine("Available Stop Bits options:");
            foreach (string s in Enum.GetNames(typeof(StopBits)))
            {
                Console.WriteLine("   {0}", s);
            }

            Console.Write("Stop Bits({0}):", defaultPortStopBits.ToString());
            stopBits = Console.ReadLine();

            if (stopBits == "")
            {
                stopBits = defaultPortStopBits.ToString();
            }

            return (StopBits)Enum.Parse(typeof(StopBits), stopBits);
        }
开发者ID:w4-pwr,项目名称:studia,代码行数:20,代码来源:Program.cs

示例4: SetPortStopBits

        // Display StopBits values and prompt user to enter a value.
        public static StopBits SetPortStopBits(StopBits defaultPortStopBits)
        {
            string stopBits;

            Console.WriteLine("Available StopBits options:");
            foreach (string s in Enum.GetNames(typeof(StopBits)))
            {
                Console.WriteLine("   {0}", s);
            }

            Console.Write("Enter StopBits value (None is not supported and \n" +
             "raises an ArgumentOutOfRangeException. \n (Default: {0}):", defaultPortStopBits.ToString());
            stopBits = Console.ReadLine();

            if (stopBits == "")
            {
                stopBits = defaultPortStopBits.ToString();
            }

            return (StopBits)Enum.Parse(typeof(StopBits), stopBits, true);
        }
开发者ID:FinnStutzenstein,项目名称:CubeAPI,代码行数:22,代码来源:Program.cs

示例5: StopBitsToStr

 /// <summary>
 /// Переводит количество стоповых битов в строку
 /// </summary>
 /// <param name="stopBits">Число стоповых битов</param>
 /// <returns>Значение количества стоповых бит</returns>
 public static string StopBitsToStr(StopBits stopBits)
 {
     switch (stopBits)
     {
         case StopBits.None:
             return "0";
         case StopBits.One:
             return "1";
         case StopBits.OnePointFive:
             return "1.5";
         case StopBits.Two:
             return "2";
         default:
             return stopBits.ToString();
     }
 }
开发者ID:n0rthwind,项目名称:fisher,代码行数:21,代码来源:Communicators.cs

示例6: SetPortStopBits

        public static StopBits SetPortStopBits(StopBits defaultPortStopBits)
        {
            string stopBits = ConfigurationManager.AppSettings["StopBits"];

            if (string.IsNullOrEmpty(stopBits))
            {
                stopBits = defaultPortStopBits.ToString();
            }

            return (StopBits)Enum.Parse(typeof(StopBits), stopBits);
        }
开发者ID:deemoowoor,项目名称:SerialReaderService,代码行数:11,代码来源:WindowsService.cs

示例7: SetPortStopBits

 // Display StopBits values and prompt user to enter a value.
 public static StopBits SetPortStopBits(StopBits defaultPortStopBits)
 {
     string stopBits;
     stopBits = defaultPortStopBits.ToString();
     return (StopBits)Enum.Parse(typeof(StopBits), stopBits, true);
 }
开发者ID:treichhalter,项目名称:01856-serien-test-tool,代码行数:7,代码来源:SerialPortCom.cs

示例8: SetPortStopBits

        public StopBits SetPortStopBits(StopBits defaultPortStopBits)
        {
            Console.WriteLine("Available StopBits options:");
            foreach (var s in Enum.GetNames(typeof(StopBits)))
            {
                Console.WriteLine("   {0}", s);
            }

            Console.Write("Enter StopBits value (None is not supported and \n" +
                          "raises an ArgumentOutOfRangeException. \n (Default: {0}):", defaultPortStopBits.ToString());
            var stopBits = Console.ReadLine();

            if (stopBits == "")
            {
                stopBits = defaultPortStopBits.ToString();
            }

            // ReSharper disable once AssignNullToNotNullAttribute
            return (StopBits)Enum.Parse(typeof(StopBits), stopBits, true);
        }
开发者ID:Emaxan,项目名称:AOKT_Laba4_COM,代码行数:20,代码来源:Program.cs


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