Exemplo n.º 1
0
        // Кнопка Выбрать сигнал(F3)
        private void button13_Click(object sender, EventArgs e)
        {
            try
            {
                SignalOutput   SO  = new SignalOutput();
                OpenFileDialog OFD = new OpenFileDialog();
                OFD.InitialDirectory = modelsPath;
                if (OFD.ShowDialog() == DialogResult.OK)
                {
                    Messages("Выбран файл: " + OFD.FileName);
                    OutputIR = SO.ConvertingBINARYorXMLtoIRsignal(OFD.FileName);
                    if (OutputIR != null)
                    {
                        label1.Enabled   = true;
                        button3.Enabled  = true;
                        textBox1.Enabled = true;

                        label4.Enabled   = true;
                        button7.Enabled  = true;
                        textBox3.Enabled = true;

                        button2.Enabled = true;
                    }
                }
                SearchRedRat SR = new SearchRedRat();
                RedRat3 = SR.FindRedRat();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 2
0
        // Event for ItemActivate
        private void listView1_ItemActivate(object sender, EventArgs e)
        {
            SignalOutput SO = new SignalOutput();
            SearchRedRat SR = new SearchRedRat();

            RedRat3 = SR.FindRedRat();
            string newPath = pathClick + "\\" + listView1.FocusedItem.Text;

            if (File.Exists(newPath))//Checker is folder or file
            {
                //MessageBox.Show("File is choice!");
                //Process.Start(pathClick);
                OutputIR = SO.ConvertingBINARYorXMLtoIRsignal(newPath);
                if (OutputIR != null)
                {
                    Messages("Выбран файл: " + listView1.FocusedItem.Text);
                    label1.Enabled   = true;
                    button3.Enabled  = true;
                    textBox1.Enabled = true;

                    label4.Enabled   = true;
                    button7.Enabled  = true;
                    textBox3.Enabled = true;

                    button2.Enabled = true;
                }
            }
            else
            {
                AddFoldersWithFileFromEnterPath(newPath, false);
            }
        }
Exemplo n.º 3
0
        public FormTimerOutputIRsignal(IRedRat3 _RedRat3, Int32 _Interval, IRPacket _OutputIR = null, bool _folderOutput = false, string _pathToFolder = "", FileInfo[] _fileInfos = null)
        {
            InitializeComponent();
            RedRat3      = _RedRat3;
            interval     = _Interval;
            OutputIR     = _OutputIR;
            folderOutput = _folderOutput;
            pathToFolder = _pathToFolder;
            fileInfos    = _fileInfos;

            if (folderOutput == false)
            {
                timer1.Interval = interval;
                timer1.Start();
            }
            else
            {
                foreach (FileInfo file in fileInfos)
                {
                    OutputIR = SO.ConvertingBINARYorXMLtoIRsignal(pathToFolder + "\\" + file.Name);
                    if ((RedRat3 != null) && (OutputIR != null))
                    {
                        SO.OutputOneIRsignal(RedRat3, OutputIR);
                        Thread.Sleep(interval);
                    }
                    else
                    {
                        MessageBox.Show("Ошибка. Проверьте ввеленные значения интервала, или Подключение RedRat3, или плохо записан сигнал.");
                    }
                }
            }
        }
Exemplo n.º 4
0
 public SignalInputDialog(IRedRat3 initRR3)
 {
     //
     // Required for Windows Form Designer support
     //
     InitializeComponent();
     rr3 = initRR3;
 }
Exemplo n.º 5
0
 // Кнопка поиска RedRat3(F1)
 private void button14_Click(object sender, EventArgs e)
 {
     try
     {
         SearchRedRat SR3 = new SearchRedRat();
         RedRat3 = SR3.FindRedRatInfo();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Exemplo n.º 6
0
        // == Создаем объект AV-устройства, чтобы мы могли хранить данные сигнала в файле XML.
        //private AVDeviceDB avDeviceDB;

        private IRedRat3 FindRedRat3()
        {
            try
            {
                var devices = RedRat3USBImpl.FindRedRat3s();

                if (devices.Length > 0)
                {
                    //Возьмем первое найденное устройство.
                    redRat3 = (IRedRat3)devices[0].GetRedRat();
                    //MessageBox.Show("Подключено устройство: \n\n\"" + redRat3.LocationInformation + "\"", "Проверка подключения", MessageBoxButtons.OK);
                }
            } catch (Exception ex)
            {
                new EntryPointNotFoundException("Error in search", ex).Throw();
            }
            return(redRat3);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Просто находит первый RedRat3, подключенный к этому компьютеру.
        /// </summary>
        public IRedRat3 FindRedRat3()
        {
            try
            {
                var devices = RedRat3USBImpl.FindDevices();

                if (devices.Count > 0)
                {
                    //Возьмем первое найденное устройство.
                    redRat3 = (IRedRat3)devices[0].GetRedRat();
                    //MessageBox.Show("Подключено устройство: \n\n\"" + redRat3.LocationInformation + "\"", "Проверка подключения", MessageBoxButtons.OK);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Ошибка в поиске RedRat.\n" + ex.Message, "Ошибка в поиске RedRat.", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }

            return(redRat3);
        }
        // Захват сигнала
        public void CaptureSignal(string fileName = "")
        {
            OpenFileDialog OFD = new OpenFileDialog();

            OFD.InitialDirectory = Form1.pathClick;
            SearchRedRat SRR = new SearchRedRat();

            if (SRR.FindRedRat() != null)
            {
                RedRat3 = SRR.FindRedRat();

                RedRat3.LearningSignalIn += SignalDataHandler;
                RedRat3.GetModulatedSignal(10000);//Ввод сигнала в RedRat3 осуществляется в течении 10с
                haveSignal = false;
                while (!haveSignal)
                {
                    Thread.Sleep(100);
                }
                if (modSignal != null)
                {
                    var mes = MessageBox.Show("OK - cохранить XML" + Environment.NewLine + "CANCEL - cохранить BIN", "Вариант сохранения файла", MessageBoxButtons.OKCancel);
                    if (mes == DialogResult.OK)
                    {
                        inputName IN = new inputName(); IN.ShowDialog();
                        RRUtil.SerializePacketToXML(Form1.pathClick + "\\" + IN.name + ".xml", modSignal);
                        tempMessage = "XML файл \"" + IN.name + "\" сохранен.";
                    }
                    else
                    {
                        inputName IN = new inputName(); IN.ShowDialog();
                        RRUtil.SerializePacketToBinary(Form1.pathClick + "\\" + IN.name + ".bin", modSignal);//SerializePacketToXML
                        //var m = MessageBox.Show("Файл \"" + IN.name + "\" сохранен.", "Прием сигнала", MessageBoxButtons.OK);
                        tempMessage = "BIN файл \"" + IN.name + "\" сохранен.";
                    }
                }
                else
                {
                    MessageBox.Show("Сигнал не был получен. Прием окончен.", "Прием сигнала", MessageBoxButtons.OK);
                }
            }
        }
        // Просто находит первый RedRat3, подключенный к этому компьютеру. + выводит информацию
        public IRedRat3 FindRedRatInfo()
        {
            try
            {
                // Поис RedRat3
                var devices = RedRat3USBImpl.FindDevices();
                //Экземпляр метода добавления к другой строке
                var RedRatInfo = new StringBuilder();

                if (devices.Count > 0)
                {
                    // Возьмем первое найденное устройство.
                    RedRat3 = (IRedRat3)devices[0].GetRedRat();

                    // Физическая информация об оборудовании USB
                    var devInfo = (USBDeviceInfo)RedRat3.DeviceInformation;
                    RedRatInfo.Append("RedRat подключен!");
                    RedRatInfo.Append("\n\nОписание:");
                    // Физическая позиция возвращается в объекте LocationInfo
                    RedRatInfo.Append("\n- Location: " + RedRat3.LocationInformation);
                    RedRatInfo.Append("\n- Info: " + devInfo);
                    RedRatInfo.Append("\n- Hardware Version: " + devInfo.ProductName + "." + devInfo.ProductDescriptor.Version);
                    // Информация о версии прошивки читается напрямую с RedRat3
                    RedRatInfo.Append("\n- Firmware Version: " + RedRat3.FirmwareVersion);
                    RedRatInfo.Append("\n- Serial Number: " + devInfo.SerialNumber);

                    MessageBox.Show(RedRatInfo.ToString(), "Поиск RedRat", MessageBoxButtons.OK);
                }
                else
                {
                    MessageBox.Show("RedRat не найден.", "Поиск RedRat", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Ошибка поиска RedRat.\n" + ex.Message, "Поиск RedRat", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }

            return(RedRat3);
        }
Exemplo n.º 10
0
        // Кнопка захвата одиночного сигнала
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                SearchRedRat SR3 = new SearchRedRat();
                RedRat3 = SR3.FindRedRat();
                if (RedRat3 != null)
                {
                    IRsignalTrainingMode IRSTM = new IRsignalTrainingMode();
                    var FTC         = new FormTimerCapture(10, "Подайте сигнал с пульта");
                    var waitsignal2 = Task.Factory.StartNew(() => { FTC.ShowDialog(); });

                    var qwe = Task.Factory.StartNew(() =>
                    {
                        IRSTM.CaptureSignal();
                        OutputIR = IRSTM.GetSignal();
                        if (OutputIR != null)
                        {
                            label1.Enabled   = true;
                            button3.Enabled  = true;
                            textBox1.Enabled = true;

                            label4.Enabled   = true;
                            button7.Enabled  = true;
                            textBox3.Enabled = true;

                            button2.Enabled = true;

                            AddFoldersWithFileFromEnterPath(pathClick);
                            FTC.Close();
                        }
                    });
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 11
0
 protected void OpenRedRat3()
 {
     try
     {
         // Find the no. of RR3s connected.
         var devices = RedRat3USBImpl.FindDevices();
         if (devices.Count > 0)
         {
             // Just take the first device found.
             redRat3 = (IRedRat3)devices[0].GetRedRat();
         }
         else
         {
             MessageBox.Show("No RedRat3 devices found.", "Warning",
                             MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
     }
 }
        // Просто находит первый RedRat3, подключенный к этому компьютеру.
        public IRedRat3 FindRedRat()
        {
            try
            {
                var devices = RedRat3USBImpl.FindDevices();
                if (devices.Count > 0)
                {
                    //Возьмем первое найденное устройство или пустоту
                    RedRat3 = (IRedRat3)devices[0].GetRedRat();
                }
                else
                {
                    RedRat3 = null;
                    MessageBox.Show("RedRat не найден.", "Поиск RedRat", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Ошибка поиска RedRat.\n" + ex.Message, "Поиск RedRat", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }

            return(RedRat3);
        }
Exemplo n.º 13
0
 /// <summary>
 /// Просто находит первый RedRat3, подключенный к этому компьютеру.
 /// </summary>
 public IRedRat3 FindRedRat3()
 {
     //logger.Trace("start");
     try
     {
         //var devices = RedRat3USBImpl.FindDevices();
         var devices = RedRat3USBImpl.FindRedRat3s();
         redRat3 = (devices.Length > 0) ? (IRedRat3)devices[0].GetRedRat() : null;
     } catch (Exception ex)
     {
         //MessageBox.Show("Ошибка в поиске RedRat.\n" + ex.Info(), "Ошибка в поиске RedRat.", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         logger.Info($"Ошибка {ex.Message}");
         PublicData.write_info($"Не найден RedRat: {ex.Message}");
         if (RestartRedratDevice())
         {
             var devices = RedRat3USBImpl.FindRedRat3s();
             logger.Trace($"Попытка after WinApi restart found Redrat {nameof(devices)}={devices?.Length}");
             redRat3 = (devices.Length > 0) ? (IRedRat3)devices[0].GetRedRat() : null;
             logger.Trace("Успешно");
         }
     }
     //logger.Trace("end");
     return(redRat3);
 }
Exemplo n.º 14
0
        public string OpenRedRat3()
        {
            try
            {
                // Найти нет. Связанных с RedRat3
                var devices = RedRat3USBImpl.FindDevices();
                if (devices.Count > 0)
                {
                    // Возьмем первое найденное устройство.
                    redRat3 = (IRedRat3)devices[0].GetRedRat();
                    MessageBox.Show("Подключено устройство: \n\n\"" + redRat3.LocationInformation + "\"", "Проверка подключения", MessageBoxButtons.OK);
                }
                else
                {
                    MessageBox.Show("Нет подключенных устройств RedRat3.", "Проверка подключения", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Ошибка в поиске RedRat.\n" + ex.Message, "Ошибка в поиске RedRat.", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }

            return(RedRatInfo());
        }
Exemplo n.º 15
0
        /// <summary>
        /// Capture/learn a remote control signal.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void learnIRButton_Click(object sender, System.EventArgs e)
        {
            IRedRat3 rr3 = parent.RedRat3;

            if (rr3 == null)
            {
                return;
            }

            SignalInputDialog signalInputDialog = null;

            // == Right, this is probably the most complicated bit of interaction ==
            // == with the RR3 in this program - but its not too bad really.      ==
            try {
                // 1. Tell the RR3 we want to input a demodulated signal (learn)
                rr3.GetModulatedSignal(0);

                // 2. Create modal dialog that allows us to cancel the operation if required.
                signalInputDialog = new SignalInputDialog(rr3);

                // 3. The dialog box has to handle the input signal event from the RR3.
                rr3.LearningSignalIn += new EventHandler(signalInputDialog.SignalDataIn);

                // 4. Popup dialog....
                signalInputDialog.ShowDialog(this);

                // 5. Once finished, get the event object
                SignalEventArgs siea = signalInputDialog.SignalInEvent;

                // Have input data of some kind...
                if (siea.Action == SignalEventAction.MODULATED_SIGNAL)
                {
                    irPacket = siea.IRPacket;
                    changed  = true;
                }

                // We have had some error from the comms with the USB device, so read exception and throw it.
                else if (siea.Action == SignalEventAction.EXCEPTION)
                {
                    throw siea.Exception;
                }

                // The user has pressed cancel
                else if (siea.Action == SignalEventAction.INPUT_CANCELLED)
                {
                    // Don't need to do anything here.
                }
            } catch (Exception ex) {
                string msg = ex.Message;
                if (ex.InnerException != null)
                {
                    msg += ": " + ex.InnerException.Message;
                }
                MessageBox.Show(msg, "Communication Error",
                                MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            finally {
                // Remove listener...
                if (signalInputDialog != null)
                {
                    rr3.LearningSignalIn -= new EventHandler(signalInputDialog.SignalDataIn);
                }
                signalInputDialog.Close();
            }
        }
Exemplo n.º 16
0
 // Вывод одного сигнала
 public void OutputOneIRsignal(IRedRat3 RedRat3, IRPacket signal)
 {
     RedRat3.OutputModulatedSignal(signal);
 }