当前位置: 首页>>代码示例>>C#>>正文


C# XmlTextWriter.WriteElementBool方法代码示例

本文整理汇总了C#中System.Xml.XmlTextWriter.WriteElementBool方法的典型用法代码示例。如果您正苦于以下问题:C# XmlTextWriter.WriteElementBool方法的具体用法?C# XmlTextWriter.WriteElementBool怎么用?C# XmlTextWriter.WriteElementBool使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Xml.XmlTextWriter的用法示例。


在下文中一共展示了XmlTextWriter.WriteElementBool方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: save

        /// <summary>
        /// Writes a SmcSettings object as text to the specified streamwriter.
        /// </summary>
        /// <param name="settings">The settings to read from.</param>
        /// <param name="sw">The file to write to.</param>
        /// <param name="device">The device that these settings came from (optional!).  Adds extra comments to the file.</param>
        public static void save(SmcSettings settings, StreamWriter sw, Smc device)
        {
            XmlTextWriter writer = new XmlTextWriter(sw);
            writer.Formatting = Formatting.Indented;
            writer.WriteComment("Pololu Simple Motor Controller settings file. http://www.pololu.com/docs/0J44");
            writer.WriteComment("Created on: " + DateTime.Now.ToString("u").TrimEnd('Z')); // save local time in a sortable format
            if (device != null)
            {
                writer.WriteComment("Device model: " + Smc.productIdToLongModelString(device.productId));
                writer.WriteComment("Device serial number: " + device.getSerialNumber());
                writer.WriteComment("Device firmware version: " + device.getFirmwareVersionString());
            }
            writer.WriteStartElement("SmcSettings");

            // XML file version, so that we can parse old XML types in the future and old versions of the
            // configuration utility don't try to read newer settings files that have a different format.
            writer.WriteAttributeString("version", "1");

            // [Add-new-settings-here]

            writer.WriteElementString("InputMode", settings.inputMode.ToString());
            writer.WriteElementString("MixingMode", settings.mixingMode.ToString());

            writer.WriteElementBool("DisableSafeStart", settings.disableSafeStart);
            writer.WriteElementBool("IgnorePotDisconnect", settings.ignorePotDisconnect);
            writer.WriteElementBool("IgnoreErrLineHigh", settings.ignoreErrLineHigh);
            writer.WriteElementBool("NeverSuspend", settings.neverSuspend);

            writer.WriteElementBool("TempLimitGradual", settings.tempLimitGradual);
            writer.WriteElementRange("OverTemp", settings.overTempMin, settings.overTempMax);
            writer.WriteElementU32("LowVinShutoffTimeout", settings.lowVinShutoffTimeout);
            writer.WriteElementU32("LowVinShutoffMv", settings.lowVinShutoffMv);
            writer.WriteElementU32("LowVinStartupMv", settings.lowVinStartupMv);
            writer.WriteElementU32("HighVinShutoffMv", settings.highVinShutoffMv);

            writer.WriteElementString("SerialMode", settings.serialMode.ToString());
            writer.WriteElementU32("SerialDeviceNumber", settings.serialDeviceNumber);
            writer.WriteElementU32("CommandTimeout", settings.commandTimeout);
            writer.WriteElementString("CrcMode", settings.crcMode.ToString());
            writer.WriteElementBool("UartResponseDelay", settings.uartResponseDelay);
            writer.WriteElementBool("UseFixedBaudRate", settings.useFixedBaudRate);
            writer.WriteElementU32("FixedBaudRate", settings.fixedBaudRateBps);

            writer.WriteComment("Input Settings");
            writer.WriteElementChannelSettings(SmcChannel.Rc1, settings.rc1);
            writer.WriteElementChannelSettings(SmcChannel.Rc2, settings.rc2);
            writer.WriteElementChannelSettings(SmcChannel.Analog1, settings.analog1);
            writer.WriteElementChannelSettings(SmcChannel.Analog2, settings.analog2);

            writer.WriteComment("Motor Settings");
            writer.WriteElementU32("PwmPeriodFactor", settings.pwmPeriodFactor);
            writer.WriteElementBool("MotorInvert", settings.motorInvert);
            writer.WriteElementU32("SpeedZeroBrakeAmount", settings.speedZeroBrakeAmount);
            writer.WriteElementU32("SpeedUpdatePeriod", settings.speedUpdatePeriod);
            writer.WriteElementMotorLimits("ForwardLimits", settings.forwardLimits);
            writer.WriteElementMotorLimits("ReverseLimits", settings.reverseLimits);

            writer.WriteComment("Advanced Settings");
            writer.WriteElementRange("PulsePeriod", settings.minPulsePeriod, settings.maxPulsePeriod);
            writer.WriteElementU32("RcTimeout", settings.rcTimeout);
            writer.WriteElementU32("ConsecGoodPulses", settings.consecGoodPulses);
            writer.WriteElementS32("VinMultiplierOffset", settings.vinMultiplierOffset);

            writer.WriteEndElement(); // End SmcSettings tag.
        }
开发者ID:Moomers,项目名称:penguins,代码行数:71,代码来源:SettingsFile.cs


注:本文中的System.Xml.XmlTextWriter.WriteElementBool方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。