コード例 #1
0
 public static void Deserialize(ref MainSettings dataMainSettings, ref Rs485Settings dataRs485Settings, ref EthernetSettings dataEthernetSettings, ref HartSettings dataHartSettings)
 {
     Deserialize(ref dataMainSettings);
     Deserialize(ref dataRs485Settings);
     Deserialize(ref dataEthernetSettings);
     Deserialize(ref dataHartSettings);
 }
コード例 #2
0
 public static void Deserialize(ref Rs485Settings dataRs485Settings)
 {
     if (dataRs485Settings == null) throw new ArgumentNullException("dataRs485Settings");
     System.Xml.Serialization.XmlSerializer reader = new System.Xml.Serialization.XmlSerializer(typeof(Rs485Settings));
     using (StreamReader file = new StreamReader(@"settings/Rs485Settings.xml"))
     {
         dataRs485Settings = (Rs485Settings)reader.Deserialize(file);
         file.Close();
     }
 }
コード例 #3
0
        public static void Serialize(Rs485Settings dataRs485Settings)
        {
            if (!Directory.Exists("settings"))
                Directory.CreateDirectory("settings");

            var writer = new System.Xml.Serialization.XmlSerializer(typeof(Rs485Settings));
            using (StreamWriter file = new StreamWriter(@"settings/Rs485Settings.xml"))
            {
                writer.Serialize(file, dataRs485Settings);
                file.Close();
            }
        }
コード例 #4
0
        private void apply_btn_Click(object sender, EventArgs e)
        {
            MainSettings mainSettings = new MainSettings();
            mainSettings.IsAutoSearch = autoSearch_checkBox.Checked;
            mainSettings.IsRs485Selected = rs485_radioButton.Checked;
            mainSettings.IsEthernetSelected = ethernet_radioButton.Checked;
            mainSettings.IsHartSelected = hart_radioButton.Checked;
            mainSettings.AddressesForSearch = sensorAddresses_textBox.Text;

            Rs485Settings rs485Settings = new Rs485Settings();
            rs485Settings.ComportName = comport_comboBox.SelectedItem.ToString();
            rs485Settings.ComportBaudrate = Convert.ToInt32(baudrate_comboBox.SelectedItem.ToString());
            if (!Parity.TryParse(parity_comboBox.SelectedItem.ToString(), out rs485Settings.ComportParity))
                MessageBox.Show("");
            if (!StopBits.TryParse(stopbits_comboBox.SelectedItem.ToString(), out rs485Settings.ComportStopBits))
                MessageBox.Show("");
            rs485Settings.ComportReadTimeout = Convert.ToInt32(readTimeout_numericUpDown.Value);
            rs485Settings.ComportWriteTimeout = Convert.ToInt32(write_numericUpDown.Value);

            ConnectionSettingsXml.Serialize(mainSettings, rs485Settings, new EthernetSettings(), new HartSettings());
        }
コード例 #5
0
 public static void Serialize(MainSettings dataMainSettings, Rs485Settings dataRs485Settings, EthernetSettings dataEthernetSettings, HartSettings dataHartSettings)
 {
     Serialize(dataMainSettings);
     Serialize(dataRs485Settings);
     Serialize(dataEthernetSettings);
     Serialize(dataHartSettings);
 }