Exemplo n.º 1
0
        public void SaveUserData()
        {
            Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);

            config.AppSettings.Settings["CommunicationMode"].Value = CommunicationMode.ToString();
            config.AppSettings.Settings["IPAddress"].Value         = IPAddress.ToString();
            config.AppSettings.Settings["TCPPort"].Value           = TCPPort.ToString();
            config.AppSettings.Settings["PortName"].Value          = PortName.ToString();
            config.AppSettings.Settings["Baud"].Value     = Baud.ToString();
            config.AppSettings.Settings["Parity"].Value   = Parity.ToString();
            config.AppSettings.Settings["SlaveId"].Value  = SlaveId.ToString();
            config.AppSettings.Settings["DataBits"].Value = DataBits.ToString();
            config.AppSettings.Settings["StopBits"].Value = StopBits.ToString();
            config.Save(ConfigurationSaveMode.Modified);
            ConfigurationManager.RefreshSection("appSettings");


            //Properties.Settings.Default.CommunicationMode = CommunicationMode.ToString();
            //Properties.Settings.Default.IPAddress = IPAddress.ToString();
            //Properties.Settings.Default.DisplayFormat = DisplayFormat.ToString();
            //Properties.Settings.Default.TCPPort = TCPPort;
            //Properties.Settings.Default.PortName = PortName;
            //Properties.Settings.Default.Baud = Baud;
            //Properties.Settings.Default.Parity = Parity;
            //Properties.Settings.Default.StartAddress = StartAddress;
            //Properties.Settings.Default.DataLength = DataLength;
            //Properties.Settings.Default.SlaveId = SlaveId;
            //Properties.Settings.Default.SlaveDelay = SlaveDelay;
            //Properties.Settings.Default.DataBits = DataBits;
            //Properties.Settings.Default.StopBits = StopBits;
            //Properties.Settings.Default.Save();
        }
Exemplo n.º 2
0
 protected override void GetXml(XmlDocument document, XmlNode rootElement)
 {
     base.GetXml(document, rootElement);
     AddElement(document, rootElement, "PortName", PortName);
     AddElement(document, rootElement, "BaudRate", BaudRate.ToString(CultureInfo.InvariantCulture));
     AddElement(document, rootElement, "DataBits", DataBits.ToString(CultureInfo.InvariantCulture));
     AddElement(document, rootElement, "Parity", Parity.ToString());
     AddElement(document, rootElement, "StopBits", StopBits.ToString());
 }
Exemplo n.º 3
0
 /// <summary>
 /// Установить параметры канала связи в соответствии с настройками
 /// </summary>
 public void SetCommCnlParams(SortedList <string, string> commCnlParams)
 {
     commCnlParams["PortName"]  = PortName;
     commCnlParams["BaudRate"]  = BaudRate.ToString();
     commCnlParams["Parity"]    = Parity.ToString();
     commCnlParams["DataBits"]  = DataBits.ToString();
     commCnlParams["StopBits"]  = StopBits.ToString();
     commCnlParams["DtrEnable"] = DtrEnable.ToString();
     commCnlParams["RtsEnable"] = RtsEnable.ToString();
     commCnlParams["Behavior"]  = Behavior.ToString();
 }
Exemplo n.º 4
0
        public override string ToString()
        {
            List <string> paraList = new List <string>();

            paraList.Add(PortName.ToString());
            paraList.Add(BaudRate.ToString());
            paraList.Add(DataBits.ToString());
            paraList.Add(StopBits.ToString());
            paraList.Add(Parity.ToString());
            return(String.Format("{0}://{1}", Prefix, String.Join(SpitChar, paraList)));
        }
 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();
 }
Exemplo n.º 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();
 }
        /**
         * This function read every setting from memory and restore it in the UI
         */
        private void readSettingsFromMemory()
        {
            if (Properties.Settings.Default.BaudRate != -1)
            {
                BaudRate = Properties.Settings.Default.BaudRate;
                baudRateDropdown.SelectedItem = BaudRate.ToString();
            }

            if (Properties.Settings.Default.Parity != -1)
            {
                var parityInt = Properties.Settings.Default.Parity;
                Parity = (Parity)parityInt;
                parityDropdown.SelectedIndex = parityInt;
            }

            if (Properties.Settings.Default.DataBits != -1)
            {
                DataBits = Properties.Settings.Default.DataBits;
                databitsDropdown.SelectedItem = DataBits.ToString();
            }

            if (Properties.Settings.Default.StopBits != -1)
            {
                var stopBitsInt = Properties.Settings.Default.StopBits;
                StopBits = (StopBits)stopBitsInt;
                stopbitsDropdown.SelectedIndex = stopBitsInt;
            }

            if (Properties.Settings.Default.FlowControl != -1)
            {
                var flowControlInt = Properties.Settings.Default.FlowControl;
                FlowControl = (Handshake)flowControlInt;
                flowcontrolDropdown.SelectedIndex = flowControlInt;
            }

            ReplaceNewLine = Properties.Settings.Default.ReplaceNewLine;
        }
Exemplo n.º 8
0
 public override string ToString()
 {
     return(String.Format("{0}-{1}-{2}-{3}-{4}", PortName.ToString(), BaudRate.ToString(), DataBits.ToString(), StopBits.ToString(), Parity.ToString()));
 }