Пример #1
0
        public System.Xml.XmlElement saveSettings()
        {
            RcSettingsTemplate sets = createSettingsObject();

            XmlSerializer serializer = new XmlSerializer(typeof(RcSettingsTemplate));
            StringWriter  sw         = new StringWriter();

            serializer.Serialize(sw, sets);
            XmlDocument xDoc = new XmlDocument();

            xDoc.LoadXml(sw.ToString());

            return(xDoc.DocumentElement);
        }
Пример #2
0
        private RcSettingsTemplate createSettingsObject()
        {
            RcSettingsTemplate        sets = new RcSettingsTemplate();
            RcChannelSettingsTemplate chan;

            for (int i = 0; i < 8; i++)
            {
                chan                = new RcChannelSettingsTemplate();
                chan.Value          = channelControls[i].Value;
                chan.ChannelEnabled = channelControls[i].ChannelEnabled;
                chan.CalibrationSettings.CenterValue  = channelControls[i].Calibration_center;
                chan.CalibrationSettings.MaxDeviation = channelControls[i].Calibration_maxDeviation;

                sets.ChannelSettings.Add(chan);
            }
            sets.PwmFrequency = pwmFrequency;

            return(sets);
        }
Пример #3
0
        public void loadSettings(System.Xml.XmlElement pwmSettings)
        {
            XmlSerializer serializer = new XmlSerializer(typeof(RcSettingsTemplate));

            StringReader stringReader;

            stringReader = new StringReader(pwmSettings.OuterXml);
            XmlTextReader      xmlReader = new XmlTextReader(stringReader);
            RcSettingsTemplate sets      = (RcSettingsTemplate)serializer.Deserialize(xmlReader);

            for (int i = 0; i < 8; i++)
            {
                channelControls[i].Value                    = sets.ChannelSettings[i].Value;
                channelControls[i].ChannelEnabled           = sets.ChannelSettings[i].ChannelEnabled;
                channelControls[i].Calibration_center       = sets.ChannelSettings[i].CalibrationSettings.CenterValue;
                channelControls[i].Calibration_maxDeviation = sets.ChannelSettings[i].CalibrationSettings.MaxDeviation;
            }
            pwmFrequency = sets.PwmFrequency;

            frequencyLabel.Text = pwmFrequency.ToString();
            frequencyBox.Text   = pwmFrequency.ToString();

            applyNewSettings();
        }
Пример #4
0
        private RcSettingsTemplate createSettingsObject()
        {
            RcSettingsTemplate sets = new RcSettingsTemplate();
            RcChannelSettingsTemplate chan;
            for (int i = 0; i < 8; i++)
            {
                chan = new RcChannelSettingsTemplate();
                chan.Value = channelControls[i].Value;
                chan.ChannelEnabled = channelControls[i].ChannelEnabled;
                chan.CalibrationSettings.CenterValue = channelControls[i].Calibration_center;
                chan.CalibrationSettings.MaxDeviation = channelControls[i].Calibration_maxDeviation;

                sets.ChannelSettings.Add(chan);
            }
            sets.PwmFrequency = pwmFrequency;

            return sets;
        }