예제 #1
0
        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);
            }
            
        }
        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;
               }
        }
    // Display PortParity values and prompt user to enter a value.
    public static Parity SetPortParity(Parity defaultPortParity)
    {
        string parity;

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

        Console.Write("Enter Parity value (Default: {0}):", defaultPortParity.ToString(), true);
        parity = Console.ReadLine();

        if (parity == "")
        {
            parity = defaultPortParity.ToString();
        }

        return((Parity)Enum.Parse(typeof(Parity), parity, true));
    }
예제 #4
0
        // 设置端口奇偶值
        public static Parity SetPortParity(Parity defaultPortParity)
        {
            string parity;

            Console.WriteLine("可用奇偶值:");
            foreach (string s in Enum.GetNames(typeof(Parity)))
            {
                Console.WriteLine("   {0}", s);
            }

            Console.Write("可用奇偶值(默认: {0}):", defaultPortParity.ToString(), true);
            parity = Console.ReadLine();

            if (parity == "")
            {
                parity = defaultPortParity.ToString();
            }

            return((Parity)Enum.Parse(typeof(Parity), parity, true));
        }
 public void Save(XmlTextWriter xml)
 {
     xml.WriteStartElement("interface");
     xml.WriteAttributeString("id", Id);
     xml.WriteAttributeString("portName", PortName);
     xml.WriteAttributeString("baudRate", BaudRate.ToString());
     xml.WriteAttributeString("dataBits", DataBits.ToString());
     xml.WriteAttributeString("handShake", HandShake.ToString());
     xml.WriteAttributeString("parity", Parity.ToString());
     xml.WriteAttributeString("stopBits", StopBits.ToString());
     xml.WriteEndElement();
 }
예제 #6
0
 /// <summary>
 /// Adds the options to the list.
 /// </summary>
 public void AddToOptionList(OptionList options)
 {
     options.Clear();
     options["PortName"]  = PortName;
     options["BaudRate"]  = BaudRate.ToString();
     options["DataBits"]  = DataBits.ToString();
     options["Parity"]    = Parity.ToString();
     options["StopBits"]  = StopBits.ToString();
     options["DtrEnable"] = DtrEnable.ToLowerString();
     options["RtsEnable"] = RtsEnable.ToLowerString();
     options["Behavior"]  = Behavior.ToString();
 }
예제 #7
0
        public Parity SetPortParity(Parity defaultPortParity)
        {
            foreach (string s in Enum.GetNames(typeof(Parity)))
            {
            }

            if (parity == "")
            {
                parity = defaultPortParity.ToString();
            }

            return((Parity)Enum.Parse(typeof(Parity), parity));
        }
 public void Save()
 {
     Basic.SetRegistryKey("UseScale", UseScale.ToString());
     Basic.SetRegistryKey("Commend", Commend.ToString());
     Basic.SetRegistryKey("PortName", PortName.ToString());
     Basic.SetRegistryKey("BaudRate", BaudRate.ToString());
     Basic.SetRegistryKey("Parity", Parity.ToString());
     Basic.SetRegistryKey("DataBit", DataBit.ToString());
     Basic.SetRegistryKey("StopBit", StopBit.ToString());
     Basic.SetRegistryKey("ScaleType", ScaleType.ToString());
     Basic.SetRegistryKey("DefaultWeight", DefaultWeight.ToString());
     Basic.SetRegistryKey("BarcodeSize", BarcodeSize.ToString());
 }
예제 #9
0
        public static Parity SetPortParity(Parity defaultPortParity, ComboBox comboBox)
        {
            string parity;

            parity = comboBox.SelectedItem.ToString();

            if (parity == "")
            {
                parity = defaultPortParity.ToString();
            }

            return((Parity)Enum.Parse(typeof(Parity), parity, true));
        }
예제 #10
0
        private void Form1_Load(object sender, EventArgs e)
        {
            // fill defaults
            cbBaudRate.Text    = BAUD_RATE.ToString();
            cbDataBits.Text    = DATA_BITS.ToString();
            cbParity.Text      = PARITY.ToString();
            cbStopBits.Text    = STOP_BITS.ToString();
            cbFlowControl.Text = HANDSHAKE.ToString();
            nmRead.Value       = READ_TIMEOUT;
            nmWrite.Value      = WRITE_TIMEOUT;

            btEnumerate_Click(null, null);
        }
예제 #11
0
        public static void ConfigureAppSettings(IAppSettingsBuilder builder)
        {
            // UDP configuration settings
            builder.Add($"{UDPSection}:{nameof(InterfaceIP)}", DefaultInterfaceIP, "Defines the IP of the network interface to use for the UDP socket. Use 0.0.0.0 to listen on all interfaces with IPv4 or ::0 for all interfaces with IPv6.");

            // Serial configuration settings
            builder.Add($"{SerialSection}:{nameof(BaudRate)}", DefaultBaudRate.ToString(), "Defines the serial baud rate. Standard values: 110, 300, 600, 1200, 2400, 4800, 9600, 14400, 19200, 38400, 57600, 115200, 128000, or 256000.");
            builder.Add($"{SerialSection}:{nameof(DataBits)}", DefaultDataBits.ToString(), "Defines the standard length of data bits per byte. Standard values: 5, 6, 7 or 8.");
            builder.Add($"{SerialSection}:{nameof(Parity)}", DefaultParity.ToString(), "Defines the parity-checking protocol. Value is one of: Even, Mark, None, Odd or Space.");
            builder.Add($"{SerialSection}:{nameof(StopBits)}", DefaultStopBits.ToString(), "Defines the standard number of stopbits per byte. Value is one of: None, One, OnePointFive or Two.");
            builder.Add($"{SerialSection}:{nameof(DtrEnable)}", DefaultDtrEnable.ToString(), "Defines the value that enables the Data Terminal Ready (DTR) signal during serial communication.");
            builder.Add($"{SerialSection}:{nameof(RtsEnable)}", DefaultRtsEnable.ToString(), "Defines the value indicating whether the Request to Send (RTS) signal is enabled during serial communication.");
        }
예제 #12
0
        /// <summary>
        /// 禁用命令
        /// </summary>
        /// <param name="addr">地址</param>
        /// <param name="parity">校验方式</param>
        public void BanExcuteCmd(byte addr, Parity parity)
        {
            this.Query(string.Format(
                           "*BanExcute:{0}:{1}",
                           addr.ToString(),
                           parity.ToString()
                           ));

            string checkStr = parity == Parity.Even
                ? "偶校验"
                : "奇校验";
            // GlobalStatusReport.Report(string.Format("禁止命令--校验方式:{0}", checkStr));
        }
        private Parity SetPortParity(Parity defaultPortParity)
        {
            string parity;

            parity = this.paridad;

            if (parity == "" || parity == null)
            {
                parity = defaultPortParity.ToString();
            }

            return((Parity)Enum.Parse(typeof(Parity), parity));
        }
예제 #14
0
        /// <summary>
        /// 加载opa命令
        /// </summary>
        /// <param name="addr">地址</param>
        /// <param name="opaData">opa命令数据</param>
        /// <param name="parity">校验方式</param>
        public void LoadOPA(byte addr, byte opaData, Parity parity = Parity.Even)
        {
            this.Query(string.Format(
                           "*OPA_Load:{0}:{1}:{2}",
                           addr.ToString(),
                           opaData.ToString(),
                           parity.ToString()
                           ));

            string checkStr = parity == Parity.Even
                ? "偶校验"
                : "奇校验";
            //  GlobalStatusReport.Report(string.Format("设置OPA--值:{0},校验方式:{1}", opaData, checkStr));
        }
예제 #15
0
        /// <summary>
        /// 加载并执行ALC命令
        /// </summary>
        /// <param name="addr">地址</param>
        /// <param name="alcData">alc数据</param>
        /// <param name="parity">奇偶校验</param>
        public void LoadAndExcuteALC(byte addr, byte alcData, Parity parity = Parity.Even)
        {
            this.Query(string.Format(
                           "*ALC_Load_Excute:{0}:{1}:{2}",
                           addr.ToString(),
                           alcData.ToString(),
                           parity.ToString()
                           ));

            string checkStr = parity == Parity.Even
                ? "偶校验"
                : "奇校验";
            // GlobalStatusReport.Report(string.Format("设置并执行ALC--值:{0},校验方式:{1}", alcData, checkStr));
        }
예제 #16
0
        /// <summary>
        /// 加载FG命令
        /// </summary>
        /// <param name="addr">地址</param>
        /// <param name="gain">增益值</param>
        /// <param name="parity">校验方式</param>
        public void LoadFG(byte addr, byte gain, Parity parity = Parity.Even)
        {
            this.Query(string.Format(
                           "*FGM_Load:{0}:{1}:{2}",
                           addr.ToString(),
                           gain.ToString(),
                           parity.ToString()
                           ));

            string checkStr = parity == Parity.Even
                ? "偶校验"
                : "奇校验";
            // GlobalStatusReport.Report(string.Format("设置FGM--值:{0},校验方式:{1}", gain, checkStr));
        }
예제 #17
0
        /// <summary>
        /// Returns a <see cref="System.String"/> that represents this instance.
        /// </summary>
        /// <returns>A <see cref="System.String"/> that represents this instance.</returns>
        public override string ToString()
        {
            string stopbits = "";

            switch (Stopbits)
            {
            //case System.IO.Ports.StopBits.None: stopbits = "0"; break; <-- not supported
            case System.IO.Ports.StopBits.One: stopbits = "1"; break;

            case System.IO.Ports.StopBits.OnePointFive: stopbits = "1.5"; break;

            case System.IO.Ports.StopBits.Two: stopbits = "2"; break;
            }
            return(Baudrate + " " + Databits + Parity.ToString().Substring(0, 1) + stopbits);
        }
예제 #18
0
        //methods
        public ComPort(string name, int bps, Parity parity, StopBits stopBits)
        {
            //debug info
            Console.WriteLine(name.ToString());
            Console.WriteLine(bps.ToString());
            Console.WriteLine(parity.ToString());
            Console.WriteLine(stopBits.ToString());

            this.name                     = name;
            this.bps                      = bps;
            this.parity                   = parity;
            this.stopBits                 = stopBits;
            recieveTimeOutTimer           = new Timer();
            recieveTimeOutTimer.AutoReset = false;
            recieveTimeOutTimer.Elapsed  += recieveTimeOut_Elapsed;
        }
예제 #19
0
        private Parity SetPortParity(Parity defaultPortParity)
        {
            string parity = string.Empty;

            foreach (string s in Enum.GetNames(typeof(Parity)))
            {
                break;
            }

            if (parity == "")
            {
                parity = defaultPortParity.ToString();
            }

            return((Parity)Enum.Parse(typeof(Parity), parity));
        }
예제 #20
0
        // Display PortParity values and prompt user to enter a value.
        public void SetPortParity()
        {
            string newParity;

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

            Console.Write("Enter Parity value (Default: {0}):", Parity.ToString(), true);
            newParity = Console.ReadLine();

            if (!String.IsNullOrEmpty(newParity))
            {
                Parity = (System.IO.Ports.Parity)Enum.Parse(typeof(Parity), newParity, true);
            }
        }
예제 #21
0
 void SetParity(Parity value)
 {
     try
     {
         Log("Изменение настроек порта: < Parity = " + value.ToString() + " >");
         m_serialPort.Parity = value;
         m_spParams.Parity   = value;
         UpdateUI();
         SaveParam();
         Log("\tВыполнено успешно");
     }
     catch (Exception ex)
     {
         Log("\tОшибка...");
         Log("\t" + ex.Message + "...");
         MessageBox.Show(ex.Message, "Ошибка установки паритета четности порта < " + m_spParams.Name + " >", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
예제 #22
0
        public Parity SetPortParity(Parity defaultPortParity)
        {
            string parity;

            //Console.WriteLine("Available Parity options:");

            /*
             * foreach (string s in Enum.GetNames(typeof(Parity)))
             * {
             *  Console.WriteLine("   {0}", s);
             * }
             */

            parity = defaultPortParity.ToString();

            _serialPort.Parity = (Parity)Enum.Parse(typeof(Parity), parity, true);

            return((Parity)Enum.Parse(typeof(Parity), parity, true));
        }
예제 #23
0
        public void Save()
        {
            XmlNodeList nodeList = doc.GetElementsByTagName("SerialPort");

            if (nodeList.Count != 0)
            {
                XmlNode xmlNode = nodeList[0];
                xmlNode.Attributes["PortName"].Value = portName;
                xmlNode.Attributes["BaudRate"].Value = baudRate.ToString();
                xmlNode.Attributes["Parity"].Value   = parity.ToString();
                xmlNode.Attributes["DataBits"].Value = dataBits.ToString();
                xmlNode.Attributes["StopBits"].Value = stopBits.ToString();
                doc.Save(configFile);
            }
            else
            {
                throw new Exception("在配置文件中找不到关于UDPServer的信息");
            }
        }
예제 #24
0
파일: ComPorts.cs 프로젝트: lulzzz/GridTrak
        public static DataTable New_CfgTable()
        {
            DataTable t0 = new DataTable(T_PORT1);

            t0.Columns.Add(new DataColumn(C_PORT_NAME, Type.GetType(Cfg.SYS_STRING)));
            t0.Columns[C_PORT_NAME].DefaultValue = DEF_PORT1_NAME;

            t0.Columns.Add(new DataColumn(C_BAUD, Type.GetType(Cfg.SYS_INT32)));
            t0.Columns[C_BAUD].DefaultValue = DEF_PORT1_BAUD;

            t0.Columns.Add(new DataColumn(C_HANDSHAKE, Type.GetType(Cfg.SYS_STRING)));
            t0.Columns[C_HANDSHAKE].DefaultValue = DEF_PORT1_HANDSHAKE.ToString();

            t0.Columns.Add(new DataColumn(C_DATABITS, Type.GetType(Cfg.SYS_INT32)));
            t0.Columns[C_DATABITS].DefaultValue = DEF_PORT1_DATABITS;

            t0.Columns.Add(new DataColumn(C_PARITY, Type.GetType(Cfg.SYS_STRING)));
            t0.Columns[C_PARITY].DefaultValue = DEF_PORT1_PARITY.ToString();

            t0.Columns.Add(new DataColumn(C_STOPBITS, Type.GetType(Cfg.SYS_STRING)));
            t0.Columns[C_STOPBITS].DefaultValue = DEF_PORT1_STOPBITS.ToString();

            t0.Columns.Add(new DataColumn(C_READBUFFERSIZE, Type.GetType(Cfg.SYS_INT32)));
            t0.Columns[C_READBUFFERSIZE].DefaultValue = DEF_PORT1_READBUFFERSIZE;

            t0.Columns.Add(new DataColumn(C_READTIMEOUT, Type.GetType(Cfg.SYS_INT32)));
            t0.Columns[C_READTIMEOUT].DefaultValue = DEF_PORT1_READTIMEOUT;

            t0.Columns.Add(new DataColumn(C_WRITEBUFFERSIZE, Type.GetType(Cfg.SYS_INT32)));
            t0.Columns[C_WRITEBUFFERSIZE].DefaultValue = DEF_PORT1_WRITEBUFFERSIZE;

            t0.Columns.Add(new DataColumn(C_WRITETIMEOUT, Type.GetType(Cfg.SYS_INT32)));
            t0.Columns[C_WRITETIMEOUT].DefaultValue = DEF_PORT1_WRITETIMEOUT;

            t0.Columns.Add(new DataColumn(C_RECEIVEDBYTESTHRESHOLD, Type.GetType(Cfg.SYS_INT32)));
            t0.Columns[C_RECEIVEDBYTESTHRESHOLD].DefaultValue = DEF_PORT1_RECEIVEDBYTESTHRESHOLD;

            t0.Rows.Add(t0.NewRow());
            t0.AcceptChanges();

            return(t0);
        }
예제 #25
0
 /* Initialise the toolbar menu */
 public void initMenu()
 {
     foreach (string s in SerialPort.GetPortNames())
     {
         this.portNameComboBox.Items.Add(s);
     }
     foreach (string s in Enum.GetNames(typeof(Parity)))
     {
         this.parityComboBox.Items.Add(s);
     }
     foreach (string s in Enum.GetNames(typeof(StopBits)))
     {
         this.stopBitsComboBox.Items.Add(s);
     }
     this.portNameComboBox.Text = _PortName;
     this.baudRateTextBox.Text  = _BaudRate.ToString();
     this.dataBitsTextBox.Text  = _DataBits.ToString();
     this.stopBitsComboBox.Text = _StopBits.ToString();
     this.parityComboBox.Text   = _Parity.ToString();
 }
 public bool Save(XmlWriter xw)
 {
     try
     {
         xw.WriteStartElement("ComPortSettings");
         xw.WriteElementString("PortName", comname);
         xw.WriteElementString("Speed", speed.ToString());
         xw.WriteElementString("Databits", databits.ToString());
         xw.WriteElementString("Parity", parity.ToString());
         xw.WriteElementString("Stopbits", stopbits.ToString());
         xw.WriteElementString("Handshake", handshake.ToString());
         xw.WriteEndElement();
         return(true);
     }
     catch (Exception ex)
     {
         DebugLogger.Instance().LogRecord(ex.Message);
         return(false);
     }
 }
예제 #27
0
 public static void ShowCurrentSettings(string portName, int baudRate, Parity parity, int dataBits, StopBits stopBits, Handshake handshake, int readTimeout, int loggingInterval)
 {
     ConsoleHelper.WriteLine("Current Settings", ConsoleColor.Cyan);
     WriteInfo("PortName", portName, portName.ToUpper() == "COM1" ? "(default)" : "");
     WriteInfo("BaudRate", baudRate, baudRate == 9600 ? "(default)" : "");
     WriteInfo("DataBits", dataBits, dataBits == 8 ? "(default)" : "");
     WriteInfo("Parity", parity, parity.ToString() == "None" ? "(default)" : "");
     WriteInfo("StopBits", stopBits, stopBits.ToString() == "One" ? "(default)" : "");
     WriteInfo("Handshake", handshake, handshake.ToString() == "None" ? "(default)" : "");
     WriteInfo("Timeout", readTimeout, readTimeout == -1 ? "(default)" : "");
     WriteInfo("LogInterval", loggingInterval, loggingInterval == 1000 ? "(default)" : "");
     EmptyOneRow();
     ConsoleHelper.Write("  To update the value, type ", ConsoleColor.DarkYellow);
     ConsoleHelper.WriteLine("/set <label> <value>", ConsoleColor.Yellow);
     ConsoleHelper.Write("  To get help, type ", ConsoleColor.DarkRed);
     ConsoleHelper.WriteLine("/help <label>", ConsoleColor.Red);
     ConsoleHelper.Write("  To start logging, type ", ConsoleColor.DarkGreen);
     ConsoleHelper.WriteLine("/start", ConsoleColor.Green);
     ConsoleHelper.WriteLine("  Data logging is automatic once connection is established.", ConsoleColor.DarkGray);
     EmptyOneRow();
 }
예제 #28
0
        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;
            }
        }
예제 #29
0
        /// <summary>
        /// Write the device configuration to the  ASCOM  Profile store
        /// </summary>
        private void WriteProfile()
        {
            using (Profile driverProfile = new Profile())
            {
                driverProfile.DeviceType = "Camera";

                driverProfile.WriteValue(driverID, webcamProfileName, webcamName);
                driverProfile.WriteValue(driverID, mediaTypeProfileName, Webcam.ToString(mediaType));
                driverProfile.WriteValue(driverID, pixelSizeXProfileName, pixelSizeX.ToString());
                driverProfile.WriteValue(driverID, pixelSizeYProfileName, pixelSizeY.ToString());

                driverProfile.WriteValue(driverID, comPortProfileName, comPortName);
                driverProfile.WriteValue(driverID, baudRateProfileName, baudRate.ToString());
                driverProfile.WriteValue(driverID, parityProfileName, parity.ToString());
                driverProfile.WriteValue(driverID, dataBitsProfileName, dataBits.ToString());
                driverProfile.WriteValue(driverID, stopBitsProfileName, stopBits.ToString());
                driverProfile.WriteValue(driverID, readTimeoutProfileName, readTimeout.ToString());
                driverProfile.WriteValue(driverID, writeTimeoutProfileName, writeTimeout.ToString());

                driverProfile.WriteValue(driverID, traceLoggerProfileName, traceLogger.Enabled.ToString());
            }
        }
        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;
            }
        }
예제 #31
0
        public static string ParityToString(Parity AValue)
        {
            switch (AValue)
            {
            case Parity.Even:
                return("Чёт");

            case Parity.Odd:
                return("Нечёт");

            case Parity.Mark:
                return("Маркер");

            case Parity.Space:
                return("Пробел");

            case Parity.None:
                return("Нет");

            default:
                return(AValue.ToString());
            }
        }
예제 #32
0
        public override string ToString()
        {
            StringBuilder times = new StringBuilder();


            times.Append("Week parity: ");
            times.Append(Parity.ToString());
            times.Append(", Day number: ");
            times.Append(Day.ToString());
            times.Append(", Time: ");
            times.Append(StartDate.ToString());
            times.Append(" - ");
            times.Append(EndDate.ToString());
            times.Append("\t");



            return("Name of Event: " + EventName + "\n"
                   + "Owner: " + EventOwner.Username + "\n"
                   + "Location: " + Location + "\n"
                   + "Description: " + Description + "\n"
                   + "Due Times: " + times.ToString() + "\n"
                   + "Category: " + Category.Name + "\n");
        }
        public void SetComboBoxes(List<String> newList, String comPortName, int baudRate, Parity parity, int dataBits, StopBits stopBits, Handshake handshake, bool rtsEnable, bool dtrEnable)
        {
            PopulatePortNameList(newList, comPortName);
               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;
               }
               switch (handshake)
               {
                    case Handshake.None:
                         cmbHandshake.SelectedIndex = GetIndexOfValue(cmbHandshake.Items, "None");
                         break;
                    case Handshake.RequestToSend:
                         cmbHandshake.SelectedIndex = GetIndexOfValue(cmbHandshake.Items, "RequestToSend");
                         break;
                    case Handshake.XOnXOff:
                         cmbHandshake.SelectedIndex = GetIndexOfValue(cmbHandshake.Items, "XOnXOff");
                         break;
                    case Handshake.RequestToSendXOnXOff:
                         cmbHandshake.SelectedIndex = GetIndexOfValue(cmbHandshake.Items, "Both");
                         break;
                    default:
                         cmbHandshake.SelectedIndex = GetIndexOfValue(cmbHandshake.Items, "None");
                         break;
               }

               if (rtsEnable)
               {
                    cmbRequestToSend.SelectedIndex = GetIndexOfValue(cmbRequestToSend.Items, "Enable");
               }
               else
               {
                    cmbRequestToSend.SelectedIndex = GetIndexOfValue(cmbRequestToSend.Items, "Disable");
               }

               if (dtrEnable)
               {
                    cmbDataTerminalReady.SelectedIndex = GetIndexOfValue(cmbDataTerminalReady.Items, "Enable");
               }
               else
               {
                    cmbDataTerminalReady.SelectedIndex = GetIndexOfValue(cmbDataTerminalReady.Items, "Disable");
               }
        }
예제 #34
0
        public Parity SetPortParity(Parity defaultPortParity)
        {
            Console.WriteLine("Available Parity options:");
            foreach (var s in Enum.GetNames(typeof(Parity)))
            {
                Console.WriteLine("   {0}", s);
            }

            Console.Write("Enter Parity value (Default: {0}):", defaultPortParity.ToString(), true);
            var parity = Console.ReadLine();

            if (parity == "")
            {
                parity = defaultPortParity.ToString();
            }

            // ReSharper disable once AssignNullToNotNullAttribute
            return (Parity)Enum.Parse(typeof(Parity), parity, true);
        }
 // Display PortParity values and prompt user to enter a value.
 public static Parity SetPortParity(Parity defaultPortParity)
 {
     string parity;
     parity = defaultPortParity.ToString();
     return (Parity)Enum.Parse(typeof(Parity), parity, true);
 }
예제 #36
0
 /// <summary>
 /// Переводит значение бита четности в рускоязычный аналог 
 /// </summary>
 /// <param name="parity">Значение бита четности</param>
 /// <returns>Рускоязычное значение бита четности</returns>
 public static string ParityToStr(Parity parity)
 {
     switch (parity)
     {
         case Parity.Even:
             return "нет";
         case Parity.Odd:
             return "нечетный";
         case Parity.None:
             return "четный";
         default:
             return parity.ToString();
     }
 }
예제 #37
0
파일: Program.cs 프로젝트: w4-pwr/studia
        public static Parity SetPortParity(Parity defaultPortParity)
        {
            string parity;

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

            Console.Write("Parity({0}):", defaultPortParity.ToString());
            parity = Console.ReadLine();

            if (parity == "")
            {
                parity = defaultPortParity.ToString();
            }

            return (Parity)Enum.Parse(typeof(Parity), parity);
        }
예제 #38
0
 private void SerialPortParity_SelectedIndexChanged(object sender, EventArgs e)
 {
     _SelectIdToParity(SerialPortParity.SelectedIndex, out portParity);
     Console.WriteLine("SerialPortParity: {0}-{1}", SerialPortParity.SelectedIndex, portParity.ToString());
 }
        public static Parity SetPortParity(Parity defaultPortParity)
        {
            string parity = ConfigurationManager.AppSettings["Parity"];

            if (string.IsNullOrEmpty(parity))
            {
                parity = defaultPortParity.ToString();
            }

            return (Parity)Enum.Parse(typeof(Parity), parity);
        }