Exemplo n.º 1
0
        private SettingsTemplate createSettingsObject()
        {
            SettingsTemplate        sets = new SettingsTemplate();
            ChannelSettingsTemplate chan;

            for (int i = 0; i < 8; i++)
            {
                chan                = new ChannelSettingsTemplate();
                chan.DutyCycle      = channelControls[i].channelSettings.DutyCycleS;
                chan.Enabled        = channelControls[i].channelSettings.Enabled;
                chan.Frequency      = channelControls[i].channelSettings.Frequency;
                chan.DutyCycleUnits = channelControls[i].DcUnits;
                chan.FrequencyUnits = channelControls[i].FrequencyUnits;

                sets.ChannelSettings.Add(chan);
            }

            if (ControlMode == PwmGeneratorModes.Synchronous)
            {
                sets.SynchronousFrequency      = synchronousPwmFrequency;
                sets.SynchronousFrequencyUnits = channelControls[0].FrequencyUnits;
            }

            return(sets);
        }
Exemplo n.º 2
0
        public System.Xml.XmlElement saveSettings()
        {
            SettingsTemplate sets = createSettingsObject();

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

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

            xDoc.LoadXml(sw.ToString());

            return(xDoc.DocumentElement);
        }
Exemplo n.º 3
0
        public void loadSettings(System.Xml.XmlElement pwmSettings)
        {
            XmlSerializer serializer = new XmlSerializer(typeof(SettingsTemplate));

            StringReader stringReader;

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

            for (int i = 0; i < 8; i++)
            {
                channelControls[i].FrequencyUnits = sets.ChannelSettings[i].FrequencyUnits;
                channelControls[i].DcUnits        = sets.ChannelSettings[i].DutyCycleUnits;

                channelControls[i].channelSettings.DutyCycleS = sets.ChannelSettings[i].DutyCycle;
                channelControls[i].channelSettings.Enabled    = sets.ChannelSettings[i].Enabled;
                channelControls[i].channelSettings.Frequency  = sets.ChannelSettings[i].Frequency;

                channelControls[i].reloadChannelSettings();
            }

            if (ControlMode == PwmGeneratorModes.Synchronous)
            {
                fUnitsBox.Text          = sets.SynchronousFrequencyUnits;
                synchronousPwmFrequency = sets.SynchronousFrequency;
                setFrequencyBoxValue(synchronousPwmFrequency);

                connector.SynchronousFrequency = synchronousPwmFrequency;

                for (int i = 0; i < 8; i++)
                {
                    channelControls[i].setNewFrequency(synchronousPwmFrequency, sets.SynchronousFrequencyUnits);
                }
            }

            applyChanges(true);
        }
Exemplo n.º 4
0
        private SettingsTemplate createSettingsObject()
        {
            SettingsTemplate sets = new SettingsTemplate();
            ChannelSettingsTemplate chan;
            for (int i = 0; i < 8; i++)
            {
                chan = new ChannelSettingsTemplate();
                chan.DutyCycle = channelControls[i].channelSettings.DutyCycleS;
                chan.Enabled = channelControls[i].channelSettings.Enabled;
                chan.Frequency = channelControls[i].channelSettings.Frequency;
                chan.DutyCycleUnits = channelControls[i].DcUnits;
                chan.FrequencyUnits = channelControls[i].FrequencyUnits;

                sets.ChannelSettings.Add(chan);
            }

            if (ControlMode == PwmGeneratorModes.Synchronous)
            {
                sets.SynchronousFrequency = synchronousPwmFrequency;
                sets.SynchronousFrequencyUnits = channelControls[0].FrequencyUnits;
            }

            return sets;
        }