Ejemplo n.º 1
0
        // Set From Config
        public void SetToCard()
        {
            ExternalChannelConfig config = Tray.ExtChannelConfig;

            // Setup command list.
            for (int i = 0; i < 10; i++)
            {
                listViewExternalCommands.Items[i].SubItems[1].Text = config.Digits[i];
            }

            listViewExternalCommands.Items[10].SubItems[1].Text = config.SelectCommand;
            listViewExternalCommands.Items[11].SubItems[1].Text = config.PreChangeCommand;

            // Setup options.
            numericUpDownPauseTime.Value = config.PauseTime;
            checkBoxSendSelect.Checked   = config.SendSelect;
            checkBoxDoubleSelect.Checked = config.DoubleChannelSelect;
            numericUpDownRepeat.Value    = config.RepeatChannelCommands;

            checkBoxDoubleSelect.Enabled = checkBoxSendSelect.Checked;

            int channelDigitsSelect = config.ChannelDigits;

            if (channelDigitsSelect > 0)
            {
                channelDigitsSelect--;
            }
            comboBoxChDigits.SelectedIndex = channelDigitsSelect;

            checkBoxUsePreChange.Checked   = config.UsePreChangeCommand;
            numericUpDownRepeatDelay.Value = new Decimal(config.RepeatPauseTime);
        }
Ejemplo n.º 2
0
        public void SetToConfig()
        {
            ExternalChannelConfig config = Tray.ExtChannelConfig;

            config.CardId = 0;

            config.PauseTime             = Decimal.ToInt32(numericUpDownPauseTime.Value);
            config.SendSelect            = checkBoxSendSelect.Checked;
            config.DoubleChannelSelect   = checkBoxDoubleSelect.Checked;
            config.RepeatChannelCommands = Decimal.ToInt32(numericUpDownRepeat.Value);

            int chDigits = comboBoxChDigits.SelectedIndex;

            if (chDigits > 0)
            {
                chDigits++;
            }
            config.ChannelDigits = chDigits;

            config.RepeatPauseTime     = Decimal.ToInt32(numericUpDownRepeatDelay.Value);
            config.UsePreChangeCommand = checkBoxUsePreChange.Checked;

            config.SelectCommand    = listViewExternalCommands.Items[10].SubItems[1].Text;
            config.PreChangeCommand = listViewExternalCommands.Items[11].SubItems[1].Text;

            for (int i = 0; i < 10; i++)
            {
                config.Digits[i] = listViewExternalCommands.Items[i].SubItems[1].Text;
            }
        }
        /// <summary>
        /// Loads the specified file into a new instance of <see cref="ExternalChannelConfig"/> class.
        /// </summary>
        /// <param name="fileName">Name of the file to load.</param>
        /// <returns>A new <see cref="ExternalChannelConfig"/> class instance.</returns>
        public static ExternalChannelConfig Load(string fileName)
        {
            ExternalChannelConfig newECC = new ExternalChannelConfig(fileName);

            XmlDocument doc = new XmlDocument();

            doc.Load(fileName);

            newECC.PauseTime             = GetInt(doc, "PauseTime", DefaultPauseTime);
            newECC.UsePreChangeCommand   = GetBool(doc, "UsePreChangeCommand", DefaultUsePreChangeCommand);
            newECC.SendSelect            = GetBool(doc, "SendSelect", DefaultSendSelect);
            newECC.DoubleChannelSelect   = GetBool(doc, "DoubleChannelSelect", DefaultDoubleChannelSelect);
            newECC.RepeatChannelCommands = GetInt(doc, "RepeatChannelCommands", DefaultRepeatChannelCommands);
            newECC.ChannelDigits         = GetInt(doc, "ChannelDigits", DefaultChannelDigits);
            newECC.RepeatPauseTime       = GetInt(doc, "RepeatDelay", DefaultRepeatPauseTime);

            newECC.SelectCommand    = GetString(doc, "SelectCommand", String.Empty);
            newECC.PreChangeCommand = GetString(doc, "PreChangeCommand", String.Empty);

            for (int index = 0; index < 10; index++)
            {
                newECC.Digits[index] = GetString(doc, "Digit" + index.ToString(), String.Empty);
            }

            return(newECC);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Load external channel configuration.
        /// </summary>
        private static void LoadExternalConfig()
        {
            string fileName = Path.Combine(ExtCfgFolder, "ExternalChannelConfig.xml");

            try
            {
                _externalChannelConfig = ExternalChannelConfig.Load(fileName);
            }
            catch (Exception ex)
            {
                IrssLog.Error(ex);

                _externalChannelConfig = new ExternalChannelConfig(fileName);
            }

            _externalChannelConfig.CardId = 0;
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Processes the external channel.
        /// </summary>
        /// <param name="args">String array of parameters.</param>
        private static void ProcessExternalChannel(object args)
        {
            try
            {
                string[] data = args as string[];
                if (data == null)
                {
                    throw new ArgumentException("Parameter is not of type string[]", "args");
                }

                ExternalChannelConfig config = _externalChannelConfig;

                // Clean up the "data[0]" string into "channel".
                StringBuilder channel = new StringBuilder();
                foreach (char digit in data[0])
                {
                    if (char.IsDigit(digit))
                    {
                        channel.Append(digit);
                    }
                }

                // Pad the channel number with leading 0's to meet ChannelDigits length.
                while (channel.Length < config.ChannelDigits)
                {
                    channel.Insert(0, '0');
                }

                // Process the channel and blast the relevant IR Commands.
                string channelString = channel.ToString();
                string command;
                int    charVal;

                for (int repeatCount = 0; repeatCount <= config.RepeatChannelCommands; repeatCount++)
                {
                    if (repeatCount > 0 && config.RepeatPauseTime > 0)
                    {
                        Thread.Sleep(config.RepeatPauseTime);
                    }

                    if (config.UsePreChangeCommand)
                    {
                        command = config.PreChangeCommand;
                        if (!String.IsNullOrEmpty(command))
                        {
                            ProcessExternalCommand(command, -1, channelString);

                            if (config.PauseTime > 0)
                            {
                                Thread.Sleep(config.PauseTime);
                            }
                        }
                    }

                    foreach (char digit in channelString)
                    {
                        charVal = digit - 48;

                        command = config.Digits[charVal];
                        if (!String.IsNullOrEmpty(command))
                        {
                            ProcessExternalCommand(command, charVal, channelString);

                            if (config.PauseTime > 0)
                            {
                                Thread.Sleep(config.PauseTime);
                            }
                        }
                    }

                    if (config.SendSelect)
                    {
                        command = config.SelectCommand;
                        if (!String.IsNullOrEmpty(command))
                        {
                            ProcessExternalCommand(command, -1, channelString);

                            if (config.DoubleChannelSelect)
                            {
                                if (config.PauseTime > 0)
                                {
                                    Thread.Sleep(config.PauseTime);
                                }

                                ProcessExternalCommand(command, -1, channelString);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                IrssLog.Error(ex);
            }
        }
Ejemplo n.º 6
0
    /// <summary>
    /// Load external channel configuration.
    /// </summary>
    private static void LoadExternalConfig()
    {
      string fileName = Path.Combine(ExtCfgFolder, "ExternalChannelConfig.xml");

      try
      {
        _externalChannelConfig = ExternalChannelConfig.Load(fileName);
      }
      catch (Exception ex)
      {
        IrssLog.Error(ex);

        _externalChannelConfig = new ExternalChannelConfig(fileName);
      }

      _externalChannelConfig.CardId = 0;
    }
    /// <summary>
    /// Loads the specified file into a new instance of <see cref="ExternalChannelConfig"/> class.
    /// </summary>
    /// <param name="fileName">Name of the file to load.</param>
    /// <returns>A new <see cref="ExternalChannelConfig"/> class instance.</returns>
    public static ExternalChannelConfig Load(string fileName)
    {
      ExternalChannelConfig newECC = new ExternalChannelConfig(fileName);

      XmlDocument doc = new XmlDocument();
      doc.Load(fileName);

      newECC.PauseTime = GetInt(doc, "PauseTime", DefaultPauseTime);
      newECC.UsePreChangeCommand = GetBool(doc, "UsePreChangeCommand", DefaultUsePreChangeCommand);
      newECC.SendSelect = GetBool(doc, "SendSelect", DefaultSendSelect);
      newECC.DoubleChannelSelect = GetBool(doc, "DoubleChannelSelect", DefaultDoubleChannelSelect);
      newECC.RepeatChannelCommands = GetInt(doc, "RepeatChannelCommands", DefaultRepeatChannelCommands);
      newECC.ChannelDigits = GetInt(doc, "ChannelDigits", DefaultChannelDigits);
      newECC.RepeatPauseTime = GetInt(doc, "RepeatDelay", DefaultRepeatPauseTime);

      newECC.SelectCommand = GetString(doc, "SelectCommand", String.Empty);
      newECC.PreChangeCommand = GetString(doc, "PreChangeCommand", String.Empty);

      for (int index = 0; index < 10; index++)
        newECC.Digits[index] = GetString(doc, "Digit" + index.ToString(), String.Empty);

      return newECC;
    }