Exemplo n.º 1
0
        /// <summary>
        /// Returns the type of the channel: RC or Analog.
        /// </summary>
        public static SmcChannelType type(this SmcChannel channel)
        {
            switch (channel)
            {
            case SmcChannel.Analog1:
            case SmcChannel.Analog2: return(SmcChannelType.Analog);

            case SmcChannel.Rc1:
            case SmcChannel.Rc2: return(SmcChannelType.RC);

            default: throw new Exception("Unknown Channel: " + channel.ToString());
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Returns true if the specified channel is a limit or kill switch and
        /// it is currently active.  This information comes from the limitStatus
        /// register.
        /// </summary>
        public static bool switchActive(this SmcVariables vars, SmcChannel channel)
        {
            switch (channel)
            {
            case SmcChannel.Analog1: return((vars.limitStatus & SmcLimitStatus.Analog1) != 0);

            case SmcChannel.Analog2: return((vars.limitStatus & SmcLimitStatus.Analog2) != 0);

            case SmcChannel.Rc1: return((vars.limitStatus & SmcLimitStatus.Rc1) != 0);

            case SmcChannel.Rc2: return((vars.limitStatus & SmcLimitStatus.Rc2) != 0);

            default: throw new Exception("Unknown Channel: " + channel.ToString());
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Changes the settings for a specified channel.
        /// </summary>
        /// <param name="settings">The settings of the device. This object will be modified.</param>
        /// <param name="channel">Specifies the channel to change.</param>
        /// <param name="channelSettings">The new settings for the channel.</param>
        public static void setChannelSettings(this SmcSettings settings, SmcChannel channel, SmcChannelSettings channelSettings)
        {
            switch (channel)
            {
            case SmcChannel.Analog1: settings.analog1 = channelSettings; break;

            case SmcChannel.Analog2: settings.analog2 = channelSettings; break;

            case SmcChannel.Rc1: settings.rc1 = channelSettings; break;

            case SmcChannel.Rc2: settings.rc2 = channelSettings; break;

            default: throw new Exception("Unknown Channel: " + channel.ToString());
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Gets the settings for the specified channel.
        /// </summary>
        /// <param name="settings">The settings of the device.</param>
        /// <param name="channel">Specifies what channel to fetch.</param>
        /// <returns>The settings of the specified channel.</returns>
        public static SmcChannelSettings getChannelSettings(this SmcSettings settings, SmcChannel channel)
        {
            switch (channel)
            {
            case SmcChannel.Analog1: return(settings.analog1);

            case SmcChannel.Analog2: return(settings.analog2);

            case SmcChannel.Rc1: return(settings.rc1);

            case SmcChannel.Rc2: return(settings.rc2);

            default: throw new Exception("Unknown Channel: " + channel.ToString());
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Gets the state of the specified channel.
        /// </summary>
        /// <param name="vars">The state of the device.</param>
        /// <param name="channel">Specifies what channel to fetch.</param>
        /// <returns>The state of the specified channel.</returns>
        public static SmcChannelVariables getChannel(this SmcVariables vars, SmcChannel channel)
        {
            switch (channel)
            {
            case SmcChannel.Analog1: return(vars.analog1);

            case SmcChannel.Analog2: return(vars.analog2);

            case SmcChannel.Rc1: return(vars.rc1);

            case SmcChannel.Rc2: return(vars.rc2);

            default: throw new Exception("Unknown Channel: " + channel.ToString());
            }
        }
Exemplo n.º 6
0
 private static void WriteElementChannelSettings(this XmlWriter writer, SmcChannel channel, SmcChannelSettings cs)
 {
     writer.WriteStartElement(channel.ToString());
     writer.WriteElementString("AlternateUse", cs.alternateUse.ToString());
     if (channel.type() == SmcChannelType.Analog)
     {
         writer.WriteElementString("PinMode", cs.pinMode.ToString());
     }
     writer.WriteElementBool("Invert", cs.invert);
     writer.WriteElementU32("ScalingDegree", cs.scalingDegree);
     writer.WriteElementRange("Error", cs.errorMin, cs.errorMax);
     writer.WriteElementRange("Input", cs.inputMin, cs.inputMax);
     writer.WriteElementRange("InputNeutral", cs.inputNeutralMin, cs.inputNeutralMax);
     writer.WriteEndElement();
 }
Exemplo n.º 7
0
        /// <summary>
        /// Returns a short user friendly name for the channel (e.g. "Analog 1").
        /// </summary>
        public static string shortName(this SmcChannel channel)
        {
            switch (channel)
            {
            case SmcChannel.Analog1: return("Analog 1");

            case SmcChannel.Analog2: return("Analog 2");

            case SmcChannel.Rc1: return("RC 1");

            case SmcChannel.Rc2: return("RC 2");

            default: throw new Exception("Unknown Channel: " + channel.ToString());
            }
        }
Exemplo n.º 8
0
 private static void WriteElementChannelSettings(this XmlWriter writer, SmcChannel channel, SmcChannelSettings cs)
 {
     writer.WriteStartElement(channel.ToString());
     writer.WriteElementString("AlternateUse", cs.alternateUse.ToString());
     if (channel.type() == SmcChannelType.Analog)
     {
         writer.WriteElementString("PinMode", cs.pinMode.ToString());
     }
     writer.WriteElementBool("Invert", cs.invert);
     writer.WriteElementU32("ScalingDegree", cs.scalingDegree);
     writer.WriteElementRange("Error", cs.errorMin, cs.errorMax);
     writer.WriteElementRange("Input", cs.inputMin, cs.inputMax);
     writer.WriteElementRange("InputNeutral", cs.inputNeutralMin, cs.inputNeutralMax);
     writer.WriteEndElement();
 }
Exemplo n.º 9
0
 /// <summary>
 /// Returns true if the specified channel is a limit or kill switch and
 /// it is currently active.  This information comes from the limitStatus
 /// register.
 /// </summary>
 public static bool switchActive(this SmcVariables vars, SmcChannel channel)
 {
     switch (channel)
     {
         case SmcChannel.Analog1: return (vars.limitStatus & SmcLimitStatus.Analog1) != 0;
         case SmcChannel.Analog2: return (vars.limitStatus & SmcLimitStatus.Analog2) != 0;
         case SmcChannel.Rc1: return (vars.limitStatus & SmcLimitStatus.Rc1) != 0;
         case SmcChannel.Rc2: return (vars.limitStatus & SmcLimitStatus.Rc2) != 0;
         default: throw new Exception("Unknown Channel: " + channel.ToString());
     }
 }
Exemplo n.º 10
0
 /// <summary>
 /// Changes the settings for a specified channel.
 /// </summary>
 /// <param name="settings">The settings of the device. This object will be modified.</param>
 /// <param name="channel">Specifies the channel to change.</param>
 /// <param name="channelSettings">The new settings for the channel.</param>
 public static void setChannelSettings(this SmcSettings settings, SmcChannel channel, SmcChannelSettings channelSettings)
 {
     switch (channel)
     {
         case SmcChannel.Analog1: settings.analog1 = channelSettings; break;
         case SmcChannel.Analog2: settings.analog2 = channelSettings; break;
         case SmcChannel.Rc1: settings.rc1 = channelSettings; break;
         case SmcChannel.Rc2: settings.rc2 = channelSettings; break;
         default: throw new Exception("Unknown Channel: " + channel.ToString());
     }
 }
Exemplo n.º 11
0
 /// <summary>
 /// Gets the settings for the specified channel.
 /// </summary>
 /// <param name="settings">The settings of the device.</param>
 /// <param name="channel">Specifies what channel to fetch.</param>
 /// <returns>The settings of the specified channel.</returns>
 public static SmcChannelSettings getChannelSettings(this SmcSettings settings, SmcChannel channel)
 {
     switch (channel)
     {
         case SmcChannel.Analog1: return settings.analog1;
         case SmcChannel.Analog2: return settings.analog2;
         case SmcChannel.Rc1: return settings.rc1;
         case SmcChannel.Rc2: return settings.rc2;
         default: throw new Exception("Unknown Channel: " + channel.ToString());
     }
 }
Exemplo n.º 12
0
 /// <summary>
 /// Gets the state of the specified channel.
 /// </summary>
 /// <param name="vars">The state of the device.</param>
 /// <param name="channel">Specifies what channel to fetch.</param>
 /// <returns>The state of the specified channel.</returns>
 public static SmcChannelVariables getChannel(this SmcVariables vars, SmcChannel channel)
 {
     switch (channel)
     {
         case SmcChannel.Analog1: return vars.analog1;
         case SmcChannel.Analog2: return vars.analog2;
         case SmcChannel.Rc1: return vars.rc1;
         case SmcChannel.Rc2: return vars.rc2;
         default: throw new Exception("Unknown Channel: " + channel.ToString());
     }
 }